Advertisement

AngelScript getters and setters (WIP)

Started by September 09, 2009 08:03 PM
1 comment, last by WitchLord 15 years, 2 months ago
I'm making good progress on the support for getters and setters in AngelScript. I still have some tests to write but I think they are already working pretty well. For that reason I'd like for whoever intend to use these to give the new feature a try, to see if we can root out any potential bugs before I release version 2.17.1. You add getters and setters in objects (both script classes and registered types) by declaring a couple of methods like this:

class MyObject
{
   int get_Prop() { /* return the value */ }
   void set_Prop(int v) { /* set the value */ }
}
When accessing the member Prop of this class, the correct property accessor method will be called based on what the expression is used for. Observation: Both the get and set methods must have matching types, otherwise the compiler won't know what type to use. Please download the latest revision from the SVN, and let me know if you encounter any problems with the getters and setters.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

If you leave out the get, can you make it write only?
If you leave out the set, can you make it read only?
Advertisement
Yes :)

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement