vbscript: Added support for VARIANT references to interp_newenum.
This commit is contained in:
parent
aa045d51b3
commit
86ee4e959a
|
@ -309,33 +309,42 @@ static void stack_popn(exec_ctx_t *ctx, unsigned n)
|
|||
VariantClear(stack_pop(ctx));
|
||||
}
|
||||
|
||||
static HRESULT stack_pop_val(exec_ctx_t *ctx, variant_val_t *v)
|
||||
static void stack_pop_deref(exec_ctx_t *ctx, variant_val_t *r)
|
||||
{
|
||||
VARIANT *var;
|
||||
VARIANT *v;
|
||||
|
||||
var = stack_pop(ctx);
|
||||
|
||||
if(V_VT(var) == (VT_BYREF|VT_VARIANT)) {
|
||||
v->owned = FALSE;
|
||||
var = V_VARIANTREF(var);
|
||||
v = stack_pop(ctx);
|
||||
if(V_VT(v) == (VT_BYREF|VT_VARIANT)) {
|
||||
r->owned = FALSE;
|
||||
r->v = V_VARIANTREF(v);
|
||||
}else {
|
||||
v->owned = TRUE;
|
||||
r->owned = TRUE;
|
||||
r->v = v;
|
||||
}
|
||||
}
|
||||
|
||||
if(V_VT(var) == VT_DISPATCH) {
|
||||
static inline void release_val(variant_val_t *v)
|
||||
{
|
||||
if(v->owned)
|
||||
VariantClear(v->v);
|
||||
}
|
||||
|
||||
static HRESULT stack_pop_val(exec_ctx_t *ctx, variant_val_t *r)
|
||||
{
|
||||
stack_pop_deref(ctx, r);
|
||||
|
||||
if(V_VT(r->v) == VT_DISPATCH) {
|
||||
DISPPARAMS dp = {0};
|
||||
HRESULT hres;
|
||||
|
||||
hres = disp_call(ctx->script, V_DISPATCH(var), DISPID_VALUE, &dp, &v->store);
|
||||
if(v->owned)
|
||||
IDispatch_Release(V_DISPATCH(var));
|
||||
hres = disp_call(ctx->script, V_DISPATCH(r->v), DISPID_VALUE, &dp, &r->store);
|
||||
if(r->owned)
|
||||
IDispatch_Release(V_DISPATCH(r->v));
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
v->owned = TRUE;
|
||||
v->v = &v->store;
|
||||
}else {
|
||||
v->v = var;
|
||||
r->owned = TRUE;
|
||||
r->v = &r->store;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
|
@ -370,12 +379,6 @@ static HRESULT stack_assume_val(exec_ctx_t *ctx, unsigned n)
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
static inline void release_val(variant_val_t *v)
|
||||
{
|
||||
if(v->owned)
|
||||
VariantClear(v->v);
|
||||
}
|
||||
|
||||
static int stack_pop_bool(exec_ctx_t *ctx, BOOL *b)
|
||||
{
|
||||
variant_val_t val;
|
||||
|
@ -1079,21 +1082,23 @@ static HRESULT interp_step(exec_ctx_t *ctx)
|
|||
|
||||
static HRESULT interp_newenum(exec_ctx_t *ctx)
|
||||
{
|
||||
VARIANT *v, r;
|
||||
variant_val_t v;
|
||||
VARIANT r;
|
||||
HRESULT hres;
|
||||
|
||||
TRACE("\n");
|
||||
|
||||
v = stack_pop(ctx);
|
||||
switch(V_VT(v)) {
|
||||
stack_pop_deref(ctx, &v);
|
||||
|
||||
switch(V_VT(v.v)) {
|
||||
case VT_DISPATCH|VT_BYREF:
|
||||
case VT_DISPATCH: {
|
||||
IEnumVARIANT *iter;
|
||||
DISPPARAMS dp = {0};
|
||||
VARIANT iterv;
|
||||
|
||||
hres = disp_call(ctx->script, V_ISBYREF(v) ? *V_DISPATCHREF(v) : V_DISPATCH(v), DISPID_NEWENUM, &dp, &iterv);
|
||||
VariantClear(v);
|
||||
hres = disp_call(ctx->script, V_ISBYREF(v.v) ? *V_DISPATCHREF(v.v) : V_DISPATCH(v.v), DISPID_NEWENUM, &dp, &iterv);
|
||||
release_val(&v);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
|
@ -1115,8 +1120,8 @@ static HRESULT interp_newenum(exec_ctx_t *ctx)
|
|||
break;
|
||||
}
|
||||
default:
|
||||
FIXME("Unsupported for %s\n", debugstr_variant(v));
|
||||
VariantClear(v);
|
||||
FIXME("Unsupported for %s\n", debugstr_variant(v.v));
|
||||
release_val(&v);
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
Option Explicit
|
||||
|
||||
dim x, y, z
|
||||
Dim obj
|
||||
|
||||
call ok(true, "true is not true?")
|
||||
ok true, "true is not true?"
|
||||
|
@ -486,6 +487,17 @@ next
|
|||
Call ok(y = 1, "y = " & y)
|
||||
Call ok(x = 2, "x = " & x)
|
||||
|
||||
Set obj = collectionObj
|
||||
Call obj.reset()
|
||||
y = 0
|
||||
x = 10
|
||||
for each x in obj
|
||||
y = y+1
|
||||
Call ok(x = y, "x <> y")
|
||||
next
|
||||
Call ok(y = 3, "y = " & y)
|
||||
Call ok(getVT(x) = "VT_EMPTY*", "getVT(x) = " & getVT(x))
|
||||
|
||||
x = false
|
||||
select case 3
|
||||
case 2
|
||||
|
@ -767,7 +779,6 @@ Stop
|
|||
set x = testObj
|
||||
Call ok(getVT(x) = "VT_DISPATCH*", "getVT(x=testObj) = " & getVT(x))
|
||||
|
||||
Dim obj
|
||||
Set obj = New EmptyClass
|
||||
Call ok(getVT(obj) = "VT_DISPATCH*", "getVT(obj) = " & getVT(obj))
|
||||
|
||||
|
|
Loading…
Reference in New Issue