From bf7b7272ee130e7c6d793c3b87cbf932be8aff48 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Mon, 16 Jul 2012 15:31:24 +0200 Subject: [PATCH] jscript: Properly set Function constructor's constructor property. --- dlls/jscript/function.c | 20 ++++++++++++++------ dlls/jscript/tests/lang.js | 2 +- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/dlls/jscript/function.c b/dlls/jscript/function.c index 765efccba6..1d188e7723 100644 --- a/dlls/jscript/function.c +++ b/dlls/jscript/function.c @@ -639,22 +639,28 @@ HRESULT create_builtin_function(script_ctx_t *ctx, builtin_invoke_t value_proc, return S_OK; } +static HRESULT set_constructor_prop(script_ctx_t *ctx, jsdisp_t *constr, jsdisp_t *prot) +{ + VARIANT v; + + static const WCHAR constructorW[] = {'c','o','n','s','t','r','u','c','t','o','r',0}; + + V_VT(&v) = VT_DISPATCH; + V_DISPATCH(&v) = to_disp(constr); + return jsdisp_propput_name(prot, constructorW, &v, NULL); +} + HRESULT create_builtin_constructor(script_ctx_t *ctx, builtin_invoke_t value_proc, const WCHAR *name, const builtin_info_t *builtin_info, DWORD flags, jsdisp_t *prototype, jsdisp_t **ret) { jsdisp_t *constr; - VARIANT v; HRESULT hres; - static const WCHAR constructorW[] = {'c','o','n','s','t','r','u','c','t','o','r',0}; - hres = create_builtin_function(ctx, value_proc, name, builtin_info, flags, prototype, &constr); if(FAILED(hres)) return hres; - V_VT(&v) = VT_DISPATCH; - V_DISPATCH(&v) = to_disp(constr); - hres = jsdisp_propput_name(prototype, constructorW, &v, NULL); + hres = set_constructor_prop(ctx, constr, prototype); if(FAILED(hres)) { jsdisp_release(constr); return hres; @@ -839,6 +845,8 @@ HRESULT init_function_constr(script_ctx_t *ctx, jsdisp_t *object_prototype) constr->value_proc = FunctionConstr_value; constr->name = FunctionW; hres = set_prototype(ctx, &constr->dispex, &prot->dispex); + if(SUCCEEDED(hres)) + hres = set_constructor_prop(ctx, &constr->dispex, &prot->dispex); if(FAILED(hres)) jsdisp_release(&constr->dispex); } diff --git a/dlls/jscript/tests/lang.js b/dlls/jscript/tests/lang.js index c37b7c74ed..a0eae4a659 100644 --- a/dlls/jscript/tests/lang.js +++ b/dlls/jscript/tests/lang.js @@ -101,7 +101,7 @@ testConstructor(Array, "Array"); testConstructor(Boolean, "Boolean"); testConstructor(Number, "Number"); testConstructor(RegExp, "RegExp"); -//testConstructor(Function, "Function"); +testConstructor(Function, "Function"); testConstructor(Date, "Date"); testConstructor(VBArray, "VBArray"); -- 2.32.0.93.g670b81a890