Commit 18c8dc99 authored by hausmann@webkit.org's avatar hausmann@webkit.org

Fix the Qt build, adapt to various JSCore API changes.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@34762 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent d9249c5c
2008-06-24 Simon Hausmann <hausmann@webkit.org>
Fix the Qt build, added missing include.
* kjs/PropertySlot.cpp:
2008-06-24 Alexey Proskuryakov <ap@webkit.org>
Reviewed by Cameron Zwarich.
......
......@@ -23,6 +23,7 @@
#include "config.h"
#include "PropertySlot.h"
#include "JSFunction.h"
#include "JSGlobalObject.h"
#include "JSObject.h"
#include "RegisterFileStack.h"
......
2008-06-24 Simon Hausmann <hausmann@webkit.org>
Fix the Qt build, adapt to various JSCore API changes.
* bridge/qt/qt_instance.cpp:
(KJS::Bindings::QtRuntimeObjectImp::construct):
(KJS::Bindings::QtInstance::getRuntimeObject):
(KJS::Bindings::QtInstance::invokeDefaultMethod):
* bridge/qt/qt_runtime.cpp:
(KJS::Bindings::convertQVariantToValue):
(KJS::Bindings::QtRuntimeMetaMethod::getCallData):
(KJS::Bindings::QtRuntimeConnectionMethod::call):
(KJS::Bindings::QtRuntimeConnectionMethod::getCallData):
(KJS::Bindings::QtConnectionObject::execute):
* bridge/qt/qt_runtime.h:
(KJS::Bindings::QtRuntimeConnectionMethod::d_func):
2008-06-24 Alexey Proskuryakov <ap@webkit.org>
Remove XMLHttpRequestProgressEvent.cpp from more project files.
......@@ -111,7 +111,9 @@ ConstructType QtRuntimeObjectImp::getConstructData(ConstructData& constructData)
JSObject* QtRuntimeObjectImp::construct(ExecState* exec, const ArgList& args)
{
// ECMA 15.2.2.1 (?)
JSValue *val = callAsFunction(exec, this, args);
CallData callData;
CallType callType = getCallData(callData);
JSValue* val = call(exec, this, callType, callData, this, args);
if (!val || val->type() == NullType || val->type() == UndefinedType)
return new (exec) JSObject(exec->lexicalGlobalObject()->objectPrototype());
......@@ -161,10 +163,10 @@ PassRefPtr<QtInstance> QtInstance::getQtInstance(QObject* o, PassRefPtr<RootObje
return ret.release();
}
JSObject* QtInstance::getRuntimeObject(ExecState* exec, PassRefPtr<QtInstance> instance)
RuntimeObjectImp* QtInstance::getRuntimeObject(ExecState* exec, PassRefPtr<QtInstance> instance)
{
JSLock lock;
JSObject* ret = cachedObjects.value(instance.get());
RuntimeObjectImp* ret = static_cast<RuntimeObjectImp*>(cachedObjects.value(instance.get()));
if (!ret) {
ret = new (exec) QtRuntimeObjectImp(instance);
cachedObjects.insert(instance.get(), ret);
......@@ -277,12 +279,13 @@ JSValue* QtInstance::invokeDefaultMethod(ExecState* exec, const ArgList& args)
return throwError(exec, GeneralError, "cannot call function of deleted QObject");
// implementsCall will update our default method cache, if possible
CallData d;
if (getCallData(d) != CallTypeNone) {
CallData callData;
CallType callType = getCallData(callData);
if (callType != CallTypeNone) {
if (!m_defaultMethod)
m_defaultMethod = new (exec) QtRuntimeMetaMethod(exec, Identifier(exec, "[[Call]]"),this, m_defaultMethodIndex, QByteArray("qscript_call"), true);
return m_defaultMethod->callAsFunction(exec, 0, args); // Luckily QtRuntimeMetaMethod ignores the obj parameter
return call(exec, m_defaultMethod, callType, callData, 0, args); // Luckily QtRuntimeMetaMethod ignores the obj parameter
} else
return throwError(exec, TypeError, "not a function");
}
......
......@@ -735,23 +735,24 @@ JSValue* convertQVariantToValue(ExecState* exec, PassRefPtr<RootObject> root, co
if (re.isValid()) {
RegExpConstructor* regExpObj = static_cast<RegExpConstructor*>(exec->lexicalGlobalObject()->regExpConstructor());
ArgList args;
UString uflags;
UString uflags;
if (re.caseSensitivity() == Qt::CaseInsensitive)
uflags = "i"; // ### Can't do g or m
UString ustring((UChar*)re.pattern().utf16(), re.pattern().length());
args.append(jsString(exec, ustring));
args.append(jsString(exec, uflags));
return regExpObj->construct(exec, args);
UString pattern((UChar*)re.pattern().utf16(), re.pattern().length());
RefPtr<KJS::RegExp> regExp = KJS::RegExp::create(pattern, uflags);
if (regExp->isValid())
return new (exec) RegExpObject(exec->lexicalGlobalObject()->regExpPrototype(), regExp.release());
else
return jsNull();
}
}
if (type == QMetaType::QDateTime ||
type == QMetaType::QDate ||
type == QMetaType::QTime) {
DateConstructor *dateObj = static_cast<DateConstructor*>(exec->lexicalGlobalObject()->dateConstructor());
ArgList args;
QDate date = QDate::currentDate();
QTime time(0,0,0); // midnight
......@@ -767,14 +768,19 @@ JSValue* convertQVariantToValue(ExecState* exec, PassRefPtr<RootObject> root, co
}
// Dates specified this way are in local time (we convert DateTimes above)
args.append(jsNumber(exec, date.year()));
args.append(jsNumber(exec, date.month() - 1));
args.append(jsNumber(exec, date.day()));
args.append(jsNumber(exec, time.hour()));
args.append(jsNumber(exec, time.minute()));
args.append(jsNumber(exec, time.second()));
args.append(jsNumber(exec, time.msec()));
return dateObj->construct(exec, args);
GregorianDateTime dt;
dt.year = date.year() - 1900;
dt.month = date.month() - 1;
dt.monthDay = date.day();
dt.hour = time.hour();
dt.minute = time.minute();
dt.second = time.second();
dt.isDST = -1;
double ms = KJS::gregorianDateTimeToMS(dt, time.msec(), /*inputIsUTC*/ false);
DateInstance* instance = new (exec) DateInstance(exec->lexicalGlobalObject()->datePrototype());
instance->setInternalValue(jsNumber(exec, trunc(ms)));
return instance;
}
if (type == QMetaType::QByteArray) {
......@@ -1275,9 +1281,9 @@ void QtRuntimeMetaMethod::mark()
d->m_disconnect->mark();
}
JSValue* QtRuntimeMetaMethod::callAsFunction(ExecState* exec, JSObject*, const ArgList& args)
JSValue* QtRuntimeMetaMethod::call(ExecState* exec, JSObject* functionObject, JSValue* thisValue, const ArgList& args)
{
QW_D(QtRuntimeMetaMethod);
QtRuntimeMetaMethodData* d = static_cast<QtRuntimeMetaMethod *>(functionObject)->d_func();
// We're limited to 10 args
if (args.size() > 10)
......@@ -1311,6 +1317,12 @@ JSValue* QtRuntimeMetaMethod::callAsFunction(ExecState* exec, JSObject*, const A
return jsUndefined();
}
CallType QtRuntimeMetaMethod::getCallData(CallData& callData)
{
callData.native.function = call;
return CallTypeNative;
}
bool QtRuntimeMetaMethod::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
if (propertyName == "connect") {
......@@ -1367,9 +1379,9 @@ QtRuntimeConnectionMethod::QtRuntimeConnectionMethod(ExecState* exec, const Iden
d->m_isConnect = isConnect;
}
JSValue *QtRuntimeConnectionMethod::callAsFunction(ExecState* exec, JSObject*, const ArgList& args)
JSValue* QtRuntimeConnectionMethod::call(ExecState* exec, JSObject* functionObject, JSValue* thisValue, const ArgList& args)
{
QW_D(QtRuntimeConnectionMethod);
QtRuntimeConnectionMethodData* d = static_cast<QtRuntimeConnectionMethod *>(functionObject)->d_func();
JSLock lock;
......@@ -1391,7 +1403,8 @@ JSValue *QtRuntimeConnectionMethod::callAsFunction(ExecState* exec, JSObject*, c
if (signalIndex != -1) {
if (args.size() == 1) {
funcObject = args[0]->toObject(exec);
if (!funcObject->implementsCall()) {
CallData callData;
if (funcObject->getCallData(callData) == CallTypeNone) {
if (d->m_isConnect)
return throwError(exec, TypeError, "QtMetaMethod.connect: target is not a function");
else
......@@ -1403,7 +1416,8 @@ JSValue *QtRuntimeConnectionMethod::callAsFunction(ExecState* exec, JSObject*, c
// Get the actual function to call
JSObject *asObj = args[1]->toObject(exec);
if (asObj->implementsCall()) {
CallData callData;
if (asObj->getCallData(callData) != CallTypeNone) {
// Function version
funcObject = asObj;
} else {
......@@ -1416,7 +1430,7 @@ JSValue *QtRuntimeConnectionMethod::callAsFunction(ExecState* exec, JSObject*, c
JSValue* val = thisObject->get(exec, funcIdent);
JSObject* asFuncObj = val->toObject(exec);
if (asFuncObj->implementsCall()) {
if (asFuncObj->getCallData(callData) != CallTypeNone) {
funcObject = asFuncObj;
} else {
if (d->m_isConnect)
......@@ -1495,6 +1509,12 @@ JSValue *QtRuntimeConnectionMethod::callAsFunction(ExecState* exec, JSObject*, c
return jsUndefined();
}
CallType QtRuntimeConnectionMethod::getCallData(CallData& callData)
{
callData.native.function = call;
return CallTypeNative;
}
bool QtRuntimeConnectionMethod::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
if (propertyName == exec->propertyNames().length) {
......@@ -1615,6 +1635,8 @@ void QtConnectionObject::execute(void **argv)
l.append(jsUndefined());
}
}
CallData callData;
CallType callType = m_funcObject->getCallData(callData);
// Stuff in the __qt_sender property, if we can
if (m_funcObject->inherits(&JSFunction::info)) {
JSFunction* fimp = static_cast<JSFunction*>(m_funcObject.get());
......@@ -1626,10 +1648,12 @@ void QtConnectionObject::execute(void **argv)
ScopeChain sc = oldsc;
sc.push(wrapper);
fimp->setScope(sc);
fimp->callAsFunction(exec, m_thisObject, l);
call(exec, fimp, callType, callData, m_thisObject, l);
fimp->setScope(oldsc);
} else
m_funcObject->callAsFunction(exec, m_thisObject, l);
} else {
call(exec, m_funcObject, callType, callData, m_thisObject, l);
}
}
}
}
......
......@@ -158,7 +158,6 @@ public:
QtRuntimeMetaMethod(ExecState *exec, const Identifier &n, PassRefPtr<QtInstance> inst, int index, const QByteArray& signature, bool allowPrivate);
virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const ArgList &args);
virtual void mark();
......@@ -166,6 +165,8 @@ protected:
QtRuntimeMetaMethodData* d_func() const {return reinterpret_cast<QtRuntimeMetaMethodData*>(d_ptr);}
private:
virtual CallType getCallData(CallData&);
static JSValue* call(ExecState* exec, JSObject* functionObject, JSValue* thisValue, const ArgList& args);
static JSValue* lengthGetter(ExecState*, const Identifier&, const PropertySlot&);
static JSValue* connectGetter(ExecState*, const Identifier&, const PropertySlot&);
static JSValue* disconnectGetter(ExecState*, const Identifier&, const PropertySlot&);
......@@ -178,12 +179,13 @@ public:
QtRuntimeConnectionMethod(ExecState *exec, const Identifier &n, bool isConnect, PassRefPtr<QtInstance> inst, int index, const QByteArray& signature );
virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const ArgList &args);
protected:
QtRuntimeConnectionMethodData* d_func() const {return reinterpret_cast<QtRuntimeConnectionMethodData*>(d_ptr);}
private:
virtual CallType getCallData(CallData&);
static JSValue* call(ExecState* exec, JSObject* functionObject, JSValue* thisValue, const ArgList& args);
static JSValue* lengthGetter(ExecState*, const Identifier&, const PropertySlot&);
static QMultiMap<QObject *, QtConnectionObject *> connections;
friend class QtConnectionObject;
......
......@@ -53,6 +53,7 @@
#include "HitTestResult.h"
#include "runtime.h"
#include "runtime_object.h"
#include "runtime_root.h"
#include "JSDOMWindow.h"
#include "qt_instance.h"
......
2008-06-24 Simon Hausmann <hausmann@webkit.org>
Fix the Qt build, added missing include for RuntimeObjectImp.
* Api/qwebframe.cpp:
2008-06-23 Benjamin C Meyer <ben@meyerhome.net>
Reviewed by Simon.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment