vbscript: Allow property getters to take arguments.
This commit is contained in:
parent
4c8edb1b4c
commit
0f50cb323e
|
@ -403,8 +403,8 @@ ClassBody
|
||||||
| PropertyDecl tNL ClassBody { $$ = add_class_function(ctx, $3, $1); CHECK_ERROR; }
|
| PropertyDecl tNL ClassBody { $$ = add_class_function(ctx, $3, $1); CHECK_ERROR; }
|
||||||
|
|
||||||
PropertyDecl
|
PropertyDecl
|
||||||
: Storage_opt tPROPERTY tGET tIdentifier EmptyBrackets_opt tNL StatementsNl_opt tEND tPROPERTY
|
: Storage_opt tPROPERTY tGET tIdentifier ArgumentsDecl_opt tNL StatementsNl_opt tEND tPROPERTY
|
||||||
{ $$ = new_function_decl(ctx, $4, FUNC_PROPGET, $1, NULL, $7); CHECK_ERROR; }
|
{ $$ = new_function_decl(ctx, $4, FUNC_PROPGET, $1, $5, $7); CHECK_ERROR; }
|
||||||
| Storage_opt tPROPERTY tLET tIdentifier '(' ArgumentDecl ')' tNL StatementsNl_opt tEND tPROPERTY
|
| Storage_opt tPROPERTY tLET tIdentifier '(' ArgumentDecl ')' tNL StatementsNl_opt tEND tPROPERTY
|
||||||
{ $$ = new_function_decl(ctx, $4, FUNC_PROPLET, $1, $6, $9); CHECK_ERROR; }
|
{ $$ = new_function_decl(ctx, $4, FUNC_PROPLET, $1, $6, $9); CHECK_ERROR; }
|
||||||
| Storage_opt tPROPERTY tSET tIdentifier '(' ArgumentDecl ')' tNL StatementsNl_opt tEND tPROPERTY
|
| Storage_opt tPROPERTY tSET tIdentifier '(' ArgumentDecl ')' tNL StatementsNl_opt tEND tPROPERTY
|
||||||
|
|
|
@ -849,6 +849,10 @@ Class TestClass
|
||||||
Call ok(getVT(publicProp2) = "VT_I2*", "getVT(publicProp2) = " & getVT(publicProp2))
|
Call ok(getVT(publicProp2) = "VT_I2*", "getVT(publicProp2) = " & getVT(publicProp2))
|
||||||
Call ok(getVT(Me.publicProp2) = "VT_I2", "getVT(Me.publicProp2) = " & getVT(Me.publicProp2))
|
Call ok(getVT(Me.publicProp2) = "VT_I2", "getVT(Me.publicProp2) = " & getVT(Me.publicProp2))
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
Property Get gsGetProp(x)
|
||||||
|
gsGetProp = x
|
||||||
|
End Property
|
||||||
End Class
|
End Class
|
||||||
|
|
||||||
Call testDisp(new testClass)
|
Call testDisp(new testClass)
|
||||||
|
@ -916,6 +920,29 @@ Call ok(funcCalled = "terminate", "funcCalled = " & funcCalled)
|
||||||
Call (New testclass).publicSub()
|
Call (New testclass).publicSub()
|
||||||
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 = "following ':' is correct syntax" :: :
|
x = "following ':' is correct syntax" :: :
|
||||||
:: x = "also correct syntax"
|
:: x = "also correct syntax"
|
||||||
|
|
Loading…
Reference in New Issue