Fix the Qt build, add ExecState where required.
authorhausmann@webkit.org <hausmann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 2 May 2008 11:04:26 +0000 (11:04 +0000)
committerhausmann@webkit.org <hausmann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 2 May 2008 11:04:26 +0000 (11:04 +0000)
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@32810 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/bridge/qt/qt_class.cpp
WebCore/bridge/qt/qt_instance.cpp
WebCore/bridge/qt/qt_instance.h
WebCore/bridge/qt/qt_runtime.cpp
WebCore/bridge/runtime.cpp
WebKit/qt/Api/qwebframe.cpp
WebKit/qt/ChangeLog

index e21051e..4450ef5 100644 (file)
@@ -1,3 +1,28 @@
+2008-05-02  Simon Hausmann  <hausmann@webkit.org>
+
+        Fix the Qt build. Add ExecState where necessary.
+
+        * bridge/qt/qt_class.cpp:
+        (KJS::Bindings::QtClass::fallbackObject):
+        * bridge/qt/qt_instance.cpp:
+        (KJS::Bindings::QtRuntimeObjectImp::construct):
+        (KJS::Bindings::QtInstance::getRuntimeObject):
+        (KJS::Bindings::QtInstance::invokeDefaultMethod):
+        (KJS::Bindings::QtInstance::defaultValue):
+        (KJS::Bindings::QtInstance::stringValue):
+        * bridge/qt/qt_instance.h:
+        (KJS::Bindings::QtInstance::getObject):
+        * bridge/qt/qt_runtime.cpp:
+        (KJS::Bindings::convertValueToQVariant):
+        (KJS::Bindings::convertQVariantToValue):
+        (KJS::Bindings::QtRuntimeMetaMethod::lengthGetter):
+        (KJS::Bindings::QtRuntimeMetaMethod::connectGetter):
+        (KJS::Bindings::QtRuntimeMetaMethod::disconnectGetter):
+        (KJS::Bindings::QtRuntimeConnectionMethod::lengthGetter):
+        (KJS::Bindings::QtConnectionObject::execute):
+        * bridge/runtime.cpp:
+        (KJS::Bindings::Instance::createRuntimeObject):
+
 2008-05-02  Simon Hausmann  <shausman@trolltech.com>
 
         Fix the Qt/Win build.
