summaryrefslogtreecommitdiffstats
path: root/src/script/api
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-08-12 13:39:55 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-08-12 13:39:55 (GMT)
commitbbadec8c68d930a4cb9f45835aa7d1659620cdc3 (patch)
tree9bd835b4264624037dab12dcf4d298e44ef5c2a1 /src/script/api
parent30d5f14e1062df9d0f4d47e308982460e8f850d3 (diff)
downloadQt-bbadec8c68d930a4cb9f45835aa7d1659620cdc3.zip
Qt-bbadec8c68d930a4cb9f45835aa7d1659620cdc3.tar.gz
Qt-bbadec8c68d930a4cb9f45835aa7d1659620cdc3.tar.bz2
Cantralize the place when we construct the default 'this' object that JSC doesn't construct.
Removes code duplication. This also indirrectly fixes the QMetaObjectWrapperObject where this was missing
Diffstat (limited to 'src/script/api')
-rw-r--r--src/script/api/qscriptengine.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp
index a0ca6b0..cc6233b 100644
--- a/src/script/api/qscriptengine.cpp
+++ b/src/script/api/qscriptengine.cpp
@@ -2271,9 +2271,18 @@ QScriptContext *QScriptEngine::pushContext()
return the new top frame. (might be the same as exec if a new stackframe was not needed) or 0 if stack overflow
*/
-JSC::CallFrame *QScriptEnginePrivate::pushContext(JSC::CallFrame *exec, const JSC::JSValue &thisObject,
+JSC::CallFrame *QScriptEnginePrivate::pushContext(JSC::CallFrame *exec, const JSC::JSValue &_thisObject,
const JSC::ArgList& args, JSC::JSObject *callee, bool calledAsConstructor)
{
+ JSC::JSValue thisObject = _thisObject;
+ if (calledAsConstructor) {
+ //JSC doesn't create default created object for native functions. so we do it
+ JSC::JSValue prototype = callee->get(exec, exec->propertyNames().prototype);
+ JSC::Structure *structure = prototype.isObject() ? JSC::asObject(prototype)->inheritorID()
+ : exec->lexicalGlobalObject()->emptyObjectStructure();
+ thisObject = new (exec) QScriptObject(structure);
+ }
+
JSC::CallFrame *newCallFrame = exec;
if (callee == 0 || !(exec->callee() == callee && exec->returnPC() != 0)) {
//We need to check if the Interpreter might have already created a frame for function called from JS.