#ifndef _RED_REDMEMBERVARIABLEASSIGNER_H_ #define _RED_REDMEMBERVARIABLEASSIGNER_H_ namespace redream { #define RED_MEMBERVARIABLEASSIGNER_GLUE(TARGET, MEMBERVARIABLENAME, MEMBERVARIABLETYPE, MEMBERVARIABLE) \ if (pTarget == TARGET && 0 == strcmp(pMemberVariableName, (MEMBERVARIABLENAME))) { \ MEMBERVARIABLETYPE pOldVar = MEMBERVARIABLE; \ MEMBERVARIABLE = dynamic_cast(pNode); \ CC_ASSERT(MEMBERVARIABLE); \ if (pOldVar != MEMBERVARIABLE) { \ CC_SAFE_RELEASE(pOldVar); \ MEMBERVARIABLE->retain(); \ } \ return true; \ } #define RED_MEMBERVARIABLEASSIGNER_GLUE_WEAK(TARGET, MEMBERVARIABLENAME, MEMBERVARIABLETYPE, MEMBERVARIABLE) \ if (pTarget == TARGET && 0 == strcmp(pMemberVariableName, MEMBERVARIABLENAME)) { \ MEMBERVARIABLE = dynamic_cast(pNode); \ CC_ASSERT(MEMBERVARIABLE); \ return true; \ } class CC_DLL REDMemberVariableAssigner { public: /** * @js NA * @lua NA */ virtual ~REDMemberVariableAssigner() {}; /** * The callback function of assigning member variable. * @note The member variable must be Node or its subclass. * @param target The custom class. * @param memberVariableName The name of the member variable. * @param node The member variable. * @return Whether the assignment was successful. */ virtual bool onAssignREDMemberVariable(cocos2d::Ref* target, const char* memberVariableName, cocos2d::Node* node) = 0; virtual void onAssignREDMemberVariableWithClass(cocos2d::Ref* target, const char* memberVariableName, cocos2d::Node* node, const std::string className){}; /** * The callback function of assigning custom properties. * @note The member variable must be Integer, Float, Boolean or String. * @param target The custom class. * @param memberVariableName The name of the member variable. * @param value The value of the property. * @return Whether the assignment was successful. */ virtual bool onAssignREDCustomProperty(cocos2d::Ref* target, const char* memberVariableName, const cocos2d::Value& value) { return false; }; }; } #endif