Commit bf7b7272 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Properly set Function constructor's constructor property.

parent d4926503
...@@ -639,22 +639,28 @@ HRESULT create_builtin_function(script_ctx_t *ctx, builtin_invoke_t value_proc, ...@@ -639,22 +639,28 @@ HRESULT create_builtin_function(script_ctx_t *ctx, builtin_invoke_t value_proc,
return S_OK; 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, 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) const builtin_info_t *builtin_info, DWORD flags, jsdisp_t *prototype, jsdisp_t **ret)
{ {
jsdisp_t *constr; jsdisp_t *constr;
VARIANT v;
HRESULT hres; 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); hres = create_builtin_function(ctx, value_proc, name, builtin_info, flags, prototype, &constr);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
V_VT(&v) = VT_DISPATCH; hres = set_constructor_prop(ctx, constr, prototype);
V_DISPATCH(&v) = to_disp(constr);
hres = jsdisp_propput_name(prototype, constructorW, &v, NULL);
if(FAILED(hres)) { if(FAILED(hres)) {
jsdisp_release(constr); jsdisp_release(constr);
return hres; return hres;
...@@ -839,6 +845,8 @@ HRESULT init_function_constr(script_ctx_t *ctx, jsdisp_t *object_prototype) ...@@ -839,6 +845,8 @@ HRESULT init_function_constr(script_ctx_t *ctx, jsdisp_t *object_prototype)
constr->value_proc = FunctionConstr_value; constr->value_proc = FunctionConstr_value;
constr->name = FunctionW; constr->name = FunctionW;
hres = set_prototype(ctx, &constr->dispex, &prot->dispex); hres = set_prototype(ctx, &constr->dispex, &prot->dispex);
if(SUCCEEDED(hres))
hres = set_constructor_prop(ctx, &constr->dispex, &prot->dispex);
if(FAILED(hres)) if(FAILED(hres))
jsdisp_release(&constr->dispex); jsdisp_release(&constr->dispex);
} }
......
...@@ -101,7 +101,7 @@ testConstructor(Array, "Array"); ...@@ -101,7 +101,7 @@ testConstructor(Array, "Array");
testConstructor(Boolean, "Boolean"); testConstructor(Boolean, "Boolean");
testConstructor(Number, "Number"); testConstructor(Number, "Number");
testConstructor(RegExp, "RegExp"); testConstructor(RegExp, "RegExp");
//testConstructor(Function, "Function"); testConstructor(Function, "Function");
testConstructor(Date, "Date"); testConstructor(Date, "Date");
testConstructor(VBArray, "VBArray"); testConstructor(VBArray, "VBArray");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment