diff options
author | Kent Hansen <khansen@trolltech.com> | 2009-07-27 13:22:58 (GMT) |
---|---|---|
committer | Kent Hansen <khansen@trolltech.com> | 2009-07-27 13:22:58 (GMT) |
commit | 76d112eb3c7ea9045f26bee070302924a84fb15c (patch) | |
tree | a5c757ba406a2dfd2dfc7b3d4b674d3e9810fa47 /src/script/api | |
parent | 94c4d2cf9ed3878d91a866d492717ae36bb253bd (diff) | |
download | Qt-76d112eb3c7ea9045f26bee070302924a84fb15c.zip Qt-76d112eb3c7ea9045f26bee070302924a84fb15c.tar.gz Qt-76d112eb3c7ea9045f26bee070302924a84fb15c.tar.bz2 |
use custom JSGlobalData clientdata to keep pointer to script engine
Better than relying on a custom Global Object.
Diffstat (limited to 'src/script/api')
-rw-r--r-- | src/script/api/qscriptengine.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index 4070c67..3230394 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -308,6 +308,15 @@ public: namespace QScript { +struct GlobalClientData : public JSC::JSGlobalData::ClientData +{ + GlobalClientData(QScriptEnginePrivate *e) + : engine(e) {} + virtual ~GlobalClientData() {} + + QScriptEnginePrivate *engine; +}; + class GlobalObject : public JSC::JSGlobalObject { public: @@ -412,7 +421,7 @@ QString qtStringFromJSCUString(const JSC::UString &str) QScriptEnginePrivate *scriptEngineFromExec(JSC::ExecState *exec) { - return static_cast<QScript::GlobalObject*>(exec->lexicalGlobalObject())->engine; + return static_cast<GlobalClientData*>(exec->globalData().clientData)->engine; } bool isFunction(JSC::JSValue value) @@ -800,6 +809,7 @@ QScriptEnginePrivate::QScriptEnginePrivate() : idGenerator(1) JSC::initializeThreading(); // ### hmmm globalData = JSC::JSGlobalData::create().releaseRef(); + globalData->clientData = new QScript::GlobalClientData(this); globalObject = new (globalData)QScript::GlobalObject(this); JSC::ExecState* exec = globalObject->globalExec(); |