diff options
author | Kent Hansen <khansen@trolltech.com> | 2009-07-09 11:00:02 (GMT) |
---|---|---|
committer | Kent Hansen <khansen@trolltech.com> | 2009-07-09 11:00:02 (GMT) |
commit | d9b959c85b1b285e63e8aa2dcc01ac0426614ddf (patch) | |
tree | 5ed7dc3bdc22ec6d7475b262390346c8c54869ce /src/script/bridge | |
parent | c0612a4557dc5e79bd4c1f941971b5a9ef1e2322 (diff) | |
download | Qt-d9b959c85b1b285e63e8aa2dcc01ac0426614ddf.zip Qt-d9b959c85b1b285e63e8aa2dcc01ac0426614ddf.tar.gz Qt-d9b959c85b1b285e63e8aa2dcc01ac0426614ddf.tar.bz2 |
make native object constructors work
With commit 6985212c8909c89183b232ca28b96a2c8a2f1385,
context->thisObject() now returns the right thing.
Diffstat (limited to 'src/script/bridge')
-rw-r--r-- | src/script/bridge/qscriptfunction.cpp | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/script/bridge/qscriptfunction.cpp b/src/script/bridge/qscriptfunction.cpp index c93e025..8d2f0c8 100644 --- a/src/script/bridge/qscriptfunction.cpp +++ b/src/script/bridge/qscriptfunction.cpp @@ -70,19 +70,17 @@ JSC::JSObject* FunctionWrapper::proxyConstruct(JSC::ExecState *exec, JSC::JSObje const JSC::ArgList &args) { FunctionWrapper *self = static_cast<FunctionWrapper*>(callee); - QScriptValue object = self->data->engine->newObject(); QScriptEnginePrivate *eng_p = QScriptEnginePrivate::get(self->data->engine); JSC::ExecState *previousFrame = eng_p->currentFrame; QScriptContext *ctx = eng_p->contextForFrame(exec); eng_p->currentFrame = exec; + QScriptValue defaultObject = ctx->thisObject(); QScriptValue result = self->data->function(ctx, self->data->engine); - if (!result.isValid()) - result = QScriptValue(QScriptValue::UndefinedValue); + if (!result.isObject()) + result = defaultObject; eng_p->currentFrame = previousFrame; eng_p->releaseContextForFrame(exec); - if (result.isObject()) - return JSC::asObject(eng_p->scriptValueToJSCValue(result)); - return JSC::asObject(eng_p->scriptValueToJSCValue(object)); + return JSC::asObject(eng_p->scriptValueToJSCValue(result)); } FunctionWithArgWrapper::FunctionWithArgWrapper(QScriptEngine *engine, int length, const JSC::Identifier &name, @@ -124,17 +122,17 @@ JSC::JSObject* FunctionWithArgWrapper::proxyConstruct(JSC::ExecState *exec, JSC: const JSC::ArgList &args) { FunctionWithArgWrapper *self = static_cast<FunctionWithArgWrapper*>(callee); - QScriptValue object = self->data->engine->newObject(); QScriptEnginePrivate *eng_p = QScriptEnginePrivate::get(self->data->engine); JSC::ExecState *previousFrame = eng_p->currentFrame; QScriptContext *ctx = eng_p->contextForFrame(exec); eng_p->currentFrame = exec; + QScriptValue defaultObject = ctx->thisObject(); QScriptValue result = self->data->function(ctx, self->data->engine, self->data->arg); + if (!result.isObject()) + result = defaultObject; eng_p->currentFrame = previousFrame; eng_p->releaseContextForFrame(exec); - if (result.isObject()) - return JSC::asObject(eng_p->scriptValueToJSCValue(result)); - return JSC::asObject(eng_p->scriptValueToJSCValue(object)); + return JSC::asObject(eng_p->scriptValueToJSCValue(result)); } } // namespace QScript |