index adbac22..f40fdcd 100644 (file)
@@ -85,7 +85,7 @@ JSValue* QtClass::fallbackObject(ExecState *exec, Instance *inst, const Identifi
     if (normal.contains('(') && (index = m_metaObject->indexOfMethod(normal)) != -1) {
         QMetaMethod m = m_metaObject->method(index);
         if (m.access() != QMetaMethod::Private) {
-            JSValue *val = new QtRuntimeMetaMethod(exec, identifier, static_cast<QtInstance*>(inst), index, normal, false);
+            JSValue *val = new (exec) QtRuntimeMetaMethod(exec, identifier, static_cast<QtInstance*>(inst), index, normal, false);
             qtinst->m_methods.insert(name, val);
             return val;
         }
@@ -102,7 +102,7 @@ JSValue* QtClass::fallbackObject(ExecState *exec, Instance *inst, const Identifi
         signature.truncate(signature.indexOf('('));
 
         if (normal == signature) {
-            JSValue* val = new QtRuntimeMetaMethod(exec, identifier, static_cast<QtInstance*>(inst), index, normal, false);
+            JSValue* val = new (exec) QtRuntimeMetaMethod(exec, identifier, static_cast<QtInstance*>(inst), index, normal, false);
             qtinst->m_methods.insert(name, val);
             return val;
         }
index bb0e141..45f9857 100644 (file)
@@ -95,7 +95,7 @@ JSObject* QtRuntimeObjectImp::construct(ExecState* exec, const List& args)
     JSValue *val = callAsFunction(exec, this, args);
 
     if (!val || val->type() == NullType || val->type() == UndefinedType)
-        return new JSObject(exec->lexicalGlobalObject()->objectPrototype());
+        return new (exec) JSObject(exec->lexicalGlobalObject()->objectPrototype());
     else
         return val->toObject(exec);
 }
@@ -142,12 +142,12 @@ PassRefPtr<QtInstance> QtInstance::getQtInstance(QObject* o, PassRefPtr<RootObje
     return ret.release();
 }
 
-JSObject* QtInstance::getRuntimeObject(PassRefPtr<QtInstance> instance)
+JSObject* QtInstance::getRuntimeObject(ExecState* exec, PassRefPtr<QtInstance> instance)
 {
     JSLock lock;
     JSObject* ret = cachedObjects.value(instance.get());
     if (!ret) {
-        ret = new QtRuntimeObjectImp(instance);
+        ret = new (exec) QtRuntimeObjectImp(instance);
         cachedObjects.insert(instance.get(), ret);
     }
     return ret;
@@ -260,25 +260,25 @@ JSValue* QtInstance::invokeDefaultMethod(ExecState* exec, const List& args)
     // implementsCall will update our default method cache, if possible
     if (implementsCall()) {
         if (!m_defaultMethod)
-            m_defaultMethod = new QtRuntimeMetaMethod(exec, Identifier("[[Call]]"),this, m_defaultMethodIndex, QByteArray("qscript_call"), true);
+            m_defaultMethod = new (exec) QtRuntimeMetaMethod(exec, Identifier("[[Call]]"),this, m_defaultMethodIndex, QByteArray("qscript_call"), true);
 
         return m_defaultMethod->callAsFunction(exec, 0, args); // Luckily QtRuntimeMetaMethod ignores the obj parameter
     } else
         return throwError(exec, TypeError, "not a function");
 }
 
-JSValue* QtInstance::defaultValue(JSType hint) const
+JSValue* QtInstance::defaultValue(ExecState* exec, JSType hint) const
 {
     if (hint == StringType)
-        return stringValue();
+        return stringValue(exec);
     if (hint == NumberType)
-        return numberValue();
+        return numberValue(exec);
     if (hint == BooleanType)
         return booleanValue();
-    return valueOf();
+    return valueOf(exec);
 }
 
-JSValue* QtInstance::stringValue() const
+JSValue* QtInstance::stringValue(ExecState* exec) const
 {
     // Hmm.. see if there is a toString defined
     QByteArray buf;
@@ -319,12 +319,12 @@ JSValue* QtInstance::stringValue() const
 
         buf = str.toLatin1();
     }
-    return jsString(buf.constData());
+    return jsString(exec, buf.constData());
 }
 
-JSValue* QtInstance::numberValue() const
+JSValue* QtInstance::numberValue(ExecState* exec) const
 {
-    return jsNumber(0);
+    return jsNumber(exec, 0);
 }
 
 JSValue* QtInstance::booleanValue() const
@@ -333,9 +333,9 @@ JSValue* QtInstance::booleanValue() const
     return jsBoolean(true);
 }
 
-JSValue* QtInstance::valueOf() const
+JSValue* QtInstance::valueOf(ExecState* exec) const
 {
-    return stringValue();
+    return stringValue(exec);
 }
 
 // In qt_runtime.cpp
index 75c1edf..b552f12 100644 (file)
@@ -49,8 +49,8 @@ public:
     virtual void begin();
     virtual void end();
 
-    virtual JSValue* valueOf() const;
-    virtual JSValue* defaultValue (JSType hint) const;
+    virtual JSValue* valueOf(ExecState* exec) const;
+    virtual JSValue* defaultValue(ExecState* exec, JSType hint) const;
 
     virtual bool implementsCall() const;
 
@@ -63,14 +63,14 @@ public:
 
     virtual BindingLanguage getBindingLanguage() const { return QtLanguage; }
 
-    JSValue* stringValue() const;
-    JSValue* numberValue() const;
+    JSValue* stringValue(ExecState* exec) const;
+    JSValue* numberValue(ExecState* exec) const;
     JSValue* booleanValue() const;
 
     QObject* getObject() const { return m_object; }
 
     static PassRefPtr<QtInstance> getQtInstance(QObject*, PassRefPtr<RootObject>);
-    static JSObject* getRuntimeObject(PassRefPtr<QtInstance>);
+    static JSObject* getRuntimeObject(ExecState* exec, PassRefPtr<QtInstance>);
 
 private:
     friend class QtClass;
