jscript: Properly set Function constructor's constructor property.
This commit is contained in:
parent
d492650332
commit
bf7b7272ee
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
|
||||
|
|
Loading…
Reference in New Issue