Jacek Caban : jscript: Added initial prototype of functions.

Alexandre Julliard julliard at winehq.org
Thu Sep 11 08:00:55 CDT 2008


Module: wine
Branch: master
Commit: 0c6b804e6302a05cd29cead8df12af6ca2f954fd
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=0c6b804e6302a05cd29cead8df12af6ca2f954fd

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Wed Sep 10 21:09:04 2008 +0200

jscript: Added initial prototype of functions.

---

 dlls/jscript/function.c    |    8 +++++++-
 dlls/jscript/tests/lang.js |   23 +++++++++++++++++++++++
 2 files changed, 30 insertions(+), 1 deletions(-)

diff --git a/dlls/jscript/function.c b/dlls/jscript/function.c
index d4a3b62..4c07cb3 100644
--- a/dlls/jscript/function.c
+++ b/dlls/jscript/function.c
@@ -424,11 +424,17 @@ HRESULT create_source_function(parser_ctx_t *ctx, parameter_t *parameters, sourc
         scope_chain_t *scope_chain, DispatchEx **ret)
 {
     FunctionInstance *function;
+    DispatchEx *prototype;
     parameter_t *iter;
     DWORD length = 0;
     HRESULT hres;
 
-    hres = create_function(ctx->script, PROPF_CONSTR, NULL, &function);
+    hres = create_object(ctx->script, NULL, &prototype);
+    if(FAILED(hres))
+        return hres;
+
+    hres = create_function(ctx->script, PROPF_CONSTR, prototype, &function);
+    jsdisp_release(prototype);
     if(FAILED(hres))
         return hres;
 
diff --git a/dlls/jscript/tests/lang.js b/dlls/jscript/tests/lang.js
index 1914a05..4a42b9d 100644
--- a/dlls/jscript/tests/lang.js
+++ b/dlls/jscript/tests/lang.js
@@ -93,4 +93,27 @@ obj1.func = function () {
 
 ok(obj1.func(true) === "test", "obj1.func(true) is not \"test\"");
 
+function testConstr1() {
+    this.var1 = 1;
+
+    ok(this !== undefined, "this is undefined");
+    ok(arguments.length === 1, "arguments.length is not 1");
+    ok(arguments["0"] === true, "arguments[0] is not 1");
+
+    return false;
+}
+
+testConstr1.prototype.pvar = 1;
+
+var obj2 = new testConstr1(true);
+ok(typeof(obj2) === "object", "typeof(obj2) is not object");
+ok(obj2.pvar === 1, "obj2.pvar is not 1");
+
+testConstr1.prototype.pvar = 2;
+ok(obj2.pvar === 2, "obj2.pvar is not 2");
+
+obj2.pvar = 3;
+testConstr1.prototype.pvar = 1;
+ok(obj2.pvar === 3, "obj2.pvar is not 3");
+
 reportSuccess();




More information about the wine-cvs mailing list