jscript: Use the value returned from constructor in 'new' expression if the value if an object.
This commit is contained in:
parent
fded8dc017
commit
fbb763a53e
|
@ -226,20 +226,27 @@ static HRESULT invoke_constructor(script_ctx_t *ctx, FunctionInstance *function,
|
|||
VARIANT *retv, jsexcept_t *ei, IServiceProvider *caller)
|
||||
{
|
||||
DispatchEx *this_obj;
|
||||
VARIANT var;
|
||||
HRESULT hres;
|
||||
|
||||
hres = create_object(ctx, &function->dispex, &this_obj);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
hres = invoke_source(ctx, function, (IDispatch*)_IDispatchEx_(this_obj), dp, retv, ei, caller);
|
||||
hres = invoke_source(ctx, function, (IDispatch*)_IDispatchEx_(this_obj), dp, &var, ei, caller);
|
||||
if(FAILED(hres)) {
|
||||
jsdisp_release(this_obj);
|
||||
return hres;
|
||||
}
|
||||
|
||||
V_VT(retv) = VT_DISPATCH;
|
||||
V_DISPATCH(retv) = (IDispatch*)_IDispatchEx_(this_obj);
|
||||
if(V_VT(&var) == VT_DISPATCH) {
|
||||
jsdisp_release(this_obj);
|
||||
V_DISPATCH(retv) = V_DISPATCH(&var);
|
||||
}else {
|
||||
VariantClear(&var);
|
||||
V_DISPATCH(retv) = (IDispatch*)_IDispatchEx_(this_obj);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -148,6 +148,21 @@ obj2.pvar = 3;
|
|||
testConstr1.prototype.pvar = 1;
|
||||
ok(obj2.pvar === 3, "obj2.pvar is not 3");
|
||||
|
||||
obj1 = new Object();
|
||||
function testConstr3() {
|
||||
return obj1;
|
||||
}
|
||||
|
||||
obj2 = new testConstr3();
|
||||
ok(obj1 === obj2, "obj1 != obj2");
|
||||
|
||||
function testConstr4() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
obj2 = new testConstr3();
|
||||
ok(typeof(obj2) === "object", "typeof(obj2) = " + typeof(obj2));
|
||||
|
||||
var obj3 = new Object;
|
||||
ok(typeof(obj3) === "object", "typeof(obj3) is not object");
|
||||
|
||||
|
|
Loading…
Reference in New Issue