diff options
author | Kent Hansen <khansen@trolltech.com> | 2009-08-05 09:26:32 (GMT) |
---|---|---|
committer | Kent Hansen <khansen@trolltech.com> | 2009-08-05 09:27:50 (GMT) |
commit | f22c8da7c2c98cb25642c255c4b4f05fa4e4da3d (patch) | |
tree | 6d782174703c5e223701e67ca34f391fc8605d79 /src/script/bridge/qscriptfunction.cpp | |
parent | 4a3cf019b7261779ca3e8267278bf07947132db4 (diff) | |
download | Qt-f22c8da7c2c98cb25642c255c4b4f05fa4e4da3d.zip Qt-f22c8da7c2c98cb25642c255c4b4f05fa4e4da3d.tar.gz Qt-f22c8da7c2c98cb25642c255c4b4f05fa4e4da3d.tar.bz2 |
don't store QScriptEngine pointer in native function wrappers
We can infer it from the JSC environment when the function is
actually called.
Diffstat (limited to 'src/script/bridge/qscriptfunction.cpp')
-rw-r--r-- | src/script/bridge/qscriptfunction.cpp | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/src/script/bridge/qscriptfunction.cpp b/src/script/bridge/qscriptfunction.cpp index 04c1abd..5b3de9e 100644 --- a/src/script/bridge/qscriptfunction.cpp +++ b/src/script/bridge/qscriptfunction.cpp @@ -61,12 +61,11 @@ namespace QScript { -FunctionWrapper::FunctionWrapper(QScriptEngine *engine, int length, const JSC::Identifier &name, - QScriptEngine::FunctionSignature function) - : JSC::PrototypeFunction(QScriptEnginePrivate::get(engine)->globalExec(), - length, name, proxyCall), data(new Data()) +FunctionWrapper::FunctionWrapper(JSC::ExecState *exec, int length, const JSC::Identifier &name, + QScriptEngine::FunctionSignature function) + : JSC::PrototypeFunction(exec, length, name, proxyCall), + data(new Data()) { - data->engine = engine; data->function = function; } @@ -85,13 +84,13 @@ JSC::JSValue FunctionWrapper::proxyCall(JSC::ExecState *exec, JSC::JSObject *cal JSC::JSValue thisObject, const JSC::ArgList &args) { FunctionWrapper *self = static_cast<FunctionWrapper*>(callee); - QScriptEnginePrivate *eng_p = QScriptEnginePrivate::get(self->data->engine); + QScriptEnginePrivate *eng_p = QScript::scriptEngineFromExec(exec); QScriptContext *ctx = eng_p->contextForFrame(exec); //We might have nested eval inside our function so we should create another scope QScriptPushScopeHelper scope(exec); - QScriptValue result = self->data->function(ctx, self->data->engine); + QScriptValue result = self->data->function(ctx, QScriptEnginePrivate::get(eng_p)); if (!result.isValid()) result = QScriptValue(QScriptValue::UndefinedValue); @@ -102,26 +101,25 @@ JSC::JSObject* FunctionWrapper::proxyConstruct(JSC::ExecState *exec, JSC::JSObje const JSC::ArgList &args) { FunctionWrapper *self = static_cast<FunctionWrapper*>(callee); - QScriptEnginePrivate *eng_p = QScriptEnginePrivate::get(self->data->engine); + QScriptEnginePrivate *eng_p = QScript::scriptEngineFromExec(exec); QScriptContext *ctx = eng_p->contextForFrame(exec); //We might have nested eval inside our function so we should create another scope QScriptPushScopeHelper scope(exec, true); QScriptValue defaultObject = ctx->thisObject(); - QScriptValue result = self->data->function(ctx, self->data->engine); + QScriptValue result = self->data->function(ctx, QScriptEnginePrivate::get(eng_p)); if (!result.isObject()) result = defaultObject; return JSC::asObject(eng_p->scriptValueToJSCValue(result)); } -FunctionWithArgWrapper::FunctionWithArgWrapper(QScriptEngine *engine, int length, const JSC::Identifier &name, - QScriptEngine::FunctionWithArgSignature function, void *arg) - : JSC::PrototypeFunction(QScriptEnginePrivate::get(engine)->globalExec(), - length, name, proxyCall), data(new Data()) +FunctionWithArgWrapper::FunctionWithArgWrapper(JSC::ExecState *exec, int length, const JSC::Identifier &name, + QScriptEngine::FunctionWithArgSignature function, void *arg) + : JSC::PrototypeFunction(exec, length, name, proxyCall), + data(new Data()) { - data->engine = engine; data->function = function; data->arg = arg; } @@ -141,12 +139,12 @@ JSC::JSValue FunctionWithArgWrapper::proxyCall(JSC::ExecState *exec, JSC::JSObje JSC::JSValue thisObject, const JSC::ArgList &args) { FunctionWithArgWrapper *self = static_cast<FunctionWithArgWrapper*>(callee); - QScriptEnginePrivate *eng_p = QScriptEnginePrivate::get(self->data->engine); + QScriptEnginePrivate *eng_p = QScript::scriptEngineFromExec(exec); //We might have nested eval inside our function so we should create another scope QScriptPushScopeHelper scope(exec); - QScriptValue result = self->data->function(eng_p->contextForFrame(exec), self->data->engine, self->data->arg); + QScriptValue result = self->data->function(eng_p->contextForFrame(exec), QScriptEnginePrivate::get(eng_p), self->data->arg); return eng_p->scriptValueToJSCValue(result); } @@ -155,14 +153,14 @@ JSC::JSObject* FunctionWithArgWrapper::proxyConstruct(JSC::ExecState *exec, JSC: const JSC::ArgList &args) { FunctionWithArgWrapper *self = static_cast<FunctionWithArgWrapper*>(callee); - QScriptEnginePrivate *eng_p = QScriptEnginePrivate::get(self->data->engine); + QScriptEnginePrivate *eng_p = QScript::scriptEngineFromExec(exec); QScriptContext *ctx = eng_p->contextForFrame(exec); //We might have nested eval inside our function so we should create another scope QScriptPushScopeHelper scope(exec, true); QScriptValue defaultObject = ctx->thisObject(); - QScriptValue result = self->data->function(ctx, self->data->engine, self->data->arg); + QScriptValue result = self->data->function(ctx, QScriptEnginePrivate::get(eng_p) , self->data->arg); if (!result.isObject()) result = defaultObject; |