From 0c6b804e6302a05cd29cead8df12af6ca2f954fd Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Wed, 10 Sep 2008 21:09:04 +0200 Subject: [PATCH] jscript: Added initial prototype of functions. --- dlls/jscript/function.c | 8 +++++++- dlls/jscript/tests/lang.js | 23 +++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/dlls/jscript/function.c b/dlls/jscript/function.c index d4a3b620d40..4c07cb3e587 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 1914a05dedc..4a42b9d6e6c 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();