vbscript: Support properties with parameters.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=33996 Signed-off-by: Robert Wilhelm <robert.wilhelm@gmx.net> Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
3acd68b241
commit
a839ac952a
|
@ -454,7 +454,7 @@ ClassBody
|
|||
PropertyDecl
|
||||
: Storage_opt tPROPERTY tGET Identifier ArgumentsDecl_opt StSep BodyStatements tEND tPROPERTY
|
||||
{ $$ = new_function_decl(ctx, $4, FUNC_PROPGET, $1, $5, $7); CHECK_ERROR; }
|
||||
| Storage_opt tPROPERTY tLET Identifier '(' ArgumentDecl ')' StSep BodyStatements tEND tPROPERTY
|
||||
| Storage_opt tPROPERTY tLET Identifier '(' ArgumentDeclList ')' StSep BodyStatements tEND tPROPERTY
|
||||
{ $$ = new_function_decl(ctx, $4, FUNC_PROPLET, $1, $6, $9); CHECK_ERROR; }
|
||||
| Storage_opt tPROPERTY tSET Identifier '(' ArgumentDecl ')' StSep BodyStatements tEND tPROPERTY
|
||||
{ $$ = new_function_decl(ctx, $4, FUNC_PROPSET, $1, $6, $9); CHECK_ERROR; }
|
||||
|
|
|
@ -1770,6 +1770,27 @@ class TestPropSyntax
|
|||
end property
|
||||
end class
|
||||
|
||||
Class TestPropParam
|
||||
Public oDict
|
||||
Public Property Let Key(oldKey,newKey)
|
||||
oDict = oldKey & newKey
|
||||
End Property
|
||||
Public Property Let three(uno,due,tre)
|
||||
oDict = uno & due & tre
|
||||
End Property
|
||||
Public Property Let ten(a,b,c,d,e,f,g,h,i,j)
|
||||
oDict = a & b & c & d & e & f & g & h & i & j
|
||||
End Property
|
||||
End Class
|
||||
|
||||
Set x = new TestPropParam
|
||||
x.key("old") = "new"
|
||||
call ok(x.oDict = "oldnew","x.oDict = " & x.oDict & " expected oldnew")
|
||||
x.three(1,2) = 3
|
||||
call ok(x.oDict = "123","x.oDict = " & x.oDict & " expected 123")
|
||||
x.ten(1,2,3,4,5,6,7,8,9) = 0
|
||||
call ok(x.oDict = "1234567890","x.oDict = " & x.oDict & " expected 1234567890")
|
||||
|
||||
set x = new TestPropSyntax
|
||||
set x.prop = new TestPropSyntax
|
||||
set x.prop.prop = new TestPropSyntax
|
||||
|
|
|
@ -197,28 +197,43 @@ static HRESULT invoke_vbdisp(vbdisp_t *This, DISPID id, DWORD flags, BOOL extern
|
|||
case DISPATCH_PROPERTYPUT|DISPATCH_PROPERTYPUTREF: {
|
||||
DISPPARAMS dp = {NULL, NULL, 1, 0};
|
||||
BOOL needs_release;
|
||||
VARIANT put_val;
|
||||
VARIANT buf[6];
|
||||
HRESULT hres;
|
||||
INT i;
|
||||
|
||||
if(arg_cnt(params)) {
|
||||
FIXME("arguments not implemented\n");
|
||||
return E_NOTIMPL;
|
||||
dp.cArgs = arg_cnt(params) + 1;
|
||||
if(dp.cArgs > ARRAY_SIZE(buf)) {
|
||||
dp.rgvarg = heap_alloc(dp.cArgs*sizeof(VARIANT));
|
||||
if(!dp.rgvarg)
|
||||
return E_OUTOFMEMORY;
|
||||
}else {
|
||||
dp.rgvarg = buf;
|
||||
}
|
||||
|
||||
hres = get_propput_arg(This->desc->ctx, params, flags, &put_val, &needs_release);
|
||||
if(FAILED(hres))
|
||||
hres = get_propput_arg(This->desc->ctx, params, flags, dp.rgvarg, &needs_release);
|
||||
if(FAILED(hres)) {
|
||||
if(dp.rgvarg != buf)
|
||||
heap_free(dp.rgvarg);
|
||||
return hres;
|
||||
}
|
||||
|
||||
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(dp.rgvarg) == VT_DISPATCH ? VBDISP_SET : VBDISP_LET];
|
||||
if(!func) {
|
||||
FIXME("no letter/setter\n");
|
||||
if(dp.rgvarg != buf)
|
||||
heap_free(dp.rgvarg);
|
||||
return DISP_E_MEMBERNOTFOUND;
|
||||
}
|
||||
|
||||
for(i=1; i < dp.cArgs; i++) {
|
||||
dp.rgvarg[i]=params->rgvarg[params->cNamedArgs+i-1];
|
||||
}
|
||||
|
||||
hres = exec_script(This->desc->ctx, extern_caller, func, This, &dp, NULL);
|
||||
if(needs_release)
|
||||
VariantClear(&put_val);
|
||||
VariantClear(dp.rgvarg);
|
||||
if(dp.rgvarg != buf)
|
||||
heap_free(dp.rgvarg);
|
||||
return hres;
|
||||
}
|
||||
default:
|
||||
|
|
Loading…
Reference in New Issue