From 25e76959da84fe4c40f98cf32b7b8c69e5087681 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Mon, 13 Jul 2009 11:19:48 +0200 Subject: add some world-class hacks to JSC to make QtScript work QtScript needs the VM to create script objects of type QScriptObject, not JSC::Object. This is so that the class of the object can be changed dynamically using e.g. QScriptValue::setScriptClass(), or the overload of QScriptEngine::newQObject() that takes an existing object as first argument (it "promotes" the plain script object to a QObject wrapper). This makes the bindings produced by the bindings generator work. When JSC becomes a shared library, we need another solution. --- .../webkit/JavaScriptCore/interpreter/Interpreter.cpp | 16 ++++++++++++++-- src/3rdparty/webkit/JavaScriptCore/runtime/JSObject.cpp | 5 +++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/3rdparty/webkit/JavaScriptCore/interpreter/Interpreter.cpp b/src/3rdparty/webkit/JavaScriptCore/interpreter/Interpreter.cpp index d9c5cda..d006b53 100644 --- a/src/3rdparty/webkit/JavaScriptCore/interpreter/Interpreter.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/interpreter/Interpreter.cpp @@ -69,6 +69,10 @@ #include "AssemblerBuffer.h" #endif +#ifdef QT_BUILD_SCRIPT_LIB +#include "bridge/qscriptobject_p.h" +#endif + using namespace std; namespace JSC { @@ -3468,8 +3472,12 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi structure = asObject(prototype)->inheritorID(); else structure = callDataScopeChain->globalObject()->emptyObjectStructure(); +#ifdef QT_BUILD_SCRIPT_LIB + // ### world-class hack + QScriptObject* newObject = new (globalData) QScriptObject(structure); +#else JSObject* newObject = new (globalData) JSObject(structure); - +#endif callFrame[thisRegister] = JSValue(newObject); // "this" value CallFrame* previousCallFrame = callFrame; @@ -3502,8 +3510,12 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi structure = asObject(prototype)->inheritorID(); else structure = scopeChain->globalObject()->emptyObjectStructure(); +#ifdef QT_BUILD_SCRIPT_LIB + // ### world-class hack + QScriptObject* newObject = new (globalData) QScriptObject(structure); +#else JSObject* newObject = new (globalData) JSObject(structure); - +#endif callFrame[thisRegister] = JSValue(newObject); // "this" value CallFrame* newCallFrame = CallFrame::create(callFrame->registers() + registerOffset); diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/JSObject.cpp b/src/3rdparty/webkit/JavaScriptCore/runtime/JSObject.cpp index 415c25d..a54c322 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/JSObject.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/JSObject.cpp @@ -524,7 +524,12 @@ NEVER_INLINE void JSObject::fillGetterPropertySlot(PropertySlot& slot, JSValue* Structure* JSObject::createInheritorID() { +#ifdef QT_BUILD_SCRIPT_LIB + // ### QtScript needs the hasOwnProperty() calls etc. for QScriptObject + m_inheritorID = Structure::create(this, TypeInfo(ObjectType, ImplementsHasInstance)); +#else m_inheritorID = JSObject::createStructure(this); +#endif return m_inheritorID.get(); } -- cgit v0.12