vbscript: Support class default sub.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=35744 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
54740a5cb8
commit
16fe2037fb
|
@ -1668,6 +1668,7 @@ static BOOL lookup_class_funcs(class_desc_t *class_desc, const WCHAR *name)
|
||||||
static HRESULT compile_class(compile_ctx_t *ctx, class_decl_t *class_decl)
|
static HRESULT compile_class(compile_ctx_t *ctx, class_decl_t *class_decl)
|
||||||
{
|
{
|
||||||
function_decl_t *func_decl, *func_prop_decl;
|
function_decl_t *func_decl, *func_prop_decl;
|
||||||
|
BOOL is_default, have_default = FALSE;
|
||||||
class_desc_t *class_desc;
|
class_desc_t *class_desc;
|
||||||
dim_decl_t *prop_decl;
|
dim_decl_t *prop_decl;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
@ -1690,14 +1691,21 @@ static HRESULT compile_class(compile_ctx_t *ctx, class_decl_t *class_decl)
|
||||||
if(!class_desc->name)
|
if(!class_desc->name)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
class_desc->func_cnt = 1; /* always allocate slot for default getter */
|
class_desc->func_cnt = 1; /* always allocate slot for default getter or method */
|
||||||
|
|
||||||
for(func_decl = class_decl->funcs; func_decl; func_decl = func_decl->next) {
|
for(func_decl = class_decl->funcs; func_decl; func_decl = func_decl->next) {
|
||||||
|
is_default = FALSE;
|
||||||
for(func_prop_decl = func_decl; func_prop_decl; func_prop_decl = func_prop_decl->next_prop_func) {
|
for(func_prop_decl = func_decl; func_prop_decl; func_prop_decl = func_prop_decl->next_prop_func) {
|
||||||
if(func_prop_decl->is_default)
|
if(func_prop_decl->is_default) {
|
||||||
|
if(have_default) {
|
||||||
|
FIXME("multiple default getters or methods\n");
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
is_default = have_default = TRUE;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(!func_prop_decl)
|
if(!is_default)
|
||||||
class_desc->func_cnt++;
|
class_desc->func_cnt++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -993,7 +993,7 @@ static function_decl_t *new_function_decl(parser_ctx_t *ctx, const WCHAR *name,
|
||||||
BOOL is_default = FALSE;
|
BOOL is_default = FALSE;
|
||||||
|
|
||||||
if(storage_flags & STORAGE_IS_DEFAULT) {
|
if(storage_flags & STORAGE_IS_DEFAULT) {
|
||||||
if(type == FUNC_PROPGET) {
|
if(type == FUNC_PROPGET || type == FUNC_FUNCTION || type == FUNC_SUB) {
|
||||||
is_default = TRUE;
|
is_default = TRUE;
|
||||||
}else {
|
}else {
|
||||||
FIXME("Invalid default property\n");
|
FIXME("Invalid default property\n");
|
||||||
|
|
|
@ -1750,6 +1750,36 @@ call ok(x.getprop.getprop().prop is obj, "x.getprop.getprop().prop is not obj (e
|
||||||
ok getVT(x) = "VT_DISPATCH*", "getVT(x) = " & getVT(x)
|
ok getVT(x) = "VT_DISPATCH*", "getVT(x) = " & getVT(x)
|
||||||
todo_wine_ok getVT(x()) = "VT_BSTR", "getVT(x()) = " & getVT(x())
|
todo_wine_ok getVT(x()) = "VT_BSTR", "getVT(x()) = " & getVT(x())
|
||||||
|
|
||||||
|
funcCalled = ""
|
||||||
|
class DefaultSubTest1
|
||||||
|
Public default Sub init(a)
|
||||||
|
funcCalled = "init" & a
|
||||||
|
end sub
|
||||||
|
end class
|
||||||
|
|
||||||
|
Set obj = New DefaultSubTest1
|
||||||
|
obj.init(1)
|
||||||
|
call ok(funcCalled = "init1","funcCalled=" & funcCalled)
|
||||||
|
funcCalled = ""
|
||||||
|
obj(2)
|
||||||
|
call ok(funcCalled = "init2","funcCalled=" & funcCalled)
|
||||||
|
|
||||||
|
class DefaultSubTest2
|
||||||
|
Public Default Function init
|
||||||
|
funcCalled = "init"
|
||||||
|
end function
|
||||||
|
end class
|
||||||
|
|
||||||
|
Set obj = New DefaultSubTest2
|
||||||
|
funcCalled = ""
|
||||||
|
obj.init()
|
||||||
|
call ok(funcCalled = "init","funcCalled=" & funcCalled)
|
||||||
|
funcCalled = ""
|
||||||
|
' todo this is not yet supported
|
||||||
|
'funcCalled = ""
|
||||||
|
'obj()
|
||||||
|
'call ok(funcCalled = "init","funcCalled=" & funcCalled)
|
||||||
|
|
||||||
with nothing
|
with nothing
|
||||||
end with
|
end with
|
||||||
|
|
||||||
|
|
|
@ -38,19 +38,17 @@ static BOOL get_func_id(vbdisp_t *This, const WCHAR *name, vbdisp_invoke_type_t
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
for(i = invoke_type == VBDISP_ANY ? 0 : 1; i < This->desc->func_cnt; i++) {
|
for(i = 0; i < This->desc->func_cnt; i++) {
|
||||||
if(invoke_type == VBDISP_ANY) {
|
if(invoke_type == VBDISP_ANY) {
|
||||||
if(!search_private && !This->desc->funcs[i].is_public)
|
if(!search_private && !This->desc->funcs[i].is_public)
|
||||||
continue;
|
continue;
|
||||||
if(!i && !This->desc->funcs[0].name) /* default value may not exist */
|
|
||||||
continue;
|
|
||||||
}else {
|
}else {
|
||||||
if(!This->desc->funcs[i].entries[invoke_type]
|
if(!This->desc->funcs[i].entries[invoke_type]
|
||||||
|| (!search_private && !This->desc->funcs[i].entries[invoke_type]->is_public))
|
|| (!search_private && !This->desc->funcs[i].entries[invoke_type]->is_public))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!wcsicmp(This->desc->funcs[i].name, name)) {
|
if(This->desc->funcs[i].name && !wcsicmp(This->desc->funcs[i].name, name)) {
|
||||||
*id = i;
|
*id = i;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue