First of all I would like to note that Wiki entry for code porting needs updating, as it is mentioning CC*X**_PROPERTY and CC*X**_SYNTHESIZE.
I would like to ask if I could use CC_SYNTHESIZE to create properties for objects like CCNode**?
I’ve seen in for example CCTMXXMLParser that you use CC_PROPERTY for CCNode** and alike.
Thanks
EDIT:
also… I can see that in CCTMXLayerInfo constructor, you are initializing m_pProperties [CCStringToStringDictionary], however you don’t initialize other properties. Is there any rationale behind it?
I believe all these do is create getter and setter functions as a macro definition. Personally, in C++ if I need a getX or setX function, I just write it myself. I don’t think there’s any downside to this. The upside of course being that you can add multiple lines of changes to your getter and setter function if needed. If you’re using the property/synthesize stuff I don’t believe you can.
I get what does macros do… I’m just wondering why are they used this way. And why is the constructor used this way.
I don’t want to make stupid mistakes when porting my game. Especially that my c++ knowledge is limited [I’m going to use lua hopefully, but I have to port few classes to c++]
I believe the only reason those macros exist is specifically for people porting Objective-C code written in Cocos2d-iPhone. It just allows them to essentially change their property, andsynthesize calls to macros and maintain equivalent functionality. If you’re coming from an Objective-C port, go wild with them. If not, I’d personally just write the c++.
For example, in Objective-C property (readwrite) bool flag; and thensynthesize flag; allows this variable to now be referenced as [class setFlag:YES]; and bool value = [class getFlag]; These macro’s allow a user to change these calls to class->setFlag(true); etc making it far easier to just do a line for line port without having to determine logic, or pointer handling, etc.
thanks for answer, but still. I know what does macros do. I am wondering why in code someone used SYNTHESIZE for int and PROPERTY for a pointer to an object.
In other words, why in CCTMXXMLParser.h it is done like this:
When we started cocos2d-x, we were not very familiar with object-c.
I think CC_PROPERTY should be used for declaring member functions, and CC_SYNTHESIZE to implements them.
I think we should change it in next version.