summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/script/api/qscriptengine.cpp6
-rw-r--r--src/script/bridge/qscriptfunction.cpp34
-rw-r--r--src/script/bridge/qscriptfunction_p.h20
3 files changed, 31 insertions, 29 deletions
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp
index 9fba7cb..02a5e2d 100644
--- a/src/script/api/qscriptengine.cpp
+++ b/src/script/api/qscriptengine.cpp
@@ -1512,7 +1512,7 @@ QScriptValue QScriptEngine::newFunction(QScriptEngine::FunctionSignature fun,
{
Q_D(QScriptEngine);
JSC::ExecState* exec = d->currentFrame;
- JSC::JSValue function = new (exec)QScript::FunctionWrapper(this, length, JSC::Identifier(exec, ""), fun);
+ JSC::JSValue function = new (exec)QScript::FunctionWrapper(exec, length, JSC::Identifier(exec, ""), fun);
QScriptValue result = d->scriptValueFromJSCValue(function);
result.setProperty(QLatin1String("prototype"), prototype, QScriptValue::Undeletable);
const_cast<QScriptValue&>(prototype)
@@ -1838,7 +1838,7 @@ QScriptValue QScriptEngine::newFunction(QScriptEngine::FunctionSignature fun, in
{
Q_D(QScriptEngine);
JSC::ExecState* exec = d->currentFrame;
- JSC::JSValue function = new (exec)QScript::FunctionWrapper(this, length, JSC::Identifier(exec, ""), fun);
+ JSC::JSValue function = new (exec)QScript::FunctionWrapper(exec, length, JSC::Identifier(exec, ""), fun);
QScriptValue result = d->scriptValueFromJSCValue(function);
QScriptValue proto = newObject();
result.setProperty(QLatin1String("prototype"), proto, QScriptValue::Undeletable);
@@ -1855,7 +1855,7 @@ QScriptValue QScriptEngine::newFunction(QScriptEngine::FunctionWithArgSignature
{
Q_D(QScriptEngine);
JSC::ExecState* exec = d->currentFrame;
- JSC::JSValue function = new (exec)QScript::FunctionWithArgWrapper(this, /*length=*/0, JSC::Identifier(exec, ""), fun, arg);
+ JSC::JSValue function = new (exec)QScript::FunctionWithArgWrapper(exec, /*length=*/0, JSC::Identifier(exec, ""), fun, arg);
QScriptValue result = d->scriptValueFromJSCValue(function);
QScriptValue proto = newObject();
result.setProperty(QLatin1String("prototype"), proto, QScriptValue::Undeletable);
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;
diff --git a/src/script/bridge/qscriptfunction_p.h b/src/script/bridge/qscriptfunction_p.h
index 360b40c..4901b72 100644
--- a/src/script/bridge/qscriptfunction_p.h
+++ b/src/script/bridge/qscriptfunction_p.h
@@ -72,18 +72,20 @@ public:
// work around CELL_SIZE limitation
struct Data
{
- QScriptEngine *engine;
QScriptEngine::FunctionSignature function;
};
- FunctionWrapper(QScriptEngine *, int length, const JSC::Identifier&, QScriptEngine::FunctionSignature);
+ FunctionWrapper(JSC::ExecState*, int length, const JSC::Identifier&,
+ QScriptEngine::FunctionSignature);
~FunctionWrapper();
private:
virtual JSC::ConstructType getConstructData(JSC::ConstructData&);
- static JSC::JSValue JSC_HOST_CALL proxyCall(JSC::ExecState *, JSC::JSObject *, JSC::JSValue, const JSC::ArgList &);
- static JSC::JSObject* proxyConstruct(JSC::ExecState *, JSC::JSObject *, const JSC::ArgList &);
+ static JSC::JSValue JSC_HOST_CALL proxyCall(JSC::ExecState *, JSC::JSObject *,
+ JSC::JSValue, const JSC::ArgList &);
+ static JSC::JSObject* proxyConstruct(JSC::ExecState *, JSC::JSObject *,
+ const JSC::ArgList &);
private:
Data *data;
@@ -95,19 +97,21 @@ public:
// work around CELL_SIZE limitation
struct Data
{
- QScriptEngine *engine;
QScriptEngine::FunctionWithArgSignature function;
void *arg;
};
- FunctionWithArgWrapper(QScriptEngine *, int length, const JSC::Identifier&, QScriptEngine::FunctionWithArgSignature, void *);
+ FunctionWithArgWrapper(JSC::ExecState*, int length, const JSC::Identifier&,
+ QScriptEngine::FunctionWithArgSignature, void *);
~FunctionWithArgWrapper();
private:
virtual JSC::ConstructType getConstructData(JSC::ConstructData&);
- static JSC::JSValue JSC_HOST_CALL proxyCall(JSC::ExecState *, JSC::JSObject *, JSC::JSValue , const JSC::ArgList &);
- static JSC::JSObject* proxyConstruct(JSC::ExecState *, JSC::JSObject *, const JSC::ArgList &);
+ static JSC::JSValue JSC_HOST_CALL proxyCall(JSC::ExecState *, JSC::JSObject *,
+ JSC::JSValue , const JSC::ArgList &);
+ static JSC::JSObject* proxyConstruct(JSC::ExecState *, JSC::JSObject *,
+ const JSC::ArgList &);
private:
Data *data;