vbscript: Allow property getters to take arguments.

This commit is contained in:
Jacek Caban 2014-04-30 11:31:30 +02:00 committed by Alexandre Julliard
parent 4c8edb1b4c
commit 0f50cb323e
2 changed files with 29 additions and 2 deletions

View File

@ -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

View File

@ -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"