Set the prototype of script and native functions.
authorRoberto Raggi <roberto.raggi@nokia.com>
Mon, 21 May 2012 13:16:19 +0000 (15:16 +0200)
committerRoberto Raggi <roberto.raggi@nokia.com>
Mon, 21 May 2012 13:16:19 +0000 (15:16 +0200)
qmljs_objects.cpp
tests/fun.4.js

index 4f26d2e..35a90ae 100644 (file)
@@ -257,12 +257,18 @@ String *ExecutionEngine::identifier(const QString &s)
 
 FunctionObject *ExecutionEngine::newNativeFunction(Context *scope, void (*code)(Context *))
 {
-    return new NativeFunction(scope, code);
+    NativeFunction *f = new NativeFunction(scope, code);
+    if (scope->engine->functionPrototype.isObject())
+        f->prototype = scope->engine->functionPrototype.objectValue;
+    return f;
 }
 
 FunctionObject *ExecutionEngine::newScriptFunction(Context *scope, IR::Function *function)
 {
-    return new ScriptFunction(scope, function);
+    ScriptFunction *f = new ScriptFunction(scope, function);
+    if (scope->engine->functionPrototype.isObject())
+        f->prototype = scope->engine->functionPrototype.objectValue;
+    return f;
 }
 
 Object *ExecutionEngine::newObject()
index fe0b704..1333fad 100644 (file)
@@ -3,6 +3,5 @@ function foo(a,b,c) {
     print("hello",a,b,c)
 }
 
-foo.call = Function.prototype.call
 foo.call(null, 1,2,3)