Commit 4bca1665 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

vbscript: Convert VT_DISPATCH propput value to trivial value if DISPATCH_PROPERTYPUTREF is not set.

parent 571b09ce
...@@ -85,19 +85,43 @@ HRESULT vbdisp_get_id(vbdisp_t *This, BSTR name, vbdisp_invoke_type_t invoke_typ ...@@ -85,19 +85,43 @@ HRESULT vbdisp_get_id(vbdisp_t *This, BSTR name, vbdisp_invoke_type_t invoke_typ
return DISP_E_UNKNOWNNAME; return DISP_E_UNKNOWNNAME;
} }
static VARIANT *get_propput_arg(const DISPPARAMS *dp) static HRESULT get_propput_arg(script_ctx_t *ctx, const DISPPARAMS *dp, WORD flags, VARIANT *v, BOOL *is_owned)
{ {
unsigned i; unsigned i;
for(i=0; i < dp->cNamedArgs; i++) { for(i=0; i < dp->cNamedArgs; i++) {
if(dp->rgdispidNamedArgs[i] == DISPID_PROPERTYPUT) if(dp->rgdispidNamedArgs[i] == DISPID_PROPERTYPUT)
return dp->rgvarg+i; break;
}
if(i == dp->cNamedArgs) {
WARN("no value to set\n");
return DISP_E_PARAMNOTOPTIONAL;
}
*v = dp->rgvarg[i];
if(V_VT(v) == (VT_VARIANT|VT_BYREF))
*v = *V_VARIANTREF(v);
*is_owned = FALSE;
if(V_VT(v) == VT_DISPATCH) {
if(!(flags & DISPATCH_PROPERTYPUTREF)) {
DISPPARAMS val_dp = {NULL};
VARIANT value;
HRESULT hres;
hres = disp_call(ctx, V_DISPATCH(v), DISPID_VALUE, &val_dp, &value);
if(FAILED(hres))
return hres;
*v = value;
*is_owned = TRUE;
}
} }
return NULL; return S_OK;
} }
static HRESULT invoke_variant_prop(VARIANT *v, WORD flags, DISPPARAMS *dp, VARIANT *res) static HRESULT invoke_variant_prop(script_ctx_t *ctx, VARIANT *v, WORD flags, DISPPARAMS *dp, VARIANT *res)
{ {
HRESULT hres; HRESULT hres;
...@@ -115,13 +139,12 @@ static HRESULT invoke_variant_prop(VARIANT *v, WORD flags, DISPPARAMS *dp, VARIA ...@@ -115,13 +139,12 @@ static HRESULT invoke_variant_prop(VARIANT *v, WORD flags, DISPPARAMS *dp, VARIA
case DISPATCH_PROPERTYPUT: case DISPATCH_PROPERTYPUT:
case DISPATCH_PROPERTYPUTREF: case DISPATCH_PROPERTYPUTREF:
case DISPATCH_PROPERTYPUT|DISPATCH_PROPERTYPUTREF: { case DISPATCH_PROPERTYPUT|DISPATCH_PROPERTYPUTREF: {
VARIANT *put_val; VARIANT put_val;
BOOL own_val;
put_val = get_propput_arg(dp); hres = get_propput_arg(ctx, dp, flags, &put_val, &own_val);
if(!put_val) { if(FAILED(hres))
WARN("no value to set\n"); return hres;
return DISP_E_PARAMNOTOPTIONAL;
}
if(arg_cnt(dp)) { if(arg_cnt(dp)) {
FIXME("Arguments not supported\n"); FIXME("Arguments not supported\n");
...@@ -131,7 +154,10 @@ static HRESULT invoke_variant_prop(VARIANT *v, WORD flags, DISPPARAMS *dp, VARIA ...@@ -131,7 +154,10 @@ static HRESULT invoke_variant_prop(VARIANT *v, WORD flags, DISPPARAMS *dp, VARIA
if(res) if(res)
V_VT(res) = VT_EMPTY; V_VT(res) = VT_EMPTY;
hres = VariantCopyInd(v, put_val); if(own_val)
*v = put_val;
else
hres = VariantCopyInd(v, &put_val);
break; break;
} }
...@@ -414,28 +440,31 @@ static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lc ...@@ -414,28 +440,31 @@ static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lc
case DISPATCH_PROPERTYPUT: case DISPATCH_PROPERTYPUT:
case DISPATCH_PROPERTYPUTREF: case DISPATCH_PROPERTYPUTREF:
case DISPATCH_PROPERTYPUT|DISPATCH_PROPERTYPUTREF: { case DISPATCH_PROPERTYPUT|DISPATCH_PROPERTYPUTREF: {
VARIANT *put_val;
DISPPARAMS dp = {NULL, NULL, 1, 0}; DISPPARAMS dp = {NULL, NULL, 1, 0};
BOOL needs_release;
VARIANT put_val;
HRESULT hres;
if(arg_cnt(pdp)) { if(arg_cnt(pdp)) {
FIXME("arguments not implemented\n"); FIXME("arguments not implemented\n");
return E_NOTIMPL; return E_NOTIMPL;
} }
put_val = get_propput_arg(pdp); hres = get_propput_arg(This->desc->ctx, pdp, wFlags, &put_val, &needs_release);
if(!put_val) { if(FAILED(hres))
WARN("no value to set\n"); return hres;
return DISP_E_PARAMNOTOPTIONAL;
}
dp.rgvarg = put_val; dp.rgvarg = &put_val;
func = This->desc->funcs[id].entries[V_VT(put_val) == VT_DISPATCH ? VBDISP_SET : VBDISP_LET]; func = This->desc->funcs[id].entries[V_VT(&put_val) == VT_DISPATCH ? VBDISP_SET : VBDISP_LET];
if(!func) { if(!func) {
FIXME("no letter/setter\n"); FIXME("no letter/setter\n");
return DISP_E_MEMBERNOTFOUND; return DISP_E_MEMBERNOTFOUND;
} }
return exec_script(This->desc->ctx, func, This, &dp, NULL); hres = exec_script(This->desc->ctx, func, This, &dp, NULL);
if(needs_release)
VariantClear(&put_val);
return hres;
} }
default: default:
FIXME("flags %x\n", wFlags); FIXME("flags %x\n", wFlags);
...@@ -444,7 +473,7 @@ static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lc ...@@ -444,7 +473,7 @@ static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lc
} }
if(id < This->desc->prop_cnt + This->desc->func_cnt) if(id < This->desc->prop_cnt + This->desc->func_cnt)
return invoke_variant_prop(This->props+(id-This->desc->func_cnt), wFlags, pdp, pvarRes); return invoke_variant_prop(This->desc->ctx, This->props+(id-This->desc->func_cnt), wFlags, pdp, pvarRes);
if(This->desc->builtin_prop_cnt) { if(This->desc->builtin_prop_cnt) {
unsigned min = 0, max = This->desc->builtin_prop_cnt-1, i; unsigned min = 0, max = This->desc->builtin_prop_cnt-1, i;
...@@ -849,7 +878,7 @@ static HRESULT WINAPI ScriptDisp_InvokeEx(IDispatchEx *iface, DISPID id, LCID lc ...@@ -849,7 +878,7 @@ static HRESULT WINAPI ScriptDisp_InvokeEx(IDispatchEx *iface, DISPID id, LCID lc
return E_NOTIMPL; return E_NOTIMPL;
} }
return invoke_variant_prop(&ident->u.var->v, wFlags, pdp, pvarRes); return invoke_variant_prop(This->ctx, &ident->u.var->v, wFlags, pdp, pvarRes);
} }
switch(wFlags) { switch(wFlags) {
......
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