vbscript: Factor out variant_call.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2019-10-28 18:40:29 +01:00 committed by Alexandre Julliard
parent 25248362ea
commit ecaa72855a
1 changed files with 52 additions and 36 deletions

View File

@ -515,32 +515,16 @@ static HRESULT array_access(exec_ctx_t *ctx, SAFEARRAY *array, DISPPARAMS *dp, V
return hres;
}
static HRESULT do_icall(exec_ctx_t *ctx, VARIANT *res)
static HRESULT variant_call(exec_ctx_t *ctx, VARIANT *v, unsigned arg_cnt, VARIANT *res)
{
BSTR identifier = ctx->instr->arg1.bstr;
const unsigned arg_cnt = ctx->instr->arg2.uint;
SAFEARRAY *array = NULL;
DISPPARAMS dp;
ref_t ref;
HRESULT hres;
hres = lookup_identifier(ctx, identifier, VBDISP_CALLGET, &ref);
if(FAILED(hres))
return hres;
TRACE("%s\n", debugstr_variant(v));
switch(ref.type) {
case REF_VAR:
case REF_CONST: {
VARIANT *v;
if(!res) {
FIXME("REF_VAR no res\n");
return E_NOTIMPL;
}
v = V_VT(ref.u.v) == (VT_VARIANT|VT_BYREF) ? V_VARIANTREF(ref.u.v) : ref.u.v;
if(arg_cnt) {
SAFEARRAY *array = NULL;
if(V_VT(v) == (VT_VARIANT|VT_BYREF))
v = V_VARIANTREF(v);
switch(V_VT(v)) {
case VT_ARRAY|VT_BYREF|VT_VARIANT:
@ -552,27 +536,59 @@ static HRESULT do_icall(exec_ctx_t *ctx, VARIANT *res)
case VT_DISPATCH:
vbstack_to_dp(ctx, arg_cnt, FALSE, &dp);
hres = disp_call(ctx->script, V_DISPATCH(v), DISPID_VALUE, &dp, res);
if(FAILED(hres))
return hres;
break;
default:
FIXME("arguments not implemented\n");
FIXME("unsupported on %s\n", debugstr_variant(v));
return E_NOTIMPL;
}
if(!array)
break;
if(array) {
if(!res) {
FIXME("no res\n");
return E_NOTIMPL;
}
vbstack_to_dp(ctx, arg_cnt, FALSE, &dp);
hres = array_access(ctx, array, &dp, &v);
if(FAILED(hres))
return hres;
}
V_VT(res) = VT_BYREF|VT_VARIANT;
V_BYREF(res) = v;
break;
}
stack_popn(ctx, arg_cnt);
return S_OK;
}
static HRESULT do_icall(exec_ctx_t *ctx, VARIANT *res)
{
BSTR identifier = ctx->instr->arg1.bstr;
const unsigned arg_cnt = ctx->instr->arg2.uint;
DISPPARAMS dp;
ref_t ref;
HRESULT hres;
TRACE("%s %u\n", debugstr_w(identifier), arg_cnt);
hres = lookup_identifier(ctx, identifier, VBDISP_CALLGET, &ref);
if(FAILED(hres))
return hres;
switch(ref.type) {
case REF_VAR:
case REF_CONST:
if(arg_cnt)
return variant_call(ctx, ref.u.v, arg_cnt, res);
if(!res) {
FIXME("REF_VAR no res\n");
return E_NOTIMPL;
}
V_VT(res) = VT_BYREF|VT_VARIANT;
V_BYREF(res) = V_VT(ref.u.v) == (VT_VARIANT|VT_BYREF) ? V_VARIANTREF(ref.u.v) : ref.u.v;
break;
case REF_DISP:
vbstack_to_dp(ctx, arg_cnt, FALSE, &dp);
hres = disp_call(ctx->script, ref.u.d.disp, ref.u.d.id, &dp, res);