index 346528e..8d767eb 100644 (file)
@@ -131,7 +131,7 @@ static JSRealType valueRealType(ExecState* exec, JSValue* val)
 QVariant convertValueToQVariant(ExecState* exec, JSValue* value, QMetaType::Type hint, int *distance)
 {
     // check magic pointer values before dereferencing value
-    if (value == jsNaN() || value == jsUndefined()) {
+    if (value == jsNaN(exec) || value == jsUndefined()) {
         if (distance)
             *distance = -1;
         return QVariant();
@@ -726,7 +726,7 @@ JSValue* convertQVariantToValue(ExecState* exec, PassRefPtr<RootObject> root, co
         type == QMetaType::UShort ||
         type == QMetaType::Float ||
         type == QMetaType::Double)
-        return jsNumber(variant.toDouble());
+        return jsNumber(exec, variant.toDouble());
 
     if (type == QMetaType::QRegExp) {
         QRegExp re = variant.value<QRegExp>();
@@ -739,8 +739,8 @@ JSValue* convertQVariantToValue(ExecState* exec, PassRefPtr<RootObject> root, co
             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(ustring));
-            args.append(jsString(uflags));
+            args.append(jsString(exec, ustring));
+            args.append(jsString(exec, uflags));
             return regExpObj->construct(exec, args);
         }
     }
@@ -765,30 +765,30 @@ JSValue* convertQVariantToValue(ExecState* exec, PassRefPtr<RootObject> root, co
         }
 
         // Dates specified this way are in local time (we convert DateTimes above)
-        args.append(jsNumber(date.year()));
-        args.append(jsNumber(date.month() - 1));
-        args.append(jsNumber(date.day()));
-        args.append(jsNumber(time.hour()));
-        args.append(jsNumber(time.minute()));
-        args.append(jsNumber(time.second()));
-        args.append(jsNumber(time.msec()));
+        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);
     }
 
     if (type == QMetaType::QByteArray) {
         QByteArray ba = variant.value<QByteArray>();
         UString ustring(ba.constData());
-        return jsString(ustring);
+        return jsString(exec, ustring);
     }
 
     if (type == QMetaType::QObjectStar || type == QMetaType::QWidgetStar) {
         QObject* obj = variant.value<QObject*>();
-        return Instance::createRuntimeObject(QtInstance::create(obj, root));
+        return Instance::createRuntimeObject(exec, QtInstance::create(obj, root));
     }
 
     if (type == QMetaType::QVariantMap) {
         // create a new object, and stuff properties into it
-        JSObject* ret = new JSObject(exec->lexicalGlobalObject()->objectPrototype());
+        JSObject* ret = new (exec) JSObject(exec->lexicalGlobalObject()->objectPrototype());
         QVariantMap map = variant.value<QVariantMap>();
         QVariantMap::const_iterator i = map.constBegin();
         while (i != map.constEnd()) {
@@ -807,16 +807,16 @@ JSValue* convertQVariantToValue(ExecState* exec, PassRefPtr<RootObject> root, co
     if (type == QMetaType::QVariantList) {
         QVariantList vl = variant.toList();
         qConvDebug() << "got a " << vl.count() << " length list:" << vl;
-        return new RuntimeArray(exec, new QtArray<QVariant>(vl, QMetaType::Void, root));
+        return new (exec) RuntimeArray(exec, new QtArray<QVariant>(vl, QMetaType::Void, root));
     } else if (type == QMetaType::QStringList) {
         QStringList sl = variant.value<QStringList>();
-        return new RuntimeArray(exec, new QtArray<QString>(sl, QMetaType::QString, root));
+        return new (exec) RuntimeArray(exec, new QtArray<QString>(sl, QMetaType::QString, root));
     } else if (type == (QMetaType::Type) qMetaTypeId<QObjectList>()) {
         QObjectList ol= variant.value<QObjectList>();
-        return new RuntimeArray(exec, new QtArray<QObject*>(ol, QMetaType::QObjectStar, root));
+        return new (exec) RuntimeArray(exec, new QtArray<QObject*>(ol, QMetaType::QObjectStar, root));
     } else if (type == (QMetaType::Type)qMetaTypeId<QList<int> >()) {
         QList<int> il= variant.value<QList<int> >();
-        return new RuntimeArray(exec, new QtArray<int>(il, QMetaType::Int, root));
+        return new (exec) RuntimeArray(exec, new QtArray<int>(il, QMetaType::Int, root));
     }
 
     if (type == (QMetaType::Type)qMetaTypeId<QVariant>()) {
@@ -829,7 +829,7 @@ JSValue* convertQVariantToValue(ExecState* exec, PassRefPtr<RootObject> root, co
 
     QString string = variant.toString();
     UString ustring((UChar*)string.utf16(), string.length());
-    return jsString(ustring);
+    return jsString(exec, ustring);
 }
 
 // ===============
@@ -1325,10 +1325,10 @@ bool QtRuntimeMetaMethod::getOwnPropertySlot(ExecState* exec, const Identifier&
     return QtRuntimeMethod::getOwnPropertySlot(exec, propertyName, slot);
 }
 
-JSValue *QtRuntimeMetaMethod::lengthGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&)
+JSValue *QtRuntimeMetaMethod::lengthGetter(ExecState* exec, JSObject*, const Identifier&, const PropertySlot&)
 {
     // QtScript always returns 0
-    return jsNumber(0);
+    return jsNumber(exec, 0);
 }
 
 JSValue *QtRuntimeMetaMethod::connectGetter(ExecState* exec, JSObject*, const Identifier& ident, const PropertySlot& slot)
@@ -1337,7 +1337,7 @@ JSValue *QtRuntimeMetaMethod::connectGetter(ExecState* exec, JSObject*, const Id
     QW_DS(QtRuntimeMetaMethod, thisObj);
 
     if (!d->m_connect)
-        d->m_connect = new QtRuntimeConnectionMethod(exec, ident, true, d->m_instance, d->m_index, d->m_signature);
+        d->m_connect = new (exec) QtRuntimeConnectionMethod(exec, ident, true, d->m_instance, d->m_index, d->m_signature);
     return d->m_connect;
 }
 
@@ -1347,7 +1347,7 @@ JSValue* QtRuntimeMetaMethod::disconnectGetter(ExecState* exec, JSObject*, const
     QW_DS(QtRuntimeMetaMethod, thisObj);
 
     if (!d->m_disconnect)
-        d->m_disconnect = new QtRuntimeConnectionMethod(exec, ident, false, d->m_instance, d->m_index, d->m_signature);
+        d->m_disconnect = new (exec) QtRuntimeConnectionMethod(exec, ident, false, d->m_instance, d->m_index, d->m_signature);
     return d->m_disconnect;
 }
 
@@ -1503,10 +1503,10 @@ bool QtRuntimeConnectionMethod::getOwnPropertySlot(ExecState* exec, const Identi
     return QtRuntimeMethod::getOwnPropertySlot(exec, propertyName, slot);
 }
 
-JSValue *QtRuntimeConnectionMethod::lengthGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&)
+JSValue *QtRuntimeConnectionMethod::lengthGetter(ExecState* exec, JSObject*, const Identifier&, const PropertySlot&)
 {
     // we have one formal argument, and one optional
-    return jsNumber(1);
+    return jsNumber(exec, 1);
 }
 
 // ===============
@@ -1617,8 +1617,8 @@ void QtConnectionObject::execute(void **argv)
                     if (m_funcObject->inherits(&FunctionImp::info)) {
                         FunctionImp* fimp = static_cast<FunctionImp*>(m_funcObject.get());
 
-                        JSObject* qt_sender = Instance::createRuntimeObject(QtInstance::create(sender(), ro));
-                        JSObject* wrapper = new JSObject();
+                        JSObject* qt_sender = Instance::createRuntimeObject(exec, QtInstance::create(sender(), ro));
+                        JSObject* wrapper = new (exec) JSObject();
                         wrapper->put(exec, "__qt_sender__", qt_sender);
                         ScopeChain oldsc = fimp->scope();
                         ScopeChain sc = oldsc;
index 589438b..ae9368b 100644 (file)
@@ -104,7 +104,7 @@ JSObject* Instance::createRuntimeObject(ExecState* exec, PassRefPtr<Instance> in
 {
 #if PLATFORM(QT)
     if (instance->getBindingLanguage() == QtLanguage)
-        return QtInstance::getRuntimeObject(static_cast<QtInstance*>(instance.get()));
+        return QtInstance::getRuntimeObject(exec, static_cast<QtInstance*>(instance.get()));
 #endif
     JSLock lock;
 
index 94096d7..01af7e9 100644 (file)
@@ -214,10 +214,12 @@ void QWebFrame::addToJavaScriptWindowObject(const QString &name, QObject *object
           return;
       }
 
+      KJS::ExecState* exec = window->globalExec();
+
       KJS::JSObject *runtimeObject =
-        KJS::Bindings::Instance::createRuntimeObject(KJS::Bindings::QtInstance::create(object, root));
+        KJS::Bindings::Instance::createRuntimeObject(exec, KJS::Bindings::QtInstance::create(object, root));
 
-      window->put(window->globalExec(), KJS::Identifier((const UChar *) name.constData(), name.length()), runtimeObject);
+      window->put(exec, KJS::Identifier((const UChar *) name.constData(), name.length()), runtimeObject);
 }
 
 /*!
index bc7ab22..04c8c13 100644 (file)
@@ -1,3 +1,10 @@
+2008-05-02  Simon Hausmann  <hausmann@webkit.org>
+
+        Fix the Qt build, ExecState is required here.
+
+        * Api/qwebframe.cpp:
+        (QWebFrame::addToJavaScriptWindowObject):
+
 2008-05-01  Marc Ordinas i Llopis  <marc.ordinasillopis@collabora.co.uk>
 
         Reviewed by Alp Toker.