Module: wine Branch: master Commit: a8de7904f5236a24286a6ac061888180f0c6e441 URL: http://source.winehq.org/git/wine.git/?a=commit;h=a8de7904f5236a24286a6ac061...
Author: Jacek Caban jacek@codeweavers.com Date: Fri Sep 16 13:28:52 2011 +0200
vbscript: Added support for default getters.
---
dlls/vbscript/compile.c | 23 +++++++++++++++++++---- dlls/vbscript/interp.c | 5 +++-- dlls/vbscript/parser.y | 3 +-- dlls/vbscript/tests/lang.vbs | 8 ++++++++ dlls/vbscript/vbscript.h | 3 ++- 5 files changed, 33 insertions(+), 9 deletions(-)
diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index 1fc6612..bcf7b52 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -684,6 +684,7 @@ static HRESULT compile_func(compile_ctx_t *ctx, statement_t *stat, function_t *f case FUNC_PROPGET: case FUNC_PROPLET: case FUNC_PROPSET: + case FUNC_DEFGET: ctx->prop_end_label = alloc_label(ctx); if(ctx->prop_end_label == -1) return E_OUTOFMEMORY; @@ -846,6 +847,7 @@ static HRESULT create_class_funcprop(compile_ctx_t *ctx, function_decl_t *func_d case FUNC_FUNCTION: case FUNC_SUB: case FUNC_PROPGET: + case FUNC_DEFGET: invoke_type = VBDISP_CALLGET; break; case FUNC_PROPLET: @@ -885,7 +887,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) { - function_decl_t *func_decl; + function_decl_t *func_decl, *func_prop_decl; class_prop_decl_t *prop_decl; class_desc_t *class_desc; unsigned i; @@ -908,8 +910,14 @@ static HRESULT compile_class(compile_ctx_t *ctx, class_decl_t *class_decl) class_desc->func_cnt = 1; /* always allocate slot for default getter */ class_desc->prop_cnt = 0;
- for(func_decl = class_decl->funcs; func_decl; func_decl = func_decl->next) - class_desc->func_cnt++; + for(func_decl = class_decl->funcs; func_decl; func_decl = func_decl->next) { + for(func_prop_decl = func_decl; func_prop_decl; func_prop_decl = func_prop_decl->next_prop_func) { + if(func_prop_decl->type == FUNC_DEFGET) + break; + } + if(!func_prop_decl) + class_desc->func_cnt++; + }
class_desc->funcs = compiler_alloc(ctx->code, class_desc->func_cnt*sizeof(*class_desc->funcs)); if(!class_desc->funcs) @@ -917,7 +925,14 @@ static HRESULT compile_class(compile_ctx_t *ctx, class_decl_t *class_decl) memset(class_desc->funcs, 0, class_desc->func_cnt*sizeof(*class_desc->funcs));
for(func_decl = class_decl->funcs, i=1; func_decl; func_decl = func_decl->next, i++) { - hres = create_class_funcprop(ctx, func_decl, class_desc->funcs + i); + for(func_prop_decl = func_decl; func_prop_decl; func_prop_decl = func_prop_decl->next_prop_func) { + if(func_prop_decl->type == FUNC_DEFGET) { + i--; + break; + } + } + + hres = create_class_funcprop(ctx, func_decl, class_desc->funcs + (func_prop_decl ? 0 : i)); if(FAILED(hres)) return hres; } diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c index 899d989..4599cbf 100644 --- a/dlls/vbscript/interp.c +++ b/dlls/vbscript/interp.c @@ -92,7 +92,8 @@ static HRESULT lookup_identifier(exec_ctx_t *ctx, BSTR name, vbdisp_invoke_type_ DISPID id; HRESULT hres;
- if(invoke_type == VBDISP_LET && (ctx->func->type == FUNC_FUNCTION || ctx->func->type == FUNC_PROPGET) + if(invoke_type == VBDISP_LET + && (ctx->func->type == FUNC_FUNCTION || ctx->func->type == FUNC_PROPGET || ctx->func->type == FUNC_DEFGET) && !strcmpiW(name, ctx->func->name)) { ref->type = REF_VAR; ref->u.v = &ctx->ret_val; @@ -1237,7 +1238,7 @@ HRESULT exec_script(script_ctx_t *ctx, function_t *func, IDispatch *this_obj, DI }
assert(!exec.top); - if(func->type != FUNC_FUNCTION && func->type != FUNC_PROPGET) + if(func->type != FUNC_FUNCTION && func->type != FUNC_PROPGET && func->type != FUNC_DEFGET) assert(V_VT(&exec.ret_val) == VT_EMPTY);
if(SUCCEEDED(hres) && res) { diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index c345432..adf1aba 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -602,8 +602,7 @@ static function_decl_t *new_function_decl(parser_ctx_t *ctx, const WCHAR *name,
if(storage_flags & STORAGE_IS_DEFAULT) { if(type == FUNC_PROPGET) { - FIXME("default value not implemented\n"); - ctx->hres = E_NOTIMPL; + type = FUNC_DEFGET; }else { FIXME("Invalid default property\n"); ctx->hres = E_FAIL; diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index 20f1f42..24bfecc 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -406,6 +406,14 @@ Class TestClass Call ok(false, "exit property not returned?") End Property
+ Public Default Property Get DefValGet + DefValGet = privateProp + funcCalled = "GetDefVal" + End Property + + Public Property Let DefValGet(x) + End Property + Public publicProp2
Public Sub publicSub diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h index 37fc7dd..37931db 100644 --- a/dlls/vbscript/vbscript.h +++ b/dlls/vbscript/vbscript.h @@ -214,7 +214,8 @@ typedef enum { FUNC_SUB, FUNC_PROPGET, FUNC_PROPLET, - FUNC_PROPSET + FUNC_PROPSET, + FUNC_DEFGET } function_type_t;
typedef struct {