From 0f50cb323efb3ee3910421eaac26950b15653c35 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Wed, 30 Apr 2014 11:31:30 +0200 Subject: [PATCH] vbscript: Allow property getters to take arguments. --- dlls/vbscript/parser.y | 4 ++-- dlls/vbscript/tests/lang.vbs | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index 6bd4907c12..c5d1c59157 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -403,8 +403,8 @@ ClassBody | PropertyDecl tNL ClassBody { $$ = add_class_function(ctx, $3, $1); CHECK_ERROR; } PropertyDecl - : Storage_opt tPROPERTY tGET tIdentifier EmptyBrackets_opt tNL StatementsNl_opt tEND tPROPERTY - { $$ = new_function_decl(ctx, $4, FUNC_PROPGET, $1, NULL, $7); CHECK_ERROR; } + : Storage_opt tPROPERTY tGET tIdentifier ArgumentsDecl_opt tNL StatementsNl_opt tEND tPROPERTY + { $$ = new_function_decl(ctx, $4, FUNC_PROPGET, $1, $5, $7); CHECK_ERROR; } | Storage_opt tPROPERTY tLET tIdentifier '(' ArgumentDecl ')' tNL StatementsNl_opt tEND tPROPERTY { $$ = new_function_decl(ctx, $4, FUNC_PROPLET, $1, $6, $9); CHECK_ERROR; } | Storage_opt tPROPERTY tSET tIdentifier '(' ArgumentDecl ')' tNL StatementsNl_opt tEND tPROPERTY diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index d3e83183b5..c24ffa6d7b 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -849,6 +849,10 @@ Class TestClass Call ok(getVT(publicProp2) = "VT_I2*", "getVT(publicProp2) = " & getVT(publicProp2)) Call ok(getVT(Me.publicProp2) = "VT_I2", "getVT(Me.publicProp2) = " & getVT(Me.publicProp2)) End Sub + + Property Get gsGetProp(x) + gsGetProp = x + End Property End Class Call testDisp(new testClass) @@ -916,6 +920,29 @@ Call ok(funcCalled = "terminate", "funcCalled = " & funcCalled) Call (New testclass).publicSub() Call (New testclass).publicSub +class PropTest + property get prop0() + prop0 = 1 + end property + + property get prop1(x) + prop1 = x+1 + end property + + property get prop2(x, y) + prop2 = x+y + end property +end class + +set obj = new PropTest + +call ok(obj.prop0 = 1, "obj.prop0 = " & obj.prop0) +call ok(obj.prop1(3) = 4, "obj.prop1(3) = " & obj.prop1(3)) +call ok(obj.prop2(3,4) = 7, "obj.prop2(3,4) = " & obj.prop2(3,4)) +call obj.prop0() +call obj.prop1(2) +call obj.prop2(3,4) + x = "following ':' is correct syntax" : x = "following ':' is correct syntax" :: : :: x = "also correct syntax"