diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id b/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id index 90a113389a..e42cc3e5b8 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -8f6bd203bc07c8cff824450938e8931abc027341 \ No newline at end of file +6f2f4d4cad4517fbd5b711d5895f5912b6d0c8bd \ No newline at end of file diff --git a/cocos/2d/CCAction.h b/cocos/2d/CCAction.h index dc5926fb0c..44c53a7676 100644 --- a/cocos/2d/CCAction.h +++ b/cocos/2d/CCAction.h @@ -28,12 +28,12 @@ THE SOFTWARE. #ifndef __ACTIONS_CCACTION_H__ #define __ACTIONS_CCACTION_H__ -#include "CCObject.h" +#include "CCRef.h" #include "CCGeometry.h" -#include "CCPlatformMacros.h" NS_CC_BEGIN +class Node; /** * @addtogroup actions * @{ @@ -42,7 +42,7 @@ NS_CC_BEGIN /** @brief Base class for Action objects. */ -class CC_DLL Action : public Object, public Clonable +class CC_DLL Action : public Ref, public Clonable { public: /// Default tag used for all the actions diff --git a/cocos/2d/CCActionCatmullRom.h b/cocos/2d/CCActionCatmullRom.h index 6ecad0c6af..86d18eb74c 100644 --- a/cocos/2d/CCActionCatmullRom.h +++ b/cocos/2d/CCActionCatmullRom.h @@ -52,7 +52,7 @@ NS_CC_BEGIN; Used by CardinalSplineTo and (By) and CatmullRomTo (and By) actions. @ingroup Actions */ -class CC_DLL PointArray : public Object, public Clonable +class CC_DLL PointArray : public Ref, public Clonable { public: diff --git a/cocos/2d/CCActionEase.h b/cocos/2d/CCActionEase.h index 3fbf7111e5..0a988994e0 100644 --- a/cocos/2d/CCActionEase.h +++ b/cocos/2d/CCActionEase.h @@ -31,8 +31,6 @@ THE SOFTWARE. NS_CC_BEGIN -class Object; - /** * @addtogroup actions * @{ diff --git a/cocos/2d/CCActionGrid3D.h b/cocos/2d/CCActionGrid3D.h index 52311b6674..cb289ef7ba 100644 --- a/cocos/2d/CCActionGrid3D.h +++ b/cocos/2d/CCActionGrid3D.h @@ -98,8 +98,6 @@ private: class CC_DLL FlipY3D : public FlipX3D { public: - FlipY3D() {} - virtual ~FlipY3D() {} /** creates the action with duration */ static FlipY3D* create(float duration); @@ -107,6 +105,9 @@ public: virtual void update(float time) override; virtual FlipY3D* clone() const override; +protected: + FlipY3D() {} + virtual ~FlipY3D() {} private: CC_DISALLOW_COPY_AND_ASSIGN(FlipY3D); }; diff --git a/cocos/2d/CCActionInstant.cpp b/cocos/2d/CCActionInstant.cpp index f0280d1380..427c1ff204 100644 --- a/cocos/2d/CCActionInstant.cpp +++ b/cocos/2d/CCActionInstant.cpp @@ -333,7 +333,7 @@ CallFunc * CallFunc::create(const std::function &func) return nullptr; } -CallFunc * CallFunc::create(Object* selectorTarget, SEL_CallFunc selector) +CallFunc * CallFunc::create(Ref* selectorTarget, SEL_CallFunc selector) { CallFunc *ret = new CallFunc(); @@ -353,7 +353,7 @@ bool CallFunc::initWithFunction(const std::function &func) return true; } -bool CallFunc::initWithTarget(Object* target) { +bool CallFunc::initWithTarget(Ref* target) { if (target) { target->retain(); @@ -426,7 +426,7 @@ CallFuncN * CallFuncN::create(const std::function &func) } // XXX deprecated -CallFuncN * CallFuncN::create(Object* selectorTarget, SEL_CallFuncN selector) +CallFuncN * CallFuncN::create(Ref* selectorTarget, SEL_CallFuncN selector) { CallFuncN *ret = new CallFuncN(); @@ -455,7 +455,7 @@ bool CallFuncN::initWithFunction(const std::function &func) return true; } -bool CallFuncN::initWithTarget(Object* selectorTarget, SEL_CallFuncN selector) +bool CallFuncN::initWithTarget(Ref* selectorTarget, SEL_CallFuncN selector) { if (CallFunc::initWithTarget(selectorTarget)) { _callFuncN = selector; @@ -485,7 +485,7 @@ CallFuncN * CallFuncN::clone() const // CallFuncND // -__CCCallFuncND * __CCCallFuncND::create(Object* selectorTarget, SEL_CallFuncND selector, void* d) +__CCCallFuncND * __CCCallFuncND::create(Ref* selectorTarget, SEL_CallFuncND selector, void* d) { __CCCallFuncND* ret = new __CCCallFuncND(); @@ -498,7 +498,7 @@ __CCCallFuncND * __CCCallFuncND::create(Object* selectorTarget, SEL_CallFuncND s return nullptr; } -bool __CCCallFuncND::initWithTarget(Object* selectorTarget, SEL_CallFuncND selector, void* d) +bool __CCCallFuncND::initWithTarget(Ref* selectorTarget, SEL_CallFuncND selector, void* d) { if (CallFunc::initWithTarget(selectorTarget)) { @@ -552,7 +552,7 @@ void __CCCallFuncO::execute() } } -__CCCallFuncO * __CCCallFuncO::create(Object* selectorTarget, SEL_CallFuncO selector, Object* object) +__CCCallFuncO * __CCCallFuncO::create(Ref* selectorTarget, SEL_CallFuncO selector, Ref* object) { __CCCallFuncO *ret = new __CCCallFuncO(); @@ -565,7 +565,7 @@ __CCCallFuncO * __CCCallFuncO::create(Object* selectorTarget, SEL_CallFuncO sele return nullptr; } -bool __CCCallFuncO::initWithTarget(Object* selectorTarget, SEL_CallFuncO selector, Object* object) +bool __CCCallFuncO::initWithTarget(Ref* selectorTarget, SEL_CallFuncO selector, Ref* object) { if (CallFunc::initWithTarget(selectorTarget)) { @@ -593,12 +593,12 @@ __CCCallFuncO * __CCCallFuncO::clone() const return a; } -Object* __CCCallFuncO::getObject() const +Ref* __CCCallFuncO::getObject() const { return _object; } -void __CCCallFuncO::setObject(Object* obj) +void __CCCallFuncO::setObject(Ref* obj) { if (obj != _object) { diff --git a/cocos/2d/CCActionInstant.h b/cocos/2d/CCActionInstant.h index 11fce3aaae..e27c09889d 100644 --- a/cocos/2d/CCActionInstant.h +++ b/cocos/2d/CCActionInstant.h @@ -259,23 +259,23 @@ public: /** creates the action with the callback - typedef void (Object::*SEL_CallFunc)(); + typedef void (Ref::*SEL_CallFunc)(); @deprecated Use the std::function API instead. * @js NA * @lua NA */ - CC_DEPRECATED_ATTRIBUTE static CallFunc * create(Object* target, SEL_CallFunc selector); + CC_DEPRECATED_ATTRIBUTE static CallFunc * create(Ref* target, SEL_CallFunc selector); public: /** executes the callback */ virtual void execute(); - inline Object* getTargetCallback() + inline Ref* getTargetCallback() { return _selectorTarget; } - inline void setTargetCallback(Object* sel) + inline void setTargetCallback(Ref* sel) { if (sel != _selectorTarget) { @@ -301,10 +301,10 @@ protected: virtual ~CallFunc(); /** initializes the action with the callback - typedef void (Object::*SEL_CallFunc)(); + typedef void (Ref::*SEL_CallFunc)(); @deprecated Use the std::function API instead. */ - CC_DEPRECATED_ATTRIBUTE bool initWithTarget(Object* target); + CC_DEPRECATED_ATTRIBUTE bool initWithTarget(Ref* target); /** initializes the action with the std::function * @js NA @@ -313,7 +313,7 @@ protected: bool initWithFunction(const std::function& func); /** Target that will be called */ - Object* _selectorTarget; + Ref* _selectorTarget; union { @@ -342,10 +342,10 @@ public: /** creates the action with the callback - typedef void (Object::*SEL_CallFuncN)(Node*); + typedef void (Ref::*SEL_CallFuncN)(Node*); @deprecated Use the std::function API instead. */ - CC_DEPRECATED_ATTRIBUTE static CallFuncN * create(Object* target, SEL_CallFuncN selector); + CC_DEPRECATED_ATTRIBUTE static CallFuncN * create(Ref* target, SEL_CallFuncN selector); // // Overrides @@ -361,10 +361,10 @@ protected: /** initializes the action with the callback - typedef void (Object::*SEL_CallFuncN)(Node*); + typedef void (Ref::*SEL_CallFuncN)(Node*); @deprecated Use the std::function API instead. */ - CC_DEPRECATED_ATTRIBUTE bool initWithTarget(Object* target, SEL_CallFuncN selector); + CC_DEPRECATED_ATTRIBUTE bool initWithTarget(Ref* target, SEL_CallFuncN selector); /** function that will be called with the "sender" as the 1st argument */ @@ -384,7 +384,7 @@ class CC_DLL __CCCallFuncND : public CallFunc { public: /** creates the action with the callback and the data to pass as an argument */ - CC_DEPRECATED_ATTRIBUTE static __CCCallFuncND * create(Object* target, SEL_CallFuncND selector, void* d); + CC_DEPRECATED_ATTRIBUTE static __CCCallFuncND * create(Ref* target, SEL_CallFuncND selector, void* d); // // Overrides @@ -397,7 +397,7 @@ protected: virtual ~__CCCallFuncND() {} /** initializes the action with the callback and the data to pass as an argument */ - bool initWithTarget(Object* target, SEL_CallFuncND selector, void* d); + bool initWithTarget(Ref* target, SEL_CallFuncND selector, void* d); SEL_CallFuncND _callFuncND; void* _data; @@ -419,30 +419,30 @@ class CC_DLL __CCCallFuncO : public CallFunc public: /** creates the action with the callback - typedef void (Object::*SEL_CallFuncO)(Object*); + typedef void (Ref::*SEL_CallFuncO)(Ref*); */ - CC_DEPRECATED_ATTRIBUTE static __CCCallFuncO * create(Object* target, SEL_CallFuncO selector, Object* object); + CC_DEPRECATED_ATTRIBUTE static __CCCallFuncO * create(Ref* target, SEL_CallFuncO selector, Ref* object); // // Overrides // virtual __CCCallFuncO* clone() const override; virtual void execute() override; - Object* getObject() const; - void setObject(Object* obj); + Ref* getObject() const; + void setObject(Ref* obj); protected: __CCCallFuncO(); virtual ~__CCCallFuncO(); /** initializes the action with the callback - typedef void (Object::*SEL_CallFuncO)(Object*); + typedef void (Ref::*SEL_CallFuncO)(Ref*); */ - bool initWithTarget(Object* target, SEL_CallFuncO selector, Object* object); + bool initWithTarget(Ref* target, SEL_CallFuncO selector, Ref* object); /** object to be passed as argument */ - Object* _object; + Ref* _object; SEL_CallFuncO _callFuncO; private: diff --git a/cocos/2d/CCActionManager.cpp b/cocos/2d/CCActionManager.cpp index 3865280806..f1cf8f8c9c 100644 --- a/cocos/2d/CCActionManager.cpp +++ b/cocos/2d/CCActionManager.cpp @@ -172,8 +172,8 @@ void ActionManager::addAction(Action *action, Node *target, bool paused) CCASSERT(target != nullptr, ""); tHashElement *element = nullptr; - // we should convert it to Object*, because we save it as Object* - Object *tmp = target; + // we should convert it to Ref*, because we save it as Ref* + Ref *tmp = target; HASH_FIND_PTR(_targets, &tmp, element); if (! element) { @@ -247,7 +247,7 @@ void ActionManager::removeAction(Action *action) } tHashElement *element = nullptr; - Object *target = action->getOriginalTarget(); + Ref *target = action->getOriginalTarget(); HASH_FIND_PTR(_targets, &target, element); if (element) { diff --git a/cocos/2d/CCActionManager.h b/cocos/2d/CCActionManager.h index 0a096f1421..0b4061571a 100644 --- a/cocos/2d/CCActionManager.h +++ b/cocos/2d/CCActionManager.h @@ -31,7 +31,7 @@ THE SOFTWARE. #include "CCAction.h" #include "CCVector.h" -#include "CCObject.h" +#include "CCRef.h" NS_CC_BEGIN @@ -53,7 +53,7 @@ struct _hashElement; @since v0.8 */ -class CC_DLL ActionManager : public Object +class CC_DLL ActionManager : public Ref { public: /** @@ -122,13 +122,14 @@ public: */ void resumeTargets(const Vector& targetsToResume); + void update(float dt); + protected: // declared in ActionManager.m void removeActionAtIndex(ssize_t index, struct _hashElement *element); void deleteHashElement(struct _hashElement *element); void actionAllocWithHashElement(struct _hashElement *element); - void update(float dt); protected: struct _hashElement *_targets; diff --git a/cocos/2d/CCAnimation.h b/cocos/2d/CCAnimation.h index 04f0fa1997..be30dbbff4 100644 --- a/cocos/2d/CCAnimation.h +++ b/cocos/2d/CCAnimation.h @@ -28,7 +28,7 @@ THE SOFTWARE. #define __CC_ANIMATION_H__ #include "CCPlatformConfig.h" -#include "CCObject.h" +#include "CCRef.h" #include "CCArray.h" #include "CCValue.h" #include "CCGeometry.h" @@ -55,7 +55,7 @@ class SpriteFrame; @since v2.0 */ -class CC_DLL AnimationFrame : public Object, public Clonable +class CC_DLL AnimationFrame : public Ref, public Clonable { public: /** @@ -135,7 +135,7 @@ You can animate a Animation object by using the Animate action. Example: @endcode */ -class CC_DLL Animation : public Object, public Clonable +class CC_DLL Animation : public Ref, public Clonable { public: /** Creates an animation diff --git a/cocos/2d/CCAnimationCache.h b/cocos/2d/CCAnimationCache.h index f47ff4fd14..7f215a3b97 100644 --- a/cocos/2d/CCAnimationCache.h +++ b/cocos/2d/CCAnimationCache.h @@ -27,9 +27,10 @@ THE SOFTWARE. #ifndef __CC_ANIMATION_CACHE_H__ #define __CC_ANIMATION_CACHE_H__ -#include "CCObject.h" +#include "CCRef.h" #include "CCMap.h" #include "CCValue.h" + #include NS_CC_BEGIN @@ -48,7 +49,7 @@ Before v0.99.5, the recommend way was to save them on the Sprite. Since v0.99.5, @since v0.99.5 */ -class CC_DLL AnimationCache : public Object +class CC_DLL AnimationCache : public Ref { public: /** diff --git a/cocos/2d/CCComponent.h b/cocos/2d/CCComponent.h index 4d5625d71f..6b6a5ed351 100644 --- a/cocos/2d/CCComponent.h +++ b/cocos/2d/CCComponent.h @@ -25,12 +25,14 @@ THE SOFTWARE. #ifndef __CC_FRAMEWORK_COMPONENT_H__ #define __CC_FRAMEWORK_COMPONENT_H__ -#include "CCObject.h" +#include "CCRef.h" #include NS_CC_BEGIN -class CC_DLL Component : public Object +class Node; + +class CC_DLL Component : public Ref { protected: /** diff --git a/cocos/2d/CCConfiguration.h b/cocos/2d/CCConfiguration.h index 4a1ec1568c..653031f43b 100644 --- a/cocos/2d/CCConfiguration.h +++ b/cocos/2d/CCConfiguration.h @@ -27,7 +27,7 @@ THE SOFTWARE. #ifndef __CCCONFIGURATION_H__ #define __CCCONFIGURATION_H__ -#include "CCObject.h" +#include "CCRef.h" #include "CCGL.h" #include "CCString.h" #include "CCValue.h" @@ -43,7 +43,7 @@ NS_CC_BEGIN @brief Configuration contains some openGL variables @since v0.99.0 */ -class CC_DLL Configuration : public Object +class CC_DLL Configuration : public Ref { public: diff --git a/cocos/2d/CCDeprecated.h b/cocos/2d/CCDeprecated.h index 7893de6149..7200183214 100644 --- a/cocos/2d/CCDeprecated.h +++ b/cocos/2d/CCDeprecated.h @@ -533,7 +533,7 @@ CC_DEPRECATED_ATTRIBUTE static inline AffineTransform CCAffineTransformIdentity( } // CC prefix compatibility -CC_DEPRECATED_ATTRIBUTE typedef Object CCObject; +CC_DEPRECATED_ATTRIBUTE typedef Ref CCObject; CC_DEPRECATED_ATTRIBUTE typedef Event CCEvent; CC_DEPRECATED_ATTRIBUTE typedef DataVisitor CCDataVisitor; CC_DEPRECATED_ATTRIBUTE typedef PrettyPrinter CCPrettyPrinter; diff --git a/cocos/2d/CCDirector.cpp b/cocos/2d/CCDirector.cpp index fa4a3f399f..72b63f6781 100644 --- a/cocos/2d/CCDirector.cpp +++ b/cocos/2d/CCDirector.cpp @@ -142,7 +142,9 @@ bool Director::init(void) _scheduler = new Scheduler(); // action manager _actionManager = new ActionManager(); - _scheduler->scheduleUpdateForTarget(_actionManager, Scheduler::PRIORITY_SYSTEM, false); + _scheduler->scheduleUpdate([this](float dt){ + this->_actionManager->update(dt); + }, _actionManager, Scheduler::PRIORITY_SYSTEM, false); _eventDispatcher = new EventDispatcher(); _eventAfterDraw = new EventCustom(EVENT_AFTER_DRAW); diff --git a/cocos/2d/CCDirector.h b/cocos/2d/CCDirector.h index b217aed0d8..d2f602959e 100644 --- a/cocos/2d/CCDirector.h +++ b/cocos/2d/CCDirector.h @@ -30,13 +30,12 @@ THE SOFTWARE. #include "CCPlatformMacros.h" -#include "CCObject.h" +#include "CCRef.h" #include "ccTypes.h" #include "CCGeometry.h" #include "CCVector.h" #include "CCGL.h" #include "CCLabelAtlas.h" - #include "kazmath/mat4.h" @@ -83,7 +82,7 @@ and when to execute the Scenes. - GL_COLOR_ARRAY is enabled - GL_TEXTURE_COORD_ARRAY is enabled */ -class CC_DLL Director : public Object +class CC_DLL Director : public Ref { public: static const char *EVENT_PROJECTION_CHANGED; diff --git a/cocos/2d/CCEvent.h b/cocos/2d/CCEvent.h index c1ec2416c0..9752af6fba 100644 --- a/cocos/2d/CCEvent.h +++ b/cocos/2d/CCEvent.h @@ -29,7 +29,7 @@ #include #include -#include "CCObject.h" +#include "CCRef.h" #include "CCPlatformMacros.h" NS_CC_BEGIN @@ -39,7 +39,7 @@ class Node; /** * Base class of all kinds of events. */ -class Event : public Object +class Event : public Ref { public: enum class Type diff --git a/cocos/2d/CCEventDispatcher.h b/cocos/2d/CCEventDispatcher.h index f7c886508b..9ffc05059d 100644 --- a/cocos/2d/CCEventDispatcher.h +++ b/cocos/2d/CCEventDispatcher.h @@ -52,7 +52,7 @@ event listeners can be added and removed even from within an EventListener, while events are being dispatched. */ -class EventDispatcher : public Object +class EventDispatcher : public Ref { public: /** Adds a event listener for a specified event with the priority of scene graph. diff --git a/cocos/2d/CCEventListener.h b/cocos/2d/CCEventListener.h index cf380dd50d..2f921823a2 100644 --- a/cocos/2d/CCEventListener.h +++ b/cocos/2d/CCEventListener.h @@ -26,7 +26,7 @@ #define cocos2d_libs_EventListener_h #include "CCPlatformMacros.h" -#include "CCObject.h" +#include "CCRef.h" #include #include @@ -43,7 +43,7 @@ class Node; * If you need custom listener which with different callback, you need to inherit this class. * For instance, you could refer to EventListenerAcceleration, EventListenerKeyboard, EventListenerTouchOneByOne, EventListenerCustom. */ -class EventListener : public Object +class EventListener : public Ref { public: enum class Type diff --git a/cocos/2d/CCFont.h b/cocos/2d/CCFont.h index 719d424a49..c384ae752a 100644 --- a/cocos/2d/CCFont.h +++ b/cocos/2d/CCFont.h @@ -36,7 +36,7 @@ NS_CC_BEGIN class FontAtlas; -class CC_DLL Font : public Object +class CC_DLL Font : public Ref { public: virtual FontAtlas *createFontAtlas() = 0; diff --git a/cocos/2d/CCFontAtlas.h b/cocos/2d/CCFontAtlas.h index a6128bf28a..ee154714eb 100644 --- a/cocos/2d/CCFontAtlas.h +++ b/cocos/2d/CCFontAtlas.h @@ -27,7 +27,7 @@ #include #include "CCPlatformMacros.h" -#include "CCObject.h" +#include "CCRef.h" NS_CC_BEGIN @@ -49,7 +49,7 @@ struct FontLetterDefinition int xAdvance; }; -class CC_DLL FontAtlas : public Object +class CC_DLL FontAtlas : public Ref { public: /** diff --git a/cocos/2d/CCGLProgram.h b/cocos/2d/CCGLProgram.h index a916caf7c7..b36e460fa3 100644 --- a/cocos/2d/CCGLProgram.h +++ b/cocos/2d/CCGLProgram.h @@ -31,8 +31,7 @@ THE SOFTWARE. #define __CCGLPROGRAM_H__ #include "ccMacros.h" -#include "CCObject.h" - +#include "CCRef.h" #include "CCGL.h" #include "kazmath/kazmath.h" @@ -54,7 +53,7 @@ typedef void (*GLLogFunction) (GLuint program, GLsizei bufsize, GLsizei* length, @since v2.0.0 */ -class CC_DLL GLProgram : public Object +class CC_DLL GLProgram : public Ref { public: enum diff --git a/cocos/2d/CCGrabber.h b/cocos/2d/CCGrabber.h index d3bdf1a07b..6683bb8e2d 100644 --- a/cocos/2d/CCGrabber.h +++ b/cocos/2d/CCGrabber.h @@ -27,7 +27,7 @@ THE SOFTWARE. #define __EFFECTS_CCGRABBER_H__ #include "CCConfiguration.h" -#include "CCObject.h" +#include "CCRef.h" #include "CCGL.h" NS_CC_BEGIN @@ -40,7 +40,7 @@ class Texture2D; */ /** FBO class that grabs the the contents of the screen */ -class Grabber : public Object +class Grabber : public Ref { public: /** diff --git a/cocos/2d/CCGrid.h b/cocos/2d/CCGrid.h index 8111190818..166613b706 100644 --- a/cocos/2d/CCGrid.h +++ b/cocos/2d/CCGrid.h @@ -26,7 +26,7 @@ THE SOFTWARE. #ifndef __EFFECTS_CCGRID_H__ #define __EFFECTS_CCGRID_H__ -#include "CCObject.h" +#include "CCRef.h" #include "CCNode.h" #include "ccTypes.h" #include "CCTexture2D.h" @@ -49,7 +49,7 @@ class GLProgram; /** Base class for other */ -class CC_DLL GridBase : public Object +class CC_DLL GridBase : public Ref { public: /** create one Grid */ diff --git a/cocos/2d/CCLabelAtlas.cpp b/cocos/2d/CCLabelAtlas.cpp index 200bec0641..84c889d81f 100644 --- a/cocos/2d/CCLabelAtlas.cpp +++ b/cocos/2d/CCLabelAtlas.cpp @@ -38,6 +38,7 @@ THE SOFTWARE. #include "platform/CCFileUtils.h" // external #include "kazmath/GL/matrix.h" +#include "CCString.h" NS_CC_BEGIN diff --git a/cocos/2d/CCLabelBMFont.h b/cocos/2d/CCLabelBMFont.h index 5edda128e1..ca2c8ca21f 100644 --- a/cocos/2d/CCLabelBMFont.h +++ b/cocos/2d/CCLabelBMFont.h @@ -106,7 +106,7 @@ typedef struct _KerningHashElement /** @brief CCBMFontConfiguration has parsed configuration of the the .fnt file @since v0.8 */ -class CC_DLL CCBMFontConfiguration : public Object +class CC_DLL CCBMFontConfiguration : public Ref { // XXX: Creating a public interface so that the bitmapFontArray[] is accessible public://@public diff --git a/cocos/2d/CCLayer.cpp b/cocos/2d/CCLayer.cpp index c3bfe5fb60..2730dcb245 100644 --- a/cocos/2d/CCLayer.cpp +++ b/cocos/2d/CCLayer.cpp @@ -46,6 +46,7 @@ THE SOFTWARE. #include "CCScene.h" #include "renderer/CCCustomCommand.h" #include "renderer/CCRenderer.h" +#include "CCString.h" NS_CC_BEGIN diff --git a/cocos/2d/CCMenuItem.cpp b/cocos/2d/CCMenuItem.cpp index f137404176..33a7e22ee9 100644 --- a/cocos/2d/CCMenuItem.cpp +++ b/cocos/2d/CCMenuItem.cpp @@ -63,7 +63,7 @@ MenuItem* MenuItem::create() } // XXX deprecated -MenuItem* MenuItem::create(Object *target, SEL_MenuHandler selector) +MenuItem* MenuItem::create(Ref *target, SEL_MenuHandler selector) { MenuItem *ret = new MenuItem(); ret->initWithTarget(target, selector); @@ -80,7 +80,7 @@ MenuItem* MenuItem::create( const ccMenuCallback& callback) } // XXX deprecated -bool MenuItem::initWithTarget(cocos2d::Object *target, SEL_MenuHandler selector ) +bool MenuItem::initWithTarget(cocos2d::Ref *target, SEL_MenuHandler selector ) { _target = target; CC_SAFE_RETAIN(_target); @@ -152,7 +152,7 @@ bool MenuItem::isSelected() const } // XXX deprecated -void MenuItem::setTarget(Object *target, SEL_MenuHandler selector) +void MenuItem::setTarget(Ref *target, SEL_MenuHandler selector) { _target = target; CC_SAFE_RETAIN(_target); @@ -191,7 +191,7 @@ void MenuItemLabel::setLabel(Node* var) } // XXX: deprecated -MenuItemLabel * MenuItemLabel::create(Node*label, Object* target, SEL_MenuHandler selector) +MenuItemLabel * MenuItemLabel::create(Node*label, Ref* target, SEL_MenuHandler selector) { MenuItemLabel *ret = new MenuItemLabel(); ret->initWithLabel(label, target, selector); @@ -216,7 +216,7 @@ MenuItemLabel* MenuItemLabel::create(Node *label) } // XXX: deprecated -bool MenuItemLabel::initWithLabel(Node* label, Object* target, SEL_MenuHandler selector) +bool MenuItemLabel::initWithLabel(Node* label, Ref* target, SEL_MenuHandler selector) { _target = target; CC_SAFE_RETAIN(_target); @@ -321,7 +321,7 @@ MenuItemAtlasFont * MenuItemAtlasFont::create(const std::string& value, const st } // XXX: deprecated -MenuItemAtlasFont * MenuItemAtlasFont::create(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap, Object* target, SEL_MenuHandler selector) +MenuItemAtlasFont * MenuItemAtlasFont::create(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap, Ref* target, SEL_MenuHandler selector) { MenuItemAtlasFont *ret = new MenuItemAtlasFont(); ret->initWithString(value, charMapFile, itemWidth, itemHeight, startCharMap, target, selector); @@ -338,7 +338,7 @@ MenuItemAtlasFont * MenuItemAtlasFont::create(const std::string& value, const st } // XXX: deprecated -bool MenuItemAtlasFont::initWithString(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap, Object* target, SEL_MenuHandler selector) +bool MenuItemAtlasFont::initWithString(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap, Ref* target, SEL_MenuHandler selector) { _target = target; CC_SAFE_RETAIN(_target); @@ -387,7 +387,7 @@ const std::string& MenuItemFont::getFontName() } // XXX: deprecated -MenuItemFont * MenuItemFont::create(const std::string& value, Object* target, SEL_MenuHandler selector) +MenuItemFont * MenuItemFont::create(const std::string& value, Ref* target, SEL_MenuHandler selector) { MenuItemFont *ret = new MenuItemFont(); ret->initWithString(value, target, selector); @@ -422,7 +422,7 @@ MenuItemFont::~MenuItemFont() } // XXX: deprecated -bool MenuItemFont::initWithString(const std::string& value, Object* target, SEL_MenuHandler selector) +bool MenuItemFont::initWithString(const std::string& value, Ref* target, SEL_MenuHandler selector) { CCASSERT( !value.empty(), "Value length must be greater than 0"); @@ -550,7 +550,7 @@ MenuItemSprite * MenuItemSprite::create(Node* normalSprite, Node* selectedSprite } // XXX deprecated -MenuItemSprite * MenuItemSprite::create(Node* normalSprite, Node* selectedSprite, Object* target, SEL_MenuHandler selector) +MenuItemSprite * MenuItemSprite::create(Node* normalSprite, Node* selectedSprite, Ref* target, SEL_MenuHandler selector) { return MenuItemSprite::create(normalSprite, selectedSprite, nullptr, target, selector); } @@ -561,7 +561,7 @@ MenuItemSprite * MenuItemSprite::create(Node* normalSprite, Node* selectedSprite } // XXX deprecated -MenuItemSprite * MenuItemSprite::create(Node *normalSprite, Node *selectedSprite, Node *disabledSprite, Object *target, SEL_MenuHandler selector) +MenuItemSprite * MenuItemSprite::create(Node *normalSprite, Node *selectedSprite, Node *disabledSprite, Ref *target, SEL_MenuHandler selector) { MenuItemSprite *ret = new MenuItemSprite(); ret->initWithNormalSprite(normalSprite, selectedSprite, disabledSprite, target, selector); @@ -578,7 +578,7 @@ MenuItemSprite * MenuItemSprite::create(Node *normalSprite, Node *selectedSprite } // XXX deprecated -bool MenuItemSprite::initWithNormalSprite(Node* normalSprite, Node* selectedSprite, Node* disabledSprite, Object* target, SEL_MenuHandler selector) +bool MenuItemSprite::initWithNormalSprite(Node* normalSprite, Node* selectedSprite, Node* disabledSprite, Ref* target, SEL_MenuHandler selector) { _target = target; CC_SAFE_RETAIN(_target); @@ -710,7 +710,7 @@ MenuItemImage * MenuItemImage::create(const std::string& normalImage, const std: } // XXX deprecated -MenuItemImage * MenuItemImage::create(const std::string& normalImage, const std::string& selectedImage, Object* target, SEL_MenuHandler selector) +MenuItemImage * MenuItemImage::create(const std::string& normalImage, const std::string& selectedImage, Ref* target, SEL_MenuHandler selector) { return MenuItemImage::create(normalImage, selectedImage, "", target, selector); } @@ -721,7 +721,7 @@ MenuItemImage * MenuItemImage::create(const std::string& normalImage, const std: } // XXX deprecated -MenuItemImage * MenuItemImage::create(const std::string& normalImage, const std::string& selectedImage, const std::string& disabledImage, Object* target, SEL_MenuHandler selector) +MenuItemImage * MenuItemImage::create(const std::string& normalImage, const std::string& selectedImage, const std::string& disabledImage, Ref* target, SEL_MenuHandler selector) { MenuItemImage *ret = new MenuItemImage(); if (ret && ret->initWithNormalImage(normalImage, selectedImage, disabledImage, target, selector)) @@ -758,7 +758,7 @@ MenuItemImage * MenuItemImage::create(const std::string& normalImage, const std: } // XXX: deprecated -bool MenuItemImage::initWithNormalImage(const std::string& normalImage, const std::string& selectedImage, const std::string& disabledImage, Object* target, SEL_MenuHandler selector) +bool MenuItemImage::initWithNormalImage(const std::string& normalImage, const std::string& selectedImage, const std::string& disabledImage, Ref* target, SEL_MenuHandler selector) { _target = target; CC_SAFE_RETAIN(_target); @@ -810,7 +810,7 @@ void MenuItemImage::setDisabledSpriteFrame(SpriteFrame * frame) // // XXX: deprecated -MenuItemToggle * MenuItemToggle::createWithTarget(Object* target, SEL_MenuHandler selector, const Vector& menuItems) +MenuItemToggle * MenuItemToggle::createWithTarget(Ref* target, SEL_MenuHandler selector, const Vector& menuItems) { MenuItemToggle *ret = new MenuItemToggle(); ret->MenuItem::initWithTarget(target, selector); @@ -831,7 +831,7 @@ MenuItemToggle * MenuItemToggle::createWithCallback(const ccMenuCallback &callba } // XXX: deprecated -MenuItemToggle * MenuItemToggle::createWithTarget(Object* target, SEL_MenuHandler selector, MenuItem* item, ...) +MenuItemToggle * MenuItemToggle::createWithTarget(Ref* target, SEL_MenuHandler selector, MenuItem* item, ...) { va_list args; va_start(args, item); @@ -862,7 +862,7 @@ MenuItemToggle * MenuItemToggle::create() } // XXX: deprecated -bool MenuItemToggle::initWithTarget(Object* target, SEL_MenuHandler selector, MenuItem* item, va_list args) +bool MenuItemToggle::initWithTarget(Ref* target, SEL_MenuHandler selector, MenuItem* item, va_list args) { _target = target; CC_SAFE_RETAIN(_target); diff --git a/cocos/2d/CCMenuItem.h b/cocos/2d/CCMenuItem.h index 9e19b4488e..263c0bec7c 100644 --- a/cocos/2d/CCMenuItem.h +++ b/cocos/2d/CCMenuItem.h @@ -38,7 +38,7 @@ THE SOFTWARE. NS_CC_BEGIN -typedef std::function ccMenuCallback; +typedef std::function ccMenuCallback; class LabelTTF; class LabelAtlas; @@ -63,7 +63,7 @@ public: /** Creates a MenuItem with no target/selector */ static MenuItem* create(); /** Creates a MenuItem with a target/selector */ - CC_DEPRECATED_ATTRIBUTE static MenuItem* create(Object *rec, SEL_MenuHandler selector); + CC_DEPRECATED_ATTRIBUTE static MenuItem* create(Ref *rec, SEL_MenuHandler selector); /** Creates a MenuItem with a target/selector */ static MenuItem* create(const ccMenuCallback& callback); @@ -93,7 +93,7 @@ public: * @js NA * @lua NA */ - CC_DEPRECATED_ATTRIBUTE void setTarget(Object *rec, SEL_MenuHandler selector); + CC_DEPRECATED_ATTRIBUTE void setTarget(Ref *rec, SEL_MenuHandler selector); virtual std::string getDescription() const override; @@ -123,14 +123,14 @@ protected: * @js NA * @lua NA */ - CC_DEPRECATED_ATTRIBUTE bool initWithTarget( Object *rec, SEL_MenuHandler selector); + CC_DEPRECATED_ATTRIBUTE bool initWithTarget(Ref *rec, SEL_MenuHandler selector); bool _selected; bool _enabled; // callback ccMenuCallback _callback; // If using the old API, the _target needs to be retained / released - Object *_target; + Ref *_target; private: CC_DISALLOW_COPY_AND_ASSIGN(MenuItem); @@ -147,7 +147,7 @@ class CC_DLL MenuItemLabel : public MenuItem { public: /** creates a MenuItemLabel with a Label, target and selector */ - CC_DEPRECATED_ATTRIBUTE static MenuItemLabel * create(Node*label, Object* target, SEL_MenuHandler selector); + CC_DEPRECATED_ATTRIBUTE static MenuItemLabel * create(Node*label, Ref* target, SEL_MenuHandler selector); /** creates a MenuItemLabel with a Label and a callback */ static MenuItemLabel * create(Node*label, const ccMenuCallback& callback); @@ -194,7 +194,7 @@ protected: bool initWithLabel(Node* label, const ccMenuCallback& callback); /** initializes a MenuItemLabel with a Label, target and selector */ - CC_DEPRECATED_ATTRIBUTE bool initWithLabel(Node* label, Object* target, SEL_MenuHandler selector); + CC_DEPRECATED_ATTRIBUTE bool initWithLabel(Node* label, Ref* target, SEL_MenuHandler selector); Color3B _colorBackup; float _originalScale; @@ -218,7 +218,7 @@ public: /** creates a menu item from a string and atlas with a target/selector */ static MenuItemAtlasFont* create(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap); /** creates a menu item from a string and atlas. Use it with MenuItemToggle */ - CC_DEPRECATED_ATTRIBUTE static MenuItemAtlasFont* create(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap, Object* target, SEL_MenuHandler selector); + CC_DEPRECATED_ATTRIBUTE static MenuItemAtlasFont* create(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap, Ref* target, SEL_MenuHandler selector); /** creates a menu item from a string and atlas. Use it with MenuItemToggle */ static MenuItemAtlasFont* create(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap, const ccMenuCallback& callback); @@ -234,7 +234,7 @@ protected: virtual ~MenuItemAtlasFont(){} /** initializes a menu item from a string and atlas with a target/selector */ - CC_DEPRECATED_ATTRIBUTE bool initWithString(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap, Object* target, SEL_MenuHandler selector); + CC_DEPRECATED_ATTRIBUTE bool initWithString(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap, Ref* target, SEL_MenuHandler selector); /** initializes a menu item from a string and atlas with a target/selector */ bool initWithString(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap, const ccMenuCallback& callback); @@ -252,7 +252,7 @@ public: /** creates a menu item from a string without target/selector. To be used with MenuItemToggle */ static MenuItemFont * create(const std::string& value = ""); /** creates a menu item from a string with a target/selector */ - CC_DEPRECATED_ATTRIBUTE static MenuItemFont * create(const std::string& value, Object* target, SEL_MenuHandler selector); + CC_DEPRECATED_ATTRIBUTE static MenuItemFont * create(const std::string& value, Ref* target, SEL_MenuHandler selector); /** creates a menu item from a string with a target/selector */ static MenuItemFont * create(const std::string& value, const ccMenuCallback& callback); @@ -307,7 +307,7 @@ protected: virtual ~MenuItemFont(); /** initializes a menu item from a string with a target/selector */ - CC_DEPRECATED_ATTRIBUTE bool initWithString(const std::string& value, Object* target, SEL_MenuHandler selector); + CC_DEPRECATED_ATTRIBUTE bool initWithString(const std::string& value, Ref* target, SEL_MenuHandler selector); /** initializes a menu item from a string with a target/selector */ bool initWithString(const std::string& value, const ccMenuCallback& callback); @@ -335,9 +335,9 @@ public: /** creates a menu item with a normal, selected and disabled image*/ static MenuItemSprite * create(Node* normalSprite, Node* selectedSprite, Node* disabledSprite = nullptr); /** creates a menu item with a normal and selected image with target/selector */ - CC_DEPRECATED_ATTRIBUTE static MenuItemSprite * create(Node* normalSprite, Node* selectedSprite, Object* target, SEL_MenuHandler selector); + CC_DEPRECATED_ATTRIBUTE static MenuItemSprite * create(Node* normalSprite, Node* selectedSprite, Ref* target, SEL_MenuHandler selector); /** creates a menu item with a normal,selected and disabled image with target/selector */ - CC_DEPRECATED_ATTRIBUTE static MenuItemSprite * create(Node* normalSprite, Node* selectedSprite, Node* disabledSprite, Object* target, SEL_MenuHandler selector); + CC_DEPRECATED_ATTRIBUTE static MenuItemSprite * create(Node* normalSprite, Node* selectedSprite, Node* disabledSprite, Ref* target, SEL_MenuHandler selector); /** creates a menu item with a normal and selected image with a callable object */ static MenuItemSprite * create(Node* normalSprite, Node* selectedSprite, const ccMenuCallback& callback); /** creates a menu item with a normal,selected and disabled image with target/selector */ @@ -376,7 +376,7 @@ protected: {} /** initializes a menu item with a normal, selected and disabled image with target/selector */ - CC_DEPRECATED_ATTRIBUTE bool initWithNormalSprite(Node* normalSprite, Node* selectedSprite, Node* disabledSprite, Object* target, SEL_MenuHandler selector); + CC_DEPRECATED_ATTRIBUTE bool initWithNormalSprite(Node* normalSprite, Node* selectedSprite, Node* disabledSprite, Ref* target, SEL_MenuHandler selector); /** initializes a menu item with a normal, selected and disabled image with a callable object */ bool initWithNormalSprite(Node* normalSprite, Node* selectedSprite, Node* disabledSprite, const ccMenuCallback& callback); @@ -412,12 +412,12 @@ public: /** creates a menu item with a normal,selected and disabled image*/ static MenuItemImage* create(const std::string& normalImage, const std::string& selectedImage, const std::string& disabledImage); /** creates a menu item with a normal and selected image with target/selector */ - CC_DEPRECATED_ATTRIBUTE static MenuItemImage* create(const std::string& normalImage, const std::string& selectedImage, Object* target, SEL_MenuHandler selector); + CC_DEPRECATED_ATTRIBUTE static MenuItemImage* create(const std::string& normalImage, const std::string& selectedImage, Ref* target, SEL_MenuHandler selector); /** creates a menu item with a normal and selected image with a callable object */ static MenuItemImage* create(const std::string&normalImage, const std::string&selectedImage, const ccMenuCallback& callback); /** creates a menu item with a normal,selected and disabled image with target/selector */ - CC_DEPRECATED_ATTRIBUTE static MenuItemImage* create(const std::string& normalImage, const std::string& selectedImage, const std::string& disabledImage, Object* target, SEL_MenuHandler selector); + CC_DEPRECATED_ATTRIBUTE static MenuItemImage* create(const std::string& normalImage, const std::string& selectedImage, const std::string& disabledImage, Ref* target, SEL_MenuHandler selector); /** creates a menu item with a normal,selected and disabled image with a callable object */ static MenuItemImage* create(const std::string&normalImage, const std::string&selectedImage, const std::string&disabledImage, const ccMenuCallback& callback); @@ -441,7 +441,7 @@ protected: bool init(); /** initializes a menu item with a normal, selected and disabled image with target/selector */ - CC_DEPRECATED_ATTRIBUTE bool initWithNormalImage(const std::string& normalImage, const std::string& selectedImage, const std::string& disabledImage, Object* target, SEL_MenuHandler selector); + CC_DEPRECATED_ATTRIBUTE bool initWithNormalImage(const std::string& normalImage, const std::string& selectedImage, const std::string& disabledImage, Ref* target, SEL_MenuHandler selector); /** initializes a menu item with a normal, selected and disabled image with a callable object */ bool initWithNormalImage(const std::string& normalImage, const std::string& selectedImage, const std::string& disabledImage, const ccMenuCallback& callback); @@ -461,12 +461,12 @@ public: * @js NA * @lua NA */ - CC_DEPRECATED_ATTRIBUTE static MenuItemToggle * createWithTarget(Object* target, SEL_MenuHandler selector, const Vector& menuItems); + CC_DEPRECATED_ATTRIBUTE static MenuItemToggle * createWithTarget(Ref* target, SEL_MenuHandler selector, const Vector& menuItems); /** creates a menu item from a list of items with a target/selector * @js NA * @lua NA */ - CC_DEPRECATED_ATTRIBUTE static MenuItemToggle* createWithTarget(Object* target, SEL_MenuHandler selector, MenuItem* item, ...)CC_REQUIRES_NULL_TERMINATION; + CC_DEPRECATED_ATTRIBUTE static MenuItemToggle* createWithTarget(Ref* target, SEL_MenuHandler selector, MenuItem* item, ...)CC_REQUIRES_NULL_TERMINATION; /** creates a menu item from a Array with a callable object */ static MenuItemToggle * createWithCallback(const ccMenuCallback& callback, const Vector& menuItems); @@ -527,7 +527,7 @@ protected: * @js NA * @lua NA */ - CC_DEPRECATED_ATTRIBUTE bool initWithTarget(Object* target, SEL_MenuHandler selector, MenuItem* item, va_list args); + CC_DEPRECATED_ATTRIBUTE bool initWithTarget(Ref* target, SEL_MenuHandler selector, MenuItem* item, va_list args); /** initializes a menu item from a list of items with a callable object */ bool initWithCallback(const ccMenuCallback& callback, MenuItem* item, va_list args); diff --git a/cocos/2d/CCNode.cpp b/cocos/2d/CCNode.cpp index d331ca1405..174f3fd394 100644 --- a/cocos/2d/CCNode.cpp +++ b/cocos/2d/CCNode.cpp @@ -492,7 +492,7 @@ void Node::setOrderOfArrival(int orderOfArrival) _orderOfArrival = orderOfArrival; } -void Node::setUserObject(Object *pUserObject) +void Node::setUserObject(Ref *pUserObject) { CC_SAFE_RETAIN(pUserObject); CC_SAFE_RELEASE(_userObject); @@ -985,7 +985,7 @@ void Node::setScheduler(Scheduler* scheduler) bool Node::isScheduled(SEL_SCHEDULE selector) { - return _scheduler->isScheduledForTarget(selector, this); + return _scheduler->isScheduled(this, schedule_selector_to_key(selector)); } void Node::scheduleUpdate() @@ -995,19 +995,23 @@ void Node::scheduleUpdate() void Node::scheduleUpdateWithPriority(int priority) { - _scheduler->scheduleUpdateForTarget(this, priority, !_running); + _scheduler->scheduleUpdate([this](float dt){ + this->update(dt); + }, this, priority, !_running); } void Node::scheduleUpdateWithPriorityLua(int nHandler, int priority) { unscheduleUpdate(); _updateScriptHandler = nHandler; - _scheduler->scheduleUpdateForTarget(this, priority, !_running); + _scheduler->scheduleUpdate([this](float dt){ + this->update(dt); + }, this, priority, !_running); } void Node::unscheduleUpdate() { - _scheduler->unscheduleUpdateForTarget(this); + _scheduler->unscheduleUpdate(this); if (_updateScriptHandler) { ScriptEngineManager::getInstance()->getScriptEngine()->removeScriptHandler(_updateScriptHandler); @@ -1030,7 +1034,9 @@ void Node::schedule(SEL_SCHEDULE selector, float interval, unsigned int repeat, CCASSERT( selector, "Argument must be non-nil"); CCASSERT( interval >=0, "Argument must be positive"); - _scheduler->scheduleSelector(selector, this, interval , repeat, delay, !_running); + _scheduler->schedule([=](float dt){ + (this->*selector)(dt); + }, this, schedule_selector_to_key(selector), interval , repeat, delay, !_running); } void Node::scheduleOnce(SEL_SCHEDULE selector, float delay) @@ -1040,11 +1046,11 @@ void Node::scheduleOnce(SEL_SCHEDULE selector, float delay) void Node::unschedule(SEL_SCHEDULE selector) { - // explicit nil handling - if (selector == 0) + // explicit null handling + if (selector == nullptr) return; - - _scheduler->unscheduleSelector(selector, this); + + _scheduler->unschedule(this, schedule_selector_to_key(selector)); } void Node::unscheduleAllSelectors() diff --git a/cocos/2d/CCNode.h b/cocos/2d/CCNode.h index 92f63c6edc..a201d3fcee 100644 --- a/cocos/2d/CCNode.h +++ b/cocos/2d/CCNode.h @@ -26,8 +26,8 @@ THE SOFTWARE. ****************************************************************************/ -#ifndef __PLATFORM_CCNODE_H__ -#define __PLATFORM_CCNODE_H__ +#ifndef __CCNODE_H__ +#define __CCNODE_H__ #include "ccMacros.h" #include "CCAffineTransform.h" @@ -126,7 +126,7 @@ class EventListener; */ -class CC_DLL Node : public Object +class CC_DLL Node : public Ref { public: /// Default tag used for all the nodes @@ -808,12 +808,12 @@ public: * @js NA * @lua NA */ - virtual Object* getUserObject() { return _userObject; } + virtual Ref* getUserObject() { return _userObject; } /** * @js NA * @lua NA */ - virtual const Object* getUserObject() const { return _userObject; } + virtual const Ref* getUserObject() const { return _userObject; } /** * Returns a user assigned Object @@ -825,7 +825,7 @@ public: * * @param userObject A user assigned Object */ - virtual void setUserObject(Object *userObject); + virtual void setUserObject(Ref *userObject); /// @} end of Tag & User Data @@ -1469,7 +1469,7 @@ protected: int _tag; ///< a tag. Can be any number you assigned just to identify this node void *_userData; ///< A user assingned void pointer, Can be point to any cpp object - Object *_userObject; ///< A user assigned Object + Ref *_userObject; ///< A user assigned Object GLProgram *_shaderProgram; ///< OpenGL shader @@ -1558,4 +1558,4 @@ private: NS_CC_END -#endif // __PLATFORM_CCNODE_H__ +#endif // __CCNODE_H__ diff --git a/cocos/2d/CCNotificationCenter.cpp b/cocos/2d/CCNotificationCenter.cpp index 98452f82cd..c6cccb2f12 100644 --- a/cocos/2d/CCNotificationCenter.cpp +++ b/cocos/2d/CCNotificationCenter.cpp @@ -76,9 +76,9 @@ void __NotificationCenter::purgeNotificationCenter(void) // // internal functions // -bool __NotificationCenter::observerExisted(Object *target, const std::string& name, Object *sender) +bool __NotificationCenter::observerExisted(Ref *target, const std::string& name, Ref *sender) { - Object* obj = nullptr; + Ref* obj = nullptr; CCARRAY_FOREACH(_observers, obj) { NotificationObserver* observer = (NotificationObserver*) obj; @@ -94,10 +94,10 @@ bool __NotificationCenter::observerExisted(Object *target, const std::string& na // // observer functions // -void __NotificationCenter::addObserver(Object *target, +void __NotificationCenter::addObserver(Ref *target, SEL_CallFuncO selector, const std::string& name, - Object *sender) + Ref *sender) { if (this->observerExisted(target, name, sender)) return; @@ -110,9 +110,9 @@ void __NotificationCenter::addObserver(Object *target, _observers->addObject(observer); } -void __NotificationCenter::removeObserver(Object *target, const std::string& name) +void __NotificationCenter::removeObserver(Ref *target, const std::string& name) { - Object* obj = nullptr; + Ref* obj = nullptr; CCARRAY_FOREACH(_observers, obj) { NotificationObserver* observer = static_cast(obj); @@ -127,9 +127,9 @@ void __NotificationCenter::removeObserver(Object *target, const std::string& nam } } -int __NotificationCenter::removeAllObservers(Object *target) +int __NotificationCenter::removeAllObservers(Ref *target) { - Object *obj = nullptr; + Ref *obj = nullptr; __Array *toRemove = __Array::create(); CCARRAY_FOREACH(_observers, obj) @@ -148,7 +148,7 @@ int __NotificationCenter::removeAllObservers(Object *target) return static_cast(toRemove->count()); } -void __NotificationCenter::registerScriptObserver( Object *target, int handler,const std::string& name) +void __NotificationCenter::registerScriptObserver(Ref *target, int handler,const std::string& name) { if (this->observerExisted(target, name, nullptr)) @@ -163,9 +163,9 @@ void __NotificationCenter::registerScriptObserver( Object *target, int handler,c _observers->addObject(observer); } -void __NotificationCenter::unregisterScriptObserver(Object *target,const std::string& name) +void __NotificationCenter::unregisterScriptObserver(Ref *target,const std::string& name) { - Object* obj = nullptr; + Ref* obj = nullptr; CCARRAY_FOREACH(_observers, obj) { NotificationObserver* observer = static_cast(obj); @@ -179,11 +179,11 @@ void __NotificationCenter::unregisterScriptObserver(Object *target,const std::st } } -void __NotificationCenter::postNotification(const std::string& name, Object *sender) +void __NotificationCenter::postNotification(const std::string& name, Ref *sender) { __Array* ObserversCopy = __Array::createWithCapacity(_observers->count()); ObserversCopy->addObjectsFromArray(_observers); - Object* obj = nullptr; + Ref* obj = nullptr; CCARRAY_FOREACH(ObserversCopy, obj) { NotificationObserver* observer = static_cast(obj); @@ -212,7 +212,7 @@ int __NotificationCenter::getObserverHandlerByName(const std::string& name) return 0; } - Object* obj = nullptr; + Ref* obj = nullptr; CCARRAY_FOREACH(_observers, obj) { NotificationObserver* observer = static_cast(obj); @@ -234,10 +234,10 @@ int __NotificationCenter::getObserverHandlerByName(const std::string& name) /// NotificationObserver /// //////////////////////////////////////////////////////////////////////////////// -NotificationObserver::NotificationObserver(Object *target, +NotificationObserver::NotificationObserver(Ref *target, SEL_CallFuncO selector, const std::string& name, - Object *sender) + Ref *sender) { _target = target; _selector = selector; @@ -252,7 +252,7 @@ NotificationObserver::~NotificationObserver() } -void NotificationObserver::performSelector(Object *sender) +void NotificationObserver::performSelector(Ref *sender) { if (_target) { @@ -264,7 +264,7 @@ void NotificationObserver::performSelector(Object *sender) } } -Object *NotificationObserver::getTarget() const +Ref *NotificationObserver::getTarget() const { return _target; } @@ -279,7 +279,7 @@ const std::string& NotificationObserver::getName() const return _name; } -Object* NotificationObserver::getSender() const +Ref* NotificationObserver::getSender() const { return _sender; } diff --git a/cocos/2d/CCNotificationCenter.h b/cocos/2d/CCNotificationCenter.h index de75060feb..a675459981 100644 --- a/cocos/2d/CCNotificationCenter.h +++ b/cocos/2d/CCNotificationCenter.h @@ -27,13 +27,14 @@ THE SOFTWARE. #ifndef __CCNOTIFICATIONCENTER_H__ #define __CCNOTIFICATIONCENTER_H__ -#include "CCObject.h" +#include "CCRef.h" #include "CCArray.h" +#include "ccTypes.h" NS_CC_BEGIN class ScriptHandlerMgr; -class CC_DLL __NotificationCenter : public Object +class CC_DLL __NotificationCenter : public Ref { friend class ScriptHandlerMgr; public: @@ -67,31 +68,31 @@ public: * @param name The name of this notification. * @param sender The object whose notifications the target wants to receive. Only notifications sent by this sender are delivered to the target. nullptr means that the sender is not used to decide whether to deliver the notification to target. */ - void addObserver(Object *target, + void addObserver(Ref *target, SEL_CallFuncO selector, const std::string& name, - Object *sender); + Ref *sender); /** @brief Removes the observer by the specified target and name. * @param target The target of this notification. * @param name The name of this notification. */ - void removeObserver(Object *target,const std::string& name); + void removeObserver(Ref *target,const std::string& name); /** @brief Removes all notifications registered by this target * @param target The target of this notification. * @returns the number of observers removed */ - int removeAllObservers(Object *target); + int removeAllObservers(Ref *target); /** @brief Registers one hander for script binding. * @note Only supports Lua Binding now. * @param handler The lua handler. */ - void registerScriptObserver(Object *target,int handler,const std::string& name); + void registerScriptObserver(Ref *target,int handler,const std::string& name); /** Unregisters script observer */ - void unregisterScriptObserver(Object *target,const std::string& name); + void unregisterScriptObserver(Ref *target,const std::string& name); /** @brief Posts one notification event by name. * @param name The name of this notification. @@ -102,7 +103,7 @@ public: * @param name The name of this notification. * @param sender The object posting the notification. Can be nullptr */ - void postNotification(const std::string& name, Object *sender); + void postNotification(const std::string& name, Ref *sender); /** @brief Gets script handler. * @note Only supports Lua Binding now. @@ -119,7 +120,7 @@ private: // internal functions // Check whether the observer exists by the specified target and name. - bool observerExisted(Object *target,const std::string& name, Object *sender); + bool observerExisted(Ref *target,const std::string& name, Ref *sender); // variables // @@ -127,7 +128,7 @@ private: int _scriptHandler; }; -class CC_DLL NotificationObserver : public Object +class CC_DLL NotificationObserver : public Ref { public: /** @brief NotificationObserver constructor @@ -138,10 +139,10 @@ public: * @js NA * @lua NA */ - NotificationObserver(Object *target, + NotificationObserver(Ref *target, SEL_CallFuncO selector, const std::string& name, - Object *sender); + Ref *sender); /** NotificationObserver destructor function * @js NA @@ -153,14 +154,14 @@ public: * @js NA * @lua NA */ - void performSelector(Object *sender); + void performSelector(Ref *sender); // Getters / Setters /** * @js NA * @lua NA */ - Object* getTarget() const; + Ref* getTarget() const; /** * @js NA * @lua NA @@ -175,7 +176,7 @@ public: * @js NA * @lua NA */ - Object* getSender() const; + Ref* getSender() const; /** * @js NA * @lua NA @@ -188,10 +189,10 @@ public: void setHandler(int handler); private: - Object* _target; + Ref* _target; SEL_CallFuncO _selector; std::string _name; - Object* _sender; + Ref* _sender; int _handler; }; diff --git a/cocos/2d/CCParallaxNode.cpp b/cocos/2d/CCParallaxNode.cpp index b8c7f1a52f..85b85ba6c5 100644 --- a/cocos/2d/CCParallaxNode.cpp +++ b/cocos/2d/CCParallaxNode.cpp @@ -29,7 +29,7 @@ THE SOFTWARE. NS_CC_BEGIN -class PointObject : Object +class PointObject : public Ref { public: static PointObject * create(Point ratio, Point offset) @@ -98,7 +98,7 @@ void ParallaxNode::addChild(Node *child, int z, const Point& ratio, const Point& CCASSERT( child != nullptr, "Argument must be non-nil"); PointObject *obj = PointObject::create(ratio, offset); obj->setChild(child); - ccArrayAppendObjectWithResize(_parallaxArray, (Object*)obj); + ccArrayAppendObjectWithResize(_parallaxArray, (Ref*)obj); Point pos = this->absolutePosition(); pos.x = -pos.x + pos.x * ratio.x + offset.x; @@ -107,12 +107,13 @@ void ParallaxNode::addChild(Node *child, int z, const Point& ratio, const Point& Node::addChild(child, z, child->getTag()); } + void ParallaxNode::removeChild(Node* child, bool cleanup) { for( int i=0;i < _parallaxArray->num;i++) { PointObject *point = (PointObject*)_parallaxArray->arr[i]; - if( point->getChild()->isEqual(child)) + if (point->getChild() == child) { ccArrayRemoveObjectAtIndex(_parallaxArray, i, true); break; @@ -120,11 +121,13 @@ void ParallaxNode::removeChild(Node* child, bool cleanup) } Node::removeChild(child, cleanup); } + void ParallaxNode::removeAllChildrenWithCleanup(bool cleanup) { ccArrayRemoveAllObjects(_parallaxArray); Node::removeAllChildrenWithCleanup(cleanup); } + Point ParallaxNode::absolutePosition() { Point ret = _position; diff --git a/cocos/2d/CCProfiling.h b/cocos/2d/CCProfiling.h index 97f1a7c92d..0807d0dd86 100644 --- a/cocos/2d/CCProfiling.h +++ b/cocos/2d/CCProfiling.h @@ -29,7 +29,7 @@ THE SOFTWARE. #include #include #include "ccConfig.h" -#include "CCObject.h" +#include "CCRef.h" #include "CCMap.h" NS_CC_BEGIN @@ -47,7 +47,7 @@ class ProfilingTimer; To use it, enable set the CC_ENABLE_PROFILERS=1 in the ccConfig.h file */ -class CC_DLL Profiler : public Object +class CC_DLL Profiler : public Ref { public: /** @@ -98,7 +98,7 @@ public: Map _activeTimers; }; -class ProfilingTimer : public Object +class ProfilingTimer : public Ref { public: /** diff --git a/cocos/2d/CCScheduler.cpp b/cocos/2d/CCScheduler.cpp index 2495fd930e..37e1723775 100644 --- a/cocos/2d/CCScheduler.cpp +++ b/cocos/2d/CCScheduler.cpp @@ -37,13 +37,24 @@ using namespace std; NS_CC_BEGIN +long schedule_selector_to_key(SEL_SCHEDULE selector) +{ + static union{ + SEL_SCHEDULE func; + long key; + }; + func = selector; + return key; +} + // data structures // A list double-linked list used for "updates with priority" typedef struct _listEntry { struct _listEntry *prev, *next; - Object *target; // not retained (retained by hashUpdateEntry) + Ref *target; // not retained (retained by hashUpdateEntry) + ccSchedulerFunc callback; int priority; bool paused; bool markedForDeletion; // selector will no longer be called and entry will be removed at end of the next tick @@ -53,7 +64,8 @@ typedef struct _hashUpdateEntry { tListEntry **list; // Which list does it belong to ? tListEntry *entry; // entry in the list - Object *target; // hash key (retained) + Ref *target; // hash key (retained) + ccSchedulerFunc callback; UT_hash_handle hh; } tHashUpdateEntry; @@ -61,9 +73,9 @@ typedef struct _hashUpdateEntry typedef struct _hashSelectorEntry { ccArray *timers; - Object *target; // hash key (retained) - int timerIndex; - Timer *currentTimer; + Ref *target; // hash key (retained) + int timerIndex; + Timer *currentTimer; bool currentTimerSalvaged; bool paused; UT_hash_handle hh; @@ -80,26 +92,17 @@ Timer::Timer() , _repeat(0) , _delay(0.0f) , _interval(0.0f) -, _selector(nullptr) +, _callback(nullptr) +, _key(0) , _scriptHandler(0) { } -Timer* Timer::create(Object *target, SEL_SCHEDULE selector) +Timer* Timer::create(const ccSchedulerFunc& callback, Ref *target, long key, float seconds/* = 0 */) { Timer *timer = new Timer(); - timer->initWithTarget(target, selector, 0.0f, kRepeatForever, 0.0f); - timer->autorelease(); - - return timer; -} - -Timer* Timer::create(Object *target, SEL_SCHEDULE selector, float seconds) -{ - Timer *timer = new Timer(); - - timer->initWithTarget(target, selector, seconds, kRepeatForever, 0.0f); + timer->initWithTarget(callback, target, key, seconds, kRepeatForever, 0.0f); timer->autorelease(); return timer; @@ -124,15 +127,11 @@ bool Timer::initWithScriptHandler(int handler, float seconds) return true; } -bool Timer::initWithTarget(Object *target, SEL_SCHEDULE selector) -{ - return initWithTarget(target, selector, 0, kRepeatForever, 0.0f); -} - -bool Timer::initWithTarget(Object *target, SEL_SCHEDULE selector, float seconds, unsigned int repeat, float delay) +bool Timer::initWithTarget(const ccSchedulerFunc& callback, Ref *target, long key, float seconds, unsigned int repeat, float delay) { _target = target; - _selector = selector; + _callback = callback; + _key = key; _elapsed = -1; _interval = seconds; _delay = delay; @@ -156,9 +155,9 @@ void Timer::update(float dt) _elapsed += dt; if (_elapsed >= _interval) { - if (_target && _selector) + if (_target && _key != 0 && _callback) { - (_target->*_selector)(_elapsed); + _callback(_elapsed); } if (0 != _scriptHandler) @@ -177,9 +176,9 @@ void Timer::update(float dt) { if( _elapsed >= _delay ) { - if (_target && _selector) + if (_target && _key != 0 && _callback) { - (_target->*_selector)(_elapsed); + _callback(_elapsed); } if (0 != _scriptHandler) @@ -198,9 +197,9 @@ void Timer::update(float dt) { if (_elapsed >= _interval) { - if (_target && _selector) + if (_target && _key != 0 && _callback) { - (_target->*_selector)(_elapsed); + _callback(_elapsed); } if (0 != _scriptHandler) @@ -218,27 +217,12 @@ void Timer::update(float dt) if (!_runForever && _timesExecuted > _repeat) { //unschedule timer - Director::getInstance()->getScheduler()->unscheduleSelector(_selector, _target); + Director::getInstance()->getScheduler()->unschedule(_target, _key); } } } } -float Timer::getInterval() const -{ - return _interval; -} - -void Timer::setInterval(float interval) -{ - _interval = interval; -} - -SEL_SCHEDULE Timer::getSelector() const -{ - return _selector; -} - // implementation of Scheduler // Priority level reserved for system services. @@ -271,7 +255,7 @@ Scheduler::~Scheduler(void) void Scheduler::removeHashElement(_hashSelectorEntry *element) { - cocos2d::Object *target = element->target; + Ref *target = element->target; ccArrayFree(element->timers); HASH_DEL(_hashForTimers, element); @@ -284,15 +268,15 @@ void Scheduler::removeHashElement(_hashSelectorEntry *element) } -void Scheduler::scheduleSelector(SEL_SCHEDULE selector, Object *target, float interval, bool paused) +void Scheduler::schedule(const ccSchedulerFunc& callback, Ref *target, long key, float interval, bool paused) { - this->scheduleSelector(selector, target, interval, kRepeatForever, 0.0f, paused); + this->schedule(callback, target, key, interval, kRepeatForever, 0.0f, paused); } -void Scheduler::scheduleSelector(SEL_SCHEDULE selector, Object *target, float interval, unsigned int repeat, float delay, bool paused) +void Scheduler::schedule(const ccSchedulerFunc& callback, Ref *target, long key, float interval, unsigned int repeat, float delay, bool paused) { - CCASSERT(selector, "Argument selector must be non-nullptr"); CCASSERT(target, "Argument target must be non-nullptr"); + CCASSERT(key != 0, "key should not be empty!"); tHashTimerEntry *element = nullptr; HASH_FIND_PTR(_hashForTimers, &target, element); @@ -325,7 +309,7 @@ void Scheduler::scheduleSelector(SEL_SCHEDULE selector, Object *target, float in { Timer *timer = (Timer*)element->timers->arr[i]; - if (selector == timer->getSelector()) + if (key == timer->getKey()) { CCLOG("CCScheduler#scheduleSelector. Selector already scheduled. Updating interval from: %.4f to %.4f", timer->getInterval(), interval); timer->setInterval(interval); @@ -335,16 +319,16 @@ void Scheduler::scheduleSelector(SEL_SCHEDULE selector, Object *target, float in ccArrayEnsureExtraCapacity(element->timers, 1); } - Timer *pTimer = new Timer(); - pTimer->initWithTarget(target, selector, interval, repeat, delay); - ccArrayAppendObject(element->timers, pTimer); - pTimer->release(); + Timer *timer = new Timer(); + timer->initWithTarget(callback, target, key, interval, repeat, delay); + ccArrayAppendObject(element->timers, timer); + timer->release(); } -void Scheduler::unscheduleSelector(SEL_SCHEDULE selector, Object *target) +void Scheduler::unschedule(Ref *target, long key) { // explicity handle nil arguments when removing an object - if (target == 0 || selector == 0) + if (target == nullptr || key == 0) { return; } @@ -361,7 +345,7 @@ void Scheduler::unscheduleSelector(SEL_SCHEDULE selector, Object *target) { Timer *timer = static_cast(element->timers->arr[i]); - if (selector == timer->getSelector()) + if (key == timer->getKey()) { if (timer == element->currentTimer && (! element->currentTimerSalvaged)) { @@ -395,10 +379,11 @@ void Scheduler::unscheduleSelector(SEL_SCHEDULE selector, Object *target) } } -void Scheduler::priorityIn(tListEntry **list, Object *target, int priority, bool paused) +void Scheduler::priorityIn(tListEntry **list, const ccSchedulerFunc& callback, Ref *target, int priority, bool paused) { - tListEntry *listElement = (tListEntry *)malloc(sizeof(*listElement)); + tListEntry *listElement = new tListEntry(); + listElement->callback = callback; listElement->target = target; listElement->priority = priority; listElement->paused = paused; @@ -452,10 +437,11 @@ void Scheduler::priorityIn(tListEntry **list, Object *target, int priority, bool HASH_ADD_PTR(_hashForUpdates, target, hashElement); } -void Scheduler::appendIn(_listEntry **list, Object *target, bool paused) +void Scheduler::appendIn(_listEntry **list, const ccSchedulerFunc& callback, Ref *target, bool paused) { - tListEntry *listElement = (tListEntry *)malloc(sizeof(*listElement)); + tListEntry *listElement = new tListEntry(); + listElement->callback = callback; listElement->target = target; listElement->paused = paused; listElement->markedForDeletion = false; @@ -471,9 +457,8 @@ void Scheduler::appendIn(_listEntry **list, Object *target, bool paused) HASH_ADD_PTR(_hashForUpdates, target, hashElement); } -void Scheduler::scheduleUpdateForTarget(Object *target, int priority, bool paused) +void Scheduler::scheduleUpdate(const ccSchedulerFunc& callback, Ref *target, int priority, bool paused) { - tHashUpdateEntry *hashElement = nullptr; HASH_FIND_PTR(_hashForUpdates, &target, hashElement); if (hashElement) @@ -491,22 +476,22 @@ void Scheduler::scheduleUpdateForTarget(Object *target, int priority, bool pause // is an special list for updates with priority 0 if (priority == 0) { - appendIn(&_updates0List, target, paused); + appendIn(&_updates0List, callback, target, paused); } else if (priority < 0) { - priorityIn(&_updatesNegList, target, priority, paused); + priorityIn(&_updatesNegList, callback, target, priority, paused); } else { // priority > 0 - priorityIn(&_updatesPosList, target, priority, paused); + priorityIn(&_updatesPosList, callback, target, priority, paused); } } -bool Scheduler::isScheduledForTarget(SEL_SCHEDULE selector, Object *target) +bool Scheduler::isScheduled(Ref *target, long key) { - CCASSERT(selector, "Argument selector must be non-nullptr"); + CCASSERT(key != 0, "Argument key must be empty"); CCASSERT(target, "Argument target must be non-nullptr"); tHashTimerEntry *element = nullptr; @@ -526,7 +511,7 @@ bool Scheduler::isScheduledForTarget(SEL_SCHEDULE selector, Object *target) { Timer *timer = (Timer*)element->timers->arr[i]; - if (selector == timer->getSelector()) + if (key == timer->getKey()) { return true; } @@ -547,10 +532,10 @@ void Scheduler::removeUpdateFromHash(struct _listEntry *entry) { // list entry DL_DELETE(*element->list, element->entry); - free(element->entry); + CC_SAFE_DELETE(element->entry); // hash entry - Object* target = element->target; + Ref* target = element->target; HASH_DEL(_hashForUpdates, element); free(element); @@ -560,7 +545,7 @@ void Scheduler::removeUpdateFromHash(struct _listEntry *entry) } } -void Scheduler::unscheduleUpdateForTarget(const Object *target) +void Scheduler::unscheduleUpdate(Ref* target) { if (target == nullptr) { @@ -609,7 +594,7 @@ void Scheduler::unscheduleAllWithMinPriority(int minPriority) { if(entry->priority >= minPriority) { - unscheduleUpdateForTarget(entry->target); + unscheduleUpdate(entry->target); } } } @@ -618,7 +603,7 @@ void Scheduler::unscheduleAllWithMinPriority(int minPriority) { DL_FOREACH_SAFE(_updates0List, entry, tmp) { - unscheduleUpdateForTarget(entry->target); + unscheduleUpdate(entry->target); } } @@ -626,14 +611,14 @@ void Scheduler::unscheduleAllWithMinPriority(int minPriority) { if(entry->priority >= minPriority) { - unscheduleUpdateForTarget(entry->target); + unscheduleUpdate(entry->target); } } _scriptHandlerEntries.clear(); } -void Scheduler::unscheduleAllForTarget(Object *target) +void Scheduler::unscheduleAllForTarget(Ref *target) { // explicit nullptr handling if (target == nullptr) @@ -666,7 +651,7 @@ void Scheduler::unscheduleAllForTarget(Object *target) } // update selector - unscheduleUpdateForTarget(target); + unscheduleUpdate(target); } unsigned int Scheduler::scheduleScriptFunc(unsigned int handler, float interval, bool paused) @@ -689,7 +674,7 @@ void Scheduler::unscheduleScriptEntry(unsigned int scheduleScriptEntryID) } } -void Scheduler::resumeTarget(Object *target) +void Scheduler::resumeTarget(Ref *target) { CCASSERT(target != nullptr, ""); @@ -711,7 +696,7 @@ void Scheduler::resumeTarget(Object *target) } } -void Scheduler::pauseTarget(Object *target) +void Scheduler::pauseTarget(Ref *target) { CCASSERT(target != nullptr, ""); @@ -733,7 +718,7 @@ void Scheduler::pauseTarget(Object *target) } } -bool Scheduler::isTargetPaused(Object *target) +bool Scheduler::isTargetPaused(Ref *target) { CCASSERT( target != nullptr, "target must be non nil" ); @@ -756,14 +741,14 @@ bool Scheduler::isTargetPaused(Object *target) return false; // should never get here } -Vector Scheduler::pauseAllTargets() +Vector Scheduler::pauseAllTargets() { return pauseAllTargetsWithMinPriority(PRIORITY_SYSTEM); } -Vector Scheduler::pauseAllTargetsWithMinPriority(int minPriority) +Vector Scheduler::pauseAllTargetsWithMinPriority(int minPriority) { - Vector idsWithSelectors(50); + Vector idsWithSelectors(50); // Custom Selectors for(tHashTimerEntry *element = _hashForTimers; element != nullptr; @@ -808,7 +793,7 @@ Vector Scheduler::pauseAllTargetsWithMinPriority(int minPriority) return idsWithSelectors; } -void Scheduler::resumeTargets(const Vector& targetsToResume) +void Scheduler::resumeTargets(const Vector& targetsToResume) { for(const auto &obj : targetsToResume) { this->resumeTarget(obj); @@ -846,7 +831,7 @@ void Scheduler::update(float dt) { if ((! entry->paused) && (! entry->markedForDeletion)) { - entry->target->update(dt); + entry->callback(dt); } } @@ -855,7 +840,7 @@ void Scheduler::update(float dt) { if ((! entry->paused) && (! entry->markedForDeletion)) { - entry->target->update(dt); + entry->callback(dt); } } @@ -864,7 +849,7 @@ void Scheduler::update(float dt) { if ((! entry->paused) && (! entry->markedForDeletion)) { - entry->target->update(dt); + entry->callback(dt); } } @@ -975,5 +960,34 @@ void Scheduler::update(float dt) } } +//OLD METHODS: +void Scheduler::scheduleSelector(SEL_SCHEDULE selector, Ref *target, float interval, unsigned int repeat, float delay, bool paused) +{ + this->schedule([=](float dt){ + (target->*selector)(dt); + }, target, schedule_selector_to_key(selector), interval , repeat, delay, paused); +} + +void Scheduler::scheduleSelector(SEL_SCHEDULE selector, Ref *target, float interval, bool paused) +{ + this->schedule([=](float dt){ + (target->*selector)(dt); + }, target, schedule_selector_to_key(selector), interval, paused); +} + +void Scheduler::scheduleUpdateForTarget(Ref *target, int priority, bool paused) +{ + CCASSERT(false, "Please use scheduleUpdate instead."); +} + +bool Scheduler::isScheduledForTarget(SEL_SCHEDULE selector, Ref *target) +{ + return this->isScheduled(target, schedule_selector_to_key(selector)); +} + +void Scheduler::unscheduleSelector(SEL_SCHEDULE selector, Ref *target) +{ + this->unschedule(target, schedule_selector_to_key(selector)); +} NS_CC_END diff --git a/cocos/2d/CCScheduler.h b/cocos/2d/CCScheduler.h index 21ed5abd6d..a3f4f4de80 100644 --- a/cocos/2d/CCScheduler.h +++ b/cocos/2d/CCScheduler.h @@ -28,13 +28,13 @@ THE SOFTWARE. #ifndef __CCSCHEDULER_H__ #define __CCSCHEDULER_H__ -#include "CCObject.h" -#include "CCVector.h" -#include "uthash.h" - #include #include +#include "CCRef.h" +#include "CCVector.h" +#include "uthash.h" + NS_CC_BEGIN /** @@ -42,54 +42,50 @@ NS_CC_BEGIN * @{ */ +long schedule_selector_to_key(SEL_SCHEDULE selector); + +typedef std::function ccSchedulerFunc; // // Timer // /** @brief Light-weight timer */ // -class CC_DLL Timer : public Object +class CC_DLL Timer : public Ref { public: - /** Allocates a timer with a target and a selector. */ - static Timer* create(Object *target, SEL_SCHEDULE selector); /** Allocates a timer with a target, a selector and an interval in seconds. */ - static Timer* create(Object *target, SEL_SCHEDULE selector, float seconds); + static Timer* create(const ccSchedulerFunc& callback, Ref *target, long key, float seconds = 0.0f); /** Allocates a timer with a script callback function and an interval in seconds. * @js NA * @lua NA */ static Timer* createWithScriptHandler(int handler, float seconds); - CC_DEPRECATED_ATTRIBUTE static Timer* timerWithTarget(Object *target, SEL_SCHEDULE selector) { return Timer::create(target, selector); } - CC_DEPRECATED_ATTRIBUTE static Timer* timerWithTarget(Object *target, SEL_SCHEDULE selector, float seconds) { return Timer::create(target, selector, seconds); } - CC_DEPRECATED_ATTRIBUTE static Timer* timerWithScriptHandler(int handler, float seconds) { return Timer::createWithScriptHandler(handler, seconds); } - Timer(void); - /** Initializes a timer with a target and a selector. */ - bool initWithTarget(Object *target, SEL_SCHEDULE selector); /** Initializes a timer with a target, a selector and an interval in seconds, repeat in number of times to repeat, delay in seconds. */ - bool initWithTarget(Object *target, SEL_SCHEDULE selector, float seconds, unsigned int repeat, float delay); + bool initWithTarget(const ccSchedulerFunc& callback, Ref *target, long key, float seconds, unsigned int repeat, float delay); /** Initializes a timer with a script callback function and an interval in seconds. */ bool initWithScriptHandler(int handler, float seconds); /** get interval in seconds */ - float getInterval() const; + inline float getInterval() const { return _interval; }; /** set interval in seconds */ - void setInterval(float interval); + inline void setInterval(float interval) { _interval = interval; }; /** * @js NA * @lua NA */ - SEL_SCHEDULE getSelector() const; - + inline const ccSchedulerFunc& getCallback() const { return _callback; }; + inline long getKey() const { return _key; }; + /** triggers the timer */ void update(float dt); inline int getScriptHandler() const { return _scriptHandler; }; protected: - Object *_target; + Ref *_target; float _elapsed; bool _runForever; bool _useDelay; @@ -97,8 +93,8 @@ protected: unsigned int _repeat; //0 = once, 1 is 2 x executed float _delay; float _interval; - SEL_SCHEDULE _selector; - + ccSchedulerFunc _callback; + long _key; int _scriptHandler; }; @@ -121,7 +117,7 @@ There are 2 different types of callbacks (selectors): The 'custom selectors' should be avoided when possible. It is faster, and consumes less memory to use the 'update selector'. */ -class CC_DLL Scheduler : public Object +class CC_DLL Scheduler : public Ref { public: // Priority level reserved for system services. @@ -163,41 +159,77 @@ public: repeat let the action be repeated repeat + 1 times, use kRepeatForever to let the action run continuously delay is the amount of time the action will wait before it'll start - @since v0.99.3, repeat and delay added in v1.1 + @since v3.0 */ - void scheduleSelector(SEL_SCHEDULE selector, Object *target, float interval, unsigned int repeat, float delay, bool paused); + void schedule(const ccSchedulerFunc& callback, Ref *target, long key, float interval, unsigned int repeat, float delay, bool paused); /** calls scheduleSelector with kRepeatForever and a 0 delay */ - void scheduleSelector(SEL_SCHEDULE selector, Object *target, float interval, bool paused); + void schedule(const ccSchedulerFunc& callback, Ref *target, long key, float interval, bool paused); + /** Schedules the 'update' selector for a given target with a given priority. The 'update' selector will be called every frame. The lower the priority, the earlier it is called. - @since v0.99.3 + @since v3.0 */ - void scheduleUpdateForTarget(Object *target, int priority, bool paused); + void scheduleUpdate(const ccSchedulerFunc& callback, Ref *target, int priority, bool paused); /** Checks whether a selector for a given taget is scheduled. @since v3.0.0 */ - bool isScheduledForTarget(SEL_SCHEDULE selector, Object *target); + bool isScheduled(Ref *target, long key); + /** Unschedule a selector for a given target. + If you want to unschedule the "update", use unscheudleUpdateForTarget. + @since v3.0 + */ + void unschedule(Ref *target, long key); + + /** Unschedules the update selector for a given target + @since v3.0 + */ + void unscheduleUpdate(Ref *target); + + /** Unschedules all selectors for a given target. + This also includes the "update" selector. + @since v3.0 + */ + void unscheduleAllForTarget(Ref *target); + + // OLD METHODS + /** The scheduled method will be called every 'interval' seconds. + If paused is true, then it won't be called until it is resumed. + If 'interval' is 0, it will be called every frame, but if so, it's recommended to use 'scheduleUpdateForTarget:' instead. + If the selector is already scheduled, then only the interval parameter will be updated without re-scheduling it again. + repeat let the action be repeated repeat + 1 times, use kRepeatForever to let the action run continuously + delay is the amount of time the action will wait before it'll start + + @since v0.99.3, repeat and delay added in v1.1 + */ + void scheduleSelector(SEL_SCHEDULE selector, Ref *target, float interval, unsigned int repeat, float delay, bool paused); + + /** calls scheduleSelector with kRepeatForever and a 0 delay */ + void scheduleSelector(SEL_SCHEDULE selector, Ref *target, float interval, bool paused); + + CC_DEPRECATED_ATTRIBUTE void scheduleUpdateForTarget(Ref *target, int priority, bool paused); + + /** Checks whether a selector for a given taget is scheduled. + @since v3.0.0 + */ + bool isScheduledForTarget(SEL_SCHEDULE selector, Ref *target); + /** Unschedule a selector for a given target. If you want to unschedule the "update", use unscheudleUpdateForTarget. @since v0.99.3 */ - void unscheduleSelector(SEL_SCHEDULE selector, Object *target); - + void unscheduleSelector(SEL_SCHEDULE selector, Ref *target); + /** Unschedules the update selector for a given target @since v0.99.3 */ - void unscheduleUpdateForTarget(const Object *target); - - /** Unschedules all selectors for a given target. - This also includes the "update" selector. - @since v0.99.3 - */ - void unscheduleAllForTarget(Object *target); - + void unscheduleUpdateForTarget(Ref *target) { unscheduleUpdate(target); }; + + /// + /** Unschedules all selectors from all targets. You should NEVER call this method, unless you know what you are doing. @@ -226,39 +258,39 @@ public: If the target is not present, nothing happens. @since v0.99.3 */ - void pauseTarget(Object *target); + void pauseTarget(Ref *target); /** Resumes the target. The 'target' will be unpaused, so all schedule selectors/update will be 'ticked' again. If the target is not present, nothing happens. @since v0.99.3 */ - void resumeTarget(Object *target); + void resumeTarget(Ref *target); /** Returns whether or not the target is paused @since v1.0.0 * In js: var isTargetPaused(var jsObject) * @lua NA */ - bool isTargetPaused(Object *target); + bool isTargetPaused(Ref *target); /** Pause all selectors from all targets. You should NEVER call this method, unless you know what you are doing. @since v2.0.0 */ - Vector pauseAllTargets(); + Vector pauseAllTargets(); /** Pause all selectors from all targets with a minimum priority. You should only call this with kPriorityNonSystemMin or higher. @since v2.0.0 */ - Vector pauseAllTargetsWithMinPriority(int minPriority); + Vector pauseAllTargetsWithMinPriority(int minPriority); /** Resume selectors on a set of targets. This can be useful for undoing a call to pauseAllSelectors. @since v2.0.0 */ - void resumeTargets(const Vector& targetsToResume); + void resumeTargets(const Vector& targetsToResume); /** calls a function on the cocos2d thread. Useful when you need to call a cocos2d function from another thread. This function is thread safe. @@ -272,8 +304,8 @@ protected: // update specific - void priorityIn(struct _listEntry **list, Object *target, int priority, bool paused); - void appendIn(struct _listEntry **list, Object *target, bool paused); + void priorityIn(struct _listEntry **list, const ccSchedulerFunc& callback, Ref *target, int priority, bool paused); + void appendIn(struct _listEntry **list, const ccSchedulerFunc& callback, Ref *target, bool paused); float _timeScale; diff --git a/cocos/2d/CCScriptSupport.h b/cocos/2d/CCScriptSupport.h index 631df08d08..8ce62b07a0 100644 --- a/cocos/2d/CCScriptSupport.h +++ b/cocos/2d/CCScriptSupport.h @@ -51,7 +51,7 @@ enum ccScriptType { kScriptTypeJavascript }; -class ScriptHandlerEntry : public Object +class ScriptHandlerEntry : public Ref { public: static ScriptHandlerEntry* create(int handler); @@ -309,7 +309,7 @@ struct CommonScriptData // Now this struct is only used in LuaBinding. int handler; char eventName[64]; - Object* eventSource; + Ref* eventSource; char eventSourceClassName[64]; // Constructor @@ -317,7 +317,7 @@ struct CommonScriptData * @js NA * @lua NA */ - CommonScriptData(int inHandler,const char* inName,Object* inSource = nullptr,const char* inClassName = nullptr) + CommonScriptData(int inHandler,const char* inName, Ref* inSource = nullptr,const char* inClassName = nullptr) : handler(inHandler), eventSource(inSource) { @@ -373,7 +373,7 @@ public: * @js NA * @lua NA */ - virtual void removeScriptObjectByObject(Object* obj) = 0; + virtual void removeScriptObjectByObject(Ref* obj) = 0; /** Remove script function handler, only LuaEngine class need to implement this function. * @js NA diff --git a/cocos/2d/CCShaderCache.h b/cocos/2d/CCShaderCache.h index 98f08dcc33..67126238f0 100644 --- a/cocos/2d/CCShaderCache.h +++ b/cocos/2d/CCShaderCache.h @@ -28,11 +28,11 @@ THE SOFTWARE. #ifndef __CCSHADERCACHE_H__ #define __CCSHADERCACHE_H__ +#include "CCRef.h" + #include #include -#include "CCDictionary.h" - NS_CC_BEGIN class GLProgram; @@ -46,7 +46,7 @@ class GLProgram; Singleton that stores manages GL shaders @since v2.0 */ -class CC_DLL ShaderCache : public Object +class CC_DLL ShaderCache : public Ref { public: /** diff --git a/cocos/2d/CCSpriteBatchNode.cpp b/cocos/2d/CCSpriteBatchNode.cpp index fe390dcd6c..ef91137a19 100644 --- a/cocos/2d/CCSpriteBatchNode.cpp +++ b/cocos/2d/CCSpriteBatchNode.cpp @@ -398,7 +398,7 @@ ssize_t SpriteBatchNode::rebuildIndexInOrder(Sprite *parent, ssize_t index) } // ignore self (batch node) - if (! parent->isEqual(this)) + if (parent != static_cast(this)) { parent->setAtlasIndex(index); index++; diff --git a/cocos/2d/CCSpriteFrame.h b/cocos/2d/CCSpriteFrame.h index 05c96d7e2a..9cdfe4c148 100644 --- a/cocos/2d/CCSpriteFrame.h +++ b/cocos/2d/CCSpriteFrame.h @@ -30,7 +30,7 @@ THE SOFTWARE. #include "CCNode.h" #include "CCProtocols.h" -#include "CCObject.h" +#include "CCRef.h" #include "CCGeometry.h" NS_CC_BEGIN @@ -52,7 +52,7 @@ class Texture2D; SpriteFrame *frame = SpriteFrame::frameWithTexture(texture, rect, offset); sprite->setDisplayFrame(frame); */ -class CC_DLL SpriteFrame : public Object, public Clonable +class CC_DLL SpriteFrame : public Ref, public Clonable { public: diff --git a/cocos/2d/CCSpriteFrameCache.h b/cocos/2d/CCSpriteFrameCache.h index df346c76bd..3ec85bf659 100644 --- a/cocos/2d/CCSpriteFrameCache.h +++ b/cocos/2d/CCSpriteFrameCache.h @@ -37,9 +37,10 @@ THE SOFTWARE. #include "CCSpriteFrame.h" #include "CCTexture2D.h" -#include "CCObject.h" +#include "CCRef.h" #include "CCValue.h" #include "CCMap.h" + #include #include @@ -56,7 +57,7 @@ class Sprite; It saves in a cache the sprite frames. @since v0.9 */ -class CC_DLL SpriteFrameCache : public Object +class CC_DLL SpriteFrameCache : public Ref { public: /** Returns the shared instance of the Sprite Frame cache */ diff --git a/cocos/2d/CCTMXObjectGroup.h b/cocos/2d/CCTMXObjectGroup.h index 85f0f59272..1dd107414c 100644 --- a/cocos/2d/CCTMXObjectGroup.h +++ b/cocos/2d/CCTMXObjectGroup.h @@ -29,9 +29,8 @@ THE SOFTWARE. #define __CCTMX_OBJECT_GROUP_H__ #include "CCGeometry.h" -#include "CCString.h" -#include "CCArray.h" #include "CCValue.h" +#include "CCRef.h" NS_CC_BEGIN @@ -43,7 +42,7 @@ NS_CC_BEGIN /** @brief TMXObjectGroup represents the TMX object group. @since v0.99.0 */ -class CC_DLL TMXObjectGroup : public Object +class CC_DLL TMXObjectGroup : public Ref { public: /** diff --git a/cocos/2d/CCTMXXMLParser.h b/cocos/2d/CCTMXXMLParser.h index 4fd4a8bf3f..47027c676a 100644 --- a/cocos/2d/CCTMXXMLParser.h +++ b/cocos/2d/CCTMXXMLParser.h @@ -29,11 +29,11 @@ THE SOFTWARE. #ifndef __CC_TM_XML_PARSER__ #define __CC_TM_XML_PARSER__ -#include "CCArray.h" #include "CCGeometry.h" #include "platform/CCSAXParser.h" #include "CCVector.h" #include "CCValue.h" + #include NS_CC_BEGIN @@ -89,7 +89,7 @@ typedef enum TMXTileFlags_ { This information is obtained from the TMX file. */ -class CC_DLL TMXLayerInfo : public Object +class CC_DLL TMXLayerInfo : public Ref { public: /** @@ -125,7 +125,7 @@ public: This information is obtained from the TMX file. */ -class CC_DLL TMXTilesetInfo : public Object +class CC_DLL TMXTilesetInfo : public Ref { public: std::string _name; @@ -163,7 +163,7 @@ And it also contains: This information is obtained from the TMX file. */ -class CC_DLL TMXMapInfo : public Object, public SAXDelegator +class CC_DLL TMXMapInfo : public Ref, public SAXDelegator { public: /** creates a TMX Format with a tmx file */ diff --git a/cocos/2d/CCTexture2D.h b/cocos/2d/CCTexture2D.h index a2e259867e..1b7fbff0f4 100644 --- a/cocos/2d/CCTexture2D.h +++ b/cocos/2d/CCTexture2D.h @@ -31,7 +31,7 @@ THE SOFTWARE. #include #include -#include "CCObject.h" +#include "CCRef.h" #include "CCGeometry.h" #include "ccTypes.h" #ifdef EMSCRIPTEN @@ -60,7 +60,7 @@ class GLProgram; * Depending on how you create the Texture2D object, the actual image area of the texture might be smaller than the texture dimensions i.e. "contentSize" != (pixelsWide, pixelsHigh) and (maxS, maxT) != (1.0, 1.0). * Be aware that the content of the generated textures will be upside-down! */ -class CC_DLL Texture2D : public Object +class CC_DLL Texture2D : public Ref #ifdef EMSCRIPTEN , public GLBufferedNode #endif // EMSCRIPTEN diff --git a/cocos/2d/CCTextureAtlas.h b/cocos/2d/CCTextureAtlas.h index ba9c0047ff..a73f37bbae 100644 --- a/cocos/2d/CCTextureAtlas.h +++ b/cocos/2d/CCTextureAtlas.h @@ -29,7 +29,7 @@ THE SOFTWARE. #define __CCTEXTURE_ATLAS_H__ #include "ccTypes.h" -#include "CCObject.h" +#include "CCRef.h" #include "ccConfig.h" #include @@ -56,7 +56,7 @@ Supported features: The quads are rendered using an OpenGL ES VBO. To render the quads using an interleaved vertex array list, you should modify the ccConfig.h file */ -class CC_DLL TextureAtlas : public Object +class CC_DLL TextureAtlas : public Ref { public: /** creates a TextureAtlas with an filename and with an initial capacity for Quads. diff --git a/cocos/2d/CCTextureCache.cpp b/cocos/2d/CCTextureCache.cpp index aaa9ccfb4a..e22f0645e8 100644 --- a/cocos/2d/CCTextureCache.cpp +++ b/cocos/2d/CCTextureCache.cpp @@ -123,7 +123,7 @@ void TextureCache::addImageAsync(const std::string &path, std::functiongetScheduler()->scheduleSelector(schedule_selector(TextureCache::addImageAsyncCallBack), this, 0, false); + Director::getInstance()->getScheduler()->schedule(CC_CALLBACK_1(TextureCache::addImageAsyncCallBack, this), this, schedule_selector_to_key(schedule_selector(TextureCache::addImageAsyncCallBack)), 0, false); } ++_asyncRefCount; @@ -277,7 +277,7 @@ void TextureCache::addImageAsyncCallBack(float dt) --_asyncRefCount; if (0 == _asyncRefCount) { - Director::getInstance()->getScheduler()->unscheduleSelector(schedule_selector(TextureCache::addImageAsyncCallBack), this); + Director::getInstance()->getScheduler()->unschedule(this, schedule_selector_to_key(schedule_selector(TextureCache::addImageAsyncCallBack))); } } } diff --git a/cocos/2d/CCTextureCache.h b/cocos/2d/CCTextureCache.h index f5b187797f..a4a75d482b 100644 --- a/cocos/2d/CCTextureCache.h +++ b/cocos/2d/CCTextureCache.h @@ -37,7 +37,7 @@ THE SOFTWARE. #include #include -#include "CCObject.h" +#include "CCRef.h" #include "CCTexture2D.h" #include "platform/CCImage.h" @@ -61,7 +61,7 @@ NS_CC_BEGIN * Once the texture is loaded, the next time it will return * a reference of the previously loaded texture reducing GPU & CPU memory */ -class CC_DLL TextureCache : public Object +class CC_DLL TextureCache : public Ref { public: /** Returns the shared instance of the cache */ diff --git a/cocos/2d/CCTouch.h b/cocos/2d/CCTouch.h index e27ac187d3..a3b9d6241d 100644 --- a/cocos/2d/CCTouch.h +++ b/cocos/2d/CCTouch.h @@ -26,7 +26,7 @@ THE SOFTWARE. #ifndef __CC_TOUCH_H__ #define __CC_TOUCH_H__ -#include "CCObject.h" +#include "CCRef.h" #include "CCGeometry.h" NS_CC_BEGIN @@ -36,7 +36,7 @@ NS_CC_BEGIN * @{ */ -class CC_DLL Touch : public Object +class CC_DLL Touch : public Ref { public: /** how the touches are dispathced */ diff --git a/cocos/2d/CCTransition.h b/cocos/2d/CCTransition.h index 471f2f1d7b..b75aff1bae 100644 --- a/cocos/2d/CCTransition.h +++ b/cocos/2d/CCTransition.h @@ -49,7 +49,7 @@ class NodeGrid; /** @brief TransitionEaseScene can ease the actions of the scene protocol. @since v0.8.2 */ -class CC_DLL TransitionEaseScene// : public Object +class CC_DLL TransitionEaseScene// : public Ref { public: virtual ~TransitionEaseScene() {} diff --git a/cocos/2d/ccCArray.cpp b/cocos/2d/ccCArray.cpp index b0827eed5c..69dd34f24e 100644 --- a/cocos/2d/ccCArray.cpp +++ b/cocos/2d/ccCArray.cpp @@ -25,7 +25,7 @@ THE SOFTWARE. ****************************************************************************/ #include "ccCArray.h" -#include "CCObject.h" +#include "CCRef.h" NS_CC_BEGIN @@ -39,7 +39,7 @@ ccArray* ccArrayNew(ssize_t capacity) ccArray *arr = (ccArray*)malloc( sizeof(ccArray) ); arr->num = 0; - arr->arr = (Object**)calloc(capacity, sizeof(Object*)); + arr->arr = (Ref**)calloc(capacity, sizeof(Ref*)); arr->max = capacity; return arr; @@ -63,7 +63,7 @@ void ccArrayFree(ccArray*& arr) void ccArrayDoubleCapacity(ccArray *arr) { arr->max *= 2; - Object** newArr = (Object**)realloc( arr->arr, arr->max * sizeof(Object*) ); + Ref** newArr = (Ref**)realloc( arr->arr, arr->max * sizeof(Ref*) ); // will fail when there's not enough memory CCASSERT(newArr != 0, "ccArrayDoubleCapacity failed. Not enough memory"); arr->arr = newArr; @@ -99,16 +99,16 @@ void ccArrayShrink(ccArray *arr) arr->max=1; } - arr->arr = (Object**)realloc(arr->arr,newSize * sizeof(Object*) ); + arr->arr = (Ref**)realloc(arr->arr,newSize * sizeof(Ref*) ); CCASSERT(arr->arr!=nullptr,"could not reallocate the memory"); } } /** Returns index of first occurrence of object, CC_INVALID_INDEX if object not found. */ -ssize_t ccArrayGetIndexOfObject(ccArray *arr, Object* object) +ssize_t ccArrayGetIndexOfObject(ccArray *arr, Ref* object) { const auto arrNum = arr->num; - Object** ptr = arr->arr; + Ref** ptr = arr->arr; for (ssize_t i = 0; i < arrNum; ++i, ++ptr) { if (*ptr == object) @@ -119,13 +119,13 @@ ssize_t ccArrayGetIndexOfObject(ccArray *arr, Object* object) } /** Returns a Boolean value that indicates whether object is present in array. */ -bool ccArrayContainsObject(ccArray *arr, Object* object) +bool ccArrayContainsObject(ccArray *arr, Ref* object) { return ccArrayGetIndexOfObject(arr, object) != CC_INVALID_INDEX; } /** Appends an object. Behavior undefined if array doesn't have enough capacity. */ -void ccArrayAppendObject(ccArray *arr, Object* object) +void ccArrayAppendObject(ccArray *arr, Ref* object) { CCASSERT(object != nullptr, "Invalid parameter!"); object->retain(); @@ -134,7 +134,7 @@ void ccArrayAppendObject(ccArray *arr, Object* object) } /** Appends an object. Capacity of arr is increased if needed. */ -void ccArrayAppendObjectWithResize(ccArray *arr, Object* object) +void ccArrayAppendObjectWithResize(ccArray *arr, Ref* object) { ccArrayEnsureExtraCapacity(arr, 1); ccArrayAppendObject(arr, object); @@ -158,7 +158,7 @@ void ccArrayAppendArrayWithResize(ccArray *arr, ccArray *plusArr) } /** Inserts an object at index */ -void ccArrayInsertObjectAtIndex(ccArray *arr, Object* object, ssize_t index) +void ccArrayInsertObjectAtIndex(ccArray *arr, Ref* object, ssize_t index) { CCASSERT(index<=arr->num, "Invalid index. Out of bounds"); CCASSERT(object != nullptr, "Invalid parameter!"); @@ -168,7 +168,7 @@ void ccArrayInsertObjectAtIndex(ccArray *arr, Object* object, ssize_t index) ssize_t remaining = arr->num - index; if (remaining > 0) { - memmove((void *)&arr->arr[index+1], (void *)&arr->arr[index], sizeof(Object*) * remaining ); + memmove((void *)&arr->arr[index+1], (void *)&arr->arr[index], sizeof(Ref*) * remaining ); } object->retain(); @@ -182,7 +182,7 @@ void ccArraySwapObjectsAtIndexes(ccArray *arr, ssize_t index1, ssize_t index2) CCASSERT(index1>=0 && index1 < arr->num, "(1) Invalid index. Out of bounds"); CCASSERT(index2>=0 && index2 < arr->num, "(2) Invalid index. Out of bounds"); - Object* object1 = arr->arr[index1]; + Ref* object1 = arr->arr[index1]; arr->arr[index1] = arr->arr[index2]; arr->arr[index2] = object1; @@ -212,7 +212,7 @@ void ccArrayRemoveObjectAtIndex(ccArray *arr, ssize_t index, bool releaseObj/* = ssize_t remaining = arr->num - index; if(remaining>0) { - memmove((void *)&arr->arr[index], (void *)&arr->arr[index+1], remaining * sizeof(Object*)); + memmove((void *)&arr->arr[index], (void *)&arr->arr[index+1], remaining * sizeof(Ref*)); } } @@ -226,7 +226,7 @@ void ccArrayFastRemoveObjectAtIndex(ccArray *arr, ssize_t index) arr->arr[index] = arr->arr[last]; } -void ccArrayFastRemoveObject(ccArray *arr, Object* object) +void ccArrayFastRemoveObject(ccArray *arr, Ref* object) { auto index = ccArrayGetIndexOfObject(arr, object); if (index != CC_INVALID_INDEX) @@ -237,7 +237,7 @@ void ccArrayFastRemoveObject(ccArray *arr, Object* object) /** Searches for the first occurrence of object and removes it. If object is not found the function has no effect. */ -void ccArrayRemoveObject(ccArray *arr, Object* object, bool releaseObj/* = true*/) +void ccArrayRemoveObject(ccArray *arr, Ref* object, bool releaseObj/* = true*/) { auto index = ccArrayGetIndexOfObject(arr, object); if (index != CC_INVALID_INDEX) diff --git a/cocos/2d/ccCArray.h b/cocos/2d/ccCArray.h index f069301098..5cc80bbecd 100644 --- a/cocos/2d/ccCArray.h +++ b/cocos/2d/ccCArray.h @@ -44,7 +44,7 @@ THE SOFTWARE. #define CC_ARRAY_H #include "ccMacros.h" -#include "CCObject.h" +#include "CCRef.h" #include #include @@ -61,7 +61,7 @@ __object__=__array__->arr[0]; for(ssize_t i=0, num=__array__->num; i -#include -#include #include "CCPlatformMacros.h" #include "ccTypes.h" #include "CCValue.h" #include "CCData.h" +#include +#include +#include + NS_CC_BEGIN /** diff --git a/cocos/2d/platform/CCImage.h b/cocos/2d/platform/CCImage.h index 7ef352507b..755c03bcec 100644 --- a/cocos/2d/platform/CCImage.h +++ b/cocos/2d/platform/CCImage.h @@ -26,7 +26,7 @@ THE SOFTWARE. #ifndef __CC_IMAGE_H__ #define __CC_IMAGE_H__ -#include "CCObject.h" +#include "CCRef.h" #include "CCTexture2D.h" // premultiply alpha, or the effect will wrong when want to use other pixel format in Texture2D, @@ -53,7 +53,7 @@ typedef struct _MipmapInfo int len; }MipmapInfo; -class CC_DLL Image : public Object +class CC_DLL Image : public Ref { public: friend class TextureCache; diff --git a/cocos/2d/platform/android/CCGLView.h b/cocos/2d/platform/android/CCGLView.h index ec83059d0d..be9c920e41 100644 --- a/cocos/2d/platform/android/CCGLView.h +++ b/cocos/2d/platform/android/CCGLView.h @@ -29,13 +29,13 @@ THE SOFTWARE. #include "CCPlatformConfig.h" #if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID -#include "CCObject.h" +#include "CCRef.h" #include "CCGeometry.h" #include "platform/CCGLViewProtocol.h" NS_CC_BEGIN -class CC_DLL GLView : public Object, public GLViewProtocol +class CC_DLL GLView : public Ref, public GLViewProtocol { public: diff --git a/cocos/2d/platform/desktop/CCGLView.h b/cocos/2d/platform/desktop/CCGLView.h index 07ee153c1f..7747b854b6 100644 --- a/cocos/2d/platform/desktop/CCGLView.h +++ b/cocos/2d/platform/desktop/CCGLView.h @@ -26,14 +26,14 @@ THE SOFTWARE. #ifndef __CC_EGLVIEW_DESKTOP_H__ #define __CC_EGLVIEW_DESKTOP_H__ -#include "CCObject.h" +#include "CCRef.h" #include "platform/CCCommon.h" #include "platform/CCGLViewProtocol.h" #include "glfw3.h" NS_CC_BEGIN -class CC_DLL GLView : public Object, public GLViewProtocol +class CC_DLL GLView : public Ref, public GLViewProtocol { public: static GLView* create(const std::string& viewName); diff --git a/cocos/2d/platform/ios/CCGLView.h b/cocos/2d/platform/ios/CCGLView.h index 0196066d36..1b0a56981c 100644 --- a/cocos/2d/platform/ios/CCGLView.h +++ b/cocos/2d/platform/ios/CCGLView.h @@ -29,7 +29,7 @@ #include "CCPlatformConfig.h" #if CC_TARGET_PLATFORM == CC_PLATFORM_IOS -#include "CCObject.h" +#include "CCRef.h" #include "platform/CCCommon.h" #include "platform/CCGLViewProtocol.h" @@ -38,7 +38,7 @@ NS_CC_BEGIN /** Class that represent the OpenGL View */ -class CC_DLL GLView : public Object, public GLViewProtocol +class CC_DLL GLView : public Ref, public GLViewProtocol { public: /** creates a GLView with a objective-c CCEAGLView instance */ diff --git a/cocos/2d/renderer/CCGroupCommand.h b/cocos/2d/renderer/CCGroupCommand.h index 42c23d02b9..56e8563fa7 100644 --- a/cocos/2d/renderer/CCGroupCommand.h +++ b/cocos/2d/renderer/CCGroupCommand.h @@ -26,14 +26,15 @@ #ifndef _CC_GROUPCOMMAND_H_ #define _CC_GROUPCOMMAND_H_ -#include "CCPlatformMacros.h" +#include "CCRef.h" #include "CCRenderCommand.h" #include "CCRenderCommandPool.h" + #include NS_CC_BEGIN -class GroupCommandManager : public Object +class GroupCommandManager : public Ref { public: static GroupCommandManager* getInstance(); diff --git a/cocos/2d/renderer/CCMaterialManager.h b/cocos/2d/renderer/CCMaterialManager.h index 53330855a5..23737ed977 100644 --- a/cocos/2d/renderer/CCMaterialManager.h +++ b/cocos/2d/renderer/CCMaterialManager.h @@ -27,13 +27,13 @@ #define _CC_MATERIALMANAGER_H_ #include "CCPlatformMacros.h" -#include "CCObject.h" +#include "CCRef.h" #include "ccTypes.h" #include NS_CC_BEGIN -class MaterialManager : public Object +class MaterialManager : public Ref { public: static MaterialManager* getInstance(); diff --git a/cocos/base/CCArray.cpp b/cocos/base/CCArray.cpp index eecd15fe63..326f931ffa 100644 --- a/cocos/base/CCArray.cpp +++ b/cocos/base/CCArray.cpp @@ -58,7 +58,7 @@ __Array* __Array::create() return array; } -__Array* __Array::createWithObject(Object* object) +__Array* __Array::createWithObject(Ref* object) { __Array* array = new __Array(); @@ -74,7 +74,7 @@ __Array* __Array::createWithObject(Object* object) return array; } -__Array* __Array::create(Object* object, ...) +__Array* __Array::create(Ref* object, ...) { va_list args; va_start(args,object); @@ -83,11 +83,11 @@ __Array* __Array::create(Object* object, ...) if (array && object) { array->addObject(object); - Object *i = va_arg(args, Object*); + Ref* i = va_arg(args, Ref*); while (i) { array->addObject(i); - i = va_arg(args, Object*); + i = va_arg(args, Ref*); } } else @@ -143,7 +143,7 @@ bool __Array::init() return initWithCapacity(7); } -bool __Array::initWithObject(Object* object) +bool __Array::initWithObject(Ref* object) { bool ret = initWithCapacity(7); if (ret) @@ -154,7 +154,7 @@ bool __Array::initWithObject(Object* object) } /** Initializes an array with some objects */ -bool __Array::initWithObjects(Object* object, ...) +bool __Array::initWithObjects(Ref* object, ...) { bool ret = false; do @@ -167,11 +167,11 @@ bool __Array::initWithObjects(Object* object, ...) if (object) { this->addObject(object); - Object* i = va_arg(args, Object*); + Ref* i = va_arg(args, Ref*); while (i) { this->addObject(i); - i = va_arg(args, Object*); + i = va_arg(args, Ref*); } ret = true; } @@ -196,7 +196,7 @@ bool __Array::initWithArray(__Array* otherArray) return true; } -ssize_t __Array::getIndexOfObject(Object* object) const +ssize_t __Array::getIndexOfObject(Ref* object) const { auto it = data.begin(); @@ -211,7 +211,7 @@ ssize_t __Array::getIndexOfObject(Object* object) const return -1; } -Object* __Array::getRandomObject() +Ref* __Array::getRandomObject() { if (data.size()==0) { @@ -230,7 +230,7 @@ Object* __Array::getRandomObject() return data[r].get(); } -bool __Array::containsObject(Object* object) const +bool __Array::containsObject(Ref* object) const { ssize_t i = this->getIndexOfObject(object); return (i >= 0); @@ -248,7 +248,7 @@ bool __Array::isEqualToArray(__Array* otherArray) return true; } -void __Array::addObject(Object* object) +void __Array::addObject(Ref* object) { data.push_back(RCPtr(object)); } @@ -258,12 +258,12 @@ void __Array::addObjectsFromArray(__Array* otherArray) data.insert(data.end(), otherArray->data.begin(), otherArray->data.end()); } -void __Array::insertObject(Object* object, int index) +void __Array::insertObject(Ref* object, int index) { data.insert(std::begin(data) + index, RCPtr(object)); } -void __Array::setObject(Object* object, int index) +void __Array::setObject(Ref* object, int index) { data[index] = RCPtr(object); } @@ -274,7 +274,7 @@ void __Array::removeLastObject(bool releaseObj) data.pop_back(); } -void __Array::removeObject(Object* object, bool releaseObj /* ignored */) +void __Array::removeObject(Ref* object, bool releaseObj /* ignored */) { data.erase(std::remove(data.begin(), data.end(), object)); } @@ -300,12 +300,12 @@ void __Array::fastRemoveObjectAtIndex(int index) removeObjectAtIndex(index); } -void __Array::fastRemoveObject(Object* object) +void __Array::fastRemoveObject(Ref* object) { removeObject(object); } -void __Array::exchangeObject(Object* object1, Object* object2) +void __Array::exchangeObject(Ref* object1, Ref* object2) { ssize_t idx1 = getIndexOfObject(object1); ssize_t idx2 = getIndexOfObject(object2); @@ -320,7 +320,7 @@ void __Array::exchangeObjectAtIndex(ssize_t index1, ssize_t index2) std::swap(data[index1], data[index2]); } -void __Array::replaceObjectAtIndex(int index, Object* object, bool releaseObject /* ignored */) +void __Array::replaceObjectAtIndex(int index, Ref* object, bool releaseObject /* ignored */) { data[index] = object; } @@ -346,15 +346,15 @@ __Array* __Array::clone() const ret->autorelease(); ret->initWithCapacity(this->data.size() > 0 ? this->data.size() : 1); - Object* obj = nullptr; - Object* tmpObj = nullptr; + Ref* obj = nullptr; + Ref* tmpObj = nullptr; Clonable* clonable = nullptr; CCARRAY_FOREACH(this, obj) { clonable = dynamic_cast(obj); if (clonable) { - tmpObj = dynamic_cast(clonable->clone()); + tmpObj = dynamic_cast(clonable->clone()); if (tmpObj) { ret->addObject(tmpObj); @@ -401,7 +401,7 @@ __Array* __Array::create() return array; } -__Array* __Array::createWithObject(Object* object) +__Array* __Array::createWithObject(Ref* object) { __Array* array = new __Array(); @@ -417,7 +417,7 @@ __Array* __Array::createWithObject(Object* object) return array; } -__Array* __Array::create(Object* object, ...) +__Array* __Array::create(Ref* object, ...) { va_list args; va_start(args,object); @@ -426,11 +426,11 @@ __Array* __Array::create(Object* object, ...) if (array && object) { array->addObject(object); - Object *i = va_arg(args, Object*); + Ref *i = va_arg(args, Ref*); while (i) { array->addObject(i); - i = va_arg(args, Object*); + i = va_arg(args, Ref*); } } else @@ -496,7 +496,7 @@ bool __Array::init() return initWithCapacity(7); } -bool __Array::initWithObject(Object* object) +bool __Array::initWithObject(Ref* object) { CCASSERT(!data, "Array cannot be re-initialized"); @@ -509,7 +509,7 @@ bool __Array::initWithObject(Object* object) } /** Initializes an array with some objects */ -bool __Array::initWithObjects(Object* object, ...) +bool __Array::initWithObjects(Ref* object, ...) { CCASSERT(!data, "Array cannot be re-initialized"); @@ -524,11 +524,11 @@ bool __Array::initWithObjects(Object* object, ...) if (object) { this->addObject(object); - Object* i = va_arg(args, Object*); + Ref* i = va_arg(args, Ref*); while (i) { this->addObject(i); - i = va_arg(args, Object*); + i = va_arg(args, Ref*); } ret = true; } @@ -563,12 +563,12 @@ bool __Array::initWithArray(__Array* otherArray) return ret; } -ssize_t __Array::getIndexOfObject(Object* object) const +ssize_t __Array::getIndexOfObject(Ref* object) const { return ccArrayGetIndexOfObject(data, object); } -Object* __Array::getRandomObject() +Ref* __Array::getRandomObject() { if (data->num == 0) { @@ -585,7 +585,7 @@ Object* __Array::getRandomObject() return data->arr[static_cast(data->num * r)]; } -bool __Array::containsObject(Object* object) const +bool __Array::containsObject(Ref* object) const { return ccArrayContainsObject(data, object); } @@ -594,7 +594,8 @@ bool __Array::isEqualToArray(__Array* otherArray) { for (int i = 0; i < this->count(); ++i) { - if (!this->getObjectAtIndex(i)->isEqual(otherArray->getObjectAtIndex(i))) +//FIXME:james + if (this->getObjectAtIndex(i) != otherArray->getObjectAtIndex(i)) { return false; } @@ -602,7 +603,7 @@ bool __Array::isEqualToArray(__Array* otherArray) return true; } -void __Array::addObject(Object* object) +void __Array::addObject(Ref* object) { CCASSERT(data, "Array not initialized"); ccArrayAppendObjectWithResize(data, object); @@ -614,13 +615,13 @@ void __Array::addObjectsFromArray(__Array* otherArray) ccArrayAppendArrayWithResize(data, otherArray->data); } -void __Array::insertObject(Object* object, ssize_t index) +void __Array::insertObject(Ref* object, ssize_t index) { CCASSERT(data, "Array not initialized"); ccArrayInsertObjectAtIndex(data, object, index); } -void __Array::setObject(Object* object, ssize_t index) +void __Array::setObject(Ref* object, ssize_t index) { CCASSERT(index >= 0 && index < count(), "Invalid index"); @@ -638,7 +639,7 @@ void __Array::removeLastObject(bool releaseObj) ccArrayRemoveObjectAtIndex(data, data->num - 1, releaseObj); } -void __Array::removeObject(Object* object, bool releaseObj/* = true*/) +void __Array::removeObject(Ref* object, bool releaseObj/* = true*/) { ccArrayRemoveObject(data, object, releaseObj); } @@ -663,12 +664,12 @@ void __Array::fastRemoveObjectAtIndex(ssize_t index) ccArrayFastRemoveObjectAtIndex(data, index); } -void __Array::fastRemoveObject(Object* object) +void __Array::fastRemoveObject(Ref* object) { ccArrayFastRemoveObject(data, object); } -void __Array::exchangeObject(Object* object1, Object* object2) +void __Array::exchangeObject(Ref* object1, Ref* object2) { auto index1 = ccArrayGetIndexOfObject(data, object1); if (index1 == CC_INVALID_INDEX) @@ -690,7 +691,7 @@ void __Array::exchangeObjectAtIndex(ssize_t index1, ssize_t index2) ccArraySwapObjectsAtIndexes(data, index1, index2); } -void __Array::replaceObjectAtIndex(ssize_t index, Object* object, bool releaseObject/* = true*/) +void __Array::replaceObjectAtIndex(ssize_t index, Ref* object, bool releaseObject/* = true*/) { ccArrayInsertObjectAtIndex(data, object, index); ccArrayRemoveObjectAtIndex(data, index + 1); @@ -730,15 +731,15 @@ __Array* __Array::clone() const ret->autorelease(); ret->initWithCapacity(this->data->num > 0 ? this->data->num : 1); - Object* obj = nullptr; - Object* tmpObj = nullptr; + Ref* obj = nullptr; + Ref* tmpObj = nullptr; Clonable* clonable = nullptr; CCARRAY_FOREACH(this, obj) { clonable = dynamic_cast(obj); if (clonable) { - tmpObj = dynamic_cast(clonable->clone()); + tmpObj = dynamic_cast(clonable->clone()); if (tmpObj) { ret->addObject(tmpObj); diff --git a/cocos/base/CCArray.h b/cocos/base/CCArray.h index 0ceedadff9..57d32b4d3c 100644 --- a/cocos/base/CCArray.h +++ b/cocos/base/CCArray.h @@ -31,12 +31,13 @@ THE SOFTWARE. #if CC_USE_ARRAY_VECTOR #include #include -#include "CCObject.h" +#include "CCRef.h" #include "ccMacros.h" #else #include "ccCArray.h" #endif +#include "CCDataVisitor.h" #if CC_USE_ARRAY_VECTOR /** @@ -167,13 +168,13 @@ I found that it's not work in C++. So it keep what it's look like in version 1.0 #define CCARRAY_FOREACH(__array__, __object__) \ if ((__array__) && (__array__)->data->num > 0) \ - for(Object** __arr__ = (__array__)->data->arr, **__end__ = (__array__)->data->arr + (__array__)->data->num-1; \ + for(Ref** __arr__ = (__array__)->data->arr, **__end__ = (__array__)->data->arr + (__array__)->data->num-1; \ __arr__ <= __end__ && (((__object__) = *__arr__) != NULL/* || true*/); \ __arr__++) #define CCARRAY_FOREACH_REVERSE(__array__, __object__) \ if ((__array__) && (__array__)->data->num > 0) \ - for(Object** __arr__ = (__array__)->data->arr + (__array__)->data->num-1, **__end__ = (__array__)->data->arr; \ + for(Ref** __arr__ = (__array__)->data->arr + (__array__)->data->num-1, **__end__ = (__array__)->data->arr; \ __arr__ >= __end__ && (((__object__) = *__arr__) != NULL/* || true*/); \ __arr__--) @@ -181,7 +182,7 @@ I found that it's not work in C++. So it keep what it's look like in version 1.0 #define CCARRAY_VERIFY_TYPE(__array__, __type__) \ do { \ if ((__array__) && (__array__)->data->num > 0) \ - for(Object** __arr__ = (__array__)->data->arr, \ + for(Ref** __arr__ = (__array__)->data->arr, \ **__end__ = (__array__)->data->arr + (__array__)->data->num-1; __arr__ <= __end__; __arr__++) \ CCASSERT(dynamic_cast<__type__>(*__arr__), "element type is wrong!"); \ } while(false) @@ -198,7 +199,7 @@ I found that it's not work in C++. So it keep what it's look like in version 1.0 do { \ if(pArray && pArray->count() > 0) \ { \ - Object* child; \ + Ref* child; \ CCARRAY_FOREACH(pArray, child) \ { \ elementType pNode = static_cast(child); \ @@ -215,7 +216,7 @@ while(false) do { \ if(pArray && pArray->count() > 0) \ { \ - Object* child; \ + Ref* child; \ CCARRAY_FOREACH(pArray, child) \ { \ elementType pNode = static_cast(child); \ @@ -231,7 +232,7 @@ while(false) NS_CC_BEGIN -class CC_DLL __Array : public Object, public Clonable +class CC_DLL __Array : public Ref, public Clonable { public: @@ -243,11 +244,11 @@ public: /** Create an array with objects * @js NA */ - static __Array* create(Object* object, ...) CC_REQUIRES_NULL_TERMINATION; + static __Array* create(Ref* object, ...) CC_REQUIRES_NULL_TERMINATION; /** Create an array with one object * @js NA */ - static __Array* createWithObject(Object* object); + static __Array* createWithObject(Ref* object); /** Create an array with a default capacity * @js NA */ @@ -286,12 +287,12 @@ public: * @js NA * @lua NA */ - bool initWithObject(Object* object); + bool initWithObject(Ref* object); /** Initializes an array with some objects * @js NA * @lua NA */ - bool initWithObjects(Object* object, ...) CC_REQUIRES_NULL_TERMINATION; + bool initWithObjects(Ref* object, ...) CC_REQUIRES_NULL_TERMINATION; /** Initializes an array with capacity * @js NA * @lua NA @@ -331,17 +332,17 @@ public: * @js NA * @lua NA */ - ssize_t getIndexOfObject(Object* object) const; + ssize_t getIndexOfObject(Ref* object) const; /** * @js NA */ - CC_DEPRECATED_ATTRIBUTE ssize_t indexOfObject(Object* object) const { return getIndexOfObject(object); } + CC_DEPRECATED_ATTRIBUTE ssize_t indexOfObject(Ref* object) const { return getIndexOfObject(object); } /** Returns an element with a certain index * @js NA * @lua NA */ - Object* getObjectAtIndex(ssize_t index) + Ref* getObjectAtIndex(ssize_t index) { CCASSERT(index>=0 && index < count(), "index out of range in getObjectAtIndex()"); #if CC_USE_ARRAY_VECTOR @@ -350,11 +351,11 @@ public: return data->arr[index]; #endif } - CC_DEPRECATED_ATTRIBUTE Object* objectAtIndex(ssize_t index) { return getObjectAtIndex(index); } + CC_DEPRECATED_ATTRIBUTE Ref* objectAtIndex(ssize_t index) { return getObjectAtIndex(index); } /** Returns the last element of the array * @js NA */ - Object* getLastObject() + Ref* getLastObject() { #if CC_USE_ARRAY_VECTOR return data.back().get(); @@ -368,20 +369,20 @@ public: /** * @js NA */ - CC_DEPRECATED_ATTRIBUTE Object* lastObject() { return getLastObject(); } + CC_DEPRECATED_ATTRIBUTE Ref* lastObject() { return getLastObject(); } /** Returns a random element * @js NA * @lua NA */ - Object* getRandomObject(); + Ref* getRandomObject(); /** * @js NA */ - CC_DEPRECATED_ATTRIBUTE Object* randomObject() { return getRandomObject(); } + CC_DEPRECATED_ATTRIBUTE Ref* randomObject() { return getRandomObject(); } /** Returns a Boolean value that indicates whether object is present in array. * @js NA */ - bool containsObject(Object* object) const; + bool containsObject(Ref* object) const; /** @since 1.1 * @js NA */ @@ -391,7 +392,7 @@ public: /** Add a certain object * @js NA */ - void addObject(Object* object); + void addObject(Ref* object); /** * @js NA */ @@ -402,17 +403,17 @@ public: /** Insert a certain object at a certain index * @js NA */ - void insertObject(Object* object, ssize_t index); + void insertObject(Ref* object, ssize_t index); /** sets a certain object at a certain index * @js NA * @lua NA */ - void setObject(Object* object, ssize_t index); + void setObject(Ref* object, ssize_t index); /** sets a certain object at a certain index without retaining. Use it with caution * @js NA * @lua NA */ - void fastSetObject(Object* object, ssize_t index) + void fastSetObject(Ref* object, ssize_t index) { #if CC_USE_ARRAY_VECTOR setObject(object, index); @@ -444,7 +445,7 @@ public: /** Remove a certain object * @js NA */ - void removeObject(Object* object, bool releaseObj = true); + void removeObject(Ref* object, bool releaseObj = true); /** Remove an element with a certain index * @js NA */ @@ -460,7 +461,7 @@ public: /** Fast way to remove a certain object * @js NA */ - void fastRemoveObject(Object* object); + void fastRemoveObject(Ref* object); /** Fast way to remove an element with a certain index * @js NA */ @@ -471,7 +472,7 @@ public: /** Swap two elements * @js NA */ - void exchangeObject(Object* object1, Object* object2); + void exchangeObject(Ref* object1, Ref* object2); /** Swap two elements with certain indexes * @js NA */ @@ -480,7 +481,7 @@ public: /** Replace object at index with another object. * @js NA */ - void replaceObjectAtIndex(ssize_t index, Object* object, bool releaseObject = true); + void replaceObjectAtIndex(ssize_t index, Ref* object, bool releaseObject = true); /** Revers the array * @js NA @@ -531,12 +532,12 @@ public: * @js NA * @lua NA */ - Object** begin() { return &data->arr[0]; } + Ref** begin() { return &data->arr[0]; } /** * @js NA * @lua NA */ - Object** end() { return &data->arr[data->num]; } + Ref** end() { return &data->arr[data->num]; } ccArray* data; diff --git a/cocos/base/CCAutoreleasePool.cpp b/cocos/base/CCAutoreleasePool.cpp index 3ce5ea4d65..9f47821ce0 100644 --- a/cocos/base/CCAutoreleasePool.cpp +++ b/cocos/base/CCAutoreleasePool.cpp @@ -55,7 +55,7 @@ AutoreleasePool::~AutoreleasePool() PoolManager::getInstance()->pop(); } -void AutoreleasePool::addObject(Object* object) +void AutoreleasePool::addObject(Ref* object) { _managedObjectArray.push_back(object); } @@ -75,7 +75,7 @@ void AutoreleasePool::clear() #endif } -bool AutoreleasePool::contains(Object* object) const +bool AutoreleasePool::contains(Ref* object) const { for (const auto& obj : _managedObjectArray) { @@ -91,7 +91,7 @@ void AutoreleasePool::dump() CCLOG("%20s%20s%20s", "Object pointer", "Object id", "reference count"); for (const auto &obj : _managedObjectArray) { - CCLOG("%20p%20u%20u\n", obj, obj->_ID, obj->getReferenceCount()); + CCLOG("%20p%20u\n", obj, obj->getReferenceCount()); } } @@ -145,7 +145,7 @@ AutoreleasePool* PoolManager::getCurrentPool() const return _curReleasePool; } -bool PoolManager::isObjectInPools(Object* obj) const +bool PoolManager::isObjectInPools(Ref* obj) const { for (const auto& pool : _releasePoolStack) { diff --git a/cocos/base/CCAutoreleasePool.h b/cocos/base/CCAutoreleasePool.h index 63461f6262..99d11255c2 100644 --- a/cocos/base/CCAutoreleasePool.h +++ b/cocos/base/CCAutoreleasePool.h @@ -28,7 +28,7 @@ THE SOFTWARE. #include #include #include -#include "CCObject.h" +#include "CCRef.h" NS_CC_BEGIN @@ -62,19 +62,19 @@ public: * Add a given object to this pool. * * The same object may be added several times to the same pool; When the - * pool is destructed, the object's Object::release() method will be called + * pool is destructed, the object's Ref::release() method will be called * for each time it was added. * * @param object The object to add to the pool. * @js NA * @lua NA */ - void addObject(Object *object); + void addObject(Ref *object); /** * Clear the autorelease pool. * - * Object::release() will be called for each time the managed object is + * Ref::release() will be called for each time the managed object is * added to the pool. * @js NA * @lua NA @@ -91,7 +91,7 @@ public: /** * Checks whether the pool contains the specified object. */ - bool contains(Object* object) const; + bool contains(Ref* object) const; /** * Dump the objects that are put into autorelease pool. It is used for debugging. @@ -107,12 +107,12 @@ private: * The underlying array of object managed by the pool. * * Although Array retains the object once when an object is added, proper - * Object::release() is called outside the array to make sure that the pool + * Ref::release() is called outside the array to make sure that the pool * does not affect the managed object's reference count. So an object can - * be destructed properly by calling Object::release() even if the object + * be destructed properly by calling Ref::release() even if the object * is in the pool. */ - std::vector _managedObjectArray; + std::vector _managedObjectArray; std::string _name; #if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0) @@ -146,7 +146,7 @@ public: */ AutoreleasePool *getCurrentPool() const; - bool isObjectInPools(Object* obj) const; + bool isObjectInPools(Ref* obj) const; /** * @js NA diff --git a/cocos/base/CCBool.h b/cocos/base/CCBool.h index 216d9b5656..3149e06c8d 100644 --- a/cocos/base/CCBool.h +++ b/cocos/base/CCBool.h @@ -26,7 +26,8 @@ Copyright (c) 2013-2014 Chukong Technologies Inc. #ifndef __CCBOOL_H__ #define __CCBOOL_H__ -#include "CCObject.h" +#include "CCRef.h" +#include "CCDataVisitor.h" NS_CC_BEGIN @@ -35,7 +36,7 @@ NS_CC_BEGIN * @{ */ -class CC_DLL __Bool : public Object, public Clonable +class CC_DLL __Bool : public Ref, public Clonable { public: __Bool(bool v) diff --git a/cocos/base/CCDataVisitor.cpp b/cocos/base/CCDataVisitor.cpp index b149321649..a908ead8bd 100644 --- a/cocos/base/CCDataVisitor.cpp +++ b/cocos/base/CCDataVisitor.cpp @@ -22,7 +22,7 @@ THE SOFTWARE. ****************************************************************************/ -#include "CCObject.h" +#include "CCRef.h" #include "CCBool.h" #include "CCInteger.h" #include "CCFloat.h" @@ -90,7 +90,7 @@ std::string PrettyPrinter::getResult() return _result; } -void PrettyPrinter::visitObject(const Object *p) +void PrettyPrinter::visitObject(const Ref *p) { char buf[50] = {0}; sprintf(buf, "%p", p); @@ -137,7 +137,7 @@ void PrettyPrinter::visit(const __Array *p) _result += "\n"; setIndentLevel(_indentLevel+1); - Object* obj; + Ref* obj; int i = 0; char buf[50] = {0}; CCARRAY_FOREACH(p, obj) @@ -148,7 +148,7 @@ void PrettyPrinter::visit(const __Array *p) sprintf(buf, "%s%02d: ", _indentStr.c_str(), i); _result += buf; PrettyPrinter v(_indentLevel); - obj->acceptVisitor(v); +//FIXME:james obj->acceptVisitor(v); _result += v.getResult(); i++; } @@ -177,7 +177,7 @@ void PrettyPrinter::visit(const __Dictionary *p) sprintf(buf, "%s%s: ", _indentStr.c_str(),element->getStrKey()); _result += buf; PrettyPrinter v(_indentLevel); - element->getObject()->acceptVisitor(v); +//FIXME:james element->getObject()->acceptVisitor(v); _result += v.getResult(); bFirstElement = false; } @@ -206,7 +206,7 @@ void PrettyPrinter::visit(const __Set *p) } _result += _indentStr.c_str(); PrettyPrinter v(_indentLevel); - (*it)->acceptVisitor(v); +//FIXME:james (*it)->acceptVisitor(v); _result += v.getResult(); } setIndentLevel(_indentLevel-1); diff --git a/cocos/base/CCDataVisitor.h b/cocos/base/CCDataVisitor.h index 96f004987f..42b3de1e68 100644 --- a/cocos/base/CCDataVisitor.h +++ b/cocos/base/CCDataVisitor.h @@ -30,7 +30,7 @@ NS_CC_BEGIN -class Object; +class Ref; class __Bool; class __Integer; class __Float; @@ -50,7 +50,7 @@ class __Set; * * Use cases: * - data serialization, - * - pretty printing of Object * + * - pretty printing of Ref* * - safe value reading from Array, __Dictionary, Set * * Usage: @@ -69,7 +69,7 @@ public: virtual ~DataVisitor() {} /** default method, called from non-overloaded methods and for unrecognized objects */ - virtual void visitObject(const Object *p) = 0; + virtual void visitObject(const Ref *p) = 0; virtual void visit(const __Bool *p); virtual void visit(const __Integer *p); @@ -90,7 +90,7 @@ public: virtual void clear(); virtual std::string getResult(); - virtual void visitObject(const Object *p); + virtual void visitObject(const Ref *p); virtual void visit(const __Bool * p); virtual void visit(const __Integer *p); virtual void visit(const __Float *p); diff --git a/cocos/base/CCDictionary.cpp b/cocos/base/CCDictionary.cpp index 5be01c5c29..9c4dfb791c 100644 --- a/cocos/base/CCDictionary.cpp +++ b/cocos/base/CCDictionary.cpp @@ -41,7 +41,7 @@ NS_CC_BEGIN // ----------------------------------------------------------------------- // DictElement -DictElement::DictElement(const char* pszKey, Object* pObject) +DictElement::DictElement(const char* pszKey, Ref* pObject) { CCASSERT(pszKey && strlen(pszKey) > 0, "Invalid key value."); _intKey = 0; @@ -60,7 +60,7 @@ DictElement::DictElement(const char* pszKey, Object* pObject) memset(&hh, 0, sizeof(hh)); } -DictElement::DictElement(intptr_t iKey, Object* pObject) +DictElement::DictElement(intptr_t iKey, Ref* pObject) { _strKey[0] = '\0'; _intKey = iKey; @@ -124,7 +124,7 @@ __Array* __Dictionary::allKeys() return array; } -__Array* __Dictionary::allKeysForObject(Object* object) +__Array* __Dictionary::allKeysForObject(Ref* object) { int iKeyCount = this->count(); if (iKeyCount <= 0) return NULL; @@ -159,7 +159,7 @@ __Array* __Dictionary::allKeysForObject(Object* object) return array; } -Object* __Dictionary::objectForKey(const std::string& key) +Ref* __Dictionary::objectForKey(const std::string& key) { // if dictionary wasn't initialized, return NULL directly. if (_dictType == kDictUnknown) return NULL; @@ -167,7 +167,7 @@ Object* __Dictionary::objectForKey(const std::string& key) // This method uses string as key, therefore we should make sure that the key type of this __Dictionary is string. CCASSERT(_dictType == kDictStr, "this dictionary does not use string as key."); - Object* pRetObject = NULL; + Ref* pRetObject = NULL; DictElement *pElement = NULL; HASH_FIND_STR(_elements, key.c_str(), pElement); if (pElement != NULL) @@ -177,7 +177,7 @@ Object* __Dictionary::objectForKey(const std::string& key) return pRetObject; } -Object* __Dictionary::objectForKey(intptr_t key) +Ref* __Dictionary::objectForKey(intptr_t key) { // if dictionary wasn't initialized, return NULL directly. if (_dictType == kDictUnknown) return NULL; @@ -185,7 +185,7 @@ Object* __Dictionary::objectForKey(intptr_t key) // This method uses integer as key, therefore we should make sure that the key type of this __Dictionary is integer. CCASSERT(_dictType == kDictInt, "this dictionary does not use integer as key."); - Object* pRetObject = NULL; + Ref* pRetObject = NULL; DictElement *pElement = NULL; HASH_FIND_PTR(_elements, &key, pElement); if (pElement != NULL) @@ -215,7 +215,7 @@ const __String* __Dictionary::valueForKey(intptr_t key) return pStr; } -void __Dictionary::setObject(Object* pObject, const std::string& key) +void __Dictionary::setObject(Ref* pObject, const std::string& key) { CCASSERT(key.length() > 0 && pObject != NULL, "Invalid Argument!"); if (_dictType == kDictUnknown) @@ -233,7 +233,7 @@ void __Dictionary::setObject(Object* pObject, const std::string& key) } else if (pElement->_object != pObject) { - Object* pTmpObj = pElement->_object; + Ref* pTmpObj = pElement->_object; pTmpObj->retain(); removeObjectForElememt(pElement); setObjectUnSafe(pObject, key); @@ -241,7 +241,7 @@ void __Dictionary::setObject(Object* pObject, const std::string& key) } } -void __Dictionary::setObject(Object* pObject, intptr_t key) +void __Dictionary::setObject(Ref* pObject, intptr_t key) { CCASSERT(pObject != NULL, "Invalid Argument!"); if (_dictType == kDictUnknown) @@ -259,7 +259,7 @@ void __Dictionary::setObject(Object* pObject, intptr_t key) } else if (pElement->_object != pObject) { - Object* pTmpObj = pElement->_object; + Ref* pTmpObj = pElement->_object; pTmpObj->retain(); removeObjectForElememt(pElement); setObjectUnSafe(pObject, key); @@ -295,14 +295,14 @@ void __Dictionary::removeObjectForKey(intptr_t key) removeObjectForElememt(pElement); } -void __Dictionary::setObjectUnSafe(Object* pObject, const std::string& key) +void __Dictionary::setObjectUnSafe(Ref* pObject, const std::string& key) { pObject->retain(); DictElement* pElement = new DictElement(key.c_str(), pObject); HASH_ADD_STR(_elements, _strKey, pElement); } -void __Dictionary::setObjectUnSafe(Object* pObject, const intptr_t key) +void __Dictionary::setObjectUnSafe(Ref* pObject, const intptr_t key) { pObject->retain(); DictElement* pElement = new DictElement(key, pObject); @@ -311,7 +311,7 @@ void __Dictionary::setObjectUnSafe(Object* pObject, const intptr_t key) void __Dictionary::removeObjectsForKeys(__Array* pKey__Array) { - Object* pObj = NULL; + Ref* pObj = NULL; CCARRAY_FOREACH(pKey__Array, pObj) { __String* pStr = static_cast<__String*>(pObj); @@ -341,14 +341,14 @@ void __Dictionary::removeAllObjects() } } -Object* __Dictionary::randomObject() +Ref* __Dictionary::randomObject() { if (_dictType == kDictUnknown) { return NULL; } - Object* key = allKeys()->getRandomObject(); + Ref* key = allKeys()->getRandomObject(); if (_dictType == kDictInt) { @@ -474,7 +474,7 @@ static ValueVector ccarray_to_valuevector(__Array* arr) { ValueVector ret; - Object* obj; + Ref* obj; CCARRAY_FOREACH(arr, obj) { Value arrElement; @@ -516,7 +516,7 @@ static ValueMap ccdictionary_to_valuemap(__Dictionary* dict) DictElement* pElement = nullptr; CCDICT_FOREACH(dict, pElement) { - Object* obj = pElement->getObject(); + Ref* obj = pElement->getObject(); __String* strVal = nullptr; __Dictionary* dictVal = nullptr; @@ -567,7 +567,7 @@ __Dictionary* __Dictionary::clone() const __Dictionary* newDict = __Dictionary::create(); DictElement* element = NULL; - Object* tmpObj = NULL; + Ref* tmpObj = NULL; Clonable* obj = NULL; if (_dictType == kDictInt) { @@ -576,7 +576,7 @@ __Dictionary* __Dictionary::clone() const obj = dynamic_cast(element->getObject()); if (obj) { - tmpObj = dynamic_cast(obj->clone()); + tmpObj = dynamic_cast(obj->clone()); if (tmpObj) { newDict->setObject(tmpObj, element->getIntKey()); @@ -595,7 +595,7 @@ __Dictionary* __Dictionary::clone() const obj = dynamic_cast(element->getObject()); if (obj) { - tmpObj = dynamic_cast(obj->clone()); + tmpObj = dynamic_cast(obj->clone()); if (tmpObj) { newDict->setObject(tmpObj, element->getStrKey()); diff --git a/cocos/base/CCDictionary.h b/cocos/base/CCDictionary.h index 6be84d7e2d..343fd05520 100644 --- a/cocos/base/CCDictionary.h +++ b/cocos/base/CCDictionary.h @@ -27,7 +27,7 @@ THE SOFTWARE. #define __CCDICTIONARY_H__ #include "uthash.h" -#include "CCObject.h" +#include "CCRef.h" #include "CCArray.h" #include "CCString.h" @@ -69,7 +69,7 @@ private: * @param pszKey The string key of this element. * @param pObject The object of this element. */ - DictElement(const char* pszKey, Object* pObject); + DictElement(const char* pszKey, Ref* pObject); /** * Constructor of DictElement. It's only for internal usage. Dictionary is its friend class. @@ -77,7 +77,7 @@ private: * @param iKey The integer key of this element. * @param pObject The object of this element. */ - DictElement(intptr_t iKey, Object* pObject); + DictElement(intptr_t iKey, Ref* pObject); public: /** @@ -120,7 +120,7 @@ public: * * @return The object of this element. */ - inline Object* getObject() const { return _object; } + inline Ref* getObject() const { return _object; } private: // The max length of string key. @@ -129,7 +129,7 @@ private: // So it's a pain that all elements will allocate 256 bytes for this array. char _strKey[MAX_KEY_LEN]; // hash key of string type intptr_t _intKey; // hash key of integer type - Object* _object; // hash value + Ref* _object; // hash value public: UT_hash_handle hh; // makes this class hashable friend class __Dictionary; // declare Dictionary as friend class @@ -172,7 +172,7 @@ public: * */ -class CC_DLL __Dictionary : public Object, public Clonable +class CC_DLL __Dictionary : public Ref, public Clonable { public: /** @@ -216,7 +216,7 @@ public: * @return The array contains all keys for the specified object. It's an autorelease object yet. * @js NA */ - __Array* allKeysForObject(Object* object); + __Array* allKeysForObject(Ref* object); /** * Get the object according to the specified string key. @@ -237,7 +237,7 @@ public: * @see objectForKey(intptr_t) * @js NA */ - Object* objectForKey(const std::string& key); + Ref* objectForKey(const std::string& key); /** * Get the object according to the specified integer key. @@ -248,7 +248,7 @@ public: * @see objectForKey(const std::string&) * @js NA */ - Object* objectForKey(intptr_t key); + Ref* objectForKey(intptr_t key); /** Get the value according to the specified string key. * @@ -281,10 +281,10 @@ public: * * @param pObject The Object to be inserted. * @param key The string key for searching. - * @see setObject(Object*, intptr_t) + * @see setObject(Ref*, intptr_t) * @js NA */ - void setObject(Object* pObject, const std::string& key); + void setObject(Ref* pObject, const std::string& key); /** Insert an object to dictionary, and match it with the specified string key. * @@ -294,10 +294,10 @@ public: * Then the new object will be inserted after that. * @param pObject The Object to be inserted. * @param key The string key for searching. - * @see setObject(Object*, const std::string&) + * @see setObject(Ref*, const std::string&) * @js NA */ - void setObject(Object* pObject, intptr_t key); + void setObject(Ref* pObject, intptr_t key); /** * Remove an object by the specified string key. @@ -357,7 +357,7 @@ public: * @js NA * @lua NA */ - Object* randomObject(); + Ref* randomObject(); /** * Create a dictionary. @@ -425,8 +425,8 @@ private: /** * For internal usage, invoked by setObject. */ - void setObjectUnSafe(Object* pObject, const std::string& key); - void setObjectUnSafe(Object* pObject, const intptr_t key); + void setObjectUnSafe(Ref* pObject, const std::string& key); + void setObjectUnSafe(Ref* pObject, const intptr_t key); public: /** diff --git a/cocos/base/CCDouble.h b/cocos/base/CCDouble.h index 0b01eb10e5..d042450837 100644 --- a/cocos/base/CCDouble.h +++ b/cocos/base/CCDouble.h @@ -25,7 +25,8 @@ #ifndef __CCDOUBLE_H__ #define __CCDOUBLE_H__ -#include "CCObject.h" +#include "CCRef.h" +#include "CCDataVisitor.h" NS_CC_BEGIN @@ -34,7 +35,7 @@ NS_CC_BEGIN * @{ */ -class CC_DLL __Double : public Object, public Clonable +class CC_DLL __Double : public Ref, public Clonable { public: __Double(double v) diff --git a/cocos/base/CCFloat.h b/cocos/base/CCFloat.h index 1c2c5e3e74..ce0d695347 100644 --- a/cocos/base/CCFloat.h +++ b/cocos/base/CCFloat.h @@ -25,7 +25,8 @@ #ifndef __CCFLOAT_H__ #define __CCFLOAT_H__ -#include "CCObject.h" +#include "CCRef.h" +#include "CCDataVisitor.h" NS_CC_BEGIN @@ -34,7 +35,7 @@ NS_CC_BEGIN * @{ */ -class CC_DLL __Float : public Object, public Clonable +class CC_DLL __Float : public Ref, public Clonable { public: __Float(float v) diff --git a/cocos/base/CCGeometry.h b/cocos/base/CCGeometry.h index 4f43ddda4b..368de0fd47 100644 --- a/cocos/base/CCGeometry.h +++ b/cocos/base/CCGeometry.h @@ -30,7 +30,6 @@ THE SOFTWARE. #include #include "CCPlatformMacros.h" -#include "CCObject.h" #include "ccMacros.h" NS_CC_BEGIN diff --git a/cocos/base/CCInteger.h b/cocos/base/CCInteger.h index f7a7b953ee..1b77cd51a7 100644 --- a/cocos/base/CCInteger.h +++ b/cocos/base/CCInteger.h @@ -25,7 +25,8 @@ #ifndef __CCINTEGER_H__ #define __CCINTEGER_H__ -#include "CCObject.h" +#include "CCRef.h" +#include "CCDataVisitor.h" #include "platform/CCCommon.h" NS_CC_BEGIN @@ -35,7 +36,7 @@ NS_CC_BEGIN * @{ */ -class CC_DLL __Integer : public Object, public Clonable +class CC_DLL __Integer : public Ref, public Clonable { public: static __Integer* create(int v) diff --git a/cocos/base/CCMap.h b/cocos/base/CCMap.h index 9f7b6b17f6..218de15024 100644 --- a/cocos/base/CCMap.h +++ b/cocos/base/CCMap.h @@ -28,7 +28,7 @@ #define USE_STD_UNORDERED_MAP 1 #include "ccMacros.h" -#include "CCObject.h" +#include "CCRef.h" #include #if USE_STD_UNORDERED_MAP @@ -73,7 +73,7 @@ public: Map() : _data() { - static_assert(std::is_convertible::value, "Invalid Type for cocos2d::Map!"); + static_assert(std::is_convertible::value, "Invalid Type for cocos2d::Map!"); CCLOGINFO("In the default constructor of Map!"); } @@ -81,7 +81,7 @@ public: explicit Map(ssize_t capacity) : _data() { - static_assert(std::is_convertible::value, "Invalid Type for cocos2d::Map!"); + static_assert(std::is_convertible::value, "Invalid Type for cocos2d::Map!"); CCLOGINFO("In the constructor with capacity of Map!"); _data.reserve(capacity); } @@ -89,7 +89,7 @@ public: /** Copy constructor */ Map(const Map& other) { - static_assert(std::is_convertible::value, "Invalid Type for cocos2d::Map!"); + static_assert(std::is_convertible::value, "Invalid Type for cocos2d::Map!"); CCLOGINFO("In the copy constructor of Map!"); _data = other._data; addRefForAllObjects(); @@ -98,7 +98,7 @@ public: /** Move constructor */ Map(Map&& other) { - static_assert(std::is_convertible::value, "Invalid Type for cocos2d::Map!"); + static_assert(std::is_convertible::value, "Invalid Type for cocos2d::Map!"); CCLOGINFO("In the move constructor of Map!"); _data = std::move(other._data); } diff --git a/cocos/base/CCObject.cpp b/cocos/base/CCRef.cpp similarity index 85% rename from cocos/base/CCObject.cpp rename to cocos/base/CCRef.cpp index 8a6c096e41..11a75b132d 100644 --- a/cocos/base/CCObject.cpp +++ b/cocos/base/CCRef.cpp @@ -23,24 +23,23 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#include "CCObject.h" +#include "CCRef.h" #include "CCAutoreleasePool.h" #include "ccMacros.h" #include "CCScriptSupport.h" NS_CC_BEGIN -Object::Object() -: _luaID(0) -, _referenceCount(1) // when the object is created, the reference count of it is 1 +Ref::Ref() +: _referenceCount(1) // when the Ref is created, the reference count of it is 1 +, _luaID(0) { static unsigned int uObjectCount = 0; - + _ID = ++uObjectCount; } -Object::~Object() +Ref::~Ref() { // if the object is referenced by Lua engine, remove it if (_luaID) @@ -57,15 +56,13 @@ Object::~Object() } } -Object* Object::autorelease() +void Ref::retain() { - PoolManager::getInstance()->getCurrentPool()->addObject(this); - return this; + CCASSERT(_referenceCount > 0, "reference count should greater than 0"); + ++_referenceCount; } - - -void Object::release() +void Ref::release() { CCASSERT(_referenceCount > 0, "reference count should greater than 0"); --_referenceCount; @@ -76,18 +73,18 @@ void Object::release() auto poolManager = PoolManager::getInstance(); if (!poolManager->getCurrentPool()->isClearing() && poolManager->isObjectInPools(this)) { - // Trigger an assert if the reference count is 0 but the object is still in autorelease pool. + // Trigger an assert if the reference count is 0 but the Ref is still in autorelease pool. // This happens when 'autorelease/release' were not used in pairs with 'new/retain'. // // Wrong usage (1): // - // auto obj = Node::create(); // Ref = 1, but it's an autorelease object which means it was in the autorelease pool. + // auto obj = Node::create(); // Ref = 1, but it's an autorelease Ref which means it was in the autorelease pool. // obj->autorelease(); // Wrong: If you wish to invoke autorelease several times, you should retain `obj` first. // // Wrong usage (2): // // auto obj = Node::create(); - // obj->release(); // Wrong: obj is an autorelease object, it will be released when clearing current pool. + // obj->release(); // Wrong: obj is an autorelease Ref, it will be released when clearing current pool. // // Correct usage (1): // @@ -110,24 +107,15 @@ void Object::release() } } -bool Object::isSingleReference() const +Ref* Ref::autorelease() { - return _referenceCount == 1; + PoolManager::getInstance()->getCurrentPool()->addObject(this); + return this; } -unsigned int Object::getReferenceCount() const +unsigned int Ref::getReferenceCount() const { return _referenceCount; } -bool Object::isEqual(const Object *object) -{ - return this == object; -} - -void Object::acceptVisitor(DataVisitor &visitor) -{ - visitor.visitObject(this); -} - NS_CC_END diff --git a/cocos/base/CCObject.h b/cocos/base/CCRef.h similarity index 51% rename from cocos/base/CCObject.h rename to cocos/base/CCRef.h index 414bc8d1fb..3e7b1df3db 100644 --- a/cocos/base/CCObject.h +++ b/cocos/base/CCRef.h @@ -23,16 +23,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#ifndef __CCOBJECT_H__ -#define __CCOBJECT_H__ +#ifndef __CCREF_H__ +#define __CCREF_H__ -#include "CCDataVisitor.h" -#include "ccMacros.h" -#include "CCConsole.h" - -#ifdef EMSCRIPTEN -#include -#endif // EMSCRIPTEN +#include "CCPlatformMacros.h" NS_CC_BEGIN @@ -41,14 +35,13 @@ NS_CC_BEGIN * @{ */ -class Object; -class Node; +class Ref; -/** Interface that defines how to clone an object */ +/** Interface that defines how to clone an Ref */ class CC_DLL Clonable { public: - /** returns a copy of the object */ + /** returns a copy of the Ref */ virtual Clonable* clone() const = 0; /** * @js NA @@ -56,10 +49,10 @@ public: */ virtual ~Clonable() {}; - /** returns a copy of the object. + /** returns a copy of the Ref. @deprecated Use clone() instead */ - CC_DEPRECATED_ATTRIBUTE Object* copy() const + CC_DEPRECATED_ATTRIBUTE Ref* copy() const { // use "clone" instead CC_ASSERT(false); @@ -67,37 +60,39 @@ public: } }; -class CC_DLL Object +class CC_DLL Ref { -public: - /// object id, ScriptSupport need public _ID - unsigned int _ID; - /// Lua reference id - int _luaID; -protected: - /// count of references - unsigned int _referenceCount; public: /** * Constructor * - * The object's reference count is 1 after construction. + * The Ref's reference count is 1 after construction. * @js NA */ - Object(); + Ref(); /** * @js NA * @lua NA */ - virtual ~Object(); + virtual ~Ref(); + + /** + * Retains the ownership. + * + * This increases the Ref's reference count. + * + * @see release, autorelease + * @js NA + */ + void retain(); /** * Release the ownership immediately. * - * This decrements the object's reference count. + * This decrements the Ref's reference count. * - * If the reference count reaches 0 after the descrement, this object is + * If the reference count reaches 0 after the descrement, this Ref is * destructed. * * @see retain, autorelease @@ -105,107 +100,63 @@ public: */ void release(); - /** - * Retains the ownership. - * - * This increases the object's reference count. - * - * @see release, autorelease - * @js NA - */ - inline void retain() - { - CCASSERT(_referenceCount > 0, "reference count should greater than 0"); - ++_referenceCount; - } - /** * Release the ownership sometime soon automatically. * - * This descrements the object's reference count at the end of current + * This descrements the Ref's reference count at the end of current * autorelease pool block. * - * If the reference count reaches 0 after the descrement, this object is + * If the reference count reaches 0 after the descrement, this Ref is * destructed. * - * @returns The object itself. + * @returns The Ref itself. * * @see AutoreleasePool, retain, release * @js NA * @lua NA */ - Object* autorelease(); + Ref* autorelease(); /** - * Returns a boolean value that indicates whether there is only one - * reference to the object. That is, whether the reference count is 1. + * Returns the Ref's current reference count. * - * @returns Whether the object's reference count is 1. + * @returns The Ref's reference count. * @js NA */ - CC_DEPRECATED_ATTRIBUTE bool isSingleReference() const; - - /** - * Returns the object's current reference count. - * - * @returns The object's reference count. - * @js NA - */ - CC_DEPRECATED_ATTRIBUTE unsigned int retainCount() const { return getReferenceCount(); }; unsigned int getReferenceCount() const; - /** - * Returns a boolean value that indicates whether this object and a given - * object are equal. - * - * @param object The object to be compared to this object. - * - * @returns True if this object and @p object are equal, otherwise false. - * @js NA - * @lua NA - */ - virtual bool isEqual(const Object* object); - /** - * @js NA - * @lua NA - */ - virtual void acceptVisitor(DataVisitor &visitor); - /** - * @js NA - * @lua NA - */ - virtual void update(float dt) {CC_UNUSED_PARAM(dt);}; +protected: + /// count of references + unsigned int _referenceCount; friend class AutoreleasePool; + +public: + /// object id, ScriptSupport need public _ID + unsigned int _ID; + /// Lua reference id + int _luaID; }; +class Node; -typedef void (Object::*SEL_SCHEDULE)(float); -typedef void (Object::*SEL_CallFunc)(); -typedef void (Object::*SEL_CallFuncN)(Node*); -typedef void (Object::*SEL_CallFuncND)(Node*, void*); -typedef void (Object::*SEL_CallFuncO)(Object*); -typedef void (Object::*SEL_MenuHandler)(Object*); -typedef int (Object::*SEL_Compare)(Object*); +typedef void (Ref::*SEL_CallFunc)(); +typedef void (Ref::*SEL_CallFuncN)(Node*); +typedef void (Ref::*SEL_CallFuncND)(Node*, void*); +typedef void (Ref::*SEL_CallFuncO)(Ref*); +typedef void (Ref::*SEL_MenuHandler)(Ref*); +typedef void (Ref::*SEL_SCHEDULE)(float); -#define schedule_selector(_SELECTOR) static_cast(&_SELECTOR) #define callfunc_selector(_SELECTOR) static_cast(&_SELECTOR) #define callfuncN_selector(_SELECTOR) static_cast(&_SELECTOR) #define callfuncND_selector(_SELECTOR) static_cast(&_SELECTOR) #define callfuncO_selector(_SELECTOR) static_cast(&_SELECTOR) #define menu_selector(_SELECTOR) static_cast(&_SELECTOR) -#define event_selector(_SELECTOR) static_cast(&_SELECTOR) -#define compare_selector(_SELECTOR) static_cast(&_SELECTOR) - -// new callbacks based on C++11 -#define CC_CALLBACK_0(__selector__,__target__, ...) std::bind(&__selector__,__target__, ##__VA_ARGS__) -#define CC_CALLBACK_1(__selector__,__target__, ...) std::bind(&__selector__,__target__, std::placeholders::_1, ##__VA_ARGS__) -#define CC_CALLBACK_2(__selector__,__target__, ...) std::bind(&__selector__,__target__, std::placeholders::_1, std::placeholders::_2, ##__VA_ARGS__) -#define CC_CALLBACK_3(__selector__,__target__, ...) std::bind(&__selector__,__target__, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3 ##__VA_ARGS__) +#define schedule_selector(_SELECTOR) static_cast(&_SELECTOR) // end of base_nodes group /// @} NS_CC_END -#endif // __CCOBJECT_H__ +#endif // __CCREF_H__ diff --git a/cocos/base/CCSet.cpp b/cocos/base/CCSet.cpp index baca990f36..081b7a5de6 100644 --- a/cocos/base/CCSet.cpp +++ b/cocos/base/CCSet.cpp @@ -31,12 +31,12 @@ NS_CC_BEGIN __Set::__Set(void) { - _set = new set; + _set = new set; } -__Set::__Set(const __Set &r__SetObject) +__Set::__Set(const __Set &other) { - _set = new set(*r__SetObject._set); + _set = new set(*other._set); // call retain of members __SetIterator iter; @@ -91,7 +91,7 @@ int __Set::count(void) return (int)_set->size(); } -void __Set::addObject(Object *pObject) +void __Set::addObject(Ref *pObject) { if (_set->count(pObject) == 0) { @@ -100,7 +100,7 @@ void __Set::addObject(Object *pObject) } } -void __Set::removeObject(Object *pObject) +void __Set::removeObject(Ref *pObject) { if (_set->erase(pObject) > 0) { @@ -122,14 +122,14 @@ void __Set::removeAllObjects() tmp = it; ++tmp; - Object * obj = *it; + Ref * obj = *it; _set->erase(it); CC_SAFE_RELEASE(obj); it = tmp; } } -bool __Set::containsObject(Object *pObject) +bool __Set::containsObject(Ref *pObject) { return _set->find(pObject) != _set->end(); } @@ -144,7 +144,7 @@ __SetIterator __Set::end(void) return _set->end(); } -Object* __Set::anyObject() +Ref* __Set::anyObject() { if (!_set || _set->empty()) { diff --git a/cocos/base/CCSet.h b/cocos/base/CCSet.h index 266946df6b..dc7e27ddbb 100644 --- a/cocos/base/CCSet.h +++ b/cocos/base/CCSet.h @@ -27,7 +27,8 @@ THE SOFTWARE. #define __CC_SET_H__ #include -#include "CCObject.h" +#include "CCRef.h" +#include "CCDataVisitor.h" NS_CC_BEGIN @@ -36,9 +37,9 @@ NS_CC_BEGIN * @{ */ -typedef std::set::iterator __SetIterator; +typedef std::set::iterator __SetIterator; -class CC_DLL __Set : public Object +class CC_DLL __Set : public Ref { public: /** @@ -72,11 +73,11 @@ public: /** *@brief Add a element into Set, it will retain the element. */ - void addObject(Object *pObject); + void addObject(Ref *pObject); /** *@brief Remove the given element, nothing todo if no element equals pObject. */ - void removeObject(Object *pObject); + void removeObject(Ref *pObject); /** *@brief Remove all elements of the set */ @@ -84,7 +85,7 @@ public: /** *@brief Check if Set contains a element equals pObject. */ - bool containsObject(Object *pObject); + bool containsObject(Ref *pObject); /** *@brief Return the iterator that points to the first element. * @js NA @@ -100,7 +101,7 @@ public: /** *@brief Return the first element if it contains elements, or null if it doesn't contain any element. */ - Object* anyObject(); + Ref* anyObject(); /** * @js NA * @lua NA @@ -108,7 +109,7 @@ public: virtual void acceptVisitor(DataVisitor &visitor); private: - std::set *_set; + std::set *_set; }; // end of data_structure group diff --git a/cocos/base/CCString.cpp b/cocos/base/CCString.cpp index a6dfcf1e0d..bb40794e88 100644 --- a/cocos/base/CCString.cpp +++ b/cocos/base/CCString.cpp @@ -203,7 +203,7 @@ __Array* __String::componentsSeparatedByString(const char *delimiter) return result; } -bool __String::isEqual(const Object* pObject) +bool __String::isEqual(const Ref* pObject) { bool bRet = false; const __String* pStr = dynamic_cast(pObject); diff --git a/cocos/base/CCString.h b/cocos/base/CCString.h index 2b9778d559..630eee6ef3 100644 --- a/cocos/base/CCString.h +++ b/cocos/base/CCString.h @@ -33,8 +33,8 @@ THE SOFTWARE. #include #include #include - -#include "CCObject.h" +#include "CCArray.h" +#include "CCRef.h" NS_CC_BEGIN @@ -43,7 +43,7 @@ NS_CC_BEGIN * @{ */ -class CC_DLL __String : public Object, public Clonable +class CC_DLL __String : public Ref, public Clonable { public: /** @@ -145,7 +145,7 @@ public: /* override functions * @js NA */ - virtual bool isEqual(const Object* pObject); + virtual bool isEqual(const Ref* pObject); /** create a string with std string, you can also pass a c string pointer because the default constructor of std::string can access a c string pointer. * @return A String pointer which is an autorelease object pointer, diff --git a/cocos/base/CCVector.h b/cocos/base/CCVector.h index 128f5951b3..67485d1641 100644 --- a/cocos/base/CCVector.h +++ b/cocos/base/CCVector.h @@ -27,7 +27,7 @@ THE SOFTWARE. #define __CCVECTOR_H__ #include "ccMacros.h" -#include "CCObject.h" +#include "CCRef.h" #include #include #include // for std::find @@ -69,14 +69,14 @@ public: Vector() : _data() { - static_assert(std::is_convertible::value, "Invalid Type for cocos2d::Vector!"); + static_assert(std::is_convertible::value, "Invalid Type for cocos2d::Vector!"); } /** Constructor with a capacity */ explicit Vector(ssize_t capacity) : _data() { - static_assert(std::is_convertible::value, "Invalid Type for cocos2d::Vector!"); + static_assert(std::is_convertible::value, "Invalid Type for cocos2d::Vector!"); CCLOGINFO("In the default constructor with capacity of Vector."); reserve(capacity); } @@ -91,7 +91,7 @@ public: /** Copy constructor */ Vector(const Vector& other) { - static_assert(std::is_convertible::value, "Invalid Type for cocos2d::Vector!"); + static_assert(std::is_convertible::value, "Invalid Type for cocos2d::Vector!"); CCLOGINFO("In the copy constructor!"); _data = other._data; addRefForAllObjects(); @@ -100,7 +100,7 @@ public: /** Move constructor */ Vector(Vector&& other) { - static_assert(std::is_convertible::value, "Invalid Type for cocos2d::Vector!"); + static_assert(std::is_convertible::value, "Invalid Type for cocos2d::Vector!"); CCLOGINFO("In the move constructor of Vector!"); _data = std::move(other._data); } @@ -251,7 +251,7 @@ public: for (ssize_t i = 0; i < s; i++) { - if (!this->at(i)->isEqual(other.at(i))) + if (this->at(i) != other.at(i)) { return false; } diff --git a/cocos/editor-support/cocosbuilder/CCBAnimationManager.cpp b/cocos/editor-support/cocosbuilder/CCBAnimationManager.cpp index b96a8c2ba5..e1184f1464 100644 --- a/cocos/editor-support/cocosbuilder/CCBAnimationManager.cpp +++ b/cocos/editor-support/cocosbuilder/CCBAnimationManager.cpp @@ -188,9 +188,9 @@ CCBAnimationManagerDelegate* CCBAnimationManager::getDelegate() void CCBAnimationManager::setDelegate(CCBAnimationManagerDelegate *pDelegate) { - CC_SAFE_RELEASE(dynamic_cast(_delegate)); + CC_SAFE_RELEASE(dynamic_cast(_delegate)); _delegate = pDelegate; - CC_SAFE_RETAIN(dynamic_cast(_delegate)); + CC_SAFE_RETAIN(dynamic_cast(_delegate)); } const char* CCBAnimationManager::getRunningSequenceName() @@ -234,7 +234,7 @@ const Value& CCBAnimationManager::getBaseValue(Node *pNode, const std::string& p return props[propName]; } -void CCBAnimationManager::setObject(Object* obj, Node *pNode, const std::string& propName) +void CCBAnimationManager::setObject(Ref* obj, Node *pNode, const std::string& propName) { auto& props = _objects[pNode]; auto iter = props.find(propName); @@ -245,7 +245,7 @@ void CCBAnimationManager::setObject(Object* obj, Node *pNode, const std::string& obj->retain(); } -Object* CCBAnimationManager::getObject(Node *pNode, const std::string& propName) +Ref* CCBAnimationManager::getObject(Node *pNode, const std::string& propName) { auto& props = _objects[pNode]; auto iter = props.find(propName); @@ -420,7 +420,7 @@ ActionInterval* CCBAnimationManager::getAction(CCBKeyframe *pKeyframe0, CCBKeyfr return nullptr; } -void CCBAnimationManager::setAnimatedProperty(const std::string& propName, Node *pNode, const Value& value, Object* obj, float fTweenDuration) +void CCBAnimationManager::setAnimatedProperty(const std::string& propName, Node *pNode, const Value& value, Ref* obj, float fTweenDuration) { if (fTweenDuration > 0) { @@ -615,7 +615,7 @@ ActionInterval* CCBAnimationManager::getEaseAction(ActionInterval *pAction, CCBK } } -Object* CCBAnimationManager::actionForCallbackChannel(CCBSequenceProperty* channel) { +Sequence* CCBAnimationManager::actionForCallbackChannel(CCBSequenceProperty* channel) { float lastKeyframeTime = 0; @@ -655,7 +655,7 @@ Object* CCBAnimationManager::actionForCallbackChannel(CCBSequenceProperty* chann } else { - Object* target = nullptr; + Ref* target = nullptr; if(selectorTarget == CCBReader::TargetType::DOCUMENT_ROOT) target = _rootNode; @@ -681,7 +681,7 @@ Object* CCBAnimationManager::actionForCallbackChannel(CCBSequenceProperty* chann } else { - auto savedTarget = std::make_shared>(); + auto savedTarget = std::make_shared>(); savedTarget->pushBack(target); auto callback = CallFuncN::create([savedTarget, selCallFunc](Node* sender){ @@ -701,10 +701,10 @@ Object* CCBAnimationManager::actionForCallbackChannel(CCBSequenceProperty* chann } if(actions.size() < 1) return nullptr; - return (Object *) Sequence::create(actions); + return Sequence::create(actions); } -Object* CCBAnimationManager::actionForSoundChannel(CCBSequenceProperty* channel) { +Sequence* CCBAnimationManager::actionForSoundChannel(CCBSequenceProperty* channel) { float lastKeyframeTime = 0; @@ -901,7 +901,7 @@ void CCBAnimationManager::debug() } -void CCBAnimationManager::setAnimationCompletedCallback(Object *target, SEL_CallFunc callbackFunc) { +void CCBAnimationManager::setAnimationCompletedCallback(Ref *target, SEL_CallFunc callbackFunc) { if (target) { target->retain(); diff --git a/cocos/editor-support/cocosbuilder/CCBAnimationManager.h b/cocos/editor-support/cocosbuilder/CCBAnimationManager.h index f1f351a631..73babb1a47 100644 --- a/cocos/editor-support/cocosbuilder/CCBAnimationManager.h +++ b/cocos/editor-support/cocosbuilder/CCBAnimationManager.h @@ -20,7 +20,7 @@ public: virtual void completedAnimationSequenceNamed(const char *name) = 0; }; -class CCBAnimationManager : public cocos2d::Object +class CCBAnimationManager : public cocos2d::Ref { public: bool _jsControlled; @@ -35,7 +35,7 @@ public: ~CCBAnimationManager(); - cocos2d::Object *_owner; + cocos2d::Ref *_owner; virtual bool init(); @@ -82,7 +82,7 @@ public: void addNode(cocos2d::Node *pNode, const std::unordered_map>& seq); void setBaseValue(const cocos2d::Value& value, cocos2d::Node *pNode, const std::string& propName); - void setObject(cocos2d::Object* obj, cocos2d::Node *pNode, const std::string& propName); + void setObject(cocos2d::Ref* obj, cocos2d::Node *pNode, const std::string& propName); void moveAnimationsFromNode(cocos2d::Node* fromNode, cocos2d::Node* toNode); @@ -100,7 +100,7 @@ public: * when this function bound to js ,the second param are callfunc_selector * @lua NA */ - void setAnimationCompletedCallback(cocos2d::Object *target, cocos2d::SEL_CallFunc callbackFunc); + void setAnimationCompletedCallback(cocos2d::Ref *target, cocos2d::SEL_CallFunc callbackFunc); void debug(); /** @@ -108,8 +108,8 @@ public: */ void setCallFunc(cocos2d::CallFunc *callFunc, const std::string &callbackNamed); - cocos2d::Object* actionForCallbackChannel(CCBSequenceProperty* channel); - cocos2d::Object* actionForSoundChannel(CCBSequenceProperty* channel); + cocos2d::Sequence* actionForCallbackChannel(CCBSequenceProperty* channel); + cocos2d::Sequence* actionForSoundChannel(CCBSequenceProperty* channel); // return -1 if timeline not exsit int getSequenceId(const char* pSequenceName); @@ -119,11 +119,11 @@ public: private: const cocos2d::Value& getBaseValue(cocos2d::Node *pNode, const std::string& propName); - Object* getObject(cocos2d::Node *pNode, const std::string& propName); + Ref* getObject(cocos2d::Node *pNode, const std::string& propName); CCBSequence* getSequence(int nSequenceId); cocos2d::ActionInterval* getAction(CCBKeyframe *pKeyframe0, CCBKeyframe *pKeyframe1, const std::string& propName, cocos2d::Node *pNode); - void setAnimatedProperty(const std::string& propName,cocos2d::Node *pNode, const cocos2d::Value& value, Object* obj, float fTweenDuraion); + void setAnimatedProperty(const std::string& propName,cocos2d::Node *pNode, const cocos2d::Value& value, Ref* obj, float fTweenDuraion); void setFirstFrame(cocos2d::Node *pNode, CCBSequenceProperty *pSeqProp, float fTweenDuration); cocos2d::ActionInterval* getEaseAction(cocos2d::ActionInterval *pAction, CCBKeyframe::EasingType easingType, float fEasingOpt); void runAction(cocos2d::Node *pNode, CCBSequenceProperty *pSeqProp, float fTweenDuration); @@ -133,7 +133,7 @@ private: cocos2d::Vector _sequences; std::unordered_map>> _nodeSequences; std::unordered_map> _baseValues; - std::unordered_map> _objects; + std::unordered_map> _objects; int _autoPlaySequenceId; @@ -156,7 +156,8 @@ private: std::string _lastCompletedSequenceName; cocos2d::SEL_CallFunc _animationCompleteCallbackFunc; - cocos2d::Object *_target; + cocos2d::Ref *_target; + }; class CCBSetSpriteFrame : public cocos2d::ActionInstant diff --git a/cocos/editor-support/cocosbuilder/CCBKeyframe.cpp b/cocos/editor-support/cocosbuilder/CCBKeyframe.cpp index 36f79370e6..ef0ffcdeea 100644 --- a/cocos/editor-support/cocosbuilder/CCBKeyframe.cpp +++ b/cocos/editor-support/cocosbuilder/CCBKeyframe.cpp @@ -26,12 +26,12 @@ void CCBKeyframe::setValue(const Value& value) _value = value; } -Object* CCBKeyframe::getObject() const +Ref* CCBKeyframe::getObject() const { return _object; } -void CCBKeyframe::setObject(Object* obj) +void CCBKeyframe::setObject(Ref* obj) { CC_SAFE_RETAIN(obj); CC_SAFE_RELEASE(_object); diff --git a/cocos/editor-support/cocosbuilder/CCBKeyframe.h b/cocos/editor-support/cocosbuilder/CCBKeyframe.h index e3c009e2df..e05a22be92 100644 --- a/cocos/editor-support/cocosbuilder/CCBKeyframe.h +++ b/cocos/editor-support/cocosbuilder/CCBKeyframe.h @@ -1,13 +1,13 @@ #ifndef __CCB_KEYFRAME_H__ #define __CCB_KEYFRAME_H__ -#include "CCObject.h" +#include "CCRef.h" #include "CCValue.h" namespace cocosbuilder { -class CCBKeyframe : public cocos2d::Object +class CCBKeyframe : public cocos2d::Ref { public: enum class EasingType @@ -45,8 +45,8 @@ public: const cocos2d::Value& getValue() const; void setValue(const cocos2d::Value& value); - cocos2d::Object* getObject() const; - void setObject(cocos2d::Object* obj); + cocos2d::Ref* getObject() const; + void setObject(cocos2d::Ref* obj); float getTime(); void setTime(float fTime); @@ -59,7 +59,7 @@ public: private: cocos2d::Value _value; - cocos2d::Object* _object; + cocos2d::Ref* _object; float _time; EasingType _easingType; float _easingOpt; diff --git a/cocos/editor-support/cocosbuilder/CCBMemberVariableAssigner.h b/cocos/editor-support/cocosbuilder/CCBMemberVariableAssigner.h index 4cafab98d6..aacaba03c3 100644 --- a/cocos/editor-support/cocosbuilder/CCBMemberVariableAssigner.h +++ b/cocos/editor-support/cocosbuilder/CCBMemberVariableAssigner.h @@ -39,7 +39,7 @@ class CCBMemberVariableAssigner { * @param node The member variable. * @return Whether the assignment was successful. */ - virtual bool onAssignCCBMemberVariable(cocos2d::Object* target, const char* memberVariableName, cocos2d::Node* node) = 0; + virtual bool onAssignCCBMemberVariable(cocos2d::Ref* target, const char* memberVariableName, cocos2d::Node* node) = 0; /** * The callback function of assigning custom properties. @@ -49,7 +49,7 @@ class CCBMemberVariableAssigner { * @param value The value of the property. * @return Whether the assignment was successful. */ - virtual bool onAssignCCBCustomProperty(cocos2d::Object* target, const char* memberVariableName, const cocos2d::Value& value) { return false; }; + virtual bool onAssignCCBCustomProperty(cocos2d::Ref* target, const char* memberVariableName, const cocos2d::Value& value) { return false; }; }; } diff --git a/cocos/editor-support/cocosbuilder/CCBReader.cpp b/cocos/editor-support/cocosbuilder/CCBReader.cpp index 056f2553d0..c915518788 100644 --- a/cocos/editor-support/cocosbuilder/CCBReader.cpp +++ b/cocos/editor-support/cocosbuilder/CCBReader.cpp @@ -192,7 +192,7 @@ set& CCBReader::getLoadedSpriteSheet() return _loadedSpriteSheets; } -Object* CCBReader::getOwner() +Ref* CCBReader::getOwner() { return _owner; } @@ -202,12 +202,12 @@ Node* CCBReader::readNodeGraphFromFile(const char *pCCBFileName) return this->readNodeGraphFromFile(pCCBFileName, nullptr); } -Node* CCBReader::readNodeGraphFromFile(const char* pCCBFileName, Object* pOwner) +Node* CCBReader::readNodeGraphFromFile(const char* pCCBFileName, Ref* pOwner) { return this->readNodeGraphFromFile(pCCBFileName, pOwner, Director::getInstance()->getWinSize()); } -Node* CCBReader::readNodeGraphFromFile(const char *pCCBFileName, Object *pOwner, const Size &parentSize) +Node* CCBReader::readNodeGraphFromFile(const char *pCCBFileName, Ref *pOwner, const Size &parentSize) { if (nullptr == pCCBFileName || strlen(pCCBFileName) == 0) { @@ -231,7 +231,7 @@ Node* CCBReader::readNodeGraphFromFile(const char *pCCBFileName, Object *pOwner, return ret; } -Node* CCBReader::readNodeGraphFromData(std::shared_ptr data, Object *pOwner, const Size &parentSize) +Node* CCBReader::readNodeGraphFromData(std::shared_ptr data, Ref *pOwner, const Size &parentSize) { _data = data; _bytes =_data->getBytes(); @@ -274,12 +274,12 @@ Scene* CCBReader::createSceneWithNodeGraphFromFile(const char *pCCBFileName) return createSceneWithNodeGraphFromFile(pCCBFileName, nullptr); } -Scene* CCBReader::createSceneWithNodeGraphFromFile(const char *pCCBFileName, Object *pOwner) +Scene* CCBReader::createSceneWithNodeGraphFromFile(const char *pCCBFileName, Ref *pOwner) { return createSceneWithNodeGraphFromFile(pCCBFileName, pOwner, Director::getInstance()->getWinSize()); } -Scene* CCBReader::createSceneWithNodeGraphFromFile(const char *pCCBFileName, Object *pOwner, const Size &parentSize) +Scene* CCBReader::createSceneWithNodeGraphFromFile(const char *pCCBFileName, Ref *pOwner, const Size &parentSize) { Node *pNode = readNodeGraphFromFile(pCCBFileName, pOwner, parentSize); Scene *pScene = Scene::create(); @@ -626,7 +626,7 @@ Node * CCBReader::readNodeGraph(Node * pParent) { if(!_jsControlled) { - Object * target = nullptr; + Ref* target = nullptr; if(memberVarAssignmentType == TargetType::DOCUMENT_ROOT) { target = _animationManager->getRootNode(); @@ -677,7 +677,7 @@ Node * CCBReader::readNodeGraph(Node * pParent) if(!_jsControlled) { - Object * target = node; + Ref* target = node; if(target != nullptr) { CCBMemberVariableAssigner * targetAsCCBMemberVariableAssigner = dynamic_cast(target); diff --git a/cocos/editor-support/cocosbuilder/CCBReader.h b/cocos/editor-support/cocosbuilder/CCBReader.h index 3c2a39c763..0fc9bef999 100644 --- a/cocos/editor-support/cocosbuilder/CCBReader.h +++ b/cocos/editor-support/cocosbuilder/CCBReader.h @@ -6,7 +6,6 @@ #include "CCNode.h" #include "CCData.h" #include "CCMap.h" - #include "CCBSequence.h" #include "extensions/GUI/CCControlExtension/CCControl.h" @@ -65,7 +64,7 @@ class CCBKeyframe; /** * @brief Parse CCBI file which is generated by CocosBuilder */ -class CCBReader : public cocos2d::Object +class CCBReader : public cocos2d::Ref { public: enum class PropertyType { @@ -170,13 +169,13 @@ public: const std::string& getCCBRootPath() const; cocos2d::Node* readNodeGraphFromFile(const char *pCCBFileName); - cocos2d::Node* readNodeGraphFromFile(const char *pCCBFileName, cocos2d::Object *pOwner); - cocos2d::Node* readNodeGraphFromFile(const char *pCCBFileName, cocos2d::Object *pOwner, const cocos2d::Size &parentSize); + cocos2d::Node* readNodeGraphFromFile(const char *pCCBFileName, cocos2d::Ref *pOwner); + cocos2d::Node* readNodeGraphFromFile(const char *pCCBFileName, cocos2d::Ref *pOwner, const cocos2d::Size &parentSize); /** * @js NA * @lua NA */ - cocos2d::Node* readNodeGraphFromData(std::shared_ptr data, cocos2d::Object *pOwner, const cocos2d::Size &parentSize); + cocos2d::Node* readNodeGraphFromData(std::shared_ptr data, cocos2d::Ref *pOwner, const cocos2d::Size &parentSize); /** @lua NA @@ -185,11 +184,11 @@ public: /** @lua NA */ - cocos2d::Scene* createSceneWithNodeGraphFromFile(const char *pCCBFileName, cocos2d::Object *pOwner); + cocos2d::Scene* createSceneWithNodeGraphFromFile(const char *pCCBFileName, cocos2d::Ref *pOwner); /** @lua NA */ - cocos2d::Scene* createSceneWithNodeGraphFromFile(const char *pCCBFileName, cocos2d::Object *pOwner, const cocos2d::Size &parentSize); + cocos2d::Scene* createSceneWithNodeGraphFromFile(const char *pCCBFileName, cocos2d::Ref *pOwner, const cocos2d::Size &parentSize); /** * @js NA @@ -227,7 +226,7 @@ public: * @js NA * @lua NA */ - cocos2d::Object* getOwner(); + cocos2d::Ref* getOwner(); /* Utility methods. * @js NA @@ -371,7 +370,7 @@ private: std::vector _stringCache; std::set _loadedSpriteSheets; - cocos2d::Object *_owner; + cocos2d::Ref *_owner; CCBAnimationManager* _animationManager; //retain CCBAnimationManagerMapPtr _animationManagers; diff --git a/cocos/editor-support/cocosbuilder/CCBSelectorResolver.h b/cocos/editor-support/cocosbuilder/CCBSelectorResolver.h index 110d2ced61..e52e8bc94e 100644 --- a/cocos/editor-support/cocosbuilder/CCBSelectorResolver.h +++ b/cocos/editor-support/cocosbuilder/CCBSelectorResolver.h @@ -25,9 +25,9 @@ class CCBSelectorResolver { * @lua NA */ virtual ~CCBSelectorResolver() {}; - virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::Object * pTarget, const char* pSelectorName) = 0; - virtual cocos2d::SEL_CallFuncN onResolveCCBCCCallFuncSelector(cocos2d::Object * pTarget, const char* pSelectorName) { return NULL; }; - virtual cocos2d::extension::Control::Handler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, const char* pSelectorName) = 0; + virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::Ref * pTarget, const char* pSelectorName) = 0; + virtual cocos2d::SEL_CallFuncN onResolveCCBCCCallFuncSelector(cocos2d::Ref * pTarget, const char* pSelectorName) { return NULL; }; + virtual cocos2d::extension::Control::Handler onResolveCCBCCControlSelector(cocos2d::Ref * pTarget, const char* pSelectorName) = 0; }; diff --git a/cocos/editor-support/cocosbuilder/CCBSequence.h b/cocos/editor-support/cocosbuilder/CCBSequence.h index 045fa536b5..2a020c96d8 100644 --- a/cocos/editor-support/cocosbuilder/CCBSequence.h +++ b/cocos/editor-support/cocosbuilder/CCBSequence.h @@ -3,12 +3,12 @@ #include -#include "CCObject.h" +#include "CCRef.h" #include "CCBSequenceProperty.h" namespace cocosbuilder { -class CCBSequence : public cocos2d::Object +class CCBSequence : public cocos2d::Ref { public: CCBSequence(); diff --git a/cocos/editor-support/cocosbuilder/CCBSequenceProperty.h b/cocos/editor-support/cocosbuilder/CCBSequenceProperty.h index fe19b15596..40be11e94a 100644 --- a/cocos/editor-support/cocosbuilder/CCBSequenceProperty.h +++ b/cocos/editor-support/cocosbuilder/CCBSequenceProperty.h @@ -1,13 +1,13 @@ #ifndef __CCB_SEQUENCE_PROPERTY_H__ #define __CCB_SEQUENCE_PROPERTY_H__ -#include "CCObject.h" +#include "CCRef.h" #include "CCVector.h" #include "CCBKeyframe.h" namespace cocosbuilder { -class CCBSequenceProperty : public cocos2d::Object +class CCBSequenceProperty : public cocos2d::Ref { public: /** diff --git a/cocos/editor-support/cocosbuilder/CCLabelBMFontLoader.h b/cocos/editor-support/cocosbuilder/CCLabelBMFontLoader.h index c24239c3f2..6b64975fa5 100644 --- a/cocos/editor-support/cocosbuilder/CCLabelBMFontLoader.h +++ b/cocos/editor-support/cocosbuilder/CCLabelBMFontLoader.h @@ -1,7 +1,7 @@ #ifndef _CCB_CCLABELBMFONTLOADER_H_ #define _CCB_CCLABELBMFONTLOADER_H_ -#include "CCObject.h" +#include "CCRef.h" #include "CCLabelBMFont.h" #include "CCNodeLoader.h" diff --git a/cocos/editor-support/cocosbuilder/CCLabelTTFLoader.h b/cocos/editor-support/cocosbuilder/CCLabelTTFLoader.h index aa0fc0cdfe..2809fe3bfd 100644 --- a/cocos/editor-support/cocosbuilder/CCLabelTTFLoader.h +++ b/cocos/editor-support/cocosbuilder/CCLabelTTFLoader.h @@ -1,7 +1,7 @@ #ifndef _CCB_CCLABELTTFLOADER_H_ #define _CCB_CCLABELTTFLOADER_H_ -#include "CCObject.h" +#include "CCRef.h" #include "CCLabelTTF.h" #include "CCNodeLoader.h" diff --git a/cocos/editor-support/cocosbuilder/CCMenuItemLoader.h b/cocos/editor-support/cocosbuilder/CCMenuItemLoader.h index 1156a46f13..ba3424b49c 100644 --- a/cocos/editor-support/cocosbuilder/CCMenuItemLoader.h +++ b/cocos/editor-support/cocosbuilder/CCMenuItemLoader.h @@ -1,7 +1,7 @@ #ifndef _CCB_CCMENUITEMLOADER_H_ #define _CCB_CCMENUITEMLOADER_H_ -#include "CCObject.h" +#include "CCRef.h" #include "CCMenuItem.h" #include "CCLayerLoader.h" diff --git a/cocos/editor-support/cocosbuilder/CCMenuLoader.h b/cocos/editor-support/cocosbuilder/CCMenuLoader.h index 75ff815f26..2dd3dae922 100644 --- a/cocos/editor-support/cocosbuilder/CCMenuLoader.h +++ b/cocos/editor-support/cocosbuilder/CCMenuLoader.h @@ -2,7 +2,7 @@ #define _CCB_CCMENULOADER_H_ #include "CCLayerLoader.h" -#include "CCObject.h" +#include "CCRef.h" #include "CCMenu.h" namespace cocosbuilder { diff --git a/cocos/editor-support/cocosbuilder/CCNodeLoader.cpp b/cocos/editor-support/cocosbuilder/CCNodeLoader.cpp index 598f6cad11..2d0bffe22f 100644 --- a/cocos/editor-support/cocosbuilder/CCNodeLoader.cpp +++ b/cocos/editor-support/cocosbuilder/CCNodeLoader.cpp @@ -80,7 +80,7 @@ void NodeLoader::parseProperties(Node * pNode, Node * pParent, CCBReader * ccbRe // Skip properties that doesn't have a value to override Array *extraPropsNames = (Array*)pNode->getUserObject(); - Object* pObj = NULL; + Ref* pObj = NULL; bool bFound = false; CCARRAY_FOREACH(extraPropsNames, pObj) { @@ -761,7 +761,7 @@ BlockData * NodeLoader::parsePropTypeBlock(Node * pNode, Node * pParent, CCBRead if(selectorTarget != CCBReader::TargetType::NONE) { - Object * target = NULL; + Ref* target = NULL; if(!ccbReader->isJSControlled()) { if(selectorTarget == CCBReader::TargetType::DOCUMENT_ROOT) @@ -844,7 +844,7 @@ BlockControlData * NodeLoader::parsePropTypeBlockControl(Node * pNode, Node * pP { if(!ccbReader->isJSControlled()) { - Object * target = NULL; + Ref* target = NULL; if(selectorTarget == CCBReader::TargetType::DOCUMENT_ROOT) { target = ccbReader->getAnimationManager()->getRootNode(); diff --git a/cocos/editor-support/cocosbuilder/CCNodeLoader.h b/cocos/editor-support/cocosbuilder/CCNodeLoader.h index e67fcb047f..9845abb623 100644 --- a/cocos/editor-support/cocosbuilder/CCNodeLoader.h +++ b/cocos/editor-support/cocosbuilder/CCNodeLoader.h @@ -30,19 +30,19 @@ namespace cocosbuilder { struct BlockData { cocos2d::SEL_MenuHandler mSELMenuHandler; - cocos2d::Object * _target; + cocos2d::Ref * _target; }; struct BlockControlData { cocos2d::extension::Control::Handler mSELControlHandler; - cocos2d::Object * _target; + cocos2d::Ref * _target; cocos2d::extension::Control::EventType mControlEvents; }; /* Forward declaration. */ class CCBReader; -class NodeLoader : public cocos2d::Object { +class NodeLoader : public cocos2d::Ref { public: /** * @js NA diff --git a/cocos/editor-support/cocosbuilder/CCNodeLoaderLibrary.h b/cocos/editor-support/cocosbuilder/CCNodeLoaderLibrary.h index 6fe711feda..eeb20256a0 100644 --- a/cocos/editor-support/cocosbuilder/CCNodeLoaderLibrary.h +++ b/cocos/editor-support/cocosbuilder/CCNodeLoaderLibrary.h @@ -10,7 +10,7 @@ class NodeLoader; typedef std::map NodeLoaderMap; typedef std::pair NodeLoaderMapEntry; -class NodeLoaderLibrary : public cocos2d::Object +class NodeLoaderLibrary : public cocos2d::Ref { public: /** diff --git a/cocos/editor-support/cocosbuilder/CCParticleSystemQuadLoader.h b/cocos/editor-support/cocosbuilder/CCParticleSystemQuadLoader.h index 64efbdecba..2c47ec7682 100644 --- a/cocos/editor-support/cocosbuilder/CCParticleSystemQuadLoader.h +++ b/cocos/editor-support/cocosbuilder/CCParticleSystemQuadLoader.h @@ -1,7 +1,7 @@ #ifndef _CCB_CCPARTICLESYSTEMQUADLOADER_H_ #define _CCB_CCPARTICLESYSTEMQUADLOADER_H_ -#include "CCObject.h" +#include "CCRef.h" #include "CCParticleSystemQuad.h" #include "CCNodeLoader.h" diff --git a/cocos/editor-support/cocostudio/CCActionFrame.h b/cocos/editor-support/cocostudio/CCActionFrame.h index 9ff01ddf05..f83d480ff0 100644 --- a/cocos/editor-support/cocostudio/CCActionFrame.h +++ b/cocos/editor-support/cocostudio/CCActionFrame.h @@ -92,7 +92,7 @@ enum class FrameEaseType * @js NA * @lua NA */ -class ActionFrame:public cocos2d::Object +class ActionFrame: public cocos2d::Ref { public: diff --git a/cocos/editor-support/cocostudio/CCActionFrameEasing.h b/cocos/editor-support/cocostudio/CCActionFrameEasing.h index 1ae824e482..4ccee0de99 100644 --- a/cocos/editor-support/cocostudio/CCActionFrameEasing.h +++ b/cocos/editor-support/cocostudio/CCActionFrameEasing.h @@ -25,7 +25,7 @@ THE SOFTWARE. #ifndef __ActionFrameEasing_H__ #define __ActionFrameEasing_H__ -#include "CCObject.h" +#include "CCRef.h" namespace cocostudio { @@ -56,7 +56,7 @@ enum FrameEasingType * @js NA * @lua NA */ -class ActionFrameEasing:public cocos2d::Object +class ActionFrameEasing:public cocos2d::Ref { protected: FrameEasingType _type; diff --git a/cocos/editor-support/cocostudio/CCActionManagerEx.cpp b/cocos/editor-support/cocostudio/CCActionManagerEx.cpp index e0bfad1a31..321d5c470c 100644 --- a/cocos/editor-support/cocostudio/CCActionManagerEx.cpp +++ b/cocos/editor-support/cocostudio/CCActionManagerEx.cpp @@ -53,7 +53,7 @@ ActionManagerEx::~ActionManagerEx() _actionDic.clear(); } -void ActionManagerEx::initWithDictionary(const char* jsonName,const rapidjson::Value &dic,Object* root) +void ActionManagerEx::initWithDictionary(const char* jsonName,const rapidjson::Value &dic, Ref* root) { std::string path = jsonName; ssize_t pos = path.find_last_of("/"); diff --git a/cocos/editor-support/cocostudio/CCActionManagerEx.h b/cocos/editor-support/cocostudio/CCActionManagerEx.h index ba4e0c7804..b33b099342 100644 --- a/cocos/editor-support/cocostudio/CCActionManagerEx.h +++ b/cocos/editor-support/cocostudio/CCActionManagerEx.h @@ -30,7 +30,7 @@ THE SOFTWARE. namespace cocostudio { -class ActionManagerEx:public cocos2d::Object +class ActionManagerEx:public cocos2d::Ref { public: @@ -95,7 +95,7 @@ public: ActionObject* playActionByName(const char* jsonName,const char* actionName, cocos2d::CallFunc* func); /*init properties with json dictionay*/ - void initWithDictionary(const char* jsonName,const rapidjson::Value &dic, Object* root); + void initWithDictionary(const char* jsonName,const rapidjson::Value &dic, Ref* root); /** * Release all actions. * diff --git a/cocos/editor-support/cocostudio/CCActionNode.cpp b/cocos/editor-support/cocostudio/CCActionNode.cpp index 22f7164264..b01b83c703 100644 --- a/cocos/editor-support/cocostudio/CCActionNode.cpp +++ b/cocos/editor-support/cocostudio/CCActionNode.cpp @@ -69,7 +69,7 @@ ActionNode::~ActionNode() _frameArray.clear(); } -void ActionNode::initWithDictionary(const rapidjson::Value& dic,Object* root) +void ActionNode::initWithDictionary(const rapidjson::Value& dic, Ref* root) { setActionTag(DICTOOL->getIntValue_json(dic, "ActionTag")); int actionFrameCount = DICTOOL->getArrayCount_json(dic, "actionframelist"); @@ -146,7 +146,7 @@ void ActionNode::initWithDictionary(const rapidjson::Value& dic,Object* root) initActionNodeFromRoot(root); } -void ActionNode::initActionNodeFromRoot(Object* root) +void ActionNode::initActionNodeFromRoot(Ref* root) { Node* rootNode = dynamic_cast(root); if (rootNode != nullptr) @@ -184,12 +184,12 @@ int ActionNode::getActionTag() return _actionTag; } -void ActionNode::setObject(Object* node) +void ActionNode::setObject(Ref* node) { _object = node; } -Object* ActionNode::getObject() +Ref* ActionNode::getObject() { return _object; } diff --git a/cocos/editor-support/cocostudio/CCActionNode.h b/cocos/editor-support/cocostudio/CCActionNode.h index 9a2195327d..f0043cb264 100644 --- a/cocos/editor-support/cocostudio/CCActionNode.h +++ b/cocos/editor-support/cocostudio/CCActionNode.h @@ -34,7 +34,7 @@ namespace cocostudio { * @js NA * @lua NA */ -class ActionNode:public cocos2d::Object +class ActionNode : public cocos2d::Ref { public: @@ -79,14 +79,14 @@ public: * * @param node which will run a action */ - void setObject(cocos2d::Object* node); + void setObject(cocos2d::Ref* node); /** * Gets node which will run a action. * * @return node which will run a action */ - cocos2d::Object* getObject(); + cocos2d::Ref* getObject(); /** * Insets a ActionFrame to ActionNode. @@ -148,7 +148,7 @@ public: virtual void stopAction(); /*init properties with a json dictionary*/ - virtual void initWithDictionary(const rapidjson::Value& dic,Object* root); + virtual void initWithDictionary(const rapidjson::Value& dic, cocos2d::Ref* root); /** * Gets if the action is done once time. @@ -165,7 +165,7 @@ protected: int _actionTag; cocos2d::Spawn * _actionSpawn; cocos2d::Action* _action; - cocos2d::Object* _object; + cocos2d::Ref* _object; std::vector*> _frameArray; int _frameArrayNum; @@ -174,7 +174,7 @@ protected: virtual cocos2d::Node* getActionNode(); virtual cocos2d::Spawn * refreshActionProperty(); virtual void runAction(); - virtual void initActionNodeFromRoot(cocos2d::Object* root); + virtual void initActionNodeFromRoot(cocos2d::Ref* root); virtual void easingToFrame(float duration,float delayTime,ActionFrame* srcFrame,ActionFrame* destFrame); }; diff --git a/cocos/editor-support/cocostudio/CCActionObject.cpp b/cocos/editor-support/cocostudio/CCActionObject.cpp index 57291ae369..62b2b8040f 100644 --- a/cocos/editor-support/cocostudio/CCActionObject.cpp +++ b/cocos/editor-support/cocostudio/CCActionObject.cpp @@ -104,7 +104,7 @@ bool ActionObject::isPlaying() return _bPlaying; } -void ActionObject::initWithDictionary(const rapidjson::Value& dic, Object* root) +void ActionObject::initWithDictionary(const rapidjson::Value& dic, Ref* root) { setName(DICTOOL->getStringValue_json(dic, "name")); setLoop(DICTOOL->getBooleanValue_json(dic, "loop")); diff --git a/cocos/editor-support/cocostudio/CCActionObject.h b/cocos/editor-support/cocostudio/CCActionObject.h index 249489b620..4d6443df6a 100644 --- a/cocos/editor-support/cocostudio/CCActionObject.h +++ b/cocos/editor-support/cocostudio/CCActionObject.h @@ -34,7 +34,7 @@ namespace cocostudio { * @js NA * @lua NA */ -class ActionObject:public cocos2d::Object +class ActionObject : public cocos2d::Ref { public: @@ -158,12 +158,12 @@ public: void updateToFrameByTime(float fTime); /*init properties with a json dictionary*/ - void initWithDictionary(const rapidjson::Value& dic,Object* root); + void initWithDictionary(const rapidjson::Value& dic, cocos2d::Ref* root); /*scheduler update function*/ void simulationActionUpdate(float dt); protected: - cocos2d::Vector _actionNodeList;/*actionnode*/ + cocos2d::Vector _actionNodeList; std::string _name; bool _loop; bool _bPause; diff --git a/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp b/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp index 2b8d2fc085..6dda544d42 100644 --- a/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp +++ b/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp @@ -453,13 +453,13 @@ std::string ArmatureAnimation::getCurrentMovementID() const return _movementID; } -void ArmatureAnimation::setMovementEventCallFunc(Object *target, SEL_MovementEventCallFunc callFunc) +void ArmatureAnimation::setMovementEventCallFunc(Ref *target, SEL_MovementEventCallFunc callFunc) { _movementEventTarget = target; _movementEventCallFunc = callFunc; } -void ArmatureAnimation::setFrameEventCallFunc(Object *target, SEL_FrameEventCallFunc callFunc) +void ArmatureAnimation::setFrameEventCallFunc(Ref *target, SEL_FrameEventCallFunc callFunc) { _frameEventTarget = target; _frameEventCallFunc = callFunc; @@ -474,7 +474,7 @@ void ArmatureAnimation::setFrameEventCallFunc(std::function listener); void setFrameEventCallFunc(std::function listener); @@ -216,12 +216,12 @@ public: * @js NA * @lua NA */ - virtual Object* getUserObject() { return _userObject; } + virtual Ref* getUserObject() { return _userObject; } /** * @js NA * @lua NA */ - virtual const Object* getUserObject() const { return _userObject; } + virtual const Ref* getUserObject() const { return _userObject; } /** * Returns a user assigned Object @@ -233,7 +233,7 @@ public: * * @param userObject A user assigned Object */ - virtual void setUserObject(Object *userObject); + virtual void setUserObject(Ref *userObject); protected: /** @@ -296,7 +296,7 @@ protected: unsigned int _movementIndex; int _movementListDurationTo; - cocos2d::Object *_userObject; + cocos2d::Ref *_userObject; protected: /** * MovementEvent CallFunc. @@ -316,8 +316,8 @@ protected: SEL_FrameEventCallFunc _frameEventCallFunc; - cocos2d::Object *_movementEventTarget; - cocos2d::Object *_frameEventTarget; + cocos2d::Ref *_movementEventTarget; + cocos2d::Ref *_frameEventTarget; std::function _movementEventListener; diff --git a/cocos/editor-support/cocostudio/CCArmatureDataManager.cpp b/cocos/editor-support/cocostudio/CCArmatureDataManager.cpp index de05838940..8f2953da2e 100644 --- a/cocos/editor-support/cocostudio/CCArmatureDataManager.cpp +++ b/cocos/editor-support/cocostudio/CCArmatureDataManager.cpp @@ -196,7 +196,7 @@ void ArmatureDataManager::addArmatureFileInfo(const std::string& configFilePath) DataReaderHelper::getInstance()->addDataFromFile(configFilePath); } -void ArmatureDataManager::addArmatureFileInfoAsync(const std::string& configFilePath, Object *target, SEL_SCHEDULE selector) +void ArmatureDataManager::addArmatureFileInfoAsync(const std::string& configFilePath, Ref *target, SEL_SCHEDULE selector) { addRelativeData(configFilePath); @@ -213,7 +213,7 @@ void ArmatureDataManager::addArmatureFileInfo(const std::string& imagePath, cons addSpriteFrameFromFile(plistPath, imagePath); } -void ArmatureDataManager::addArmatureFileInfoAsync(const std::string& imagePath, const std::string& plistPath, const std::string& configFilePath, Object *target, SEL_SCHEDULE selector) +void ArmatureDataManager::addArmatureFileInfoAsync(const std::string& imagePath, const std::string& plistPath, const std::string& configFilePath, Ref *target, SEL_SCHEDULE selector) { addRelativeData(configFilePath); diff --git a/cocos/editor-support/cocostudio/CCArmatureDataManager.h b/cocos/editor-support/cocostudio/CCArmatureDataManager.h index f621a6c6bf..0375890180 100644 --- a/cocos/editor-support/cocostudio/CCArmatureDataManager.h +++ b/cocos/editor-support/cocostudio/CCArmatureDataManager.h @@ -42,7 +42,7 @@ struct RelativeData /** * @brief format and manage armature configuration and armature animation */ -class ArmatureDataManager : public cocos2d::Object +class ArmatureDataManager : public cocos2d::Ref { public: /** @deprecated Use getInstance() instead */ @@ -141,7 +141,7 @@ public: * @brief Add ArmatureFileInfo, it is managed by ArmatureDataManager. * It will load data in a new thread */ - void addArmatureFileInfoAsync(const std::string& configFilePath, cocos2d::Object *target, cocos2d::SEL_SCHEDULE selector); + void addArmatureFileInfoAsync(const std::string& configFilePath, cocos2d::Ref *target, cocos2d::SEL_SCHEDULE selector); /** * @brief Add ArmatureFileInfo, it is managed by ArmatureDataManager. @@ -152,7 +152,7 @@ public: * @brief Add ArmatureFileInfo, it is managed by ArmatureDataManager. * It will load data in a new thread */ - void addArmatureFileInfoAsync(const std::string& imagePath, const std::string& plistPath, const std::string& configFilePath, cocos2d::Object *target, cocos2d::SEL_SCHEDULE selector); + void addArmatureFileInfoAsync(const std::string& imagePath, const std::string& plistPath, const std::string& configFilePath, cocos2d::Ref *target, cocos2d::SEL_SCHEDULE selector); /** * @brief Add sprite frame to CCSpriteFrameCache, it will save display name and it's relative image name diff --git a/cocos/editor-support/cocostudio/CCBone.h b/cocos/editor-support/cocostudio/CCBone.h index c81583a8c9..15705832af 100644 --- a/cocos/editor-support/cocostudio/CCBone.h +++ b/cocos/editor-support/cocostudio/CCBone.h @@ -30,10 +30,10 @@ THE SOFTWARE. #include "cocostudio/CCTween.h" #include "cocostudio/CCDecorativeDisplay.h" #include "cocostudio/CCDisplayManager.h" +#include "CCNode.h" namespace cocostudio { - class Armature; class Bone : public cocos2d::Node diff --git a/cocos/editor-support/cocostudio/CCColliderDetector.h b/cocos/editor-support/cocostudio/CCColliderDetector.h index 9619ed4f29..8c4335c741 100644 --- a/cocos/editor-support/cocostudio/CCColliderDetector.h +++ b/cocos/editor-support/cocostudio/CCColliderDetector.h @@ -85,7 +85,7 @@ protected: #endif }; -class ColliderBody : public cocos2d::Object +class ColliderBody : public cocos2d::Ref { public: ColliderBody(ContourData *contourData); @@ -130,7 +130,7 @@ private: * @js NA * @lua NA */ -class ColliderDetector : public cocos2d::Object +class ColliderDetector : public cocos2d::Ref { public: static ColliderDetector *create(); diff --git a/cocos/editor-support/cocostudio/CCComBase.h b/cocos/editor-support/cocostudio/CCComBase.h index 2f32d20045..050d275848 100644 --- a/cocos/editor-support/cocostudio/CCComBase.h +++ b/cocos/editor-support/cocostudio/CCComBase.h @@ -33,10 +33,10 @@ THE SOFTWARE. #define DECLARE_CLASS_COMPONENT_INFO \ public: \ static cocostudio::ObjectFactory::TInfo Type; \ - static cocos2d::Object* createInstance(void); \ + static cocos2d::Ref* createInstance(void); \ #define IMPLEMENT_CLASS_COMPONENT_INFO(className) \ - cocos2d::Object* className::createInstance(void) \ + cocos2d::Ref* className::createInstance(void) \ { \ return className::create(); \ } \ diff --git a/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp b/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp index 1f19d3af43..895784be29 100644 --- a/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp +++ b/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp @@ -310,7 +310,7 @@ void DataReaderHelper::addDataFromFile(const std::string& filePath) } } -void DataReaderHelper::addDataFromFileAsync(const std::string& imagePath, const std::string& plistPath, const std::string& filePath, Object *target, SEL_SCHEDULE selector) +void DataReaderHelper::addDataFromFileAsync(const std::string& imagePath, const std::string& plistPath, const std::string& filePath, Ref *target, SEL_SCHEDULE selector) { /* * Check if file is already added to ArmatureDataManager, if then return. @@ -363,7 +363,7 @@ void DataReaderHelper::addDataFromFileAsync(const std::string& imagePath, const if (0 == _asyncRefCount) { - Director::getInstance()->getScheduler()->scheduleSelector(schedule_selector(DataReaderHelper::addDataAsyncCallBack), this, 0, false); + Director::getInstance()->getScheduler()->scheduleSelector(schedule_selector(DataReaderHelper::addDataAsyncCallBack), this, 0, false); } ++_asyncRefCount; @@ -448,7 +448,7 @@ void DataReaderHelper::addDataAsyncCallBack(float dt) } - Object *target = pAsyncStruct->target; + Ref* target = pAsyncStruct->target; SEL_SCHEDULE selector = pAsyncStruct->selector; --_asyncRefCount; diff --git a/cocos/editor-support/cocostudio/CCDataReaderHelper.h b/cocos/editor-support/cocostudio/CCDataReaderHelper.h index ac580d6385..26d3c25d35 100644 --- a/cocos/editor-support/cocostudio/CCDataReaderHelper.h +++ b/cocos/editor-support/cocostudio/CCDataReaderHelper.h @@ -48,7 +48,7 @@ namespace cocostudio { * @js NA * @lua NA */ -class DataReaderHelper : cocos2d::Object +class DataReaderHelper : cocos2d::Ref { protected: @@ -64,7 +64,7 @@ protected: std::string fileContent; ConfigType configType; std::string baseFilePath; - cocos2d::Object *target; + cocos2d::Ref *target; cocos2d::SEL_SCHEDULE selector; bool autoLoadSpriteFile; @@ -110,7 +110,7 @@ public: ~DataReaderHelper(); void addDataFromFile(const std::string& filePath); - void addDataFromFileAsync(const std::string& imagePath, const std::string& plistPath, const std::string& filePath, cocos2d::Object *target, cocos2d::SEL_SCHEDULE selector); + void addDataFromFileAsync(const std::string& imagePath, const std::string& plistPath, const std::string& filePath, cocos2d::Ref *target, cocos2d::SEL_SCHEDULE selector); void addDataAsyncCallBack(float dt); diff --git a/cocos/editor-support/cocostudio/CCDatas.h b/cocos/editor-support/cocostudio/CCDatas.h index 62dad65314..8a57898051 100644 --- a/cocos/editor-support/cocostudio/CCDatas.h +++ b/cocos/editor-support/cocostudio/CCDatas.h @@ -25,12 +25,12 @@ THE SOFTWARE. #ifndef __CCARMATURE_DATAS_H__ #define __CCARMATURE_DATAS_H__ -#include "CCObject.h" +#include "CCRef.h" #include "ccTypes.h" #include "CCVector.h" #include "CCMap.h" #include "CCAffineTransform.h" -#include "CCNode.h" + #include "cocostudio/CCArmatureDefine.h" #include "CCTweenFunction.h" @@ -68,7 +68,7 @@ namespace cocostudio { * @js NA * @lua NA */ -class BaseData : public cocos2d::Object +class BaseData : public cocos2d::Ref { public: CC_CREATE_NO_PARAM_NO_INIT(BaseData) @@ -137,7 +137,7 @@ enum DisplayType * @js NA * @lua NA */ -class DisplayData : public cocos2d::Object +class DisplayData : public cocos2d::Ref { public: CC_CREATE_NO_PARAM_NO_INIT(DisplayData) @@ -268,7 +268,7 @@ public: * @js NA * @lua NA */ -class ArmatureData : public cocos2d::Object +class ArmatureData : public cocos2d::Ref { public: CC_CREATE_NO_PARAM(ArmatureData) @@ -361,7 +361,7 @@ public: * @js NA * @lua NA */ -class MovementBoneData : public cocos2d::Object +class MovementBoneData : public cocos2d::Ref { public: CC_CREATE_NO_PARAM(MovementBoneData) @@ -393,7 +393,7 @@ public: * @js NA * @lua NA */ -class MovementData : public cocos2d::Object +class MovementData : public cocos2d::Ref { public: CC_CREATE_NO_PARAM_NO_INIT(MovementData) @@ -455,7 +455,7 @@ public: * @js NA * @lua NA */ -class AnimationData : public cocos2d::Object +class AnimationData : public cocos2d::Ref { public: CC_CREATE_NO_PARAM_NO_INIT(AnimationData) @@ -486,7 +486,7 @@ public: * @js NA * @lua NA */ -class ContourData : public cocos2d::Object +class ContourData : public cocos2d::Ref { public: CC_CREATE_NO_PARAM(ContourData) @@ -515,7 +515,7 @@ public: * @js NA * @lua NA */ -class TextureData : public cocos2d::Object +class TextureData : public cocos2d::Ref { public: CC_CREATE_NO_PARAM(TextureData) diff --git a/cocos/editor-support/cocostudio/CCDecorativeDisplay.cpp b/cocos/editor-support/cocostudio/CCDecorativeDisplay.cpp index 1d4c899dea..14d724f91d 100644 --- a/cocos/editor-support/cocostudio/CCDecorativeDisplay.cpp +++ b/cocos/editor-support/cocostudio/CCDecorativeDisplay.cpp @@ -23,6 +23,7 @@ THE SOFTWARE. ****************************************************************************/ #include "cocostudio/CCDecorativeDisplay.h" +#include "CCNode.h" using namespace cocos2d; @@ -66,4 +67,14 @@ bool DecorativeDisplay::init() return true; } +void DecorativeDisplay::setDisplay(cocos2d::Node *display) +{ + if (_display != display) + { + CC_SAFE_RETAIN(display); + CC_SAFE_RELEASE(_display); + _display = display; + } +} + } diff --git a/cocos/editor-support/cocostudio/CCDecorativeDisplay.h b/cocos/editor-support/cocostudio/CCDecorativeDisplay.h index 1d6dcbe979..1902565550 100644 --- a/cocos/editor-support/cocostudio/CCDecorativeDisplay.h +++ b/cocos/editor-support/cocostudio/CCDecorativeDisplay.h @@ -34,12 +34,16 @@ THE SOFTWARE. #include "cocostudio/CCColliderDetector.h" #endif +namespace cocos2d { + class Node; +} + namespace cocostudio { /** * @js NA * @lua NA */ -class DecorativeDisplay: public cocos2d::Object +class DecorativeDisplay: public cocos2d::Ref { public: static DecorativeDisplay *create(); @@ -49,15 +53,7 @@ public: virtual bool init(); - virtual void setDisplay(cocos2d::Node *display) - { - if (_display != display) - { - CC_SAFE_RETAIN(display); - CC_SAFE_RELEASE(_display); - _display = display; - } - } + virtual void setDisplay(cocos2d::Node *display); virtual cocos2d::Node *getDisplay() const { return _display; } virtual void setDisplayData(DisplayData *data) diff --git a/cocos/editor-support/cocostudio/CCDisplayManager.h b/cocos/editor-support/cocostudio/CCDisplayManager.h index 39b89e45af..f91b4f3341 100644 --- a/cocos/editor-support/cocostudio/CCDisplayManager.h +++ b/cocos/editor-support/cocostudio/CCDisplayManager.h @@ -37,7 +37,7 @@ class Bone; * @js NA * @lua NA */ -class DisplayManager : public cocos2d::Object +class DisplayManager : public cocos2d::Ref { public: static DisplayManager *create(Bone *bone); diff --git a/cocos/editor-support/cocostudio/CCInputDelegate.h b/cocos/editor-support/cocostudio/CCInputDelegate.h index 9341179bf8..258be8466d 100644 --- a/cocos/editor-support/cocostudio/CCInputDelegate.h +++ b/cocos/editor-support/cocostudio/CCInputDelegate.h @@ -31,6 +31,7 @@ THE SOFTWARE. #include "ccTypes.h" #include "CCEventKeyboard.h" #include "CCEventListener.h" +#include "CCSet.h" namespace cocostudio { diff --git a/cocos/editor-support/cocostudio/CCProcessBase.h b/cocos/editor-support/cocostudio/CCProcessBase.h index 33d9b754f7..59f0824f6b 100644 --- a/cocos/editor-support/cocostudio/CCProcessBase.h +++ b/cocos/editor-support/cocostudio/CCProcessBase.h @@ -50,7 +50,7 @@ enum AnimationType * @js NA * @lua NA */ -class ProcessBase : public cocos2d::Object +class ProcessBase : public cocos2d::Ref { public: ProcessBase(void); diff --git a/cocos/editor-support/cocostudio/CCSGUIReader.cpp b/cocos/editor-support/cocostudio/CCSGUIReader.cpp index a8bd016948..716392f987 100644 --- a/cocos/editor-support/cocostudio/CCSGUIReader.cpp +++ b/cocos/editor-support/cocostudio/CCSGUIReader.cpp @@ -196,7 +196,7 @@ Widget* WidgetPropertiesReader0250::createWidget(const rapidjson::Value& data, c // ActionManager::getInstance()->releaseActions(); /* ********************** */ CCLOG("file name == [%s]",fileName); - Object* rootWidget = (Object*) widget; + Ref* rootWidget = (Ref*) widget; ActionManagerEx::getInstance()->initWithDictionary(fileName,actions,rootWidget); return widget; } @@ -895,7 +895,7 @@ Widget* WidgetPropertiesReader0300::createWidget(const rapidjson::Value& data, c // ActionManager::getInstance()->releaseActions(); /* ********************** */ CCLOG("file name == [%s]",fileName); - Object* rootWidget = (Object*) widget; + Ref* rootWidget = (Ref*) widget; ActionManagerEx::getInstance()->initWithDictionary(fileName,actions,rootWidget); return widget; } diff --git a/cocos/editor-support/cocostudio/CCSGUIReader.h b/cocos/editor-support/cocostudio/CCSGUIReader.h index e44e390a97..bc7d0011a1 100644 --- a/cocos/editor-support/cocostudio/CCSGUIReader.h +++ b/cocos/editor-support/cocostudio/CCSGUIReader.h @@ -32,7 +32,7 @@ namespace cocostudio { #define kCCSVersion 1.0 -class GUIReader : public cocos2d::Object +class GUIReader : public cocos2d::Ref { public: CC_DEPRECATED_ATTRIBUTE static GUIReader* shareReader() { return GUIReader::getInstance(); }; @@ -61,7 +61,7 @@ protected: }; -class WidgetPropertiesReader : public cocos2d::Object +class WidgetPropertiesReader : public cocos2d::Ref { public: virtual cocos2d::gui::Widget* createWidget(const rapidjson::Value& dic, const char* fullPath, const char* fileName)=0; diff --git a/cocos/editor-support/cocostudio/CCSSceneReader.cpp b/cocos/editor-support/cocostudio/CCSSceneReader.cpp index ba7818826b..aa9e68cc27 100644 --- a/cocos/editor-support/cocostudio/CCSSceneReader.cpp +++ b/cocos/editor-support/cocostudio/CCSSceneReader.cpp @@ -172,7 +172,7 @@ Node* SceneReader::createObject(const rapidjson::Value &dict, cocos2d::Node* par return nullptr; } -void SceneReader::setTarget(const std::function& selector) +void SceneReader::setTarget(const std::function& selector) { _fnSelector = selector; } diff --git a/cocos/editor-support/cocostudio/CCSSceneReader.h b/cocos/editor-support/cocostudio/CCSSceneReader.h index 19ca837c6a..f604d1429e 100644 --- a/cocos/editor-support/cocostudio/CCSSceneReader.h +++ b/cocos/editor-support/cocostudio/CCSSceneReader.h @@ -41,7 +41,7 @@ public: static void destroyInstance(); static const char* sceneReaderVersion(); cocos2d::Node* createNodeWithSceneFile(const std::string &fileName); - void setTarget(const std::function& selector); + void setTarget(const std::function& selector); cocos2d::Node* getNodeByTag(int nTag); private: @@ -54,7 +54,7 @@ private: cocos2d::Node* nodeByTag(cocos2d::Node *parent, int tag); private: static SceneReader* s_sharedReader; - std::function _fnSelector; + std::function _fnSelector; cocos2d::Node* _node; }; diff --git a/cocos/editor-support/cocostudio/ObjectFactory.cpp b/cocos/editor-support/cocostudio/ObjectFactory.cpp index b74fee8859..1a3794be49 100644 --- a/cocos/editor-support/cocostudio/ObjectFactory.cpp +++ b/cocos/editor-support/cocostudio/ObjectFactory.cpp @@ -87,9 +87,9 @@ void ObjectFactory::destroyInstance() CC_SAFE_DELETE(_sharedFactory); } -Object* ObjectFactory::createObject(const std::string &name) +Ref* ObjectFactory::createObject(const std::string &name) { - Object *o = nullptr; + Ref *o = nullptr; do { const TInfo t = _typeMap[name]; @@ -127,7 +127,7 @@ Component* ObjectFactory::createComponent(const std::string &name) { CCASSERT(false, "Unregistered Component!"); } - Object *o = NULL; + Ref *o = NULL; do { const TInfo t = _typeMap[comName]; diff --git a/cocos/editor-support/cocostudio/ObjectFactory.h b/cocos/editor-support/cocostudio/ObjectFactory.h index 94be620b56..2e3258f106 100644 --- a/cocos/editor-support/cocostudio/ObjectFactory.h +++ b/cocos/editor-support/cocostudio/ObjectFactory.h @@ -34,7 +34,7 @@ namespace cocostudio { class ObjectFactory { public: - typedef cocos2d::Object* (*Instance)(void); + typedef cocos2d::Ref* (*Instance)(void); struct TInfo { TInfo(void); @@ -49,7 +49,7 @@ public: static ObjectFactory* getInstance(); static void destroyInstance(); - cocos2d::Object* createObject(const std::string &name); + cocos2d::Ref* createObject(const std::string &name); cocos2d::Component* createComponent(const std::string &name); void registerType(const TInfo &t); void removeAll(); diff --git a/cocos/editor-support/cocostudio/TriggerBase.h b/cocos/editor-support/cocostudio/TriggerBase.h index f90d8028b2..20e172ec30 100644 --- a/cocos/editor-support/cocostudio/TriggerBase.h +++ b/cocos/editor-support/cocostudio/TriggerBase.h @@ -35,10 +35,10 @@ THE SOFTWARE. #define DECLARE_CLASS_INFO \ public: \ static cocostudio::ObjectFactory::TInfo Type; \ - static cocos2d::Object* createInstance(void); \ + static cocos2d::Ref* createInstance(void); \ #define IMPLEMENT_CLASS_INFO(className) \ - cocos2d::Object* className::createInstance(void) \ + cocos2d::Ref* className::createInstance(void) \ { \ return new className; \ } \ diff --git a/cocos/editor-support/cocostudio/TriggerMng.cpp b/cocos/editor-support/cocostudio/TriggerMng.cpp index 92420e7724..c289d4c520 100644 --- a/cocos/editor-support/cocostudio/TriggerMng.cpp +++ b/cocos/editor-support/cocostudio/TriggerMng.cpp @@ -238,7 +238,7 @@ bool TriggerMng::isEmpty(void) const return _eventTriggers.empty(); } -void TriggerMng::addArmatureMovementCallBack(Armature *pAr, Object *pTarget, SEL_MovementEventCallFunc mecf) +void TriggerMng::addArmatureMovementCallBack(Armature *pAr, Ref *pTarget, SEL_MovementEventCallFunc mecf) { if (pAr == nullptr || _movementDispatches == nullptr || pTarget == nullptr || mecf == nullptr) { @@ -262,7 +262,7 @@ void TriggerMng::addArmatureMovementCallBack(Armature *pAr, Object *pTarget, SEL } } -void TriggerMng::removeArmatureMovementCallBack(Armature *pAr, Object *pTarget, SEL_MovementEventCallFunc mecf) +void TriggerMng::removeArmatureMovementCallBack(Armature *pAr, Ref *pTarget, SEL_MovementEventCallFunc mecf) { if (pAr == nullptr || _movementDispatches == nullptr || pTarget == nullptr || mecf == nullptr) { @@ -314,7 +314,7 @@ void TriggerMng::removeAllArmatureMovementCallBack() ArmatureMovementDispatcher::ArmatureMovementDispatcher(void) : _mapEventAnimation(nullptr) { - _mapEventAnimation = new std::unordered_map ; + _mapEventAnimation = new std::unordered_map ; } ArmatureMovementDispatcher::~ArmatureMovementDispatcher(void) @@ -331,12 +331,12 @@ ArmatureMovementDispatcher::~ArmatureMovementDispatcher(void) } } - void ArmatureMovementDispatcher::addAnimationEventCallBack(Object *pTarget, SEL_MovementEventCallFunc mecf) + void ArmatureMovementDispatcher::addAnimationEventCallBack(Ref *pTarget, SEL_MovementEventCallFunc mecf) { _mapEventAnimation->insert(std::make_pair(pTarget, mecf)); } - void ArmatureMovementDispatcher::removeAnnimationEventCallBack(Object *pTarget, SEL_MovementEventCallFunc mecf) + void ArmatureMovementDispatcher::removeAnnimationEventCallBack(Ref *pTarget, SEL_MovementEventCallFunc mecf) { _mapEventAnimation->erase(pTarget); } diff --git a/cocos/editor-support/cocostudio/TriggerMng.h b/cocos/editor-support/cocostudio/TriggerMng.h index 3f84d3810b..179a346168 100644 --- a/cocos/editor-support/cocostudio/TriggerMng.h +++ b/cocos/editor-support/cocostudio/TriggerMng.h @@ -31,18 +31,18 @@ namespace cocostudio { class TriggerObj; -class ArmatureMovementDispatcher : public cocos2d::Object +class ArmatureMovementDispatcher : public cocos2d::Ref { public: ArmatureMovementDispatcher(void); ~ArmatureMovementDispatcher(void); public: - void addAnimationEventCallBack(cocos2d::Object*pTarget, SEL_MovementEventCallFunc mecf); - void removeAnnimationEventCallBack(cocos2d::Object*pTarget, SEL_MovementEventCallFunc mecf); + void addAnimationEventCallBack(cocos2d::Ref*pTarget, SEL_MovementEventCallFunc mecf); + void removeAnnimationEventCallBack(cocos2d::Ref*pTarget, SEL_MovementEventCallFunc mecf); void animationEvent(Armature *armature, MovementEventType movementType, const std::string& movementID); private: - std::unordered_map *_mapEventAnimation; + std::unordered_map *_mapEventAnimation; }; @@ -67,8 +67,8 @@ public: bool remove(unsigned int event, TriggerObj *pObj); bool removeTriggerObj(unsigned int id); bool isEmpty(void) const; - void addArmatureMovementCallBack(Armature *pAr, cocos2d::Object *pTarget, SEL_MovementEventCallFunc mecf); - void removeArmatureMovementCallBack(Armature *pAr, cocos2d::Object *pTarget, SEL_MovementEventCallFunc mecf); + void addArmatureMovementCallBack(Armature *pAr, cocos2d::Ref *pTarget, SEL_MovementEventCallFunc mecf); + void removeArmatureMovementCallBack(Armature *pAr, cocos2d::Ref *pTarget, SEL_MovementEventCallFunc mecf); void removeArmatureAllMovementCallBack(Armature *pAr); void removeAllArmatureMovementCallBack(); diff --git a/cocos/editor-support/cocostudio/TriggerObj.h b/cocos/editor-support/cocostudio/TriggerObj.h index 55d98ca504..1a705e2057 100644 --- a/cocos/editor-support/cocostudio/TriggerObj.h +++ b/cocos/editor-support/cocostudio/TriggerObj.h @@ -32,7 +32,7 @@ THE SOFTWARE. namespace cocostudio { -class BaseTriggerCondition : public cocos2d::Object +class BaseTriggerCondition : public cocos2d::Ref { protected: BaseTriggerCondition(void); @@ -44,7 +44,7 @@ public: virtual void removeAll(); }; -class BaseTriggerAction : public cocos2d::Object +class BaseTriggerAction : public cocos2d::Ref { protected: BaseTriggerAction(void); @@ -57,7 +57,7 @@ public: }; -class TriggerObj : public cocos2d::Object +class TriggerObj : public cocos2d::Ref { public: TriggerObj(void); diff --git a/cocos/editor-support/spine/CCSkeletonAnimation.cpp b/cocos/editor-support/spine/CCSkeletonAnimation.cpp index f4cd9dab9a..e088316e2b 100644 --- a/cocos/editor-support/spine/CCSkeletonAnimation.cpp +++ b/cocos/editor-support/spine/CCSkeletonAnimation.cpp @@ -119,7 +119,7 @@ void SkeletonAnimation::setMix (const char* fromAnimation, const char* toAnimati spAnimationStateData_setMixByName(state->data, fromAnimation, toAnimation, duration); } -void SkeletonAnimation::setAnimationListener (Object* instance, SEL_AnimationStateEvent method) { +void SkeletonAnimation::setAnimationListener (Ref* instance, SEL_AnimationStateEvent method) { listenerInstance = instance; listenerMethod = method; } diff --git a/cocos/editor-support/spine/CCSkeletonAnimation.h b/cocos/editor-support/spine/CCSkeletonAnimation.h index 3c09ee28c3..295cd74095 100644 --- a/cocos/editor-support/spine/CCSkeletonAnimation.h +++ b/cocos/editor-support/spine/CCSkeletonAnimation.h @@ -40,7 +40,7 @@ namespace spine { class SkeletonAnimation; -typedef void (cocos2d::Object::*SEL_AnimationStateEvent)(spine::SkeletonAnimation* node, int trackIndex, spEventType type, spEvent* event, int loopCount); +typedef void (cocos2d::Ref::*SEL_AnimationStateEvent)(spine::SkeletonAnimation* node, int trackIndex, spEventType type, spEvent* event, int loopCount); #define animationStateEvent_selector(_SELECTOR) (SEL_AnimationStateEvent)(&_SELECTOR) /** Draws an animated skeleton, providing an AnimationState for applying one or more animations and queuing animations to be @@ -64,7 +64,7 @@ public: void setAnimationStateData (spAnimationStateData* stateData); void setMix (const char* fromAnimation, const char* toAnimation, float duration); - void setAnimationListener (cocos2d::Object* instance, SEL_AnimationStateEvent method); + void setAnimationListener (cocos2d::Ref* instance, SEL_AnimationStateEvent method); spTrackEntry* setAnimation (int trackIndex, const char* name, bool loop); spTrackEntry* addAnimation (int trackIndex, const char* name, bool loop, float delay = 0); spTrackEntry* getCurrent (int trackIndex = 0); @@ -78,7 +78,7 @@ protected: private: typedef Skeleton super; - cocos2d::Object* listenerInstance; + cocos2d::Ref* listenerInstance; SEL_AnimationStateEvent listenerMethod; bool ownsAnimationStateData; diff --git a/cocos/gui/UICheckBox.cpp b/cocos/gui/UICheckBox.cpp index f37baf2b0b..91f726f948 100644 --- a/cocos/gui/UICheckBox.cpp +++ b/cocos/gui/UICheckBox.cpp @@ -316,7 +316,7 @@ void CheckBox::unSelectedEvent() } } -void CheckBox::addEventListenerCheckBox(Object *target, SEL_SelectedStateEvent selector) +void CheckBox::addEventListenerCheckBox(Ref *target, SEL_SelectedStateEvent selector) { _checkBoxEventListener = target; _checkBoxEventSelector = selector; diff --git a/cocos/gui/UICheckBox.h b/cocos/gui/UICheckBox.h index c332c003a7..73102e0230 100644 --- a/cocos/gui/UICheckBox.h +++ b/cocos/gui/UICheckBox.h @@ -37,7 +37,7 @@ typedef enum CHECKBOX_STATE_EVENT_UNSELECTED }CheckBoxEventType; -typedef void (Object::*SEL_SelectedStateEvent)(Object*,CheckBoxEventType); +typedef void (Ref::*SEL_SelectedStateEvent)(Ref*,CheckBoxEventType); #define checkboxselectedeventselector(_SELECTOR) (SEL_SelectedStateEvent)(&_SELECTOR) /** @@ -140,7 +140,7 @@ public: virtual void setAnchorPoint(const Point &pt) override; //add a call back function would called when checkbox is selected or unselected. - void addEventListenerCheckBox(Object* target,SEL_SelectedStateEvent selector); + void addEventListenerCheckBox(Ref* target,SEL_SelectedStateEvent selector); //override "setFlipX" method of widget. virtual void setFlipX(bool flipX) override; @@ -192,7 +192,7 @@ protected: Sprite* _frontCrossDisabledRenderer; bool _isSelected; - Object* _checkBoxEventListener; + Ref* _checkBoxEventListener; SEL_SelectedStateEvent _checkBoxEventSelector; TextureResType _backGroundTexType; diff --git a/cocos/gui/UILayoutParameter.h b/cocos/gui/UILayoutParameter.h index 9065a16176..3337c7f2b0 100644 --- a/cocos/gui/UILayoutParameter.h +++ b/cocos/gui/UILayoutParameter.h @@ -41,7 +41,7 @@ typedef enum * @js NA * @lua NA */ -class LayoutParameter : public Object +class LayoutParameter : public Ref { public: /** diff --git a/cocos/gui/UIListView.cpp b/cocos/gui/UIListView.cpp index 8c732f6e70..51cb50e6bb 100644 --- a/cocos/gui/UIListView.cpp +++ b/cocos/gui/UIListView.cpp @@ -394,7 +394,7 @@ void ListView::sortAllChildren() } } -void ListView::addEventListenerListView(Object *target, SEL_ListViewEvent selector) +void ListView::addEventListenerListView(Ref *target, SEL_ListViewEvent selector) { _listViewEventListener = target; _listViewEventSelector = selector; diff --git a/cocos/gui/UIListView.h b/cocos/gui/UIListView.h index 2a6b2df848..549e9668a7 100644 --- a/cocos/gui/UIListView.h +++ b/cocos/gui/UIListView.h @@ -48,7 +48,7 @@ typedef enum LISTVIEW_ONSELECTEDITEM }ListViewEventType; -typedef void (Object::*SEL_ListViewEvent)(Object*,ListViewEventType); +typedef void (Ref::*SEL_ListViewEvent)(Ref*,ListViewEventType); #define listvieweventselector(_SELECTOR) (SEL_ListViewEvent)(&_SELECTOR) class ListView : public ScrollView @@ -154,7 +154,7 @@ public: ssize_t getCurSelectedIndex() const; - void addEventListenerListView(Object* target, SEL_ListViewEvent selector); + void addEventListenerListView(Ref* target, SEL_ListViewEvent selector); /** * Changes scroll direction of scrollview. @@ -198,7 +198,7 @@ protected: Vector _items; ListViewGravity _gravity; float _itemsMargin; - Object* _listViewEventListener; + Ref* _listViewEventListener; SEL_ListViewEvent _listViewEventSelector; ssize_t _curSelectedIndex; bool _refreshViewDirty; diff --git a/cocos/gui/UIPageView.cpp b/cocos/gui/UIPageView.cpp index cc265a7f89..3312e0c1f3 100644 --- a/cocos/gui/UIPageView.cpp +++ b/cocos/gui/UIPageView.cpp @@ -571,7 +571,7 @@ void PageView::pageTurningEvent() } } -void PageView::addEventListenerPageView(Object *target, SEL_PageViewEvent selector) +void PageView::addEventListenerPageView(Ref *target, SEL_PageViewEvent selector) { _pageViewEventListener = target; _pageViewEventSelector = selector; diff --git a/cocos/gui/UIPageView.h b/cocos/gui/UIPageView.h index 4b4a890199..e005bb606a 100644 --- a/cocos/gui/UIPageView.h +++ b/cocos/gui/UIPageView.h @@ -37,7 +37,7 @@ typedef enum PAGEVIEW_EVENT_TURNING, }PageViewEventType; -typedef void (Object::*SEL_PageViewEvent)(Object*, PageViewEventType); +typedef void (Ref::*SEL_PageViewEvent)(Ref*, PageViewEventType); #define pagevieweventselector(_SELECTOR)(SEL_PageViewEvent)(&_SELECTOR) typedef enum { @@ -124,7 +124,7 @@ public: Layout* getPage(ssize_t index); // event - void addEventListenerPageView(Object *target, SEL_PageViewEvent selector); + void addEventListenerPageView(Ref *target, SEL_PageViewEvent selector); @@ -209,7 +209,7 @@ protected: float _autoScrollSpeed; int _autoScrollDir; float _childFocusCancelOffset; - Object* _pageViewEventListener; + Ref* _pageViewEventListener; SEL_PageViewEvent _pageViewEventSelector; }; diff --git a/cocos/gui/UIScrollView.cpp b/cocos/gui/UIScrollView.cpp index 8bb23aae8d..1a2835d17d 100644 --- a/cocos/gui/UIScrollView.cpp +++ b/cocos/gui/UIScrollView.cpp @@ -1584,7 +1584,7 @@ void ScrollView::bounceRightEvent() } } -void ScrollView::addEventListenerScrollView(Object *target, SEL_ScrollViewEvent selector) +void ScrollView::addEventListenerScrollView(Ref *target, SEL_ScrollViewEvent selector) { _scrollViewEventListener = target; _scrollViewEventSelector = selector; diff --git a/cocos/gui/UIScrollView.h b/cocos/gui/UIScrollView.h index 0b196cef55..d57eb08913 100644 --- a/cocos/gui/UIScrollView.h +++ b/cocos/gui/UIScrollView.h @@ -53,7 +53,7 @@ typedef enum SCROLLVIEW_EVENT_BOUNCE_RIGHT }ScrollviewEventType; -typedef void (Object::*SEL_ScrollViewEvent)(Object*, ScrollviewEventType); +typedef void (Ref::*SEL_ScrollViewEvent)(Ref*, ScrollviewEventType); #define scrollvieweventselector(_SELECTOR) (SEL_ScrollViewEvent)(&_SELECTOR) @@ -233,7 +233,7 @@ public: /** * Add call back function called scrollview event triggered */ - void addEventListenerScrollView(Object* target, SEL_ScrollViewEvent selector); + void addEventListenerScrollView(Ref* target, SEL_ScrollViewEvent selector); virtual void addChild(Node * child) override; /** @@ -402,7 +402,7 @@ protected: - Object* _scrollViewEventListener; + Ref* _scrollViewEventListener; SEL_ScrollViewEvent _scrollViewEventSelector; }; diff --git a/cocos/gui/UISlider.cpp b/cocos/gui/UISlider.cpp index d138def5a3..978380fef0 100644 --- a/cocos/gui/UISlider.cpp +++ b/cocos/gui/UISlider.cpp @@ -391,7 +391,7 @@ float Slider::getPercentWithBallPos(float px) return (((px-(-_barLength/2.0f))/_barLength)*100.0f); } -void Slider::addEventListenerSlider(Object *target, SEL_SlidPercentChangedEvent selector) +void Slider::addEventListenerSlider(Ref *target, SEL_SlidPercentChangedEvent selector) { _sliderEventListener = target; _sliderEventSelector = selector; diff --git a/cocos/gui/UISlider.h b/cocos/gui/UISlider.h index bc952ede15..5de009f1ba 100644 --- a/cocos/gui/UISlider.h +++ b/cocos/gui/UISlider.h @@ -36,7 +36,7 @@ typedef enum SLIDER_PERCENTCHANGED }SliderEventType; -typedef void (Object::*SEL_SlidPercentChangedEvent)(Object*,SliderEventType); +typedef void (Ref::*SEL_SlidPercentChangedEvent)(Ref*,SliderEventType); #define sliderpercentchangedselector(_SELECTOR) (SEL_SlidPercentChangedEvent)(&_SELECTOR) /** @@ -164,7 +164,7 @@ public: /** * Add call back function called when slider's percent has changed to slider. */ - void addEventListenerSlider(Object* target,SEL_SlidPercentChangedEvent selector); + void addEventListenerSlider(Ref* target,SEL_SlidPercentChangedEvent selector); virtual bool onTouchBegan(Touch *touch, Event *unusedEvent) override; virtual void onTouchMoved(Touch *touch, Event *unusedEvent) override; @@ -221,7 +221,7 @@ protected: Rect _capInsetsBarRenderer; Rect _capInsetsProgressBarRenderer; - Object* _sliderEventListener; + Ref* _sliderEventListener; SEL_SlidPercentChangedEvent _sliderEventSelector; TextureResType _barTexType; TextureResType _progressBarTexType; diff --git a/cocos/gui/UITextField.cpp b/cocos/gui/UITextField.cpp index c463293006..550b7be10b 100644 --- a/cocos/gui/UITextField.cpp +++ b/cocos/gui/UITextField.cpp @@ -513,7 +513,7 @@ void TextField::deleteBackwardEvent() } } -void TextField::addEventListenerTextField(Object *target, SEL_TextFieldEvent selecor) +void TextField::addEventListenerTextField(Ref *target, SEL_TextFieldEvent selecor) { _textFieldEventListener = target; _textFieldEventSelector = selecor; diff --git a/cocos/gui/UITextField.h b/cocos/gui/UITextField.h index 1f01103592..acbba4230f 100644 --- a/cocos/gui/UITextField.h +++ b/cocos/gui/UITextField.h @@ -94,7 +94,7 @@ typedef enum TEXTFIELD_EVENT_DELETE_BACKWARD, }TextFiledEventType; -typedef void (Object::*SEL_TextFieldEvent)(Object*, TextFiledEventType); +typedef void (Ref::*SEL_TextFieldEvent)(Ref*, TextFiledEventType); #define textfieldeventselector(_SELECTOR) (SEL_TextFieldEvent)(&_SELECTOR) /** class UITextField : public Widget @@ -131,7 +131,7 @@ public: void setInsertText(bool insertText); bool getDeleteBackward(); void setDeleteBackward(bool deleteBackward); - void addEventListenerTextField(Object* target, SEL_TextFieldEvent selecor); + void addEventListenerTextField(Ref* target, SEL_TextFieldEvent selecor); virtual void setAnchorPoint(const Point &pt) override; @@ -162,7 +162,7 @@ protected: float _touchHeight; bool _useTouchArea; - Object* _textFieldEventListener; + Ref* _textFieldEventListener; SEL_TextFieldEvent _textFieldEventSelector; std::string _passwordStyleText; diff --git a/cocos/gui/UIWidget.cpp b/cocos/gui/UIWidget.cpp index d83c7a42db..243029cf4d 100644 --- a/cocos/gui/UIWidget.cpp +++ b/cocos/gui/UIWidget.cpp @@ -801,7 +801,7 @@ void Widget::cancelUpEvent() } } -void Widget::addTouchEventListener(Object *target, SEL_TouchEvent selector) +void Widget::addTouchEventListener(Ref *target, SEL_TouchEvent selector) { _touchEventListener = target; _touchEventSelector = selector; diff --git a/cocos/gui/UIWidget.h b/cocos/gui/UIWidget.h index 3827c60db2..122d541ae1 100644 --- a/cocos/gui/UIWidget.h +++ b/cocos/gui/UIWidget.h @@ -25,7 +25,7 @@ THE SOFTWARE. #ifndef __UIWIDGET_H__ #define __UIWIDGET_H__ -#include "cocos2d.h" +#include "CCNode.h" #include "gui/UILayoutDefine.h" #include "gui/UILayoutParameter.h" @@ -72,7 +72,7 @@ typedef enum POSITION_PERCENT }PositionType; -typedef void (Object::*SEL_TouchEvent)(Object*,TouchEventType); +typedef void (Ref::*SEL_TouchEvent)(Ref*,TouchEventType); #define toucheventselector(_SELECTOR) (SEL_TouchEvent)(&_SELECTOR) /** * @js NA @@ -336,7 +336,7 @@ public: /** * Sets the touch event target/selector of the menu item */ - void addTouchEventListener(Object* target,SEL_TouchEvent selector); + void addTouchEventListener(Ref* target,SEL_TouchEvent selector); //cocos2d property @@ -663,7 +663,7 @@ protected: Point _touchStartPos; ///< touch began point Point _touchMovePos; ///< touch moved point Point _touchEndPos; ///< touch ended point - Object* _touchEventListener; + Ref* _touchEventListener; SEL_TouchEvent _touchEventSelector; std::string _name; WidgetType _widgetType; diff --git a/cocos/network/HttpClient.cpp b/cocos/network/HttpClient.cpp index 771a23c6f8..39f319746a 100644 --- a/cocos/network/HttpClient.cpp +++ b/cocos/network/HttpClient.cpp @@ -495,7 +495,7 @@ void HttpClient::dispatchResponseCallbacks() if (response) { HttpRequest *request = response->getHttpRequest(); - Object *pTarget = request->getTarget(); + Ref* pTarget = request->getTarget(); SEL_HttpResponse pSelector = request->getSelector(); if (pTarget && pSelector) diff --git a/cocos/network/HttpRequest.h b/cocos/network/HttpRequest.h index 8ca5eee84d..e6c2118332 100644 --- a/cocos/network/HttpRequest.h +++ b/cocos/network/HttpRequest.h @@ -26,8 +26,10 @@ #ifndef __HTTP_REQUEST_H__ #define __HTTP_REQUEST_H__ -#include "CCPlatformMacros.h" -#include "CCObject.h" +#include +#include +#include "CCRef.h" +#include "ccMacros.h" NS_CC_BEGIN @@ -35,16 +37,17 @@ namespace network { class HttpClient; class HttpResponse; -typedef void (cocos2d::Object::*SEL_HttpResponse)(HttpClient* client, HttpResponse* response); + +typedef void (cocos2d::Ref::*SEL_HttpResponse)(HttpClient* client, HttpResponse* response); #define httpresponse_selector(_SELECTOR) (cocos2d::network::SEL_HttpResponse)(&_SELECTOR) /** @brief defines the object which users must packed for HttpClient::send(HttpRequest*) method. - Please refer to samples/TestCpp/Classes/ExtensionTest/NetworkTest/HttpClientTest.cpp as a sample + Please refer to tests/test-cpp/Classes/ExtensionTest/NetworkTest/HttpClientTest.cpp as a sample @since v2.0.2 */ -class HttpRequest : public cocos2d::Object +class HttpRequest : public Ref { public: /** Use this enum type as param in setReqeustType(param) */ @@ -84,7 +87,7 @@ public: }; /** Override autorelease method to avoid developers to call it */ - cocos2d::Object* autorelease(void) + Ref* autorelease(void) { CCASSERT(false, "HttpResponse is used between network thread and ui thread \ therefore, autorelease is forbidden here"); @@ -169,12 +172,12 @@ public: /** Required field. You should set the callback selector function at ack the http request completed */ - CC_DEPRECATED_ATTRIBUTE inline void setResponseCallback(cocos2d::Object* pTarget, cocos2d::SEL_CallFuncND pSelector) + CC_DEPRECATED_ATTRIBUTE inline void setResponseCallback(Ref* pTarget, SEL_CallFuncND pSelector) { setResponseCallback(pTarget, (SEL_HttpResponse) pSelector); } - inline void setResponseCallback(cocos2d::Object* pTarget, SEL_HttpResponse pSelector) + inline void setResponseCallback(Ref* pTarget, SEL_HttpResponse pSelector) { _pTarget = pTarget; _pSelector = pSelector; @@ -185,7 +188,7 @@ public: } } /** Get the target of callback selector funtion, mainly used by HttpClient */ - inline cocos2d::Object* getTarget() + inline Ref* getTarget() { return _pTarget; } @@ -198,7 +201,7 @@ public: _prxy( SEL_HttpResponse cb ) :_cb(cb) {} ~_prxy(){}; operator SEL_HttpResponse() const { return _cb; } - CC_DEPRECATED_ATTRIBUTE operator cocos2d::SEL_CallFuncND() const { return (cocos2d::SEL_CallFuncND) _cb; } + CC_DEPRECATED_ATTRIBUTE operator SEL_CallFuncND() const { return (SEL_CallFuncND) _cb; } protected: SEL_HttpResponse _cb; }; @@ -223,11 +226,11 @@ public: protected: // properties - Type _requestType; /// kHttpRequestGet, kHttpRequestPost or other enums + Type _requestType; /// kHttpRequestGet, kHttpRequestPost or other enums std::string _url; /// target url that this request is sent to std::vector _requestData; /// used for POST std::string _tag; /// user defined tag, to identify different requests in response callback - cocos2d::Object* _pTarget; /// callback target of pSelector function + Ref* _pTarget; /// callback target of pSelector function SEL_HttpResponse _pSelector; /// callback function, e.g. MyLayer::onHttpResponse(HttpClient *sender, HttpResponse * response) void* _pUserData; /// You can add your customed data here std::vector _headers; /// custom http headers diff --git a/cocos/network/HttpResponse.h b/cocos/network/HttpResponse.h index ebad23ec64..d66b09eb32 100644 --- a/cocos/network/HttpResponse.h +++ b/cocos/network/HttpResponse.h @@ -37,7 +37,7 @@ namespace network { Please refer to samples/TestCpp/Classes/ExtensionTest/NetworkTest/HttpClientTest.cpp as a sample @since v2.0.2 */ -class HttpResponse : public cocos2d::Object +class HttpResponse : public cocos2d::Ref { public: /** Constructor, it's used by HttpClient internal, users don't need to create HttpResponse manually @@ -68,7 +68,7 @@ public: } /** Override autorelease method to prevent developers from calling it */ - cocos2d::Object* autorelease(void) + cocos2d::Ref* autorelease(void) { CCASSERT(false, "HttpResponse is used between network thread and ui thread \ therefore, autorelease is forbidden here"); diff --git a/cocos/network/SocketIO.cpp b/cocos/network/SocketIO.cpp index cc4b489e32..23e850d0f6 100644 --- a/cocos/network/SocketIO.cpp +++ b/cocos/network/SocketIO.cpp @@ -46,7 +46,7 @@ namespace network { * Clients/endpoints may share the same impl to accomplish multiplexing on the same websocket */ class SIOClientImpl : - public cocos2d::Object, + public cocos2d::Ref, public WebSocket::Delegate { private: diff --git a/cocos/network/SocketIO.h b/cocos/network/SocketIO.h index 8562fc1ba9..4721810c5c 100644 --- a/cocos/network/SocketIO.h +++ b/cocos/network/SocketIO.h @@ -129,7 +129,7 @@ typedef std::unordered_map EventRegistry; * @brief A single connection to a socket.io endpoint */ class SIOClient - : public cocos2d::Object + : public cocos2d::Ref { private: int _port; diff --git a/cocos/network/WebSocket.cpp b/cocos/network/WebSocket.cpp index 3b5b3559f7..f244212b99 100644 --- a/cocos/network/WebSocket.cpp +++ b/cocos/network/WebSocket.cpp @@ -56,7 +56,7 @@ public: /** * @brief Websocket thread helper, it's used for sending message between UI thread and websocket thread. */ -class WsThreadHelper : public Object +class WsThreadHelper : public Ref { public: WsThreadHelper(); diff --git a/cocos/physics/CCPhysicsBody.h b/cocos/physics/CCPhysicsBody.h index 09574a22cc..47329e2b5f 100644 --- a/cocos/physics/CCPhysicsBody.h +++ b/cocos/physics/CCPhysicsBody.h @@ -28,12 +28,14 @@ #include "ccConfig.h" #if CC_USE_PHYSICS -#include "CCObject.h" +#include "CCRef.h" #include "CCGeometry.h" #include "CCPhysicsShape.h" #include "CCVector.h" NS_CC_BEGIN + +class Node; class Sprite; class PhysicsWorld; class PhysicsJoint; @@ -51,7 +53,7 @@ const PhysicsMaterial PHYSICSBODY_MATERIAL_DEFAULT(0.1f, 0.5f, 0.5f); * if you create body with createEdgeXXX, the mass and moment will be PHYSICS_INFINITY by default. and it's a static body. * you can change mass and moment with setMass() and setMoment(). and you can change the body to be dynamic or static by use function setDynamic(). */ -class PhysicsBody : public Object +class PhysicsBody : public Ref { public: /** create a body with defult mass and moment. */ @@ -291,7 +293,7 @@ protected: virtual void setPosition(Point position); virtual void setRotation(float rotation); - virtual void update(float delta) override; + void update(float delta); void removeJoint(PhysicsJoint* joint); diff --git a/cocos/physics/CCPhysicsContact.h b/cocos/physics/CCPhysicsContact.h index cb7932b599..b8fd4cf4c9 100644 --- a/cocos/physics/CCPhysicsContact.h +++ b/cocos/physics/CCPhysicsContact.h @@ -28,7 +28,7 @@ #include "ccConfig.h" #if CC_USE_PHYSICS -#include "CCObject.h" +#include "CCRef.h" #include "CCGeometry.h" #include "CCEventListenerCustom.h" #include "CCEvent.h" diff --git a/cocos/physics/CCPhysicsJoint.h b/cocos/physics/CCPhysicsJoint.h index e2a2d5a9a9..3ec16c6e29 100644 --- a/cocos/physics/CCPhysicsJoint.h +++ b/cocos/physics/CCPhysicsJoint.h @@ -28,11 +28,12 @@ #include "ccConfig.h" #if CC_USE_PHYSICS -#include "CCObject.h" +#include "CCRef.h" #include "CCGeometry.h" NS_CC_BEGIN +class Node; class PhysicsBody; class PhysicsWorld; class PhysicsJointInfo; diff --git a/cocos/physics/CCPhysicsShape.h b/cocos/physics/CCPhysicsShape.h index 6863e47377..175717d06f 100644 --- a/cocos/physics/CCPhysicsShape.h +++ b/cocos/physics/CCPhysicsShape.h @@ -28,7 +28,7 @@ #include "ccConfig.h" #if CC_USE_PHYSICS -#include "CCObject.h" +#include "CCRef.h" #include "CCGeometry.h" NS_CC_BEGIN @@ -62,7 +62,7 @@ const PhysicsMaterial PHYSICSSHAPE_MATERIAL_DEFAULT(0.0f, 0.5f, 0.5f); /** * @brief A shape for body. You do not create PhysicsWorld objects directly, instead, you can view PhysicsBody to see how to create it. */ -class PhysicsShape : public Object +class PhysicsShape : public Ref { public: enum class Type diff --git a/cocos/physics/CCPhysicsWorld.cpp b/cocos/physics/CCPhysicsWorld.cpp index c3f70af16d..bb4b16eaef 100644 --- a/cocos/physics/CCPhysicsWorld.cpp +++ b/cocos/physics/CCPhysicsWorld.cpp @@ -207,7 +207,7 @@ void PhysicsWorld::debugDraw() { if (_debugDrawMask & DEBUGDRAW_SHAPE) { - for (Object* obj : _bodies) + for (Ref* obj : _bodies) { PhysicsBody* body = dynamic_cast(obj); diff --git a/cocos/physics/CCPhysicsWorld.h b/cocos/physics/CCPhysicsWorld.h index 4ce0a2bb2a..ed09a521a2 100644 --- a/cocos/physics/CCPhysicsWorld.h +++ b/cocos/physics/CCPhysicsWorld.h @@ -29,7 +29,7 @@ #if CC_USE_PHYSICS #include "CCVector.h" -#include "CCObject.h" +#include "CCRef.h" #include "CCGeometry.h" #include diff --git a/cocos/physics/chipmunk/CCPhysicsBodyInfo_chipmunk.h b/cocos/physics/chipmunk/CCPhysicsBodyInfo_chipmunk.h index 7f3d6aa177..3cbade4a7b 100644 --- a/cocos/physics/chipmunk/CCPhysicsBodyInfo_chipmunk.h +++ b/cocos/physics/chipmunk/CCPhysicsBodyInfo_chipmunk.h @@ -30,7 +30,7 @@ #include "chipmunk.h" #include "CCPlatformMacros.h" -#include "CCObject.h" +#include "CCRef.h" NS_CC_BEGIN diff --git a/cocos/scripting/auto-generated b/cocos/scripting/auto-generated index 8c8ddeab15..81741a72e6 160000 --- a/cocos/scripting/auto-generated +++ b/cocos/scripting/auto-generated @@ -1 +1 @@ -Subproject commit 8c8ddeab158e65016e215131032a5e86dc7d93b5 +Subproject commit 81741a72e650ecf3bcf113c9ffa9b0bf18942aa4 diff --git a/cocos/scripting/javascript/bindings/ScriptingCore.cpp b/cocos/scripting/javascript/bindings/ScriptingCore.cpp index 7cd0055408..e1040d14b1 100644 --- a/cocos/scripting/javascript/bindings/ScriptingCore.cpp +++ b/cocos/scripting/javascript/bindings/ScriptingCore.cpp @@ -662,7 +662,7 @@ bool ScriptingCore::log(JSContext* cx, uint32_t argc, jsval *vp) } -void ScriptingCore::removeScriptObjectByObject(Object* pObj) +void ScriptingCore::removeScriptObjectByObject(Ref* pObj) { js_proxy_t* nproxy; js_proxy_t* jsproxy; @@ -791,7 +791,7 @@ void ScriptingCore::cleanupSchedulesAndActions(js_proxy_t* p) Array* arr = JSScheduleWrapper::getTargetForJSObject(p->obj); if (arr) { Scheduler* pScheduler = Director::getInstance()->getScheduler(); - Object* pObj = NULL; + Ref* pObj = NULL; CCARRAY_FOREACH(arr, pObj) { pScheduler->unscheduleAllForTarget(pObj); @@ -1459,7 +1459,7 @@ void ScriptingCore::enableDebugger() t.detach(); Scheduler* scheduler = Director::getInstance()->getScheduler(); - scheduler->scheduleUpdateForTarget(this->_runLoop, 0, false); + scheduler->scheduleUpdate(CC_CALLBACK_1(SimpleRunLoop::update, this->_runLoop), this->_runLoop, 0, false); } } diff --git a/cocos/scripting/javascript/bindings/ScriptingCore.h b/cocos/scripting/javascript/bindings/ScriptingCore.h index 696eeb5330..98bf67567c 100644 --- a/cocos/scripting/javascript/bindings/ScriptingCore.h +++ b/cocos/scripting/javascript/bindings/ScriptingCore.h @@ -28,7 +28,7 @@ typedef void (*sc_register_sth)(JSContext* cx, JSObject* global); void registerDefaultClasses(JSContext* cx, JSObject* global); -class SimpleRunLoop : public cocos2d::Object +class SimpleRunLoop : public cocos2d::Ref { public: void update(float d); @@ -60,7 +60,7 @@ public: @brief Remove Object from lua state @param object to remove */ - virtual void removeScriptObjectByObject(cocos2d::Object* pObj); + virtual void removeScriptObjectByObject(cocos2d::Ref* obj); /** @brief Execute script code contained in the given string. diff --git a/cocos/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id b/cocos/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id index f03353b528..b03dbda085 100644 --- a/cocos/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id +++ b/cocos/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id @@ -1 +1 @@ -6b152e5e2a94123ea842debbc4aa3eecff5119d7 \ No newline at end of file +60e98a17932dbac3428a8901c0d798e5a1ae557f \ No newline at end of file diff --git a/cocos/scripting/javascript/bindings/cocos2d_specifics.hpp b/cocos/scripting/javascript/bindings/cocos2d_specifics.hpp index c4dabf4b36..3d819ea9b0 100644 --- a/cocos/scripting/javascript/bindings/cocos2d_specifics.hpp +++ b/cocos/scripting/javascript/bindings/cocos2d_specifics.hpp @@ -93,7 +93,7 @@ jsval anonEvaluate(JSContext *cx, JSObject *thisObj, const char* string); void register_cocos2dx_js_extensions(JSContext* cx, JSObject* obj); -class JSCallbackWrapper: public cocos2d::Object { +class JSCallbackWrapper: public cocos2d::Ref { public: JSCallbackWrapper(); virtual ~JSCallbackWrapper(); @@ -135,10 +135,10 @@ public: void pause(); void scheduleFunc(float dt); - virtual void update(float dt); + void update(float dt); - Object* getTarget(); - void setTarget(Object* pTarget); + Ref* getTarget(); + void setTarget(Ref* pTarget); void setPureJSTarget(JSObject* jstarget); JSObject* getPureJSTarget(); @@ -150,14 +150,14 @@ public: bool isUpdateSchedule(); protected: - Object* _pTarget; + Ref* _pTarget; JSObject* _pPureJSTarget; int _priority; bool _isUpdateSchedule; }; -class JSTouchDelegate: public cocos2d::Object +class JSTouchDelegate: public cocos2d::Ref { public: JSTouchDelegate(); diff --git a/cocos/scripting/javascript/bindings/cocosbuilder/js_bindings_ccbreader.cpp b/cocos/scripting/javascript/bindings/cocosbuilder/js_bindings_ccbreader.cpp index a37d9ccc6e..4bed05cdd1 100644 --- a/cocos/scripting/javascript/bindings/cocosbuilder/js_bindings_ccbreader.cpp +++ b/cocos/scripting/javascript/bindings/cocosbuilder/js_bindings_ccbreader.cpp @@ -23,14 +23,14 @@ static void removeSelector(std::string &str) { } } -SEL_MenuHandler CCBScriptCallbackProxy::onResolveCCBCCMenuItemSelector(cocos2d::Object * pTarget, +SEL_MenuHandler CCBScriptCallbackProxy::onResolveCCBCCMenuItemSelector(cocos2d::Ref * pTarget, const char * pSelectorName) { this->callBackProp = pSelectorName; removeSelector(this->callBackProp); return menu_selector(CCBScriptCallbackProxy::menuItemCallback); } -Control::Handler CCBScriptCallbackProxy::onResolveCCBCCControlSelector(Object * pTarget, +Control::Handler CCBScriptCallbackProxy::onResolveCCBCCControlSelector(Ref * pTarget, const char * pSelectorName) { this->callBackProp = pSelectorName; @@ -38,7 +38,7 @@ Control::Handler CCBScriptCallbackProxy::onResolveCCBCCControlSelector(Object * return cccontrol_selector(CCBScriptCallbackProxy::controlCallback); } -bool CCBScriptCallbackProxy::onAssignCCBMemberVariable(Object * pTarget, +bool CCBScriptCallbackProxy::onAssignCCBMemberVariable(Ref * pTarget, const char * pMemberVariableName, Node * pNode) { return true; @@ -53,11 +53,11 @@ CCBSelectorResolver * CCBScriptCallbackProxy::createNew() { return dynamic_cast(ret); } -void CCBScriptCallbackProxy::menuItemCallback(Object *pSender) { +void CCBScriptCallbackProxy::menuItemCallback(Ref *pSender) { ScriptingCore::getInstance()->executeFunctionWithOwner(owner, callBackProp.c_str() ); } -void CCBScriptCallbackProxy::controlCallback(Object *pSender, Control::EventType event) { +void CCBScriptCallbackProxy::controlCallback(Ref *pSender, Control::EventType event) { ScriptingCore::getInstance()->executeFunctionWithOwner(owner, callBackProp.c_str() ); } @@ -113,12 +113,12 @@ bool js_cocos2dx_CCBReader_readNodeGraphFromFile(JSContext *cx, uint32_t argc, j if (argc == 2) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); - cocos2d::Object* arg1; + cocos2d::Ref* arg1; do { js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); - arg1 = (cocos2d::Object*)(proxy ? proxy->ptr : NULL); + arg1 = (cocos2d::Ref*)(proxy ? proxy->ptr : NULL); } while (0); JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); @@ -155,12 +155,12 @@ bool js_cocos2dx_CCBReader_readNodeGraphFromFile(JSContext *cx, uint32_t argc, j if (argc == 3) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); - cocos2d::Object* arg1; + cocos2d::Ref* arg1; do { js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); - arg1 = (cocos2d::Object*)(proxy ? proxy->ptr : NULL); + arg1 = (cocos2d::Ref*)(proxy ? proxy->ptr : NULL); } while (0); cocos2d::Size arg2; ok &= jsval_to_ccsize(cx, argv[2], &arg2); @@ -196,12 +196,12 @@ bool js_cocos2dx_CCBReader_createSceneWithNodeGraphFromFile(JSContext *cx, uint3 if (argc == 2) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); - cocos2d::Object* arg1; + cocos2d::Ref* arg1; do { js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); - arg1 = (cocos2d::Object*)(proxy ? proxy->ptr : NULL); + arg1 = (cocos2d::Ref*)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, arg1) } while (0); @@ -239,12 +239,12 @@ bool js_cocos2dx_CCBReader_createSceneWithNodeGraphFromFile(JSContext *cx, uint3 if (argc == 3) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); - cocos2d::Object* arg1; + cocos2d::Ref* arg1; do { js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); - arg1 = (cocos2d::Object*)(proxy ? proxy->ptr : NULL); + arg1 = (cocos2d::Ref*)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, arg1) } while (0); cocos2d::Size arg2; diff --git a/cocos/scripting/javascript/bindings/cocosbuilder/js_bindings_ccbreader.h b/cocos/scripting/javascript/bindings/cocosbuilder/js_bindings_ccbreader.h index a1e122bad7..9dd6c776be 100644 --- a/cocos/scripting/javascript/bindings/cocosbuilder/js_bindings_ccbreader.h +++ b/cocos/scripting/javascript/bindings/cocosbuilder/js_bindings_ccbreader.h @@ -25,19 +25,19 @@ public: virtual ~CCBScriptCallbackProxy() {} CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(CCBScriptCallbackProxy, create); - virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::Object * pTarget, + virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::Ref * pTarget, const char * pSelectorName); - virtual cocos2d::extension::Control::Handler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, + virtual cocos2d::extension::Control::Handler onResolveCCBCCControlSelector(cocos2d::Ref * pTarget, const char * pSelectorName); - virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName, + virtual bool onAssignCCBMemberVariable(cocos2d::Ref * pTarget, const char * pMemberVariableName, cocos2d::Node * pNode); virtual void onNodeLoaded(cocos2d::Node * pNode, cocosbuilder::NodeLoader * pNodeLoader); virtual CCBSelectorResolver * createNew(); - void menuItemCallback(Object *pSender); - void controlCallback(Object *pSender, cocos2d::extension::Control::EventType event); + void menuItemCallback(Ref *pSender); + void controlCallback(Ref *pSender, cocos2d::extension::Control::EventType event); void setCallbackProperty(const char *prop); void setJSOwner(jsval ownr); jsval getJSOwner(); diff --git a/cocos/scripting/javascript/bindings/extension/jsb_cocos2dx_extension_manual.cpp b/cocos/scripting/javascript/bindings/extension/jsb_cocos2dx_extension_manual.cpp index 9868db1c70..31e64f99ef 100644 --- a/cocos/scripting/javascript/bindings/extension/jsb_cocos2dx_extension_manual.cpp +++ b/cocos/scripting/javascript/bindings/extension/jsb_cocos2dx_extension_manual.cpp @@ -15,7 +15,7 @@ USING_NS_CC_EXT; class JSB_ScrollViewDelegate -: public Object +: public Ref , public ScrollViewDelegate { public: @@ -101,7 +101,7 @@ static bool js_cocos2dx_CCScrollView_setDelegate(JSContext *cx, uint32_t argc, j #define KEY_TABLEVIEW_DELEGATE "TableViewDelegate" class JSB_TableViewDelegate -: public Object +: public Ref , public TableViewDelegate { public: @@ -230,7 +230,7 @@ static bool js_cocos2dx_CCTableView_setDelegate(JSContext *cx, uint32_t argc, js } class JSB_TableViewDataSource -: public Object +: public Ref , public TableViewDataSource { public: @@ -490,7 +490,7 @@ static bool js_cocos2dx_CCTableView_create(JSContext *cx, uint32_t argc, jsval * } class JSB_EditBoxDelegate -: public Object +: public Ref , public EditBoxDelegate { public: @@ -595,7 +595,7 @@ static bool js_cocos2dx_CCEditBox_setDelegate(JSContext *cx, uint32_t argc, jsva -class JSB_ControlButtonTarget : public Object +class JSB_ControlButtonTarget : public Ref { public: JSB_ControlButtonTarget() @@ -626,7 +626,7 @@ public: } } - virtual void onEvent(Object *controlButton, Control::EventType event) + virtual void onEvent(Ref *controlButton, Control::EventType event) { js_proxy_t * p; JS_GET_PROXY(p, controlButton); diff --git a/cocos/scripting/javascript/bindings/gui/jsb_cocos2dx_gui_manual.cpp b/cocos/scripting/javascript/bindings/gui/jsb_cocos2dx_gui_manual.cpp index 773306569e..b25f27bfb0 100644 --- a/cocos/scripting/javascript/bindings/gui/jsb_cocos2dx_gui_manual.cpp +++ b/cocos/scripting/javascript/bindings/gui/jsb_cocos2dx_gui_manual.cpp @@ -19,7 +19,7 @@ public: virtual void setJSCallbackThis(jsval thisObj); - virtual void eventCallbackFunc(Object*,int); + virtual void eventCallbackFunc(Ref*,int); private: bool m_bNeedUnroot; @@ -55,7 +55,7 @@ void JSStudioEventListenerWrapper::setJSCallbackThis(jsval jsThisObj) } } -void JSStudioEventListenerWrapper::eventCallbackFunc(Object* sender,int eventType) +void JSStudioEventListenerWrapper::eventCallbackFunc(Ref* sender,int eventType) { JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); JSObject *thisObj = JSVAL_IS_VOID(_jsThisObj) ? NULL : JSVAL_TO_OBJECT(_jsThisObj); diff --git a/cocos/scripting/javascript/bindings/js_bindings_opengl.cpp b/cocos/scripting/javascript/bindings/js_bindings_opengl.cpp index 38bef1ee1d..0098b293db 100644 --- a/cocos/scripting/javascript/bindings/js_bindings_opengl.cpp +++ b/cocos/scripting/javascript/bindings/js_bindings_opengl.cpp @@ -32,7 +32,7 @@ bool js_cocos2dx_GLNode_constructor(JSContext *cx, uint32_t argc, jsval *vp) if (argc == 0) { GLNode* cobj = new GLNode(); - cocos2d::Object *_ccobj = dynamic_cast(cobj); + cocos2d::Ref *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } diff --git a/cocos/scripting/javascript/bindings/js_manual_conversions.cpp b/cocos/scripting/javascript/bindings/js_manual_conversions.cpp index bd5e49b910..129d5b59b9 100644 --- a/cocos/scripting/javascript/bindings/js_manual_conversions.cpp +++ b/cocos/scripting/javascript/bindings/js_manual_conversions.cpp @@ -587,7 +587,7 @@ bool jsvals_variadic_to_ccarray( JSContext *cx, jsval *vp, int argc, Array** ret JSObject* obj = JSVAL_TO_OBJECT(*vp); p = jsb_get_js_proxy(obj); if (p) { - pArray->addObject((Object*)p->ptr); + pArray->addObject((Ref*)p->ptr); } } // next @@ -831,7 +831,7 @@ bool jsval_to_ccarray(JSContext* cx, jsval v, __Array** ret) js_proxy_t *proxy; JSObject *tmp = JSVAL_TO_OBJECT(value); proxy = jsb_get_js_proxy(tmp); - cocos2d::Object* cobj = (cocos2d::Object *)(proxy ? proxy->ptr : NULL); + cocos2d::Ref* cobj = (cocos2d::Ref *)(proxy ? proxy->ptr : NULL); // Don't test it. //TEST_NATIVE_OBJECT(cx, cobj) if (cobj) { @@ -1276,14 +1276,14 @@ jsval ccarray_to_jsval(JSContext* cx, __Array *arr) { JSObject *jsretArr = JS_NewArrayObject(cx, 0, NULL); - Object* obj; + Ref* obj; int i = 0; CCARRAY_FOREACH(arr, obj) { JS::RootedValue arrElement(cx); //First, check whether object is associated with js object. - js_proxy_t* jsproxy = js_get_or_create_proxy(cx, obj); + js_proxy_t* jsproxy = js_get_or_create_proxy(cx, obj); if (jsproxy) { arrElement = OBJECT_TO_JSVAL(jsproxy->obj); } @@ -1329,9 +1329,9 @@ jsval ccdictionary_to_jsval(JSContext* cx, __Dictionary* dict) CCDICT_FOREACH(dict, pElement) { JS::RootedValue dictElement(cx); - Object* obj = pElement->getObject(); + Ref* obj = pElement->getObject(); //First, check whether object is associated with js object. - js_proxy_t* jsproxy = js_get_or_create_proxy(cx, obj); + js_proxy_t* jsproxy = js_get_or_create_proxy(cx, obj); if (jsproxy) { dictElement = OBJECT_TO_JSVAL(jsproxy->obj); } @@ -1416,7 +1416,7 @@ bool jsval_to_ccdictionary(JSContext* cx, jsval v, __Dictionary** ret) js_proxy_t *proxy; tmp = JSVAL_TO_OBJECT(value); proxy = jsb_get_js_proxy(tmp); - cocos2d::Object* cobj = (cocos2d::Object *)(proxy ? proxy->ptr : NULL); + cocos2d::Ref* cobj = (cocos2d::Ref *)(proxy ? proxy->ptr : NULL); // Don't test it. //TEST_NATIVE_OBJECT(cx, cobj) if (cobj) { diff --git a/cocos/scripting/javascript/bindings/js_manual_conversions.h b/cocos/scripting/javascript/bindings/js_manual_conversions.h index a00e9c97bc..679c80d84c 100644 --- a/cocos/scripting/javascript/bindings/js_manual_conversions.h +++ b/cocos/scripting/javascript/bindings/js_manual_conversions.h @@ -255,7 +255,7 @@ jsval ccvector_to_jsval(JSContext* cx, const cocos2d::Vector& v) JS::RootedValue arrElement(cx); //First, check whether object is associated with js object. - js_proxy_t* jsproxy = js_get_or_create_proxy(cx, obj); + js_proxy_t* jsproxy = js_get_or_create_proxy(cx, obj); if (jsproxy) { arrElement = OBJECT_TO_JSVAL(jsproxy->obj); } @@ -281,7 +281,7 @@ jsval ccmap_string_key_to_jsval(JSContext* cx, const cocos2d::Mapsecond; //First, check whether object is associated with js object. - js_proxy_t* jsproxy = js_get_or_create_proxy(cx, obj); + js_proxy_t* jsproxy = js_get_or_create_proxy(cx, obj); if (jsproxy) { element = OBJECT_TO_JSVAL(jsproxy->obj); } diff --git a/cocos/scripting/javascript/bindings/network/XMLHTTPRequest.h b/cocos/scripting/javascript/bindings/network/XMLHTTPRequest.h index c634ef481e..881e2536af 100644 --- a/cocos/scripting/javascript/bindings/network/XMLHTTPRequest.h +++ b/cocos/scripting/javascript/bindings/network/XMLHTTPRequest.h @@ -36,7 +36,7 @@ #include "ScriptingCore.h" #include "jsb_helper.h" -class MinXmlHttpRequest : public cocos2d::Object +class MinXmlHttpRequest : public cocos2d::Ref { public: enum class ResponseType diff --git a/cocos/scripting/lua/bindings/CCLuaEngine.cpp b/cocos/scripting/lua/bindings/CCLuaEngine.cpp index 502909695d..4b2f103f8e 100644 --- a/cocos/scripting/lua/bindings/CCLuaEngine.cpp +++ b/cocos/scripting/lua/bindings/CCLuaEngine.cpp @@ -75,7 +75,7 @@ void LuaEngine::addLuaLoader(lua_CFunction func) _stack->addLuaLoader(func); } -void LuaEngine::removeScriptObjectByObject(Object* pObj) +void LuaEngine::removeScriptObjectByObject(Ref* pObj) { _stack->removeScriptObjectByObject(pObj); ScriptHandlerMgr::getInstance()->removeObjectAllHandlers(pObj); @@ -128,7 +128,7 @@ int LuaEngine::executeNotificationEvent(NotificationCenter* pNotificationCenter, return ret; } -int LuaEngine::executeCallFuncActionEvent(CallFunc* pAction, Object* pTarget/* = NULL*/) +int LuaEngine::executeCallFuncActionEvent(CallFunc* pAction, Ref* pTarget/* = NULL*/) { return 0; } @@ -162,7 +162,7 @@ int LuaEngine::executeAccelerometerEvent(Layer* pLayer, Acceleration* pAccelerat return 0; } -int LuaEngine::executeEvent(int nHandler, const char* pEventName, Object* pEventSource /* = NULL*/, const char* pEventSourceClassName /* = NULL*/) +int LuaEngine::executeEvent(int nHandler, const char* pEventName, Ref* pEventSource /* = NULL*/, const char* pEventSourceClassName /* = NULL*/) { _stack->pushString(pEventName); if (pEventSource) @@ -349,7 +349,7 @@ int LuaEngine::handleCallFuncActionEvent(void* data) if (0 == handler) return 0; - Object* target = static_cast(basicScriptData->value); + Ref* target = static_cast(basicScriptData->value); if (NULL != target) { _stack->pushObject(target, "cc.Node"); @@ -585,7 +585,7 @@ int LuaEngine::handlerControlEvent(void* data) if (0 != handler) { - _stack->pushObject((Object*)basicScriptData->nativeObject, "cc.Object"); + _stack->pushObject((Ref*)basicScriptData->nativeObject, "cc.Object"); _stack->pushInt(controlEvents); ret = _stack->executeFunctionByHandler(handler, 2); _stack->clean(); @@ -872,7 +872,7 @@ int LuaEngine::handleTableViewEvent(ScriptHandlerMgr::HandlerType type,void* dat if (0 == handler) return 0; - Object* obj = static_cast(eventData->nativeObject); + Ref* obj = static_cast(eventData->nativeObject); if (nullptr == obj) return 0; @@ -891,7 +891,7 @@ int LuaEngine::handleTableViewEvent(ScriptHandlerMgr::HandlerType type,void* dat case ScriptHandlerMgr::HandlerType::TABLECELL_UNHIGHLIGHT: case ScriptHandlerMgr::HandlerType::TABLECELL_WILL_RECYCLE: { - Object* cellObject = static_cast(tableViewData->value); + Ref* cellObject = static_cast(tableViewData->value); if (nullptr == cellObject) { break; } @@ -923,7 +923,7 @@ int LuaEngine::handleTableViewEvent(ScriptHandlerMgr::HandlerType handlerType,vo if (0 == handler) return 0; - Object* obj = static_cast(eventData->nativeObject); + Ref* obj = static_cast(eventData->nativeObject); if (nullptr == obj) return 0; diff --git a/cocos/scripting/lua/bindings/CCLuaEngine.h b/cocos/scripting/lua/bindings/CCLuaEngine.h index e3f4ff9bef..2de9605edc 100644 --- a/cocos/scripting/lua/bindings/CCLuaEngine.h +++ b/cocos/scripting/lua/bindings/CCLuaEngine.h @@ -69,7 +69,7 @@ public: @brief Remove Object from lua state @param object to remove */ - virtual void removeScriptObjectByObject(Object* object); + virtual void removeScriptObjectByObject(Ref* object); /** @brief Remove Lua function reference @@ -106,14 +106,14 @@ public: virtual int executeNodeEvent(Node* pNode, int nAction); virtual int executeMenuItemEvent(MenuItem* pMenuItem); virtual int executeNotificationEvent(NotificationCenter* pNotificationCenter, const char* pszName); - virtual int executeCallFuncActionEvent(CallFunc* pAction, Object* pTarget = NULL); + virtual int executeCallFuncActionEvent(CallFunc* pAction, Ref* pTarget = NULL); virtual int executeSchedule(int nHandler, float dt, Node* pNode = NULL); virtual int executeLayerTouchesEvent(Layer* pLayer, int eventType, Set *pTouches); virtual int executeLayerTouchEvent(Layer* pLayer, int eventType, Touch *pTouch); virtual int executeLayerKeypadEvent(Layer* pLayer, int eventType); /** execute a accelerometer event */ virtual int executeAccelerometerEvent(Layer* pLayer, Acceleration* pAccelerationValue); - virtual int executeEvent(int nHandler, const char* pEventName, Object* pEventSource = NULL, const char* pEventSourceClassName = NULL); + virtual int executeEvent(int nHandler, const char* pEventName, Ref* pEventSource = NULL, const char* pEventSourceClassName = NULL); virtual bool handleAssert(const char *msg); diff --git a/cocos/scripting/lua/bindings/CCLuaStack.cpp b/cocos/scripting/lua/bindings/CCLuaStack.cpp index b836f49853..d68fbace56 100644 --- a/cocos/scripting/lua/bindings/CCLuaStack.cpp +++ b/cocos/scripting/lua/bindings/CCLuaStack.cpp @@ -237,7 +237,7 @@ void LuaStack::addLuaLoader(lua_CFunction func) } -void LuaStack::removeScriptObjectByObject(Object* pObj) +void LuaStack::removeScriptObjectByObject(Ref* pObj) { toluafix_remove_ccobject_by_refid(_state, pObj->_luaID); } @@ -330,7 +330,7 @@ void LuaStack::pushNil(void) lua_pushnil(_state); } -void LuaStack::pushObject(Object* objectValue, const char* typeName) +void LuaStack::pushObject(Ref* objectValue, const char* typeName) { toluafix_pushusertype_ccobject(_state, objectValue->_ID, &objectValue->_luaID, objectValue, typeName); } @@ -576,7 +576,7 @@ int LuaStack::executeFunctionReturnArray(int handler,int numArgs,int numResults, }else{ - resultArray.addObject(static_cast(tolua_tousertype(_state, -1, NULL))); + resultArray.addObject(static_cast(tolua_tousertype(_state, -1, NULL))); } // remove return value from stack lua_pop(_state, 1); /* L: ... [G] ret1 ret2 ... ret*/ diff --git a/cocos/scripting/lua/bindings/CCLuaStack.h b/cocos/scripting/lua/bindings/CCLuaStack.h index ed31c48b91..442f19eafb 100644 --- a/cocos/scripting/lua/bindings/CCLuaStack.h +++ b/cocos/scripting/lua/bindings/CCLuaStack.h @@ -35,7 +35,7 @@ extern "C" { NS_CC_BEGIN -class LuaStack : public Object +class LuaStack : public Ref { public: static LuaStack *create(void); @@ -66,7 +66,7 @@ public: @brief Remove Object from lua state @param object The object to be removed. */ - virtual void removeScriptObjectByObject(Object* object); + virtual void removeScriptObjectByObject(Ref* object); /** @brief Remove Lua function reference @@ -108,7 +108,7 @@ public: virtual void pushString(const char* stringValue); virtual void pushString(const char* stringValue, int length); virtual void pushNil(void); - virtual void pushObject(Object* objectValue, const char* typeName); + virtual void pushObject(Ref* objectValue, const char* typeName); virtual void pushLuaValue(const LuaValue& value); virtual void pushLuaValueDict(const LuaValueDict& dict); virtual void pushLuaValueArray(const LuaValueArray& array); diff --git a/cocos/scripting/lua/bindings/CCLuaValue.cpp b/cocos/scripting/lua/bindings/CCLuaValue.cpp index 584f17a6a8..1365ee6216 100644 --- a/cocos/scripting/lua/bindings/CCLuaValue.cpp +++ b/cocos/scripting/lua/bindings/CCLuaValue.cpp @@ -84,7 +84,7 @@ const LuaValue LuaValue::arrayValue(const LuaValueArray& arrayValue) return value; } -const LuaValue LuaValue::ccobjectValue(Object* ccobjectValue, const char* objectTypename) +const LuaValue LuaValue::ccobjectValue(Ref* ccobjectValue, const char* objectTypename) { LuaValue value; value._type = LuaValueTypeObject; @@ -94,7 +94,7 @@ const LuaValue LuaValue::ccobjectValue(Object* ccobjectValue, const char* object return value; } -const LuaValue LuaValue::ccobjectValue(Object* ccobjectValue, const std::string& objectTypename) +const LuaValue LuaValue::ccobjectValue(Ref* ccobjectValue, const std::string& objectTypename) { return LuaValue::ccobjectValue(ccobjectValue, objectTypename.c_str()); } diff --git a/cocos/scripting/lua/bindings/CCLuaValue.h b/cocos/scripting/lua/bindings/CCLuaValue.h index eefc0c85c4..2a915789f6 100644 --- a/cocos/scripting/lua/bindings/CCLuaValue.h +++ b/cocos/scripting/lua/bindings/CCLuaValue.h @@ -35,7 +35,7 @@ extern "C" { } #include "ccTypes.h" -#include "CCObject.h" +#include "CCRef.h" #if CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY using std::memset; @@ -72,7 +72,7 @@ typedef union { std::string* stringValue; LuaValueDict* dictValue; LuaValueArray* arrayValue; - Object* ccobjectValue; + Ref* ccobjectValue; } LuaValueField; class LuaValue @@ -85,8 +85,8 @@ public: static const LuaValue stringValue(const std::string& stringValue); static const LuaValue dictValue(const LuaValueDict& dictValue); static const LuaValue arrayValue(const LuaValueArray& arrayValue); - static const LuaValue ccobjectValue(Object* ccobjectValue, const char* objectTypename); - static const LuaValue ccobjectValue(Object* ccobjectValue, const std::string& objectTypename); + static const LuaValue ccobjectValue(Ref* ccobjectValue, const char* objectTypename); + static const LuaValue ccobjectValue(Ref* ccobjectValue, const std::string& objectTypename); LuaValue(void) : _type(LuaValueTypeInt) @@ -130,7 +130,7 @@ public: return *_field.arrayValue; } - Object* ccobjectValue(void) const { + Ref* ccobjectValue(void) const { return _field.ccobjectValue; } diff --git a/cocos/scripting/lua/bindings/LuaBasicConversions.cpp b/cocos/scripting/lua/bindings/LuaBasicConversions.cpp index a2d97434c8..ddd12b5259 100644 --- a/cocos/scripting/lua/bindings/LuaBasicConversions.cpp +++ b/cocos/scripting/lua/bindings/LuaBasicConversions.cpp @@ -822,7 +822,7 @@ bool luaval_to_array(lua_State* L,int lo, Array** outValue) if (lua_isuserdata(L, -1)) { - Object* obj = static_cast(tolua_tousertype(L, -1, NULL) ); + Ref* obj = static_cast(tolua_tousertype(L, -1, NULL) ); if (NULL != obj) { arr->addObject(obj); @@ -925,7 +925,7 @@ bool luaval_to_dictionary(lua_State* L,int lo, Dictionary** outValue) { if (lua_isuserdata(L, -1)) { - Object* obj = static_cast(tolua_tousertype(L, -1, NULL) ); + Ref* obj = static_cast(tolua_tousertype(L, -1, NULL) ); if (NULL != obj) { //get the key to string @@ -1079,7 +1079,7 @@ bool luavals_variadic_to_array(lua_State* L,int argc, Array** ret) ok = false; break; } - Object* obj = static_cast(tolua_tousertype(L, i + 2, nullptr)); + Ref* obj = static_cast(tolua_tousertype(L, i + 2, nullptr)); array->addObject(obj); } } @@ -1827,7 +1827,7 @@ void array_to_luaval(lua_State* L,Array* inValue) if (nullptr == L || nullptr == inValue) return; - Object* obj = nullptr; + Ref* obj = nullptr; std::string className = ""; String* strVal = nullptr; @@ -1849,7 +1849,7 @@ void array_to_luaval(lua_State* L,Array* inValue) if (g_luaType.end() != iter) { className = iter->second; - if (nullptr != dynamic_cast(obj)) + if (nullptr != dynamic_cast(obj)) { lua_pushnumber(L, (lua_Number)indexTable); int ID = (obj) ? (int)obj->_ID : -1; @@ -1939,7 +1939,7 @@ void dictionary_to_luaval(lua_State* L, Dictionary* dict) if (g_luaType.end() != iter) { className = iter->second; - if ( nullptr != dynamic_cast(element->getObject())) + if ( nullptr != dynamic_cast(element->getObject())) { lua_pushstring(L, element->getStrKey()); int ID = (element->getObject()) ? (int)element->getObject()->_ID : -1; diff --git a/cocos/scripting/lua/bindings/LuaBasicConversions.h b/cocos/scripting/lua/bindings/LuaBasicConversions.h index ac57af4556..9044d41dad 100644 --- a/cocos/scripting/lua/bindings/LuaBasicConversions.h +++ b/cocos/scripting/lua/bindings/LuaBasicConversions.h @@ -243,7 +243,7 @@ void ccvector_to_luaval(lua_State* L,const cocos2d::Vector& inValue) continue; - if (nullptr != dynamic_cast(obj)) + if (nullptr != dynamic_cast(obj)) { std::string typeName = typeid(*obj).name(); auto iter = g_luaType.find(typeName); @@ -273,7 +273,7 @@ void ccmap_string_key_to_luaval(lua_State* L, const cocos2d::Map { std::string key = iter->first; T obj = iter->second; - if (nullptr != dynamic_cast(obj)) + if (nullptr != dynamic_cast(obj)) { std::string name = typeid(*obj).name(); auto typeIter = g_luaType.find(name); @@ -314,7 +314,7 @@ void object_to_luaval(lua_State* L,const char* type, T* ret) className = type; } - cocos2d::Object* dynObject = dynamic_cast(ret); + cocos2d::Ref* dynObject = dynamic_cast(ret); if (nullptr != dynObject) { int ID = (int)(dynObject->_ID) ; diff --git a/cocos/scripting/lua/bindings/LuaScriptHandlerMgr.h b/cocos/scripting/lua/bindings/LuaScriptHandlerMgr.h index 7cc980a37e..08dcd2f4a8 100644 --- a/cocos/scripting/lua/bindings/LuaScriptHandlerMgr.h +++ b/cocos/scripting/lua/bindings/LuaScriptHandlerMgr.h @@ -30,7 +30,7 @@ extern "C" { } -#include "CCObject.h" +#include "CCRef.h" #include "ccMacros.h" #include "CCActionInstant.h" #include @@ -44,7 +44,7 @@ class ScheduleHandlerDelegate; typedef std::vector VecShedule; typedef std::map MapNodeSchedules; -class ScheduleHandlerDelegate:public cocos2d::Object +class ScheduleHandlerDelegate:public cocos2d::Ref { public: ScheduleHandlerDelegate():_isUpdateSchedule(false) diff --git a/cocos/scripting/lua/bindings/Lua_web_socket.cpp b/cocos/scripting/lua/bindings/Lua_web_socket.cpp index f508e720f6..fbad0066b8 100644 --- a/cocos/scripting/lua/bindings/Lua_web_socket.cpp +++ b/cocos/scripting/lua/bindings/Lua_web_socket.cpp @@ -251,7 +251,7 @@ static int tolua_Cocos2d_WebSocket_createByProtocolArray00(lua_State* tolua_S) Array* protocolArray = ((Array*) tolua_tousertype(tolua_S,3,0)); std::vector protocols; if (NULL != protocolArray) { - Object* pObj = NULL; + Ref* pObj = NULL; CCARRAY_FOREACH(protocolArray, pObj) { String* pStr = static_cast(pObj); diff --git a/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.cpp b/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.cpp index 581279907d..e468eefe30 100644 --- a/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.cpp +++ b/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.cpp @@ -40,7 +40,7 @@ extern "C" { using namespace cocostudio; -class LuaArmatureWrapper:public Object +class LuaArmatureWrapper:public Ref { public: LuaArmatureWrapper(); diff --git a/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.hpp b/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.hpp index fcbdb8b7b1..33146f254a 100644 --- a/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.hpp +++ b/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.hpp @@ -32,7 +32,8 @@ extern "C" { } #endif -#include "CCObject.h" +#include "CCRef.h" +#include TOLUA_API int register_all_cocos2dx_coco_studio_manual(lua_State* L); @@ -55,23 +56,23 @@ struct LuaArmatureWrapperEventData struct LuaArmatureMovementEventData { - cocos2d::Object* objTarget; + cocos2d::Ref* objTarget; int movementType; std::string movementID; - LuaArmatureMovementEventData(cocos2d::Object* _objTarget, int _movementType,const std::string& _movementID):objTarget(_objTarget),movementType(_movementType),movementID(_movementID) + LuaArmatureMovementEventData(cocos2d::Ref* _objTarget, int _movementType,const std::string& _movementID):objTarget(_objTarget),movementType(_movementType),movementID(_movementID) { } }; struct LuaArmatureFrameEventData { - cocos2d::Object* objTarget; + cocos2d::Ref* objTarget; std::string frameEventName; int originFrameIndex; int currentFrameIndex; - LuaArmatureFrameEventData( cocos2d::Object* _objTarget, const std::string& _frameEventName, int _originFrameIndex, int _currentFrameIndex):objTarget(_objTarget), frameEventName(_frameEventName),originFrameIndex(_originFrameIndex), currentFrameIndex(_currentFrameIndex) + LuaArmatureFrameEventData( cocos2d::Ref* _objTarget, const std::string& _frameEventName, int _originFrameIndex, int _currentFrameIndex):objTarget(_objTarget), frameEventName(_frameEventName),originFrameIndex(_originFrameIndex), currentFrameIndex(_currentFrameIndex) { } }; diff --git a/cocos/scripting/lua/bindings/lua_cocos2dx_deprecated.cpp b/cocos/scripting/lua/bindings/lua_cocos2dx_deprecated.cpp index e907189be2..015950a437 100644 --- a/cocos/scripting/lua/bindings/lua_cocos2dx_deprecated.cpp +++ b/cocos/scripting/lua/bindings/lua_cocos2dx_deprecated.cpp @@ -525,7 +525,7 @@ static int tolua_Cocos2d_CCArray_createWithObject00(lua_State* tolua_S) else #endif { - Object* pObject = ((Object*) tolua_tousertype(tolua_S,2,0)); + Ref* pObject = ((Ref*) tolua_tousertype(tolua_S,2,0)); { Array* tolua_ret = (Array*) Array::createWithObject(pObject); int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; @@ -717,7 +717,7 @@ static int tolua_Cocos2d_CCArray_indexOfObject00(lua_State* tolua_S) #endif { Array* self = (Array*) tolua_tousertype(tolua_S,1,0); - Object* object = ((Object*) tolua_tousertype(tolua_S,2,0)); + Ref* object = ((Ref*) tolua_tousertype(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'indexOfObject'", NULL); #endif @@ -756,7 +756,7 @@ static int tolua_Cocos2d_CCArray_objectAtIndex00(lua_State* tolua_S) if (!self) tolua_error(tolua_S,"invalid 'self' in function 'objectAtIndex'", NULL); #endif { - Object* tolua_ret = (Object*) self->getObjectAtIndex(index); + Ref* tolua_ret = (Ref*) self->getObjectAtIndex(index); int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"Object"); @@ -790,7 +790,7 @@ static int tolua_Cocos2d_CCArray_lastObject00(lua_State* tolua_S) if (!self) tolua_error(tolua_S,"invalid 'self' in function 'lastObject'", NULL); #endif { - Object* tolua_ret = (Object*) self->getLastObject(); + Ref* tolua_ret = (Ref*) self->getLastObject(); int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"Object"); @@ -824,7 +824,7 @@ static int tolua_Cocos2d_CCArray_randomObject00(lua_State* tolua_S) if (!self) tolua_error(tolua_S,"invalid 'self' in function 'randomObject'", NULL); #endif { - Object* tolua_ret = (Object*) self->getRandomObject(); + Ref* tolua_ret = (Ref*) self->getRandomObject(); int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"Object"); @@ -889,7 +889,7 @@ static int tolua_Cocos2d_CCArray_containsObject00(lua_State* tolua_S) #endif { Array* self = (Array*) tolua_tousertype(tolua_S,1,0); - Object* object = ((Object*) tolua_tousertype(tolua_S,2,0)); + Ref* object = ((Ref*) tolua_tousertype(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'containsObject'", NULL); #endif @@ -923,7 +923,7 @@ static int tolua_Cocos2d_CCArray_addObject00(lua_State* tolua_S) #endif { Array* self = (Array*) tolua_tousertype(tolua_S,1,0); - Object* object = ((Object*) tolua_tousertype(tolua_S,2,0)); + Ref* object = ((Ref*) tolua_tousertype(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addObject'", NULL); #endif @@ -989,7 +989,7 @@ static int tolua_Cocos2d_CCArray_insertObject00(lua_State* tolua_S) #endif { Array* self = (Array*) tolua_tousertype(tolua_S,1,0); - Object* object = ((Object*) tolua_tousertype(tolua_S,2,0)); + Ref* object = ((Ref*) tolua_tousertype(tolua_S,2,0)); unsigned int index = ((unsigned int) tolua_tonumber(tolua_S,3,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'insertObject'", NULL); @@ -1056,7 +1056,7 @@ static int tolua_Cocos2d_CCArray_removeObject00(lua_State* tolua_S) #endif { Array* self = (Array*) tolua_tousertype(tolua_S,1,0); - Object* object = ((Object*) tolua_tousertype(tolua_S,2,0)); + Ref* object = ((Ref*) tolua_tousertype(tolua_S,2,0)); bool bReleaseObj = ((bool) tolua_toboolean(tolua_S,3,true)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeObject'", NULL); @@ -1186,7 +1186,7 @@ static int tolua_Cocos2d_CCArray_fastRemoveObject00(lua_State* tolua_S) #endif { Array* self = (Array*) tolua_tousertype(tolua_S,1,0); - Object* object = ((Object*) tolua_tousertype(tolua_S,2,0)); + Ref* object = ((Ref*) tolua_tousertype(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'fastRemoveObject'", NULL); #endif @@ -1252,8 +1252,8 @@ static int tolua_Cocos2d_CCArray_exchangeObject00(lua_State* tolua_S) #endif { Array* self = (Array*) tolua_tousertype(tolua_S,1,0); - Object* object1 = ((Object*) tolua_tousertype(tolua_S,2,0)); - Object* object2 = ((Object*) tolua_tousertype(tolua_S,3,0)); + Ref* object1 = ((Ref*) tolua_tousertype(tolua_S,2,0)); + Ref* object2 = ((Ref*) tolua_tousertype(tolua_S,3,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'exchangeObject'", NULL); #endif @@ -1385,7 +1385,7 @@ static int tolua_Cocos2d_CCArray_replaceObjectAtIndex00(lua_State* tolua_S) { Array* self = (Array*) tolua_tousertype(tolua_S,1,0); unsigned int uIndex = ((unsigned int) tolua_tonumber(tolua_S,2,0)); - Object* pObject = ((Object*) tolua_tousertype(tolua_S,3,0)); + Ref* pObject = ((Ref*) tolua_tousertype(tolua_S,3,0)); bool bReleaseObject = ((bool) tolua_toboolean(tolua_S,4,true)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'replaceObjectAtIndex'", NULL); @@ -1791,7 +1791,7 @@ static int tolua_Cocos2d_CCString_isEqual00(lua_State* tolua_S) #endif { String* self = (String*) tolua_tousertype(tolua_S,1,0); - const Object* pObject = ((const Object*) tolua_tousertype(tolua_S,2,0)); + const Ref* pObject = ((const Ref*) tolua_tousertype(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isEqual'", NULL); #endif diff --git a/cocos/scripting/lua/bindings/lua_cocos2dx_extension_manual.cpp b/cocos/scripting/lua/bindings/lua_cocos2dx_extension_manual.cpp index 739abb548c..7dec168f29 100644 --- a/cocos/scripting/lua/bindings/lua_cocos2dx_extension_manual.cpp +++ b/cocos/scripting/lua/bindings/lua_cocos2dx_extension_manual.cpp @@ -42,7 +42,7 @@ USING_NS_CC; USING_NS_CC_EXT; using namespace cocostudio; -class LuaScrollViewDelegate:public Object, public ScrollViewDelegate +class LuaScrollViewDelegate:public Ref, public ScrollViewDelegate { public: virtual ~LuaScrollViewDelegate() @@ -769,7 +769,7 @@ static int tolua_cocos2d_CCBReader_load(lua_State* tolua_S) if (!tolua_isusertype(tolua_S, 3, "cc.Object", 0, &tolua_err)) goto tolua_lerror; #endif - Object* owner = static_cast(tolua_tousertype(tolua_S, 3, 0)); + Ref* owner = static_cast(tolua_tousertype(tolua_S, 3, 0)); //In lua owner always define in lua script by table, so owner is always nullptr if (2 == argc) { @@ -883,7 +883,7 @@ static void extendCCBAnimationManager(lua_State* tolua_S) lua_pop(tolua_S, 1); } -class LuaAssetsManagerDelegateProtocol:public Object, public AssetsManagerDelegateProtocol +class LuaAssetsManagerDelegateProtocol:public Ref, public AssetsManagerDelegateProtocol { public: virtual ~LuaAssetsManagerDelegateProtocol() @@ -1000,7 +1000,7 @@ static void extendAssetsManager(lua_State* L) #define KEY_TABLEVIEW_DATA_SOURCE "TableViewDataSource" #define KEY_TABLEVIEW_DELEGATE "TableViewDelegate" -class LUA_TableViewDelegate:public Object, public TableViewDelegate +class LUA_TableViewDelegate:public Ref, public TableViewDelegate { public: LUA_TableViewDelegate(){} @@ -1152,7 +1152,7 @@ tolua_lerror: #endif } -class LUA_TableViewDataSource:public Object,public TableViewDataSource +class LUA_TableViewDataSource:public Ref,public TableViewDataSource { public: LUA_TableViewDataSource(){} diff --git a/cocos/scripting/lua/bindings/lua_cocos2dx_gui_manual.cpp b/cocos/scripting/lua/bindings/lua_cocos2dx_gui_manual.cpp index b51979ff53..6d1d1b1a4a 100644 --- a/cocos/scripting/lua/bindings/lua_cocos2dx_gui_manual.cpp +++ b/cocos/scripting/lua/bindings/lua_cocos2dx_gui_manual.cpp @@ -40,7 +40,7 @@ extern "C" { using namespace gui; -class LuaCocoStudioEventListener:public Object +class LuaCocoStudioEventListener:public Ref { public: LuaCocoStudioEventListener(); @@ -48,7 +48,7 @@ public: static LuaCocoStudioEventListener* create(); - virtual void eventCallbackFunc(Object* sender,int eventType); + virtual void eventCallbackFunc(Ref* sender,int eventType); }; LuaCocoStudioEventListener::LuaCocoStudioEventListener() @@ -72,7 +72,7 @@ LuaCocoStudioEventListener* LuaCocoStudioEventListener::create() return listener; } -void LuaCocoStudioEventListener::eventCallbackFunc(Object* sender,int eventType) +void LuaCocoStudioEventListener::eventCallbackFunc(Ref* sender,int eventType) { int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER); diff --git a/cocos/scripting/lua/bindings/lua_cocos2dx_gui_manual.hpp b/cocos/scripting/lua/bindings/lua_cocos2dx_gui_manual.hpp index d18581a291..b85e45f8e5 100644 --- a/cocos/scripting/lua/bindings/lua_cocos2dx_gui_manual.hpp +++ b/cocos/scripting/lua/bindings/lua_cocos2dx_gui_manual.hpp @@ -32,16 +32,16 @@ extern "C" { } #endif -#include "CCObject.h" +#include "CCRef.h" TOLUA_API int register_all_cocos2dx_gui_manual(lua_State* L); struct LuaStudioEventListenerData { - cocos2d::Object* objTarget; + cocos2d::Ref* objTarget; int eventType; - LuaStudioEventListenerData(cocos2d::Object* _objTarget, int _eventType):objTarget(_objTarget),eventType(_eventType) + LuaStudioEventListenerData(cocos2d::Ref* _objTarget, int _eventType):objTarget(_objTarget),eventType(_eventType) { } }; diff --git a/cocos/scripting/lua/bindings/lua_cocos2dx_physics_manual.cpp b/cocos/scripting/lua/bindings/lua_cocos2dx_physics_manual.cpp index 8e0d8e323f..e13fef57ed 100644 --- a/cocos/scripting/lua/bindings/lua_cocos2dx_physics_manual.cpp +++ b/cocos/scripting/lua/bindings/lua_cocos2dx_physics_manual.cpp @@ -411,7 +411,7 @@ int lua_cocos2dx_physics_PhysicsBody_createPolygon(lua_State* tolua_S) } else { className = "cc.PhysicsBody"; } - cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); + cocos2d::Ref *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; @@ -452,7 +452,7 @@ int lua_cocos2dx_physics_PhysicsBody_createPolygon(lua_State* tolua_S) } else { className = "cc.PhysicsBody"; } - cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); + cocos2d::Ref *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; @@ -495,7 +495,7 @@ int lua_cocos2dx_physics_PhysicsBody_createPolygon(lua_State* tolua_S) } else { className = "cc.PhysicsBody"; } - cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); + cocos2d::Ref *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; @@ -558,7 +558,7 @@ int lua_cocos2dx_physics_PhysicsBody_createEdgePolygon(lua_State* tolua_S) } else { className = "cc.PhysicsBody"; } - cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); + cocos2d::Ref *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; @@ -599,7 +599,7 @@ int lua_cocos2dx_physics_PhysicsBody_createEdgePolygon(lua_State* tolua_S) } else { className = "cc.PhysicsBody"; } - cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); + cocos2d::Ref *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; @@ -642,7 +642,7 @@ int lua_cocos2dx_physics_PhysicsBody_createEdgePolygon(lua_State* tolua_S) } else { className = "cc.PhysicsBody"; } - cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); + cocos2d::Ref *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; @@ -705,7 +705,7 @@ int lua_cocos2dx_physics_PhysicsBody_createEdgeChain(lua_State* tolua_S) } else { className = "cc.PhysicsBody"; } - cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); + cocos2d::Ref *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; @@ -746,7 +746,7 @@ int lua_cocos2dx_physics_PhysicsBody_createEdgeChain(lua_State* tolua_S) } else { className = "cc.PhysicsBody"; } - cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); + cocos2d::Ref *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; @@ -789,7 +789,7 @@ int lua_cocos2dx_physics_PhysicsBody_createEdgeChain(lua_State* tolua_S) } else { className = "cc.PhysicsBody"; } - cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); + cocos2d::Ref *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; diff --git a/cocos/scripting/lua/bindings/lua_cocos2dx_spine_manual.hpp b/cocos/scripting/lua/bindings/lua_cocos2dx_spine_manual.hpp index 85797a1a83..8bda268aea 100644 --- a/cocos/scripting/lua/bindings/lua_cocos2dx_spine_manual.hpp +++ b/cocos/scripting/lua/bindings/lua_cocos2dx_spine_manual.hpp @@ -32,7 +32,7 @@ extern "C" { } #endif -#include "CCObject.h" +#include "CCRef.h" TOLUA_API int register_all_cocos2dx_spine_manual(lua_State* L); diff --git a/cocos/scripting/lua/bindings/lua_xml_http_request.h b/cocos/scripting/lua/bindings/lua_xml_http_request.h index c76f1ba383..036cad42d9 100644 --- a/cocos/scripting/lua/bindings/lua_xml_http_request.h +++ b/cocos/scripting/lua/bindings/lua_xml_http_request.h @@ -37,7 +37,7 @@ extern "C" { #include "network/HttpClient.h" -class LuaMinXmlHttpRequest : public cocos2d::Object +class LuaMinXmlHttpRequest : public cocos2d::Ref { public: enum class ResponseType diff --git a/docs/RELEASE_NOTES.md b/docs/RELEASE_NOTES.md index 73409beae2..75332c2fa9 100644 --- a/docs/RELEASE_NOTES.md +++ b/docs/RELEASE_NOTES.md @@ -152,7 +152,7 @@ auto item = MenuItemLabel::create(label, std::bind(&MyClass::callback, this, std // in v3.0 you can use lambdas or any other "Function" object auto item = MenuItemLabel::create(label, - [&](Object *sender) { + [&](Ref *sender) { // do something. Item "sender" clicked }); ``` diff --git a/extensions/GUI/CCControlExtension/CCControl.cpp b/extensions/GUI/CCControlExtension/CCControl.cpp index 8b31a48843..2e594eb9c5 100644 --- a/extensions/GUI/CCControlExtension/CCControl.cpp +++ b/extensions/GUI/CCControlExtension/CCControl.cpp @@ -125,7 +125,7 @@ void Control::sendActionsForControlEvents(EventType controlEvents) } } } -void Control::addTargetWithActionForControlEvents(Object* target, Handler action, EventType controlEvents) +void Control::addTargetWithActionForControlEvents(Ref* target, Handler action, EventType controlEvents) { // For each control events for (int i = 0; i < kControlEventTotalNumber; i++) @@ -153,7 +153,7 @@ void Control::addTargetWithActionForControlEvents(Object* target, Handler action * @param controlEvent A control event for which the action message is sent. * See "CCControlEvent" for constants. */ -void Control::addTargetWithActionForControlEvent(Object* target, Handler action, EventType controlEvent) +void Control::addTargetWithActionForControlEvent(Ref* target, Handler action, EventType controlEvent) { // Create the invocation object Invocation *invocation = Invocation::create(target, action, controlEvent); @@ -163,7 +163,7 @@ void Control::addTargetWithActionForControlEvent(Object* target, Handler action, eventInvocationList.pushBack(invocation); } -void Control::removeTargetWithActionForControlEvents(Object* target, Handler action, EventType controlEvents) +void Control::removeTargetWithActionForControlEvents(Ref* target, Handler action, EventType controlEvents) { // For each control events for (int i = 0; i < kControlEventTotalNumber; i++) @@ -176,7 +176,7 @@ void Control::removeTargetWithActionForControlEvents(Object* target, Handler act } } -void Control::removeTargetWithActionForControlEvent(Object* target, Handler action, EventType controlEvent) +void Control::removeTargetWithActionForControlEvent(Ref* target, Handler action, EventType controlEvent) { // Retrieve all invocations for the given control event // diff --git a/extensions/GUI/CCControlExtension/CCControl.h b/extensions/GUI/CCControlExtension/CCControl.h index 5c1815291f..b148ff4c9f 100644 --- a/extensions/GUI/CCControlExtension/CCControl.h +++ b/extensions/GUI/CCControlExtension/CCControl.h @@ -78,7 +78,7 @@ public: VALUE_CHANGED = 1 << 8 // A touch dragging or otherwise manipulating a control, causing it to emit a series of different values. }; - typedef void (Object::*Handler)(Object*, EventType); + typedef void (Ref::*Handler)(Ref*, EventType); /** The possible state for a control. */ enum class State @@ -131,7 +131,7 @@ public: * @param controlEvents A bitmask specifying the control events for which the * action message is sent. See "CCControlEvent" for bitmask constants. */ - virtual void addTargetWithActionForControlEvents(Object* target, Handler action, EventType controlEvents); + virtual void addTargetWithActionForControlEvents(Ref* target, Handler action, EventType controlEvents); /** * Removes a target and action for a particular event (or events) from an @@ -145,7 +145,7 @@ public: * @param controlEvents A bitmask specifying the control events associated with * target and action. See "CCControlEvent" for bitmask constants. */ - virtual void removeTargetWithActionForControlEvents(Object* target, Handler action, EventType controlEvents); + virtual void removeTargetWithActionForControlEvents(Ref* target, Handler action, EventType controlEvents); /** * Returns a point corresponding to the touh location converted into the @@ -198,7 +198,7 @@ protected: * @return an Invocation object able to construct messages using a given * target-action pair. */ - Invocation* invocationWithTargetAndActionForControlEvent(Object* target, Handler action, EventType controlEvent); + Invocation* invocationWithTargetAndActionForControlEvent(Ref* target, Handler action, EventType controlEvent); /** * Returns the Invocation list for the given control event. If the list does @@ -224,7 +224,7 @@ protected: * @param controlEvent A control event for which the action message is sent. * See "CCControlEvent" for constants. */ - void addTargetWithActionForControlEvent(Object* target, Handler action, EventType controlEvent); + void addTargetWithActionForControlEvent(Ref* target, Handler action, EventType controlEvent); /** * Removes a target and action for a particular event from an internal dispatch @@ -238,7 +238,7 @@ protected: * @param controlEvent A control event for which the action message is sent. * See "CCControlEvent" for constants. */ - void removeTargetWithActionForControlEvent(Object* target, Handler action, EventType controlEvent); + void removeTargetWithActionForControlEvent(Ref* target, Handler action, EventType controlEvent); bool _enabled; bool _selected; diff --git a/extensions/GUI/CCControlExtension/CCControlButton.cpp b/extensions/GUI/CCControlExtension/CCControlButton.cpp index 9312c82995..eb3792e701 100644 --- a/extensions/GUI/CCControlExtension/CCControlButton.cpp +++ b/extensions/GUI/CCControlExtension/CCControlButton.cpp @@ -663,7 +663,7 @@ void ControlButton::setOpacity(GLubyte opacity) Control::setOpacity(opacity); // _opacity = opacity; // -// Object* child; +// Ref* child; // Array* children=getChildren(); // CCARRAY_FOREACH(children, child) // { diff --git a/extensions/GUI/CCControlExtension/CCControlColourPicker.cpp b/extensions/GUI/CCControlExtension/CCControlColourPicker.cpp index 082c929bea..b88561ab17 100644 --- a/extensions/GUI/CCControlExtension/CCControlColourPicker.cpp +++ b/extensions/GUI/CCControlExtension/CCControlColourPicker.cpp @@ -160,7 +160,7 @@ void ControlColourPicker::updateHueAndControlPicker() } -void ControlColourPicker::hueSliderValueChanged(Object * sender, Control::EventType controlEvent) +void ControlColourPicker::hueSliderValueChanged(Ref * sender, Control::EventType controlEvent) { _hsv.h = ((ControlHuePicker*)sender)->getHue(); @@ -174,7 +174,7 @@ void ControlColourPicker::hueSliderValueChanged(Object * sender, Control::EventT updateControlPicker(); } -void ControlColourPicker::colourSliderValueChanged(Object * sender, Control::EventType controlEvent) +void ControlColourPicker::colourSliderValueChanged(Ref * sender, Control::EventType controlEvent) { _hsv.s=((ControlSaturationBrightnessPicker*)sender)->getSaturation(); _hsv.v=((ControlSaturationBrightnessPicker*)sender)->getBrightness(); diff --git a/extensions/GUI/CCControlExtension/CCControlColourPicker.h b/extensions/GUI/CCControlExtension/CCControlColourPicker.h index 23f887c82c..eb6cfe7668 100644 --- a/extensions/GUI/CCControlExtension/CCControlColourPicker.h +++ b/extensions/GUI/CCControlExtension/CCControlColourPicker.h @@ -67,8 +67,8 @@ public: virtual void setEnabled(bool bEnabled); //virtual ~ControlColourPicker(); - void hueSliderValueChanged(Object * sender, Control::EventType controlEvent); - void colourSliderValueChanged(Object * sender, Control::EventType controlEvent); + void hueSliderValueChanged(Ref * sender, Control::EventType controlEvent); + void colourSliderValueChanged(Ref * sender, Control::EventType controlEvent); protected: void updateControlPicker(); diff --git a/extensions/GUI/CCControlExtension/CCControlUtils.h b/extensions/GUI/CCControlExtension/CCControlUtils.h index 8739883f0c..bf40641e22 100644 --- a/extensions/GUI/CCControlExtension/CCControlUtils.h +++ b/extensions/GUI/CCControlExtension/CCControlUtils.h @@ -62,7 +62,7 @@ typedef struct */ //helper class to store Color3B's in mutable arrays -class Color3bObject : public Object +class Color3bObject : public Ref { public: Color3B value; diff --git a/extensions/GUI/CCControlExtension/CCInvocation.cpp b/extensions/GUI/CCControlExtension/CCInvocation.cpp index 8638946a26..a93429303e 100644 --- a/extensions/GUI/CCControlExtension/CCInvocation.cpp +++ b/extensions/GUI/CCControlExtension/CCInvocation.cpp @@ -28,7 +28,7 @@ NS_CC_EXT_BEGIN -Invocation* Invocation::create(Object* target, Control::Handler action, Control::EventType controlEvent) +Invocation* Invocation::create(Ref* target, Control::Handler action, Control::EventType controlEvent) { Invocation* pRet = new Invocation(target, action, controlEvent); if (pRet != NULL) @@ -38,14 +38,14 @@ Invocation* Invocation::create(Object* target, Control::Handler action, Control: return pRet; } -Invocation::Invocation(Object* target, Control::Handler action, Control::EventType controlEvent) +Invocation::Invocation(Ref* target, Control::Handler action, Control::EventType controlEvent) { _target=target; _action=action; _controlEvent=controlEvent; } -void Invocation::invoke(Object* sender) +void Invocation::invoke(Ref* sender) { if (_target && _action) { diff --git a/extensions/GUI/CCControlExtension/CCInvocation.h b/extensions/GUI/CCControlExtension/CCInvocation.h index 215f2b1ebd..d99e69bec3 100644 --- a/extensions/GUI/CCControlExtension/CCInvocation.h +++ b/extensions/GUI/CCControlExtension/CCInvocation.h @@ -30,7 +30,7 @@ #ifndef __CCINVOCATION_H__ #define __CCINVOCATION_H__ -#include "CCObject.h" +#include "CCRef.h" #include "../../ExtensionMacros.h" #include "CCControl.h" @@ -45,28 +45,28 @@ NS_CC_EXT_BEGIN #define cccontrol_selector(_SELECTOR) static_cast(&_SELECTOR) -class Invocation : public Object +class Invocation : public Ref { public: /** * @js NA * @lua NA */ - static Invocation* create(Object* target, Control::Handler action, Control::EventType controlEvent); + static Invocation* create(Ref* target, Control::Handler action, Control::EventType controlEvent); /** * @js NA * @lua NA */ - Invocation(Object* target, Control::Handler action, Control::EventType controlEvent); + Invocation(Ref* target, Control::Handler action, Control::EventType controlEvent); /** * @js NA * @lua NA */ - void invoke(Object* sender); + void invoke(Ref* sender); protected: CC_SYNTHESIZE_READONLY(Control::Handler, _action, Action); - CC_SYNTHESIZE_READONLY(Object*, _target, Target); + CC_SYNTHESIZE_READONLY(Ref*, _target, Target); CC_SYNTHESIZE_READONLY(Control::EventType, _controlEvent, ControlEvent); }; diff --git a/extensions/GUI/CCEditBox/CCEditBox.cpp b/extensions/GUI/CCEditBox/CCEditBox.cpp index 21657355be..4e2b1a5e20 100644 --- a/extensions/GUI/CCEditBox/CCEditBox.cpp +++ b/extensions/GUI/CCEditBox/CCEditBox.cpp @@ -51,7 +51,7 @@ EditBox::~EditBox(void) } -void EditBox::touchDownAction(Object *sender, Control::EventType controlEvent) +void EditBox::touchDownAction(Ref *sender, Control::EventType controlEvent) { _editBoxImpl->openKeyboard(); } diff --git a/extensions/GUI/CCEditBox/CCEditBox.h b/extensions/GUI/CCEditBox/CCEditBox.h index ff6a4149b4..bab229a1c6 100644 --- a/extensions/GUI/CCEditBox/CCEditBox.h +++ b/extensions/GUI/CCEditBox/CCEditBox.h @@ -410,7 +410,7 @@ public: * @js NA * @lua NA */ - void touchDownAction(Object *sender, Control::EventType controlEvent); + void touchDownAction(Ref *sender, Control::EventType controlEvent); protected: EditBoxImpl* _editBoxImpl; diff --git a/extensions/GUI/CCScrollView/CCScrollView.cpp b/extensions/GUI/CCScrollView/CCScrollView.cpp index b88f7fea03..498cde77fb 100644 --- a/extensions/GUI/CCScrollView/CCScrollView.cpp +++ b/extensions/GUI/CCScrollView/CCScrollView.cpp @@ -157,7 +157,7 @@ bool ScrollView::isNodeVisible(Node* node) return viewRect.intersectsRect(node->getBoundingBox()); } -void ScrollView::pause(Object* sender) +void ScrollView::pause(Ref* sender) { _container->pause(); @@ -167,7 +167,7 @@ void ScrollView::pause(Object* sender) } } -void ScrollView::resume(Object* sender) +void ScrollView::resume(Ref* sender) { auto& children = _container->getChildren(); for(const auto &child : children) { diff --git a/extensions/GUI/CCScrollView/CCScrollView.h b/extensions/GUI/CCScrollView/CCScrollView.h index 88fc9b4523..8ab06f01f7 100644 --- a/extensions/GUI/CCScrollView/CCScrollView.h +++ b/extensions/GUI/CCScrollView/CCScrollView.h @@ -162,11 +162,11 @@ public: /** * Provided to make scroll view compatible with SWLayer's pause method */ - void pause(Object* sender); + void pause(Ref* sender); /** * Provided to make scroll view compatible with SWLayer's resume method */ - void resume(Object* sender); + void resume(Ref* sender); void setTouchEnabled(bool enabled); bool isTouchEnabled() const; diff --git a/extensions/GUI/CCScrollView/CCTableView.cpp b/extensions/GUI/CCScrollView/CCTableView.cpp index ad639e4986..558a6ae8ba 100644 --- a/extensions/GUI/CCScrollView/CCTableView.cpp +++ b/extensions/GUI/CCScrollView/CCTableView.cpp @@ -499,7 +499,7 @@ void TableView::scrollViewDidScroll(ScrollView* view) } #if 0 // For Testing. - Object* pObj; + Ref* pObj; int i = 0; CCARRAY_FOREACH(_cellsUsed, pObj) { diff --git a/tests/test-cpp/Classes/ActionManagerTest/ActionManagerTest.cpp b/tests/test-cpp/Classes/ActionManagerTest/ActionManagerTest.cpp index f57288ccde..a62e810d4d 100644 --- a/tests/test-cpp/Classes/ActionManagerTest/ActionManagerTest.cpp +++ b/tests/test-cpp/Classes/ActionManagerTest/ActionManagerTest.cpp @@ -82,7 +82,7 @@ std::string ActionManagerTest::title() const return "No title"; } -void ActionManagerTest::restartCallback(Object* sender) +void ActionManagerTest::restartCallback(Ref* sender) { auto s = new ActionManagerTestScene(); s->addChild(restartActionManagerAction()); @@ -91,7 +91,7 @@ void ActionManagerTest::restartCallback(Object* sender) s->release(); } -void ActionManagerTest::nextCallback(Object* sender) +void ActionManagerTest::nextCallback(Ref* sender) { auto s = new ActionManagerTestScene(); s->addChild( nextActionManagerAction() ); @@ -99,7 +99,7 @@ void ActionManagerTest::nextCallback(Object* sender) s->release(); } -void ActionManagerTest::backCallback(Object* sender) +void ActionManagerTest::backCallback(Ref* sender) { auto s = new ActionManagerTestScene(); s->addChild( backActionManagerAction() ); diff --git a/tests/test-cpp/Classes/ActionManagerTest/ActionManagerTest.h b/tests/test-cpp/Classes/ActionManagerTest/ActionManagerTest.h index 67a1c27388..474846ce9e 100644 --- a/tests/test-cpp/Classes/ActionManagerTest/ActionManagerTest.h +++ b/tests/test-cpp/Classes/ActionManagerTest/ActionManagerTest.h @@ -17,9 +17,9 @@ public: virtual std::string title() const override; - void restartCallback(Object* sender); - void nextCallback(Object* sender); - void backCallback(Object* sender); + void restartCallback(Ref* sender); + void nextCallback(Ref* sender); + void backCallback(Ref* sender); }; class CrashTest : public ActionManagerTest diff --git a/tests/test-cpp/Classes/ActionsEaseTest/ActionsEaseTest.cpp b/tests/test-cpp/Classes/ActionsEaseTest/ActionsEaseTest.cpp index 7d0d3cc57c..e3e4976755 100644 --- a/tests/test-cpp/Classes/ActionsEaseTest/ActionsEaseTest.cpp +++ b/tests/test-cpp/Classes/ActionsEaseTest/ActionsEaseTest.cpp @@ -1095,7 +1095,7 @@ void EaseSpriteDemo::onEnter() _tamara->setPosition(Point(VisibleRect::left().x + 60, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height*4/5)); } -void EaseSpriteDemo::restartCallback(Object* sender) +void EaseSpriteDemo::restartCallback(Ref* sender) { auto s = new ActionsEaseTestScene();//CCScene::create(); s->addChild(restartEaseAction()); @@ -1104,7 +1104,7 @@ void EaseSpriteDemo::restartCallback(Object* sender) s->release(); } -void EaseSpriteDemo::nextCallback(Object* sender) +void EaseSpriteDemo::nextCallback(Ref* sender) { auto s = new ActionsEaseTestScene();//CCScene::create(); s->addChild( nextEaseAction() ); @@ -1112,7 +1112,7 @@ void EaseSpriteDemo::nextCallback(Object* sender) s->release(); } -void EaseSpriteDemo::backCallback(Object* sender) +void EaseSpriteDemo::backCallback(Ref* sender) { auto s = new ActionsEaseTestScene();//CCScene::create(); s->addChild( backEaseAction() ); diff --git a/tests/test-cpp/Classes/ActionsEaseTest/ActionsEaseTest.h b/tests/test-cpp/Classes/ActionsEaseTest/ActionsEaseTest.h index ab95777f33..ac1816d290 100644 --- a/tests/test-cpp/Classes/ActionsEaseTest/ActionsEaseTest.h +++ b/tests/test-cpp/Classes/ActionsEaseTest/ActionsEaseTest.h @@ -50,9 +50,9 @@ public: void centerSprites(unsigned int numberOfSprites); - void restartCallback(Object* sender); - void nextCallback(Object* sender); - void backCallback(Object* sender); + void restartCallback(Ref* sender); + void nextCallback(Ref* sender); + void backCallback(Ref* sender); void positionForTwo(); }; diff --git a/tests/test-cpp/Classes/ActionsProgressTest/ActionsProgressTest.cpp b/tests/test-cpp/Classes/ActionsProgressTest/ActionsProgressTest.cpp index 42f3774e3b..69c2bf5332 100644 --- a/tests/test-cpp/Classes/ActionsProgressTest/ActionsProgressTest.cpp +++ b/tests/test-cpp/Classes/ActionsProgressTest/ActionsProgressTest.cpp @@ -121,7 +121,7 @@ void SpriteDemo::onEnter() addChild(background, -10); } -void SpriteDemo::restartCallback(Object* sender) +void SpriteDemo::restartCallback(Ref* sender) { auto s = new ProgressActionsTestScene(); s->addChild(restartAction()); @@ -130,7 +130,7 @@ void SpriteDemo::restartCallback(Object* sender) s->release(); } -void SpriteDemo::nextCallback(Object* sender) +void SpriteDemo::nextCallback(Ref* sender) { auto s = new ProgressActionsTestScene(); s->addChild( nextAction() ); @@ -138,7 +138,7 @@ void SpriteDemo::nextCallback(Object* sender) s->release(); } -void SpriteDemo::backCallback(Object* sender) +void SpriteDemo::backCallback(Ref* sender) { auto s = new ProgressActionsTestScene(); s->addChild( backAction() ); diff --git a/tests/test-cpp/Classes/ActionsProgressTest/ActionsProgressTest.h b/tests/test-cpp/Classes/ActionsProgressTest/ActionsProgressTest.h index f453ac0c2f..35ccf2175e 100644 --- a/tests/test-cpp/Classes/ActionsProgressTest/ActionsProgressTest.h +++ b/tests/test-cpp/Classes/ActionsProgressTest/ActionsProgressTest.h @@ -39,9 +39,9 @@ public: virtual std::string subtitle() const override; virtual void onEnter(); - void restartCallback(Object* sender); - void nextCallback(Object* sender); - void backCallback(Object* sender); + void restartCallback(Ref* sender); + void nextCallback(Ref* sender); + void backCallback(Ref* sender); }; class SpriteProgressToRadial : public SpriteDemo diff --git a/tests/test-cpp/Classes/ActionsTest/ActionsTest.cpp b/tests/test-cpp/Classes/ActionsTest/ActionsTest.cpp index b290364d39..4ec278b9bc 100644 --- a/tests/test-cpp/Classes/ActionsTest/ActionsTest.cpp +++ b/tests/test-cpp/Classes/ActionsTest/ActionsTest.cpp @@ -163,7 +163,7 @@ void ActionsDemo::onExit() BaseTest::onExit(); } -void ActionsDemo::restartCallback(Object* sender) +void ActionsDemo::restartCallback(Ref* sender) { auto s = new ActionsTestScene(); s->addChild( restartAction() ); @@ -171,7 +171,7 @@ void ActionsDemo::restartCallback(Object* sender) s->release(); } -void ActionsDemo::nextCallback(Object* sender) +void ActionsDemo::nextCallback(Ref* sender) { auto s = new ActionsTestScene(); s->addChild( nextAction() ); @@ -179,7 +179,7 @@ void ActionsDemo::nextCallback(Object* sender) s->release(); } -void ActionsDemo::backCallback(Object* sender) +void ActionsDemo::backCallback(Ref* sender) { auto s = new ActionsTestScene(); s->addChild( backAction() ); diff --git a/tests/test-cpp/Classes/ActionsTest/ActionsTest.h b/tests/test-cpp/Classes/ActionsTest/ActionsTest.h index 949ad43a38..ea238068b7 100644 --- a/tests/test-cpp/Classes/ActionsTest/ActionsTest.h +++ b/tests/test-cpp/Classes/ActionsTest/ActionsTest.h @@ -57,9 +57,9 @@ public: virtual std::string title() const override; virtual std::string subtitle() const override; - void restartCallback(Object* sender); - void nextCallback(Object* sender); - void backCallback(Object* sender); + void restartCallback(Ref* sender); + void nextCallback(Ref* sender); + void backCallback(Ref* sender); }; class ActionManual : public ActionsDemo diff --git a/tests/test-cpp/Classes/BaseTest.cpp b/tests/test-cpp/Classes/BaseTest.cpp index 529a1337ec..dd9131742e 100644 --- a/tests/test-cpp/Classes/BaseTest.cpp +++ b/tests/test-cpp/Classes/BaseTest.cpp @@ -80,17 +80,17 @@ std::string BaseTest::subtitle() const return ""; } -void BaseTest::restartCallback(Object* sender) +void BaseTest::restartCallback(Ref* sender) { log("override restart!"); } -void BaseTest::nextCallback(Object* sender) +void BaseTest::nextCallback(Ref* sender) { log("override next!"); } -void BaseTest::backCallback(Object* sender) +void BaseTest::backCallback(Ref* sender) { log("override back!"); } diff --git a/tests/test-cpp/Classes/BaseTest.h b/tests/test-cpp/Classes/BaseTest.h index 1c509e1716..2bc1d3efd8 100644 --- a/tests/test-cpp/Classes/BaseTest.h +++ b/tests/test-cpp/Classes/BaseTest.h @@ -33,9 +33,9 @@ public: virtual std::string title() const; virtual std::string subtitle() const; - virtual void restartCallback(Object* sender); - virtual void nextCallback(Object* sender); - virtual void backCallback(Object* sender); + virtual void restartCallback(Ref* sender); + virtual void nextCallback(Ref* sender); + virtual void backCallback(Ref* sender); virtual void onEnter() override; virtual void onExit() override; diff --git a/tests/test-cpp/Classes/Box2DTest/Box2dTest.cpp b/tests/test-cpp/Classes/Box2DTest/Box2dTest.cpp index 941cf42b4d..7a80011dc5 100644 --- a/tests/test-cpp/Classes/Box2DTest/Box2dTest.cpp +++ b/tests/test-cpp/Classes/Box2DTest/Box2dTest.cpp @@ -121,7 +121,7 @@ void Box2DTestLayer::initPhysics() void Box2DTestLayer::createResetButton() { - auto reset = MenuItemImage::create("Images/r1.png", "Images/r2.png", [](Object *sender) { + auto reset = MenuItemImage::create("Images/r1.png", "Images/r2.png", [](Ref *sender) { auto s = new Box2DTestScene(); auto child = new Box2DTestLayer(); s->addChild(child); diff --git a/tests/test-cpp/Classes/Box2DTestBed/Box2dView.cpp b/tests/test-cpp/Classes/Box2DTestBed/Box2dView.cpp index 2b05f4a60b..53ab909011 100644 --- a/tests/test-cpp/Classes/Box2DTestBed/Box2dView.cpp +++ b/tests/test-cpp/Classes/Box2DTestBed/Box2dView.cpp @@ -94,7 +94,7 @@ bool MenuLayer::initWithEntryID(int entryId) return true; } -void MenuLayer::restartCallback(Object* sender) +void MenuLayer::restartCallback(Ref* sender) { auto s = new Box2dTestBedScene(); auto box = MenuLayer::menuWithEntryID(m_entryID); @@ -103,7 +103,7 @@ void MenuLayer::restartCallback(Object* sender) s->release(); } -void MenuLayer::nextCallback(Object* sender) +void MenuLayer::nextCallback(Ref* sender) { auto s = new Box2dTestBedScene(); int next = m_entryID + 1; @@ -115,7 +115,7 @@ void MenuLayer::nextCallback(Object* sender) s->release(); } -void MenuLayer::backCallback(Object* sender) +void MenuLayer::backCallback(Ref* sender) { auto s = new Box2dTestBedScene(); int next = m_entryID - 1; diff --git a/tests/test-cpp/Classes/Box2DTestBed/Box2dView.h b/tests/test-cpp/Classes/Box2DTestBed/Box2dView.h index 39bef0dbe2..8316e98263 100644 --- a/tests/test-cpp/Classes/Box2DTestBed/Box2dView.h +++ b/tests/test-cpp/Classes/Box2DTestBed/Box2dView.h @@ -15,9 +15,9 @@ public: bool initWithEntryID(int entryId); - void restartCallback(Object* sender); - void nextCallback(Object* sender); - void backCallback(Object* sender); + void restartCallback(Ref* sender); + void nextCallback(Ref* sender); + void backCallback(Ref* sender); bool onTouchBegan(Touch* touch, Event* event); diff --git a/tests/test-cpp/Classes/BugsTest/Bug-1159.cpp b/tests/test-cpp/Classes/BugsTest/Bug-1159.cpp index 5aa471f144..0354d9a268 100644 --- a/tests/test-cpp/Classes/BugsTest/Bug-1159.cpp +++ b/tests/test-cpp/Classes/BugsTest/Bug-1159.cpp @@ -56,7 +56,7 @@ bool Bug1159Layer::init() return false; } -void Bug1159Layer::callBack(Object* sender) +void Bug1159Layer::callBack(Ref* sender) { Director::getInstance()->replaceScene(TransitionPageTurn::create(1.0f, Bug1159Layer::scene(), false)); } diff --git a/tests/test-cpp/Classes/BugsTest/Bug-1159.h b/tests/test-cpp/Classes/BugsTest/Bug-1159.h index 1c7383a952..a3f9f30139 100644 --- a/tests/test-cpp/Classes/BugsTest/Bug-1159.h +++ b/tests/test-cpp/Classes/BugsTest/Bug-1159.h @@ -9,7 +9,7 @@ public: virtual bool init(); virtual void onExit(); static Scene* scene(); - void callBack(Object* sender); + void callBack(Ref* sender); CREATE_FUNC(Bug1159Layer); }; diff --git a/tests/test-cpp/Classes/BugsTest/Bug-422.cpp b/tests/test-cpp/Classes/BugsTest/Bug-422.cpp index e72fd35deb..04a52ce1b9 100644 --- a/tests/test-cpp/Classes/BugsTest/Bug-422.cpp +++ b/tests/test-cpp/Classes/BugsTest/Bug-422.cpp @@ -54,7 +54,7 @@ void Bug422Layer::check(Node* t) } } -void Bug422Layer::menuCallback(Object* sender) +void Bug422Layer::menuCallback(Ref* sender) { reset(); } diff --git a/tests/test-cpp/Classes/BugsTest/Bug-422.h b/tests/test-cpp/Classes/BugsTest/Bug-422.h index e33faf424a..8b2188c0f9 100644 --- a/tests/test-cpp/Classes/BugsTest/Bug-422.h +++ b/tests/test-cpp/Classes/BugsTest/Bug-422.h @@ -10,7 +10,7 @@ public: void reset(); void check(Node* target); - void menuCallback(Object* sender); + void menuCallback(Ref* sender); }; #endif // __BUG_422_H__ diff --git a/tests/test-cpp/Classes/BugsTest/Bug-458/Bug-458.cpp b/tests/test-cpp/Classes/BugsTest/Bug-458/Bug-458.cpp index 65bd0b6f01..261f4ba461 100644 --- a/tests/test-cpp/Classes/BugsTest/Bug-458/Bug-458.cpp +++ b/tests/test-cpp/Classes/BugsTest/Bug-458/Bug-458.cpp @@ -40,7 +40,7 @@ bool Bug458Layer::init() return false; } -void Bug458Layer::selectAnswer(Object* sender) +void Bug458Layer::selectAnswer(Ref* sender) { log("Selected"); } diff --git a/tests/test-cpp/Classes/BugsTest/Bug-458/Bug-458.h b/tests/test-cpp/Classes/BugsTest/Bug-458/Bug-458.h index 3b7f9df04d..4758f59b79 100644 --- a/tests/test-cpp/Classes/BugsTest/Bug-458/Bug-458.h +++ b/tests/test-cpp/Classes/BugsTest/Bug-458/Bug-458.h @@ -7,7 +7,7 @@ class Bug458Layer : public BugsTestBaseLayer { public: virtual bool init(); - void selectAnswer(Object* sender); + void selectAnswer(Ref* sender); }; #endif // __BUG_458_H__ diff --git a/tests/test-cpp/Classes/BugsTest/Bug-914.cpp b/tests/test-cpp/Classes/BugsTest/Bug-914.cpp index 1064524e1c..3dfb43c73d 100644 --- a/tests/test-cpp/Classes/BugsTest/Bug-914.cpp +++ b/tests/test-cpp/Classes/BugsTest/Bug-914.cpp @@ -77,7 +77,7 @@ void Bug914Layer::onTouchesBegan(const std::vector& touches, Event * eve onTouchesMoved(touches, event); } -void Bug914Layer::restart(Object* sender) +void Bug914Layer::restart(Ref* sender) { Director::getInstance()->replaceScene(Bug914Layer::scene()); } diff --git a/tests/test-cpp/Classes/BugsTest/Bug-914.h b/tests/test-cpp/Classes/BugsTest/Bug-914.h index d6af9092fe..bbfa668c87 100644 --- a/tests/test-cpp/Classes/BugsTest/Bug-914.h +++ b/tests/test-cpp/Classes/BugsTest/Bug-914.h @@ -11,7 +11,7 @@ public: void onTouchesMoved(const std::vector& touches, Event * event); void onTouchesBegan(const std::vector& touches, Event * event); - void restart(Object* sender); + void restart(Ref* sender); CREATE_FUNC(Bug914Layer); }; diff --git a/tests/test-cpp/Classes/BugsTest/BugsTest.cpp b/tests/test-cpp/Classes/BugsTest/BugsTest.cpp index 096ca45d21..6c40c408bc 100644 --- a/tests/test-cpp/Classes/BugsTest/BugsTest.cpp +++ b/tests/test-cpp/Classes/BugsTest/BugsTest.cpp @@ -29,17 +29,17 @@ static Point s_tCurPos = Point::ZERO; struct { const char *test_name; - std::function callback; + std::function callback; } g_bugs[] = { - { "Bug-350", [](Object* sender){ TEST_BUG(350)} }, - { "Bug-422", [](Object* sender){ TEST_BUG(422)} }, - { "Bug-458", [](Object* sender){ TEST_BUG(458)} }, - { "Bug-624", [](Object* sender){ TEST_BUG(624)} }, - { "Bug-886", [](Object* sender){ TEST_BUG(886)} }, - { "Bug-899", [](Object* sender){ TEST_BUG(899)} }, - { "Bug-914", [](Object* sender){ TEST_BUG(914)} }, - { "Bug-1159", [](Object* sender){ TEST_BUG(1159)} }, - { "Bug-1174", [](Object* sender){ TEST_BUG(1174)} }, + { "Bug-350", [](Ref* sender){ TEST_BUG(350)} }, + { "Bug-422", [](Ref* sender){ TEST_BUG(422)} }, + { "Bug-458", [](Ref* sender){ TEST_BUG(458)} }, + { "Bug-624", [](Ref* sender){ TEST_BUG(624)} }, + { "Bug-886", [](Ref* sender){ TEST_BUG(886)} }, + { "Bug-899", [](Ref* sender){ TEST_BUG(899)} }, + { "Bug-914", [](Ref* sender){ TEST_BUG(914)} }, + { "Bug-1159", [](Ref* sender){ TEST_BUG(1159)} }, + { "Bug-1174", [](Ref* sender){ TEST_BUG(1174)} }, }; static const int g_maxitems = sizeof(g_bugs) / sizeof(g_bugs[0]); @@ -123,7 +123,7 @@ void BugsTestBaseLayer::onEnter() addChild(menu); } -void BugsTestBaseLayer::backCallback(Object* sender) +void BugsTestBaseLayer::backCallback(Ref* sender) { // Director::getInstance()->enableRetinaDisplay(false); auto scene = new BugsTestScene(); diff --git a/tests/test-cpp/Classes/BugsTest/BugsTest.h b/tests/test-cpp/Classes/BugsTest/BugsTest.h index 06e6fb535c..f8c5efdf50 100644 --- a/tests/test-cpp/Classes/BugsTest/BugsTest.h +++ b/tests/test-cpp/Classes/BugsTest/BugsTest.h @@ -20,7 +20,7 @@ class BugsTestBaseLayer : public Layer { public: virtual void onEnter(); - void backCallback(Object* sender); + void backCallback(Ref* sender); }; class BugsTestScene : public TestScene diff --git a/tests/test-cpp/Classes/ChipmunkTest/ChipmunkTest.cpp b/tests/test-cpp/Classes/ChipmunkTest/ChipmunkTest.cpp index 8c0c94afec..dcb9c0e0f1 100644 --- a/tests/test-cpp/Classes/ChipmunkTest/ChipmunkTest.cpp +++ b/tests/test-cpp/Classes/ChipmunkTest/ChipmunkTest.cpp @@ -76,7 +76,7 @@ ChipmunkTestLayer::ChipmunkTestLayer() } -void ChipmunkTestLayer::toggleDebugCallback(Object* sender) +void ChipmunkTestLayer::toggleDebugCallback(Ref* sender) { #if CC_ENABLE_CHIPMUNK_INTEGRATION _debugLayer->setVisible(! _debugLayer->isVisible()); @@ -164,7 +164,7 @@ void ChipmunkTestLayer::createResetButton() this->addChild(menu, -1); } -void ChipmunkTestLayer::reset(Object* sender) +void ChipmunkTestLayer::reset(Ref* sender) { auto s = new ChipmunkAccelTouchTestScene(); auto child = new ChipmunkTestLayer(); diff --git a/tests/test-cpp/Classes/ChipmunkTest/ChipmunkTest.h b/tests/test-cpp/Classes/ChipmunkTest/ChipmunkTest.h index 046f53d3fa..13d216c359 100644 --- a/tests/test-cpp/Classes/ChipmunkTest/ChipmunkTest.h +++ b/tests/test-cpp/Classes/ChipmunkTest/ChipmunkTest.h @@ -19,11 +19,11 @@ public: void onEnter(); void initPhysics(); void createResetButton(); - void reset(Object* sender); + void reset(Ref* sender); void addNewSpriteAtPosition(Point p); void update(float dt); - void toggleDebugCallback(Object* sender); + void toggleDebugCallback(Ref* sender); void onTouchesEnded(const std::vector& touches, Event* event); virtual void onAcceleration(Acceleration* acc, Event* event); diff --git a/tests/test-cpp/Classes/ClippingNodeTest/ClippingNodeTest.cpp b/tests/test-cpp/Classes/ClippingNodeTest/ClippingNodeTest.cpp index 829c8766dc..9d69a16fce 100644 --- a/tests/test-cpp/Classes/ClippingNodeTest/ClippingNodeTest.cpp +++ b/tests/test-cpp/Classes/ClippingNodeTest/ClippingNodeTest.cpp @@ -100,7 +100,7 @@ std::string BaseClippingNodeTest::subtitle() const return ""; } -void BaseClippingNodeTest::restartCallback(Object* sender) +void BaseClippingNodeTest::restartCallback(Ref* sender) { Scene *s = new ClippingNodeTestScene(); s->addChild(restartAction()); @@ -108,7 +108,7 @@ void BaseClippingNodeTest::restartCallback(Object* sender) s->release(); } -void BaseClippingNodeTest::nextCallback(Object* sender) +void BaseClippingNodeTest::nextCallback(Ref* sender) { Scene *s = new ClippingNodeTestScene(); s->addChild(nextAction()); @@ -116,7 +116,7 @@ void BaseClippingNodeTest::nextCallback(Object* sender) s->release(); } -void BaseClippingNodeTest::backCallback(Object* sender) +void BaseClippingNodeTest::backCallback(Ref* sender) { Scene *s = new ClippingNodeTestScene(); s->addChild(backAction()); diff --git a/tests/test-cpp/Classes/ClippingNodeTest/ClippingNodeTest.h b/tests/test-cpp/Classes/ClippingNodeTest/ClippingNodeTest.h index 944c99ca2a..0c3ad9e2ee 100644 --- a/tests/test-cpp/Classes/ClippingNodeTest/ClippingNodeTest.h +++ b/tests/test-cpp/Classes/ClippingNodeTest/ClippingNodeTest.h @@ -18,9 +18,9 @@ public: virtual std::string subtitle() const override; virtual void setup(); - void backCallback(Object* sender); - void nextCallback(Object* sender); - void restartCallback(Object* sender); + void backCallback(Ref* sender); + void nextCallback(Ref* sender); + void restartCallback(Ref* sender); }; class BasicTest : public BaseClippingNodeTest diff --git a/tests/test-cpp/Classes/ConfigurationTest/ConfigurationTest.cpp b/tests/test-cpp/Classes/ConfigurationTest/ConfigurationTest.cpp index de6f94c98c..460b874556 100644 --- a/tests/test-cpp/Classes/ConfigurationTest/ConfigurationTest.cpp +++ b/tests/test-cpp/Classes/ConfigurationTest/ConfigurationTest.cpp @@ -69,7 +69,7 @@ void ConfigurationBase::onExit() BaseTest::onExit(); } -void ConfigurationBase::restartCallback(Object* sender) +void ConfigurationBase::restartCallback(Ref* sender) { auto s = new ConfigurationTestScene(); s->addChild( restartAction() ); @@ -77,7 +77,7 @@ void ConfigurationBase::restartCallback(Object* sender) s->release(); } -void ConfigurationBase::nextCallback(Object* sender) +void ConfigurationBase::nextCallback(Ref* sender) { auto s = new ConfigurationTestScene(); s->addChild( nextAction() ); @@ -85,7 +85,7 @@ void ConfigurationBase::nextCallback(Object* sender) s->release(); } -void ConfigurationBase::backCallback(Object* sender) +void ConfigurationBase::backCallback(Ref* sender) { auto s = new ConfigurationTestScene(); s->addChild( backAction() ); diff --git a/tests/test-cpp/Classes/ConfigurationTest/ConfigurationTest.h b/tests/test-cpp/Classes/ConfigurationTest/ConfigurationTest.h index f0fff05f68..55305f2938 100644 --- a/tests/test-cpp/Classes/ConfigurationTest/ConfigurationTest.h +++ b/tests/test-cpp/Classes/ConfigurationTest/ConfigurationTest.h @@ -27,9 +27,9 @@ public: virtual std::string title() const override; virtual std::string subtitle() const override; - void restartCallback(Object* sender); - void nextCallback(Object* sender); - void backCallback(Object* sender); + void restartCallback(Ref* sender); + void nextCallback(Ref* sender); + void backCallback(Ref* sender); }; class ConfigurationLoadConfig : public ConfigurationBase diff --git a/tests/test-cpp/Classes/ConsoleTest/ConsoleTest.cpp b/tests/test-cpp/Classes/ConsoleTest/ConsoleTest.cpp index 78cbf47439..aba6ae4b52 100644 --- a/tests/test-cpp/Classes/ConsoleTest/ConsoleTest.cpp +++ b/tests/test-cpp/Classes/ConsoleTest/ConsoleTest.cpp @@ -92,7 +92,7 @@ void BaseTestConsole::onEnter() BaseTest::onEnter(); } -void BaseTestConsole::restartCallback(Object* sender) +void BaseTestConsole::restartCallback(Ref* sender) { auto s = new ConsoleTestScene(); s->addChild(restartConsoleTest()); @@ -101,7 +101,7 @@ void BaseTestConsole::restartCallback(Object* sender) s->release(); } -void BaseTestConsole::nextCallback(Object* sender) +void BaseTestConsole::nextCallback(Ref* sender) { auto s = new ConsoleTestScene(); s->addChild( nextConsoleTest() ); @@ -109,7 +109,7 @@ void BaseTestConsole::nextCallback(Object* sender) s->release(); } -void BaseTestConsole::backCallback(Object* sender) +void BaseTestConsole::backCallback(Ref* sender) { auto s = new ConsoleTestScene(); s->addChild( backConsoleTest() ); diff --git a/tests/test-cpp/Classes/ConsoleTest/ConsoleTest.h b/tests/test-cpp/Classes/ConsoleTest/ConsoleTest.h index e25355b123..2304bad67e 100644 --- a/tests/test-cpp/Classes/ConsoleTest/ConsoleTest.h +++ b/tests/test-cpp/Classes/ConsoleTest/ConsoleTest.h @@ -40,9 +40,9 @@ public: virtual std::string title() const override; virtual void onEnter() override; - void restartCallback(Object* sender) override; - void nextCallback(Object* sender) override; - void backCallback(Object* sender) override; + void restartCallback(Ref* sender) override; + void nextCallback(Ref* sender) override; + void backCallback(Ref* sender) override; }; class ConsoleTCP : public BaseTestConsole diff --git a/tests/test-cpp/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp b/tests/test-cpp/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp index 622220f09d..64bfe1bbfb 100644 --- a/tests/test-cpp/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp +++ b/tests/test-cpp/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp @@ -71,7 +71,7 @@ void BaseLayer::onEnter() BaseTest::onEnter(); } -void BaseLayer::restartCallback(cocos2d::Object *pSender) +void BaseLayer::restartCallback(cocos2d::Ref *pSender) { auto s = new DrawPrimitivesTestScene(); s->addChild(restartAction()); @@ -80,7 +80,7 @@ void BaseLayer::restartCallback(cocos2d::Object *pSender) s->release(); } -void BaseLayer::nextCallback(cocos2d::Object *pSender) +void BaseLayer::nextCallback(cocos2d::Ref *pSender) { auto s = new DrawPrimitivesTestScene();; s->addChild(nextAction()); @@ -89,7 +89,7 @@ void BaseLayer::nextCallback(cocos2d::Object *pSender) s->release(); } -void BaseLayer::backCallback(cocos2d::Object *pSender) +void BaseLayer::backCallback(cocos2d::Ref *pSender) { auto s = new DrawPrimitivesTestScene(); s->addChild(backAction()); diff --git a/tests/test-cpp/Classes/DrawPrimitivesTest/DrawPrimitivesTest.h b/tests/test-cpp/Classes/DrawPrimitivesTest/DrawPrimitivesTest.h index 0022b1d387..02c956ccf3 100644 --- a/tests/test-cpp/Classes/DrawPrimitivesTest/DrawPrimitivesTest.h +++ b/tests/test-cpp/Classes/DrawPrimitivesTest/DrawPrimitivesTest.h @@ -12,9 +12,9 @@ class BaseLayer : public BaseTest public: BaseLayer(); - void restartCallback(Object* sender); - void nextCallback(Object* sender); - void backCallback(Object* sender); + void restartCallback(Ref* sender); + void nextCallback(Ref* sender); + void backCallback(Ref* sender); virtual std::string title() const override; virtual std::string subtitle() const override; virtual void onEnter(); diff --git a/tests/test-cpp/Classes/EffectsAdvancedTest/EffectsAdvancedTest.cpp b/tests/test-cpp/Classes/EffectsAdvancedTest/EffectsAdvancedTest.cpp index 2ee518c246..6c594d5d3d 100644 --- a/tests/test-cpp/Classes/EffectsAdvancedTest/EffectsAdvancedTest.cpp +++ b/tests/test-cpp/Classes/EffectsAdvancedTest/EffectsAdvancedTest.cpp @@ -386,7 +386,7 @@ std::string EffectAdvanceTextLayer::subtitle() const return ""; } -void EffectAdvanceTextLayer::restartCallback(Object* sender) +void EffectAdvanceTextLayer::restartCallback(Ref* sender) { auto s = new EffectAdvanceScene(); s->addChild(restartEffectAdvanceAction()); @@ -395,7 +395,7 @@ void EffectAdvanceTextLayer::restartCallback(Object* sender) s->release(); } -void EffectAdvanceTextLayer::nextCallback(Object* sender) +void EffectAdvanceTextLayer::nextCallback(Ref* sender) { auto s = new EffectAdvanceScene(); s->addChild( nextEffectAdvanceAction() ); @@ -404,7 +404,7 @@ void EffectAdvanceTextLayer::nextCallback(Object* sender) s->release(); } -void EffectAdvanceTextLayer::backCallback(Object* sender) +void EffectAdvanceTextLayer::backCallback(Ref* sender) { auto s = new EffectAdvanceScene(); s->addChild( backEffectAdvanceAction() ); diff --git a/tests/test-cpp/Classes/EffectsAdvancedTest/EffectsAdvancedTest.h b/tests/test-cpp/Classes/EffectsAdvancedTest/EffectsAdvancedTest.h index 9662243e17..dcb000bdc5 100644 --- a/tests/test-cpp/Classes/EffectsAdvancedTest/EffectsAdvancedTest.h +++ b/tests/test-cpp/Classes/EffectsAdvancedTest/EffectsAdvancedTest.h @@ -23,9 +23,9 @@ public: virtual std::string title() const override; virtual std::string subtitle() const override; - void restartCallback(Object* sender); - void nextCallback(Object* sender); - void backCallback(Object* sender); + void restartCallback(Ref* sender); + void nextCallback(Ref* sender); + void backCallback(Ref* sender); }; class Effect1 : public EffectAdvanceTextLayer diff --git a/tests/test-cpp/Classes/EffectsTest/EffectsTest.cpp b/tests/test-cpp/Classes/EffectsTest/EffectsTest.cpp index 79b6efd4b7..da7f6a27b9 100644 --- a/tests/test-cpp/Classes/EffectsTest/EffectsTest.cpp +++ b/tests/test-cpp/Classes/EffectsTest/EffectsTest.cpp @@ -414,12 +414,12 @@ void TextLayer::newScene() s->release(); } -void TextLayer::restartCallback(Object* sender) +void TextLayer::restartCallback(Ref* sender) { newScene(); } -void TextLayer::nextCallback(Object* sender) +void TextLayer::nextCallback(Ref* sender) { // update the action index actionIdx++; @@ -428,7 +428,7 @@ void TextLayer::nextCallback(Object* sender) newScene(); } -void TextLayer::backCallback(Object* sender) +void TextLayer::backCallback(Ref* sender) { // update the action index actionIdx--; diff --git a/tests/test-cpp/Classes/EffectsTest/EffectsTest.h b/tests/test-cpp/Classes/EffectsTest/EffectsTest.h index 6772578b45..5d82435c5d 100644 --- a/tests/test-cpp/Classes/EffectsTest/EffectsTest.h +++ b/tests/test-cpp/Classes/EffectsTest/EffectsTest.h @@ -23,9 +23,9 @@ public: virtual void onEnter(); - void restartCallback(Object* sender); - void nextCallback(Object* sender); - void backCallback(Object* sender); + void restartCallback(Ref* sender); + void nextCallback(Ref* sender); + void backCallback(Ref* sender); void newScene(); diff --git a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp index 88a63ce1f9..c54aab1d8c 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp +++ b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp @@ -142,7 +142,7 @@ void ArmatureTestScene::runThisTest() Director::getInstance()->replaceScene(this); } -void ArmatureTestScene::MainMenuCallback(Object *pSender) +void ArmatureTestScene::MainMenuCallback(Ref *pSender) { //TestScene::MainMenuCallback(pSender); @@ -209,21 +209,21 @@ std::string ArmatureTestLayer::subtitle() const return ""; } -void ArmatureTestLayer::restartCallback(Object *pSender) +void ArmatureTestLayer::restartCallback(Ref *pSender) { Scene *s = new ArmatureTestScene(); s->addChild( RestartTest() ); Director::getInstance()->replaceScene(s); s->release(); } -void ArmatureTestLayer::nextCallback(Object *pSender) +void ArmatureTestLayer::nextCallback(Ref *pSender) { Scene *s = new ArmatureTestScene(); s->addChild( NextTest() ); Director::getInstance()->replaceScene(s); s->release(); } -void ArmatureTestLayer::backCallback(Object *pSender) +void ArmatureTestLayer::backCallback(Ref *pSender) { Scene *s = new ArmatureTestScene(); s->addChild( BackTest() ); @@ -270,7 +270,7 @@ std::string TestAsynchronousLoading::subtitle() const return "current percent : "; } -void TestAsynchronousLoading::restartCallback(Object* pSender) +void TestAsynchronousLoading::restartCallback(Ref* pSender) { ArmatureDataManager::destroyInstance(); ArmatureTestLayer::restartCallback(pSender); @@ -390,11 +390,11 @@ std::string TestPerformance::subtitle() const { return "Current Armature Count : "; } -void TestPerformance::onIncrease(Object* pSender) +void TestPerformance::onIncrease(Ref* pSender) { addArmature(20); } -void TestPerformance::onDecrease(Object* pSender) +void TestPerformance::onDecrease(Ref* pSender) { if (armatureCount == 0) return; @@ -1335,7 +1335,7 @@ void TestArmatureNesting2::onTouchesEnded(const std::vector& touches, Ev armature->runAction(Sequence::create(move, nullptr)); } -void TestArmatureNesting2::changeMountCallback(Object* pSender) +void TestArmatureNesting2::changeMountCallback(Ref* pSender) { hero->stopAllActions(); diff --git a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h index 9a07cc0d5d..67f5626885 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h +++ b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h @@ -22,7 +22,7 @@ public: virtual void runThisTest(); // The CallBack for back to the main menu scene - virtual void MainMenuCallback(Object* pSender); + virtual void MainMenuCallback(Ref* pSender); }; enum { @@ -55,9 +55,9 @@ public: virtual std::string title() const; virtual std::string subtitle() const; - virtual void restartCallback(Object* pSender); - virtual void nextCallback(Object* pSender); - virtual void backCallback(Object* pSender); + virtual void restartCallback(Ref* pSender); + virtual void nextCallback(Ref* pSender); + virtual void backCallback(Ref* pSender); // overrides virtual void onEnter() override; @@ -76,7 +76,7 @@ public: virtual void onEnter(); virtual std::string title() const override; virtual std::string subtitle() const override; - virtual void restartCallback(Object* pSender); + virtual void restartCallback(Ref* pSender); void dataLoaded(float percent); }; @@ -111,8 +111,8 @@ public: virtual void onEnter(); virtual std::string title() const override; virtual std::string subtitle() const override; - virtual void onIncrease(Object* pSender); - virtual void onDecrease(Object* pSender); + virtual void onIncrease(Ref* pSender); + virtual void onDecrease(Ref* pSender); virtual void addArmature(int number); virtual void addArmatureToParent(cocostudio::Armature *armature); virtual void removeArmatureFromParent(int tag); @@ -344,7 +344,7 @@ public: virtual std::string subtitle() const override; void onTouchesEnded(const std::vector& touches, Event* event); - void changeMountCallback(Object* pSender); + void changeMountCallback(Ref* pSender); virtual cocostudio::Armature *createMount(const char *name, Point position); private: diff --git a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioComponentsTest/ComponentsTestScene.cpp b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioComponentsTest/ComponentsTestScene.cpp index 539f9cbd0f..3f844b265c 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioComponentsTest/ComponentsTestScene.cpp +++ b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioComponentsTest/ComponentsTestScene.cpp @@ -81,7 +81,7 @@ cocos2d::Node* ComponentsTestLayer::createGameScene() root->addChild(player, 1, 1); - auto itemBack = MenuItemFont::create("Back", [](Object* sender){ + auto itemBack = MenuItemFont::create("Back", [](Ref* sender){ auto scene = new ExtensionsTestScene(); scene->runThisTest(); scene->release(); diff --git a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioComponentsTest/GameOverScene.cpp b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioComponentsTest/GameOverScene.cpp index 701f75a096..d9f9960045 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioComponentsTest/GameOverScene.cpp +++ b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioComponentsTest/GameOverScene.cpp @@ -72,7 +72,7 @@ bool GameOverLayer::init() nullptr)); - auto itemBack = MenuItemFont::create("Back", [](Object* sender){ + auto itemBack = MenuItemFont::create("Back", [](Ref* sender){ auto scene = new ExtensionsTestScene(); scene->runThisTest(); scene->release(); diff --git a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/CocosGUIScene.cpp b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/CocosGUIScene.cpp index ddc01e03fc..63308fda76 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/CocosGUIScene.cpp +++ b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/CocosGUIScene.cpp @@ -12,13 +12,13 @@ enum static struct { const char *name; - std::function callback; + std::function callback; } g_guisTests[] = { { "gui ButtonTest", - [](Object* sender) + [](Ref* sender) { UISceneManager* pManager = UISceneManager::sharedUISceneManager(); pManager->setCurrentUISceneId(kUIButtonTest); @@ -30,7 +30,7 @@ g_guisTests[] = }, { "gui CheckBoxTest", - [](Object* sender) + [](Ref* sender) { UISceneManager* pManager = UISceneManager::sharedUISceneManager(); pManager->setCurrentUISceneId(kUICheckBoxTest); @@ -42,7 +42,7 @@ g_guisTests[] = }, { "gui SliderTest", - [](Object* sender) + [](Ref* sender) { UISceneManager* pManager = UISceneManager::sharedUISceneManager(); pManager->setCurrentUISceneId(kUISliderTest); @@ -55,7 +55,7 @@ g_guisTests[] = /* { "gui PotentiometerTest", - [](Object* sender) + [](Ref* sender) { UISceneManager* pManager = UISceneManager::sharedUISceneManager(); pManager->setCurrentUISceneId(kUIPotentiometerTest); @@ -67,7 +67,7 @@ g_guisTests[] = }, { "gui SwitchTest", - [](Object* sender) + [](Ref* sender) { UISceneManager* pManager = UISceneManager::sharedUISceneManager(); pManager->setCurrentUISceneId(kUISwitchTest_Horizontal); @@ -80,7 +80,7 @@ g_guisTests[] = */ { "gui ImageViewTest", - [](Object* sender) + [](Ref* sender) { UISceneManager* pManager = UISceneManager::sharedUISceneManager(); pManager->setCurrentUISceneId(kUIImageViewTest); @@ -92,7 +92,7 @@ g_guisTests[] = }, { "gui LoadingBarTest", - [](Object* sender) + [](Ref* sender) { UISceneManager* pManager = UISceneManager::sharedUISceneManager(); pManager->setCurrentUISceneId(kUILoadingBarTest_Left); @@ -105,7 +105,7 @@ g_guisTests[] = /* { "gui ProgressTimerTest", - [](Object* sender) + [](Ref* sender) { UISceneManager* pManager = UISceneManager::sharedUISceneManager(); pManager->setCurrentUISceneId(kUIProgressTimerTest_Radial); @@ -118,7 +118,7 @@ g_guisTests[] = */ { "gui LabelAtalsTest", - [](Object* sender) + [](Ref* sender) { UISceneManager* pManager = UISceneManager::sharedUISceneManager(); pManager->setCurrentUISceneId(kUILabelAtlasTest); @@ -130,7 +130,7 @@ g_guisTests[] = }, { "gui LabelTest", - [](Object* sender) + [](Ref* sender) { UISceneManager* pManager = UISceneManager::sharedUISceneManager(); pManager->setCurrentUISceneId(kUILabelTest); @@ -142,7 +142,7 @@ g_guisTests[] = }, { "gui LabelBMFontTest", - [](Object* sender) + [](Ref* sender) { UISceneManager* pManager = UISceneManager::sharedUISceneManager(); pManager->setCurrentUISceneId(kUILabelBMFontTest); @@ -154,7 +154,7 @@ g_guisTests[] = }, { "gui TextFieldTest", - [](Object* sender) + [](Ref* sender) { UISceneManager* pManager = UISceneManager::sharedUISceneManager(); pManager->setCurrentUISceneId(kUITextFieldTest); @@ -166,7 +166,7 @@ g_guisTests[] = }, { "gui LayoutTest", - [](Object* sender) + [](Ref* sender) { UISceneManager* pManager = UISceneManager::sharedUISceneManager(); pManager->setCurrentUISceneId(kUILayoutTest); @@ -178,7 +178,7 @@ g_guisTests[] = }, { "gui ScrollViewTest", - [](Object* sender) + [](Ref* sender) { UISceneManager* pManager = UISceneManager::sharedUISceneManager(); pManager->setCurrentUISceneId(kUIScrollViewTest_Vertical); @@ -190,7 +190,7 @@ g_guisTests[] = }, { "gui PageViewTest", - [](Object* sender) + [](Ref* sender) { UISceneManager* pManager = UISceneManager::sharedUISceneManager(); pManager->setCurrentUISceneId(kUIPageViewTest); @@ -202,7 +202,7 @@ g_guisTests[] = }, { "gui ListViewTest", - [](Object* sender) + [](Ref* sender) { UISceneManager* pManager = UISceneManager::sharedUISceneManager(); pManager->setCurrentUISceneId(kUIListViewTest_Vertical); @@ -215,7 +215,7 @@ g_guisTests[] = /* { "gui GridViewTest", - [](Object* sender) + [](Ref* sender) { UISceneManager* pManager = UISceneManager::sharedUISceneManager(); pManager->setCurrentUISceneId(kUIGridViewTest_Mode_Column); @@ -227,7 +227,7 @@ g_guisTests[] = }, { "gui PickerViewTest", - [](Object* sender) + [](Ref* sender) { UISceneManager* pManager = UISceneManager::sharedUISceneManager(); pManager->setCurrentUISceneId(kUIPickerViewTest_Vertical); @@ -240,7 +240,7 @@ g_guisTests[] = */ { "gui WidgetAddNodeTest", - [](Object* sender) + [](Ref* sender) { UISceneManager* pManager = UISceneManager::sharedUISceneManager(); pManager->setCurrentUISceneId(kUIWidgetAddNodeTest); diff --git a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/CocosGUIScene.h b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/CocosGUIScene.h index 1ca0fa3012..d30be82a23 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/CocosGUIScene.h +++ b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/CocosGUIScene.h @@ -63,12 +63,12 @@ public: virtual void runThisTest(); // The CallBack for back to the main menu scene - virtual void MainMenuCallback(Object* sender); + virtual void MainMenuCallback(Ref* sender); - void load(Object* pSender, int count); - void loadTextureCallBack(Object *obj); + void load(Ref* pSender, int count); + void loadTextureCallBack(Ref *obj); - void menuCallback(Object* pSender); + void menuCallback(Ref* pSender); UILayer* _ul; diff --git a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp index 55cafbf86c..8c613dc025 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp +++ b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp @@ -52,7 +52,7 @@ bool UIButtonTest::init() return false; } -void UIButtonTest::touchEvent(Object *pSender, TouchEventType type) +void UIButtonTest::touchEvent(Ref *pSender, TouchEventType type) { switch (type) { @@ -130,7 +130,7 @@ bool UIButtonTest_Scale9::init() return false; } -void UIButtonTest_Scale9::touchEvent(Object *pSender, TouchEventType type) +void UIButtonTest_Scale9::touchEvent(Ref *pSender, TouchEventType type) { switch (type) { @@ -204,7 +204,7 @@ bool UIButtonTest_PressedAction::init() return false; } -void UIButtonTest_PressedAction::touchEvent(Object *pSender, TouchEventType type) +void UIButtonTest_PressedAction::touchEvent(Ref *pSender, TouchEventType type) { switch (type) { @@ -279,7 +279,7 @@ bool UIButtonTest_Title::init() } -void UIButtonTest_Title::touchEvent(Object *pSender, TouchEventType type) +void UIButtonTest_Title::touchEvent(Ref *pSender, TouchEventType type) { switch (type) { diff --git a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UIButtonTest/UIButtonTest.h b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UIButtonTest/UIButtonTest.h index 061e11f8b2..0e1f0dc036 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UIButtonTest/UIButtonTest.h +++ b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UIButtonTest/UIButtonTest.h @@ -33,7 +33,7 @@ public: UIButtonTest(); ~UIButtonTest(); bool init(); - void touchEvent(Object *pSender, TouchEventType type); + void touchEvent(Ref *pSender, TouchEventType type); protected: UI_SCENE_CREATE_FUNC(UIButtonTest) @@ -46,7 +46,7 @@ public: UIButtonTest_Scale9(); ~UIButtonTest_Scale9(); bool init(); - void touchEvent(Object *pSender, TouchEventType type); + void touchEvent(Ref *pSender, TouchEventType type); protected: UI_SCENE_CREATE_FUNC(UIButtonTest_Scale9) @@ -59,7 +59,7 @@ public: UIButtonTest_PressedAction(); ~UIButtonTest_PressedAction(); bool init(); - void touchEvent(Object *pSender, TouchEventType type); + void touchEvent(Ref *pSender, TouchEventType type); protected: UI_SCENE_CREATE_FUNC(UIButtonTest_PressedAction) @@ -72,7 +72,7 @@ public: UIButtonTest_Title(); ~UIButtonTest_Title(); bool init(); - void touchEvent(Object *pSender, TouchEventType type); + void touchEvent(Ref *pSender, TouchEventType type); protected: UI_SCENE_CREATE_FUNC(UIButtonTest_Title) diff --git a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp index 1e049998a7..2415844a0f 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp +++ b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp @@ -56,7 +56,7 @@ bool UICheckBoxTest::init() return false; } -void UICheckBoxTest::selectedEvent(Object* pSender,CheckBoxEventType type) +void UICheckBoxTest::selectedEvent(Ref* pSender,CheckBoxEventType type) { switch (type) { diff --git a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.h b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.h index 90a7003da8..983121b604 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.h +++ b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.h @@ -33,7 +33,7 @@ public: UICheckBoxTest(); ~UICheckBoxTest(); bool init(); - void selectedEvent(Object* pSender,CheckBoxEventType type); + void selectedEvent(Ref* pSender,CheckBoxEventType type); protected: UI_SCENE_CREATE_FUNC(UICheckBoxTest) diff --git a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UIListViewTest/UIListViewTest.cpp b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UIListViewTest/UIListViewTest.cpp index 26ef4781b2..f8b3f7e29e 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UIListViewTest/UIListViewTest.cpp +++ b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UIListViewTest/UIListViewTest.cpp @@ -167,7 +167,7 @@ bool UIListViewTest_Vertical::init() return false; } -void UIListViewTest_Vertical::selectedItemEvent(Object *pSender, ListViewEventType type) +void UIListViewTest_Vertical::selectedItemEvent(Ref *pSender, ListViewEventType type) { switch (type) { @@ -340,7 +340,7 @@ bool UIListViewTest_Horizontal::init() return false; } -void UIListViewTest_Horizontal::selectedItemEvent(Object *pSender, ListViewEventType type) +void UIListViewTest_Horizontal::selectedItemEvent(Ref *pSender, ListViewEventType type) { switch (type) { diff --git a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UIListViewTest/UIListViewTest.h b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UIListViewTest/UIListViewTest.h index 5424c905cb..b628a43798 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UIListViewTest/UIListViewTest.h +++ b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UIListViewTest/UIListViewTest.h @@ -33,7 +33,7 @@ public: UIListViewTest_Vertical(); ~UIListViewTest_Vertical(); bool init(); - void selectedItemEvent(Object* pSender, ListViewEventType type); + void selectedItemEvent(Ref* pSender, ListViewEventType type); protected: UI_SCENE_CREATE_FUNC(UIListViewTest_Vertical) @@ -48,7 +48,7 @@ public: UIListViewTest_Horizontal(); ~UIListViewTest_Horizontal(); bool init(); - void selectedItemEvent(Object* pSender, ListViewEventType type); + void selectedItemEvent(Ref* pSender, ListViewEventType type); protected: UI_SCENE_CREATE_FUNC(UIListViewTest_Horizontal) diff --git a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp index ffb6f081b5..f52f99f9e2 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp +++ b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp @@ -58,7 +58,7 @@ void UILoadingBarTest_Left::update(float delta) loadingBar->setPercent(_count); } -void UILoadingBarTest_Left::previousCallback(Object* sender, TouchEventType type) +void UILoadingBarTest_Left::previousCallback(Ref* sender, TouchEventType type) { if (type == TOUCH_EVENT_ENDED) { @@ -67,7 +67,7 @@ void UILoadingBarTest_Left::previousCallback(Object* sender, TouchEventType type } } -void UILoadingBarTest_Left::restartCallback(Object* sender, TouchEventType type) +void UILoadingBarTest_Left::restartCallback(Ref* sender, TouchEventType type) { if (type == TOUCH_EVENT_ENDED) { @@ -76,7 +76,7 @@ void UILoadingBarTest_Left::restartCallback(Object* sender, TouchEventType type) } } -void UILoadingBarTest_Left::nextCallback(Object* sender, TouchEventType type) +void UILoadingBarTest_Left::nextCallback(Ref* sender, TouchEventType type) { if (type == TOUCH_EVENT_ENDED) { @@ -141,7 +141,7 @@ void UILoadingBarTest_Right::update(float delta) loadingBar->setPercent(_count); } -void UILoadingBarTest_Right::previousCallback(Object* sender, TouchEventType type) +void UILoadingBarTest_Right::previousCallback(Ref* sender, TouchEventType type) { if (type == TOUCH_EVENT_ENDED) { @@ -150,7 +150,7 @@ void UILoadingBarTest_Right::previousCallback(Object* sender, TouchEventType typ } } -void UILoadingBarTest_Right::restartCallback(Object* sender, TouchEventType type) +void UILoadingBarTest_Right::restartCallback(Ref* sender, TouchEventType type) { if (type == TOUCH_EVENT_ENDED) { @@ -159,7 +159,7 @@ void UILoadingBarTest_Right::restartCallback(Object* sender, TouchEventType type } } -void UILoadingBarTest_Right::nextCallback(Object* sender, TouchEventType type) +void UILoadingBarTest_Right::nextCallback(Ref* sender, TouchEventType type) { if (type == TOUCH_EVENT_ENDED) { @@ -226,7 +226,7 @@ void UILoadingBarTest_Left_Scale9::update(float delta) loadingBar->setPercent(_count); } -void UILoadingBarTest_Left_Scale9::previousCallback(Object* sender, TouchEventType type) +void UILoadingBarTest_Left_Scale9::previousCallback(Ref* sender, TouchEventType type) { if (type == TOUCH_EVENT_ENDED) { @@ -235,7 +235,7 @@ void UILoadingBarTest_Left_Scale9::previousCallback(Object* sender, TouchEventTy } } -void UILoadingBarTest_Left_Scale9::restartCallback(Object* sender, TouchEventType type) +void UILoadingBarTest_Left_Scale9::restartCallback(Ref* sender, TouchEventType type) { if (type == TOUCH_EVENT_ENDED) { @@ -244,7 +244,7 @@ void UILoadingBarTest_Left_Scale9::restartCallback(Object* sender, TouchEventTyp } } -void UILoadingBarTest_Left_Scale9::nextCallback(Object* sender, TouchEventType type) +void UILoadingBarTest_Left_Scale9::nextCallback(Ref* sender, TouchEventType type) { if (type == TOUCH_EVENT_ENDED) { @@ -312,7 +312,7 @@ void UILoadingBarTest_Right_Scale9::update(float delta) loadingBar->setPercent(_count); } -void UILoadingBarTest_Right_Scale9::previousCallback(Object* sender, TouchEventType type) +void UILoadingBarTest_Right_Scale9::previousCallback(Ref* sender, TouchEventType type) { if (type == TOUCH_EVENT_ENDED) { @@ -321,7 +321,7 @@ void UILoadingBarTest_Right_Scale9::previousCallback(Object* sender, TouchEventT } } -void UILoadingBarTest_Right_Scale9::restartCallback(Object* sender, TouchEventType type) +void UILoadingBarTest_Right_Scale9::restartCallback(Ref* sender, TouchEventType type) { if (type == TOUCH_EVENT_ENDED) { @@ -330,7 +330,7 @@ void UILoadingBarTest_Right_Scale9::restartCallback(Object* sender, TouchEventTy } } -void UILoadingBarTest_Right_Scale9::nextCallback(Object* sender, TouchEventType type) +void UILoadingBarTest_Right_Scale9::nextCallback(Ref* sender, TouchEventType type) { if (type == TOUCH_EVENT_ENDED) { diff --git a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.h b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.h index 6f720401d1..7afae165b8 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.h +++ b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.h @@ -35,9 +35,9 @@ public: bool init(); void update(float delta); - virtual void previousCallback(Object* sender, TouchEventType type) override; - virtual void restartCallback(Object* sender, TouchEventType type) override; - virtual void nextCallback(Object* sender, TouchEventType type) override; + virtual void previousCallback(Ref* sender, TouchEventType type) override; + virtual void restartCallback(Ref* sender, TouchEventType type) override; + virtual void nextCallback(Ref* sender, TouchEventType type) override; protected: UI_SCENE_CREATE_FUNC(UILoadingBarTest_Left) @@ -52,9 +52,9 @@ public: bool init(); void update(float delta); - virtual void previousCallback(Object* sender, TouchEventType type) override; - virtual void restartCallback(Object* sender, TouchEventType type) override; - virtual void nextCallback(Object* sender, TouchEventType type) override; + virtual void previousCallback(Ref* sender, TouchEventType type) override; + virtual void restartCallback(Ref* sender, TouchEventType type) override; + virtual void nextCallback(Ref* sender, TouchEventType type) override; protected: UI_SCENE_CREATE_FUNC(UILoadingBarTest_Right) @@ -69,9 +69,9 @@ public: bool init(); void update(float delta); - virtual void previousCallback(Object* sender, TouchEventType type) override; - virtual void restartCallback(Object* sender, TouchEventType type) override; - virtual void nextCallback(Object* sender, TouchEventType type) override; + virtual void previousCallback(Ref* sender, TouchEventType type) override; + virtual void restartCallback(Ref* sender, TouchEventType type) override; + virtual void nextCallback(Ref* sender, TouchEventType type) override; protected: UI_SCENE_CREATE_FUNC(UILoadingBarTest_Left_Scale9) @@ -86,9 +86,9 @@ public: bool init(); void update(float delta); - virtual void previousCallback(Object* sender, TouchEventType type) override; - virtual void restartCallback(Object* sender, TouchEventType type) override; - virtual void nextCallback(Object* sender, TouchEventType type) override; + virtual void previousCallback(Ref* sender, TouchEventType type) override; + virtual void restartCallback(Ref* sender, TouchEventType type) override; + virtual void nextCallback(Ref* sender, TouchEventType type) override; protected: UI_SCENE_CREATE_FUNC(UILoadingBarTest_Right_Scale9) diff --git a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp index a2f43dd5af..f1579cfdde 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp +++ b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp @@ -84,7 +84,7 @@ bool UIPageViewTest::init() return false; } -void UIPageViewTest::pageViewEvent(Object *pSender, PageViewEventType type) +void UIPageViewTest::pageViewEvent(Ref *pSender, PageViewEventType type) { switch (type) { diff --git a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.h b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.h index 5c48851768..9be8efac02 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.h +++ b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.h @@ -34,7 +34,7 @@ public: ~UIPageViewTest(); bool init(); - void pageViewEvent(Object* pSender, PageViewEventType type); + void pageViewEvent(Ref* pSender, PageViewEventType type); protected: UI_SCENE_CREATE_FUNC(UIPageViewTest) diff --git a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UIScene.cpp b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UIScene.cpp index 7eafc723da..3660eeedd1 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UIScene.cpp +++ b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UIScene.cpp @@ -56,7 +56,7 @@ bool UIScene::init() return false; } -void UIScene::menuCloseCallback(Object* pSender, TouchEventType type) +void UIScene::menuCloseCallback(Ref* pSender, TouchEventType type) { if (type == TOUCH_EVENT_ENDED) { @@ -67,7 +67,7 @@ void UIScene::menuCloseCallback(Object* pSender, TouchEventType type) } } -void UIScene::toCocosGUITestScene(Object* sender, TouchEventType type) +void UIScene::toCocosGUITestScene(Ref* sender, TouchEventType type) { if (type == TOUCH_EVENT_ENDED) { @@ -79,7 +79,7 @@ void UIScene::toCocosGUITestScene(Object* sender, TouchEventType type) } } -void UIScene::previousCallback(Object* sender, TouchEventType type) +void UIScene::previousCallback(Ref* sender, TouchEventType type) { if (type == TOUCH_EVENT_ENDED) { @@ -87,7 +87,7 @@ void UIScene::previousCallback(Object* sender, TouchEventType type) } } -void UIScene::restartCallback(Object* sender, TouchEventType type) +void UIScene::restartCallback(Ref* sender, TouchEventType type) { if (type == TOUCH_EVENT_ENDED) { @@ -95,7 +95,7 @@ void UIScene::restartCallback(Object* sender, TouchEventType type) } } -void UIScene::nextCallback(Object* sender, TouchEventType type) +void UIScene::nextCallback(Ref* sender, TouchEventType type) { if (type == TOUCH_EVENT_ENDED) { diff --git a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UIScene.h b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UIScene.h index 32d073c97b..61ef4d9af8 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UIScene.h +++ b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UIScene.h @@ -59,10 +59,10 @@ public: ~UIScene(); bool init(); // Menu Callbacks - void toCocosGUITestScene(Object* sender, TouchEventType type); - virtual void previousCallback(Object* sender, TouchEventType type); - virtual void restartCallback(Object* sender, TouchEventType type); - virtual void nextCallback(Object* sender, TouchEventType type); + void toCocosGUITestScene(Ref* sender, TouchEventType type); + virtual void previousCallback(Ref* sender, TouchEventType type); + virtual void restartCallback(Ref* sender, TouchEventType type); + virtual void nextCallback(Ref* sender, TouchEventType type); /** Title label of the scene. */ CC_SYNTHESIZE_READONLY(gui::Text*, _sceneTitle, SceneTitle) @@ -71,7 +71,7 @@ public: protected: // a selector callback - void menuCloseCallback(Object* pSender, TouchEventType type); + void menuCloseCallback(Ref* pSender, TouchEventType type); protected: Layer* _uiLayer; diff --git a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UISceneManager.h b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UISceneManager.h index fef30e428e..e8eba22c91 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UISceneManager.h +++ b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UISceneManager.h @@ -100,7 +100,7 @@ enum kUITestMax }; -class UISceneManager : public Object +class UISceneManager : public Ref { public: UISceneManager(); diff --git a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp index 1723200de6..28a7d424d3 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp +++ b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp @@ -68,7 +68,7 @@ bool UISliderTest::init() return false; } -void UISliderTest::sliderEvent(Object *pSender, SliderEventType type) +void UISliderTest::sliderEvent(Ref *pSender, SliderEventType type) { if (type == SLIDER_PERCENTCHANGED) { @@ -149,7 +149,7 @@ bool UISliderTest_Scale9::init() return false; } -void UISliderTest_Scale9::sliderEvent(Object *pSender, SliderEventType type) +void UISliderTest_Scale9::sliderEvent(Ref *pSender, SliderEventType type) { if (type == SLIDER_PERCENTCHANGED) { diff --git a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UISliderTest/UISliderTest.h b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UISliderTest/UISliderTest.h index f86ad7f440..34ddf2e77f 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UISliderTest/UISliderTest.h +++ b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UISliderTest/UISliderTest.h @@ -33,7 +33,7 @@ public: UISliderTest(); ~UISliderTest(); bool init(); - void sliderEvent(Object* pSender, SliderEventType type); + void sliderEvent(Ref* pSender, SliderEventType type); protected: UI_SCENE_CREATE_FUNC(UISliderTest) @@ -46,7 +46,7 @@ public: UISliderTest_Scale9(); ~UISliderTest_Scale9(); bool init(); - void sliderEvent(Object* pSender, SliderEventType type); + void sliderEvent(Ref* pSender, SliderEventType type); protected: UI_SCENE_CREATE_FUNC(UISliderTest_Scale9) diff --git a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp index 0862a7dc52..56d0b0034d 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp +++ b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp @@ -52,7 +52,7 @@ bool UITextFieldTest::init() return false; } -void UITextFieldTest::textFieldEvent(Object *pSender, TextFiledEventType type) +void UITextFieldTest::textFieldEvent(Ref *pSender, TextFiledEventType type) { switch (type) { @@ -140,7 +140,7 @@ bool UITextFieldTest_MaxLength::init() return false; } -void UITextFieldTest_MaxLength::textFieldEvent(Object *pSender, TextFiledEventType type) +void UITextFieldTest_MaxLength::textFieldEvent(Ref *pSender, TextFiledEventType type) { switch (type) { @@ -234,7 +234,7 @@ bool UITextFieldTest_Password::init() return false; } -void UITextFieldTest_Password::textFieldEvent(Object *pSender, TextFiledEventType type) +void UITextFieldTest_Password::textFieldEvent(Ref *pSender, TextFiledEventType type) { switch (type) { diff --git a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.h b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.h index e568d9f400..eb12e2abc5 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.h +++ b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.h @@ -33,7 +33,7 @@ public: UITextFieldTest(); ~UITextFieldTest(); bool init(); - void textFieldEvent(Object* pSender, TextFiledEventType type); + void textFieldEvent(Ref* pSender, TextFiledEventType type); protected: UI_SCENE_CREATE_FUNC(UITextFieldTest) @@ -46,7 +46,7 @@ public: UITextFieldTest_MaxLength(); ~UITextFieldTest_MaxLength(); bool init(); - void textFieldEvent(Object* pSender, TextFiledEventType type); + void textFieldEvent(Ref* pSender, TextFiledEventType type); protected: UI_SCENE_CREATE_FUNC(UITextFieldTest_MaxLength) @@ -59,7 +59,7 @@ public: UITextFieldTest_Password(); ~UITextFieldTest_Password(); bool init(); - void textFieldEvent(Object* pSender, TextFiledEventType type); + void textFieldEvent(Ref* pSender, TextFiledEventType type); protected: UI_SCENE_CREATE_FUNC(UITextFieldTest_Password) diff --git a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp index 70d3ac2cbd..48447e2168 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp +++ b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp @@ -101,7 +101,7 @@ void SceneEditorTestScene::runThisTest() CCDirector::getInstance()->replaceScene(this); } -void SceneEditorTestScene::MainMenuCallback(Object *pSender) +void SceneEditorTestScene::MainMenuCallback(Ref *pSender) { removeAllChildren(); } @@ -170,7 +170,7 @@ std::string SceneEditorTestLayer::subtitle() return ""; } -void SceneEditorTestLayer::restartCallback(Object *pSender) +void SceneEditorTestLayer::restartCallback(Ref *pSender) { Scene *s = new SceneEditorTestScene(); s->addChild(Restart()); @@ -178,7 +178,7 @@ void SceneEditorTestLayer::restartCallback(Object *pSender) s->release(); } -void SceneEditorTestLayer::nextCallback(Object *pSender) +void SceneEditorTestLayer::nextCallback(Ref *pSender) { Scene *s = new SceneEditorTestScene(); s->addChild(Next()); @@ -186,7 +186,7 @@ void SceneEditorTestLayer::nextCallback(Object *pSender) s->release(); } -void SceneEditorTestLayer::backCallback(Object *pSender) +void SceneEditorTestLayer::backCallback(Ref *pSender) { Scene *s = new SceneEditorTestScene(); s->addChild(Back()); @@ -404,7 +404,7 @@ cocos2d::Node* UIComponentTest::createGameScene() return node; } -void UIComponentTest::touchEvent(Object *pSender, TouchEventType type) +void UIComponentTest::touchEvent(Ref *pSender, TouchEventType type) { switch (type) { diff --git a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.h b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.h index 68f08bac2f..501503e9c4 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.h +++ b/tests/test-cpp/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.h @@ -13,7 +13,7 @@ public: virtual void runThisTest(); // The CallBack for back to the main menu scene - virtual void MainMenuCallback(cocos2d::Object* pSender); + virtual void MainMenuCallback(cocos2d::Ref* pSender); }; enum { @@ -39,9 +39,9 @@ public: virtual std::string title(); virtual std::string subtitle(); - virtual void restartCallback(cocos2d::Object* pSender); - virtual void nextCallback(cocos2d::Object* pSender); - virtual void backCallback(cocos2d::Object* pSender); + virtual void restartCallback(cocos2d::Ref* pSender); + virtual void nextCallback(cocos2d::Ref* pSender); + virtual void backCallback(cocos2d::Ref* pSender); virtual void draw(); @@ -100,7 +100,7 @@ public: virtual void onEnter(); virtual void onExit(); cocos2d::Node* createGameScene(); - void touchEvent(cocos2d::Object *pSender, cocos2d::gui::TouchEventType type); + void touchEvent(cocos2d::Ref *pSender, cocos2d::gui::TouchEventType type); private: cocos2d::Node* _node; }; diff --git a/tests/test-cpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.cpp b/tests/test-cpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.cpp index 934552aed5..02ef579e92 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.cpp +++ b/tests/test-cpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.cpp @@ -13,12 +13,12 @@ AnimationsTestLayer::~AnimationsTestLayer() CC_SAFE_RELEASE_NULL(mAnimationManager); } -SEL_MenuHandler AnimationsTestLayer::onResolveCCBCCMenuItemSelector(Object * pTarget, const char * pSelectorName) +SEL_MenuHandler AnimationsTestLayer::onResolveCCBCCMenuItemSelector(Ref * pTarget, const char * pSelectorName) { return NULL; } -Control::Handler AnimationsTestLayer::onResolveCCBCCControlSelector(Object *pTarget, const char*pSelectorName) +Control::Handler AnimationsTestLayer::onResolveCCBCCControlSelector(Ref *pTarget, const char*pSelectorName) { CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onCCControlButtonIdleClicked", AnimationsTestLayer::onControlButtonIdleClicked); CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onCCControlButtonWaveClicked", AnimationsTestLayer::onControlButtonWaveClicked); @@ -28,7 +28,7 @@ Control::Handler AnimationsTestLayer::onResolveCCBCCControlSelector(Object *pTar return NULL; } -bool AnimationsTestLayer::onAssignCCBMemberVariable(Object * pTarget, const char * pMemberVariableName, Node * pNode) { +bool AnimationsTestLayer::onAssignCCBMemberVariable(Ref * pTarget, const char * pMemberVariableName, Node * pNode) { CCB_MEMBERVARIABLEASSIGNER_GLUE(this, "mAnimationManager", CCBAnimationManager *, this->mAnimationManager); return false; @@ -41,18 +41,18 @@ void AnimationsTestLayer::setAnimationManager(cocosbuilder::CCBAnimationManager CC_SAFE_RETAIN(mAnimationManager); } -void AnimationsTestLayer::onControlButtonIdleClicked(Object *pSender, Control::EventType pControlEvent) { +void AnimationsTestLayer::onControlButtonIdleClicked(Ref *pSender, Control::EventType pControlEvent) { mAnimationManager->runAnimationsForSequenceNamedTweenDuration("Idle", 0.3f); } -void AnimationsTestLayer::onControlButtonWaveClicked(Object *pSender, Control::EventType pControlEvent) { +void AnimationsTestLayer::onControlButtonWaveClicked(Ref *pSender, Control::EventType pControlEvent) { mAnimationManager->runAnimationsForSequenceNamedTweenDuration("Wave", 0.3f); } -void AnimationsTestLayer::onControlButtonJumpClicked(Object *pSender, Control::EventType pControlEvent) { +void AnimationsTestLayer::onControlButtonJumpClicked(Ref *pSender, Control::EventType pControlEvent) { mAnimationManager->runAnimationsForSequenceNamedTweenDuration("Jump", 0.3f); } -void AnimationsTestLayer::onControlButtonFunkyClicked(Object *pSender, Control::EventType pControlEvent) { +void AnimationsTestLayer::onControlButtonFunkyClicked(Ref *pSender, Control::EventType pControlEvent) { mAnimationManager->runAnimationsForSequenceNamedTweenDuration("Funky", 0.3f); } \ No newline at end of file diff --git a/tests/test-cpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.h b/tests/test-cpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.h index 2ad6658306..6bd009d9be 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.h +++ b/tests/test-cpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.h @@ -16,14 +16,14 @@ public: AnimationsTestLayer(); virtual ~AnimationsTestLayer(); - virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(Object * pTarget, const char * pSelectorName); - virtual cocos2d::extension::Control::Handler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, const char * pSelectorName); - virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName, cocos2d::Node * node); + virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(Ref * pTarget, const char * pSelectorName); + virtual cocos2d::extension::Control::Handler onResolveCCBCCControlSelector(cocos2d::Ref * pTarget, const char * pSelectorName); + virtual bool onAssignCCBMemberVariable(cocos2d::Ref * pTarget, const char * pMemberVariableName, cocos2d::Node * node); - void onControlButtonIdleClicked(cocos2d::Object * sender, cocos2d::extension::Control::EventType pControlEvent); - void onControlButtonWaveClicked(cocos2d::Object * sender, cocos2d::extension::Control::EventType pControlEvent); - void onControlButtonJumpClicked(cocos2d::Object * sender, cocos2d::extension::Control::EventType pControlEvent); - void onControlButtonFunkyClicked(cocos2d::Object * sender, cocos2d::extension::Control::EventType pControlEvent); + void onControlButtonIdleClicked(cocos2d::Ref * sender, cocos2d::extension::Control::EventType pControlEvent); + void onControlButtonWaveClicked(cocos2d::Ref * sender, cocos2d::extension::Control::EventType pControlEvent); + void onControlButtonJumpClicked(cocos2d::Ref * sender, cocos2d::extension::Control::EventType pControlEvent); + void onControlButtonFunkyClicked(cocos2d::Ref * sender, cocos2d::extension::Control::EventType pControlEvent); void setAnimationManager(cocosbuilder::CCBAnimationManager *pAnimationManager); diff --git a/tests/test-cpp/Classes/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.cpp b/tests/test-cpp/Classes/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.cpp index 238918e170..c10f5632b6 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.cpp +++ b/tests/test-cpp/Classes/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.cpp @@ -13,23 +13,23 @@ ButtonTestLayer::~ButtonTestLayer() CC_SAFE_RELEASE(mControlEventLabel); } -SEL_MenuHandler ButtonTestLayer::onResolveCCBCCMenuItemSelector(Object * pTarget, const char * pSelectorName) { +SEL_MenuHandler ButtonTestLayer::onResolveCCBCCMenuItemSelector(Ref * pTarget, const char * pSelectorName) { return NULL; } -Control::Handler ButtonTestLayer::onResolveCCBCCControlSelector(Object * pTarget, const char * pSelectorName) { +Control::Handler ButtonTestLayer::onResolveCCBCCControlSelector(Ref * pTarget, const char * pSelectorName) { CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onCCControlButtonClicked", ButtonTestLayer::onControlButtonClicked); return NULL; } -bool ButtonTestLayer::onAssignCCBMemberVariable(Object * pTarget, const char * pMemberVariableName, Node * pNode) { +bool ButtonTestLayer::onAssignCCBMemberVariable(Ref * pTarget, const char * pMemberVariableName, Node * pNode) { CCB_MEMBERVARIABLEASSIGNER_GLUE(this, "mCCControlEventLabel", LabelBMFont *, this->mControlEventLabel); return false; } -void ButtonTestLayer::onControlButtonClicked(cocos2d::Object *pSender, Control::EventType pControlEvent) { +void ButtonTestLayer::onControlButtonClicked(cocos2d::Ref *pSender, Control::EventType pControlEvent) { switch(pControlEvent) { case Control::EventType::TOUCH_DOWN: this->mControlEventLabel->setString("Touch Down."); diff --git a/tests/test-cpp/Classes/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.h b/tests/test-cpp/Classes/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.h index 1fa38a7e0c..40563ff565 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.h +++ b/tests/test-cpp/Classes/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.h @@ -16,11 +16,11 @@ public: ButtonTestLayer(); virtual ~ButtonTestLayer(); - virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::Object * pTarget, const char * pSelectorName); - virtual cocos2d::extension::Control::Handler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, const char * pSelectorName); - virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName, cocos2d::Node * node); + virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::Ref * pTarget, const char * pSelectorName); + virtual cocos2d::extension::Control::Handler onResolveCCBCCControlSelector(cocos2d::Ref * pTarget, const char * pSelectorName); + virtual bool onAssignCCBMemberVariable(cocos2d::Ref * pTarget, const char * pMemberVariableName, cocos2d::Node * node); - void onControlButtonClicked(cocos2d::Object * sender, cocos2d::extension::Control::EventType pControlEvent); + void onControlButtonClicked(cocos2d::Ref * sender, cocos2d::extension::Control::EventType pControlEvent); private: cocos2d::LabelBMFont * mControlEventLabel; diff --git a/tests/test-cpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp b/tests/test-cpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp index 9ea484c52c..92077a4438 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp +++ b/tests/test-cpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp @@ -69,11 +69,11 @@ void HelloCocosBuilderLayer::onNodeLoaded(cocos2d::Node * node, cocosbuilder::N } -SEL_MenuHandler HelloCocosBuilderLayer::onResolveCCBCCMenuItemSelector(Object * pTarget, const char * pSelectorName) { +SEL_MenuHandler HelloCocosBuilderLayer::onResolveCCBCCMenuItemSelector(Ref * pTarget, const char * pSelectorName) { return NULL; } -Control::Handler HelloCocosBuilderLayer::onResolveCCBCCControlSelector(Object * pTarget, const char * pSelectorName) { +Control::Handler HelloCocosBuilderLayer::onResolveCCBCCControlSelector(Ref * pTarget, const char * pSelectorName) { CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onMenuTestClicked", HelloCocosBuilderLayer::onMenuTestClicked); CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onSpriteTestClicked", HelloCocosBuilderLayer::onSpriteTestClicked); CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onButtonTestClicked", HelloCocosBuilderLayer::onButtonTestClicked); @@ -85,14 +85,14 @@ Control::Handler HelloCocosBuilderLayer::onResolveCCBCCControlSelector(Object * return NULL; } -bool HelloCocosBuilderLayer::onAssignCCBMemberVariable(Object * pTarget, const char * pMemberVariableName, Node * pNode) { +bool HelloCocosBuilderLayer::onAssignCCBMemberVariable(Ref * pTarget, const char * pMemberVariableName, Node * pNode) { CCB_MEMBERVARIABLEASSIGNER_GLUE(this, "mBurstSprite", Sprite *, this->mBurstSprite); CCB_MEMBERVARIABLEASSIGNER_GLUE(this, "mTestTitleLabelTTF", LabelTTF *, this->mTestTitleLabelTTF); return false; } -bool HelloCocosBuilderLayer::onAssignCCBCustomProperty(Object* pTarget, const char* pMemberVariableName, const Value& pCCBValue) +bool HelloCocosBuilderLayer::onAssignCCBCustomProperty(Ref* pTarget, const char* pMemberVariableName, const Value& pCCBValue) { bool bRet = false; if (pTarget == this) @@ -127,19 +127,19 @@ bool HelloCocosBuilderLayer::onAssignCCBCustomProperty(Object* pTarget, const ch return bRet; } -void HelloCocosBuilderLayer::onMenuTestClicked(Object * sender, Control::EventType pControlEvent) { +void HelloCocosBuilderLayer::onMenuTestClicked(Ref * sender, Control::EventType pControlEvent) { this->openTest("ccb/ccb/TestMenus.ccbi", "TestMenusLayer", MenuTestLayerLoader::loader()); } -void HelloCocosBuilderLayer::onSpriteTestClicked(Object * sender, Control::EventType pControlEvent) { +void HelloCocosBuilderLayer::onSpriteTestClicked(Ref * sender, Control::EventType pControlEvent) { this->openTest("ccb/ccb/TestSprites.ccbi", "TestSpritesLayer", SpriteTestLayerLoader::loader()); } -void HelloCocosBuilderLayer::onButtonTestClicked(Object * sender, Control::EventType pControlEvent) { +void HelloCocosBuilderLayer::onButtonTestClicked(Ref * sender, Control::EventType pControlEvent) { this->openTest("ccb/ccb/TestButtons.ccbi", "TestButtonsLayer", ButtonTestLayerLoader::loader()); } -void HelloCocosBuilderLayer::onAnimationsTestClicked(Object * sender, Control::EventType pControlEvent) { +void HelloCocosBuilderLayer::onAnimationsTestClicked(Ref * sender, Control::EventType pControlEvent) { /* Create an autorelease NodeLoaderLibrary. */ NodeLoaderLibrary * ccNodeLoaderLibrary = NodeLoaderLibrary::newDefaultNodeLoaderLibrary(); @@ -180,16 +180,16 @@ void HelloCocosBuilderLayer::onAnimationsTestClicked(Object * sender, Control::E //this->openTest("TestAnimations.ccbi", "TestAnimationsLayer", AnimationsTestLayerLoader::loader()); } -void HelloCocosBuilderLayer::onParticleSystemTestClicked(Object * sender, Control::EventType pControlEvent) { +void HelloCocosBuilderLayer::onParticleSystemTestClicked(Ref * sender, Control::EventType pControlEvent) { this->openTest("ccb/ccb/TestParticleSystems.ccbi", "TestParticleSystemsLayer", ParticleSystemTestLayerLoader::loader()); } -void HelloCocosBuilderLayer::onScrollViewTestClicked(Object * sender, Control::EventType pControlEvent) +void HelloCocosBuilderLayer::onScrollViewTestClicked(Ref * sender, Control::EventType pControlEvent) { this->openTest("ccb/ccb/TestScrollViews.ccbi", "TestScrollViewsLayer", ScrollViewTestLayerLoader::loader()); } -void HelloCocosBuilderLayer::onTimelineCallbackSoundClicked(Object * sender, Control::EventType pControlEvent) +void HelloCocosBuilderLayer::onTimelineCallbackSoundClicked(Ref * sender, Control::EventType pControlEvent) { this->openTest("ccb/ccb/TestTimelineCallback.ccbi", "TimelineCallbackTestLayer", TimelineCallbackTestLayerLoader::loader()); } diff --git a/tests/test-cpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.h b/tests/test-cpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.h index 8eb3c528d3..f2d6a0a9cd 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.h +++ b/tests/test-cpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.h @@ -29,19 +29,19 @@ class HelloCocosBuilderLayer void openTest(const char * pCCBFileName, const char * nodeName = NULL, cocosbuilder::NodeLoader * nodeLoader = NULL); - virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::Object * pTarget, const char * pSelectorName); - virtual cocos2d::extension::Control::Handler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, const char * pSelectorName); - virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName, cocos2d::Node * node); - virtual bool onAssignCCBCustomProperty(Object* pTarget, const char* pMemberVariableName, const cocos2d::Value& pCCBValue); + virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::Ref * pTarget, const char * pSelectorName); + virtual cocos2d::extension::Control::Handler onResolveCCBCCControlSelector(cocos2d::Ref * pTarget, const char * pSelectorName); + virtual bool onAssignCCBMemberVariable(cocos2d::Ref * pTarget, const char * pMemberVariableName, cocos2d::Node * node); + virtual bool onAssignCCBCustomProperty(Ref* pTarget, const char* pMemberVariableName, const cocos2d::Value& pCCBValue); virtual void onNodeLoaded(cocos2d::Node * node, cocosbuilder::NodeLoader * nodeLoader); - void onMenuTestClicked(cocos2d::Object * sender, cocos2d::extension::Control::EventType pControlEvent); - void onSpriteTestClicked(cocos2d::Object * sender, cocos2d::extension::Control::EventType pControlEvent); - void onButtonTestClicked(cocos2d::Object * sender, cocos2d::extension::Control::EventType pControlEvent); - void onAnimationsTestClicked(cocos2d::Object * sender, cocos2d::extension::Control::EventType pControlEvent); - void onParticleSystemTestClicked(cocos2d::Object * sender, cocos2d::extension::Control::EventType pControlEvent); - void onScrollViewTestClicked(cocos2d::Object * sender, cocos2d::extension::Control::EventType pControlEvent); - void onTimelineCallbackSoundClicked(cocos2d::Object * sender, cocos2d::extension::Control::EventType pControlEvent); + void onMenuTestClicked(cocos2d::Ref * sender, cocos2d::extension::Control::EventType pControlEvent); + void onSpriteTestClicked(cocos2d::Ref * sender, cocos2d::extension::Control::EventType pControlEvent); + void onButtonTestClicked(cocos2d::Ref * sender, cocos2d::extension::Control::EventType pControlEvent); + void onAnimationsTestClicked(cocos2d::Ref * sender, cocos2d::extension::Control::EventType pControlEvent); + void onParticleSystemTestClicked(cocos2d::Ref * sender, cocos2d::extension::Control::EventType pControlEvent); + void onScrollViewTestClicked(cocos2d::Ref * sender, cocos2d::extension::Control::EventType pControlEvent); + void onTimelineCallbackSoundClicked(cocos2d::Ref * sender, cocos2d::extension::Control::EventType pControlEvent); private: cocos2d::Sprite * mBurstSprite; diff --git a/tests/test-cpp/Classes/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.cpp b/tests/test-cpp/Classes/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.cpp index f29fd86cad..6a8a70e1e2 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.cpp +++ b/tests/test-cpp/Classes/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.cpp @@ -13,7 +13,7 @@ MenuTestLayer::~MenuTestLayer() CC_SAFE_RELEASE(mMenuItemStatusLabelBMFont); } -SEL_MenuHandler MenuTestLayer::onResolveCCBCCMenuItemSelector(Object * pTarget, const char * pSelectorName) { +SEL_MenuHandler MenuTestLayer::onResolveCCBCCMenuItemSelector(Ref * pTarget, const char * pSelectorName) { CCB_SELECTORRESOLVER_CCMENUITEM_GLUE(this, "onMenuItemAClicked", MenuTestLayer::onMenuItemAClicked); CCB_SELECTORRESOLVER_CCMENUITEM_GLUE(this, "onMenuItemBClicked", MenuTestLayer::onMenuItemBClicked); CCB_SELECTORRESOLVER_CCMENUITEM_GLUE(this, "onMenuItemCClicked", MenuTestLayer::onMenuItemCClicked); @@ -21,24 +21,24 @@ SEL_MenuHandler MenuTestLayer::onResolveCCBCCMenuItemSelector(Object * pTarget, return NULL; } -Control::Handler MenuTestLayer::onResolveCCBCCControlSelector(Object * pTarget, const char * pSelectorName) { +Control::Handler MenuTestLayer::onResolveCCBCCControlSelector(Ref * pTarget, const char * pSelectorName) { return NULL; } -bool MenuTestLayer::onAssignCCBMemberVariable(Object * pTarget, const char * pMemberVariableName, Node * pNode) { +bool MenuTestLayer::onAssignCCBMemberVariable(Ref * pTarget, const char * pMemberVariableName, Node * pNode) { CCB_MEMBERVARIABLEASSIGNER_GLUE(this, "mMenuItemStatusLabelBMFont", LabelBMFont *, this->mMenuItemStatusLabelBMFont); return false; } -void MenuTestLayer::onMenuItemAClicked(cocos2d::Object *pSender) { +void MenuTestLayer::onMenuItemAClicked(cocos2d::Ref *pSender) { this->mMenuItemStatusLabelBMFont->setString("Menu Item A clicked."); } -void MenuTestLayer::onMenuItemBClicked(cocos2d::Object *pSender) { +void MenuTestLayer::onMenuItemBClicked(cocos2d::Ref *pSender) { this->mMenuItemStatusLabelBMFont->setString("Menu Item B clicked."); } -void MenuTestLayer::onMenuItemCClicked(cocos2d::Object *pSender) { +void MenuTestLayer::onMenuItemCClicked(cocos2d::Ref *pSender) { this->mMenuItemStatusLabelBMFont->setString("Menu Item C clicked."); } \ No newline at end of file diff --git a/tests/test-cpp/Classes/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.h b/tests/test-cpp/Classes/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.h index 36c256cf94..eceb206568 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.h +++ b/tests/test-cpp/Classes/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.h @@ -16,13 +16,13 @@ class MenuTestLayer MenuTestLayer(); virtual ~MenuTestLayer(); - virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::Object * pTarget, const char * pSelectorName); - virtual cocos2d::extension::Control::Handler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, const char * pSelectorName); - virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName, cocos2d::Node * node); + virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::Ref * pTarget, const char * pSelectorName); + virtual cocos2d::extension::Control::Handler onResolveCCBCCControlSelector(cocos2d::Ref * pTarget, const char * pSelectorName); + virtual bool onAssignCCBMemberVariable(cocos2d::Ref * pTarget, const char * pMemberVariableName, cocos2d::Node * node); - void onMenuItemAClicked(cocos2d::Object * sender); - void onMenuItemBClicked(cocos2d::Object * sender); - void onMenuItemCClicked(cocos2d::Object * sender); + void onMenuItemAClicked(cocos2d::Ref * sender); + void onMenuItemBClicked(cocos2d::Ref * sender); + void onMenuItemCClicked(cocos2d::Ref * sender); private: cocos2d::LabelBMFont * mMenuItemStatusLabelBMFont; diff --git a/tests/test-cpp/Classes/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.cpp b/tests/test-cpp/Classes/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.cpp index e54a947bec..7bf26107ae 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.cpp +++ b/tests/test-cpp/Classes/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.cpp @@ -4,13 +4,13 @@ USING_NS_CC; USING_NS_CC_EXT; using namespace cocosbuilder; -SEL_MenuHandler TestHeaderLayer::onResolveCCBCCMenuItemSelector(Object * pTarget, const char * pSelectorName) { +SEL_MenuHandler TestHeaderLayer::onResolveCCBCCMenuItemSelector(Ref * pTarget, const char * pSelectorName) { CCB_SELECTORRESOLVER_CCMENUITEM_GLUE(this, "onBackClicked", TestHeaderLayer::onBackClicked); return NULL; } -Control::Handler TestHeaderLayer::onResolveCCBCCControlSelector(Object * pTarget, const char * pSelectorName) { +Control::Handler TestHeaderLayer::onResolveCCBCCControlSelector(Ref * pTarget, const char * pSelectorName) { return NULL; } @@ -20,6 +20,6 @@ void TestHeaderLayer::onNodeLoaded(cocos2d::Node * node, cocosbuilder::NodeLoade CCLOG("TestHeaderLayer::onNodeLoaded"); } -void TestHeaderLayer::onBackClicked(cocos2d::Object *pSender) { +void TestHeaderLayer::onBackClicked(cocos2d::Ref *pSender) { Director::getInstance()->popScene(); } \ No newline at end of file diff --git a/tests/test-cpp/Classes/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.h b/tests/test-cpp/Classes/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.h index 6adde2aeda..06792951dc 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.h +++ b/tests/test-cpp/Classes/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.h @@ -13,11 +13,11 @@ class TestHeaderLayer public: CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(TestHeaderLayer, create); - virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::Object * pTarget, const char * pSelectorName); - virtual cocos2d::extension::Control::Handler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, const char * pSelectorName); + virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::Ref * pTarget, const char * pSelectorName); + virtual cocos2d::extension::Control::Handler onResolveCCBCCControlSelector(cocos2d::Ref * pTarget, const char * pSelectorName); virtual void onNodeLoaded(cocos2d::Node * node, cocosbuilder::NodeLoader * nodeLoader); - void onBackClicked(cocos2d::Object * sender); + void onBackClicked(cocos2d::Ref * sender); }; #endif \ No newline at end of file diff --git a/tests/test-cpp/Classes/ExtensionsTest/CocosBuilderTest/TimelineCallbackTest/TimelineCallbackTestLayer.cpp b/tests/test-cpp/Classes/ExtensionsTest/CocosBuilderTest/TimelineCallbackTest/TimelineCallbackTestLayer.cpp index ba9dcbafe0..8667067870 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/CocosBuilderTest/TimelineCallbackTest/TimelineCallbackTestLayer.cpp +++ b/tests/test-cpp/Classes/ExtensionsTest/CocosBuilderTest/TimelineCallbackTest/TimelineCallbackTestLayer.cpp @@ -15,22 +15,22 @@ TimelineCallbackTestLayer::~TimelineCallbackTestLayer() CocosDenshion::SimpleAudioEngine::end(); } -SEL_MenuHandler TimelineCallbackTestLayer::onResolveCCBCCMenuItemSelector(Object * pTarget, const char * pSelectorName) { +SEL_MenuHandler TimelineCallbackTestLayer::onResolveCCBCCMenuItemSelector(Ref * pTarget, const char * pSelectorName) { return NULL; } -Control::Handler TimelineCallbackTestLayer::onResolveCCBCCControlSelector(Object * pTarget, const char * pSelectorName) { +Control::Handler TimelineCallbackTestLayer::onResolveCCBCCControlSelector(Ref * pTarget, const char * pSelectorName) { return NULL; } -SEL_CallFuncN TimelineCallbackTestLayer::onResolveCCBCCCallFuncSelector(Object * pTarget, const char* pSelectorName) +SEL_CallFuncN TimelineCallbackTestLayer::onResolveCCBCCCallFuncSelector(Ref * pTarget, const char* pSelectorName) { CCB_SELECTORRESOLVER_CALLFUNC_GLUE(this, "onCallback1", TimelineCallbackTestLayer::onCallback1); CCB_SELECTORRESOLVER_CALLFUNC_GLUE(this, "onCallback2", TimelineCallbackTestLayer::onCallback2); return NULL; } -bool TimelineCallbackTestLayer::onAssignCCBMemberVariable(Object * pTarget, const char * pMemberVariableName, Node * pNode) { +bool TimelineCallbackTestLayer::onAssignCCBMemberVariable(Ref * pTarget, const char * pMemberVariableName, Node * pNode) { CCB_MEMBERVARIABLEASSIGNER_GLUE(this, "helloLabel", LabelTTF *, this->_helloLabel); return false; diff --git a/tests/test-cpp/Classes/ExtensionsTest/CocosBuilderTest/TimelineCallbackTest/TimelineCallbackTestLayer.h b/tests/test-cpp/Classes/ExtensionsTest/CocosBuilderTest/TimelineCallbackTest/TimelineCallbackTestLayer.h index f3d47ca84c..73200bb9dc 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/CocosBuilderTest/TimelineCallbackTest/TimelineCallbackTestLayer.h +++ b/tests/test-cpp/Classes/ExtensionsTest/CocosBuilderTest/TimelineCallbackTest/TimelineCallbackTestLayer.h @@ -16,10 +16,10 @@ class TimelineCallbackTestLayer TimelineCallbackTestLayer(); virtual ~TimelineCallbackTestLayer(); - virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::Object * pTarget, const char * pSelectorName); - virtual cocos2d::extension::Control::Handler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, const char * pSelectorName); - virtual cocos2d::SEL_CallFuncN onResolveCCBCCCallFuncSelector(Object * pTarget, const char* pSelectorName); - virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName, cocos2d::Node * node); + virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::Ref * pTarget, const char * pSelectorName); + virtual cocos2d::extension::Control::Handler onResolveCCBCCControlSelector(cocos2d::Ref * pTarget, const char * pSelectorName); + virtual cocos2d::SEL_CallFuncN onResolveCCBCCCallFuncSelector(Ref * pTarget, const char* pSelectorName); + virtual bool onAssignCCBMemberVariable(cocos2d::Ref * pTarget, const char * pMemberVariableName, cocos2d::Node * node); void onCallback1(Node* sender); void onCallback2(Node* sender); diff --git a/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp b/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp index bb39259ab1..00cc48fa9e 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp +++ b/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp @@ -176,47 +176,47 @@ bool ControlButtonTest_Event::init() return false; } -void ControlButtonTest_Event::touchBitmaskAction(Object *senderz, Control::EventType controlEvent) +void ControlButtonTest_Event::touchBitmaskAction(Ref *senderz, Control::EventType controlEvent) { _displayBitmaskLabel->setString(String::createWithFormat("using bitmask (%d)", controlEvent)->getCString()); } -void ControlButtonTest_Event::touchDownAction(Object *senderz, Control::EventType controlEvent) +void ControlButtonTest_Event::touchDownAction(Ref *senderz, Control::EventType controlEvent) { _displayValueLabel->setString(String::createWithFormat("Touch Down")->getCString()); } -void ControlButtonTest_Event::touchDragInsideAction(Object *sender, Control::EventType controlEvent) +void ControlButtonTest_Event::touchDragInsideAction(Ref *sender, Control::EventType controlEvent) { _displayValueLabel->setString(String::createWithFormat("Drag Inside")->getCString()); } -void ControlButtonTest_Event::touchDragOutsideAction(Object *sender, Control::EventType controlEvent) +void ControlButtonTest_Event::touchDragOutsideAction(Ref *sender, Control::EventType controlEvent) { _displayValueLabel->setString(String::createWithFormat("Drag Outside")->getCString()); } -void ControlButtonTest_Event::touchDragEnterAction(Object *sender, Control::EventType controlEvent) +void ControlButtonTest_Event::touchDragEnterAction(Ref *sender, Control::EventType controlEvent) { _displayValueLabel->setString(String::createWithFormat("Drag Enter")->getCString()); } -void ControlButtonTest_Event::touchDragExitAction(Object *sender, Control::EventType controlEvent) +void ControlButtonTest_Event::touchDragExitAction(Ref *sender, Control::EventType controlEvent) { _displayValueLabel->setString(String::createWithFormat("Drag Exit")->getCString()); } -void ControlButtonTest_Event::touchUpInsideAction(Object *sender, Control::EventType controlEvent) +void ControlButtonTest_Event::touchUpInsideAction(Ref *sender, Control::EventType controlEvent) { _displayValueLabel->setString(String::createWithFormat("Touch Up Inside.")->getCString()); } -void ControlButtonTest_Event::touchUpOutsideAction(Object *sender, Control::EventType controlEvent) +void ControlButtonTest_Event::touchUpOutsideAction(Ref *sender, Control::EventType controlEvent) { _displayValueLabel->setString(String::createWithFormat("Touch Up Outside.")->getCString()); } -void ControlButtonTest_Event::touchCancelAction(Object *sender, Control::EventType controlEvent) +void ControlButtonTest_Event::touchCancelAction(Ref *sender, Control::EventType controlEvent) { _displayValueLabel->setString(String::createWithFormat("Touch Cancel")->getCString()); } diff --git a/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.h b/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.h index 1efbf9c604..0a062a306d 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.h +++ b/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.h @@ -46,15 +46,15 @@ public: ControlButtonTest_Event(); ~ControlButtonTest_Event(); bool init(); - void touchDownAction(Object *sender, Control::EventType controlEvent); - void touchDragInsideAction(Object *sender, Control::EventType controlEvent); - void touchDragOutsideAction(Object *sender, Control::EventType controlEvent); - void touchDragEnterAction(Object *sender, Control::EventType controlEvent); - void touchDragExitAction(Object *sender, Control::EventType controlEvent); - void touchUpInsideAction(Object *sender, Control::EventType controlEvent); - void touchUpOutsideAction(Object *sender, Control::EventType controlEvent); - void touchCancelAction(Object *sender, Control::EventType controlEvent); - void touchBitmaskAction(Object *sender, Control::EventType controlEvent); + void touchDownAction(Ref *sender, Control::EventType controlEvent); + void touchDragInsideAction(Ref *sender, Control::EventType controlEvent); + void touchDragOutsideAction(Ref *sender, Control::EventType controlEvent); + void touchDragEnterAction(Ref *sender, Control::EventType controlEvent); + void touchDragExitAction(Ref *sender, Control::EventType controlEvent); + void touchUpInsideAction(Ref *sender, Control::EventType controlEvent); + void touchUpOutsideAction(Ref *sender, Control::EventType controlEvent); + void touchCancelAction(Ref *sender, Control::EventType controlEvent); + void touchBitmaskAction(Ref *sender, Control::EventType controlEvent); protected: CC_SYNTHESIZE_RETAIN(LabelTTF *, _displayValueLabel, DisplayValueLabel) CC_SYNTHESIZE_RETAIN(LabelTTF *, _displayBitmaskLabel, DisplayBitmaskLabel) diff --git a/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.cpp b/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.cpp index c0614bcff2..ffc05cad6c 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.cpp +++ b/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.cpp @@ -89,7 +89,7 @@ ControlColourPickerTest::~ControlColourPickerTest() CC_SAFE_RELEASE(_colorLabel); } -void ControlColourPickerTest::colourValueChanged(Object *sender, Control::EventType controlEvent) +void ControlColourPickerTest::colourValueChanged(Ref *sender, Control::EventType controlEvent) { ControlColourPicker* pPicker = (ControlColourPicker*)sender; _colorLabel->setString(String::createWithFormat("#%02X%02X%02X",pPicker->getColor().r, pPicker->getColor().g, pPicker->getColor().b)->getCString()); diff --git a/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.h b/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.h index 7c5c6839a4..39cc3d2095 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.h +++ b/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.h @@ -35,7 +35,7 @@ public: virtual ~ControlColourPickerTest(); bool init(); /** Callback for the change value. */ - void colourValueChanged(Object *sender, Control::EventType controlEvent); + void colourValueChanged(Ref *sender, Control::EventType controlEvent); CC_SYNTHESIZE_RETAIN(LabelTTF*, _colorLabel, ColorLabel) diff --git a/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlPotentiometerTest/CCControlPotentiometerTest.cpp b/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlPotentiometerTest/CCControlPotentiometerTest.cpp index 709dc6a81a..0e7f79dc2e 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlPotentiometerTest/CCControlPotentiometerTest.cpp +++ b/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlPotentiometerTest/CCControlPotentiometerTest.cpp @@ -84,7 +84,7 @@ bool ControlPotentiometerTest::init() return false; } -void ControlPotentiometerTest::valueChanged(Object *sender, Control::EventType controlEvent) +void ControlPotentiometerTest::valueChanged(Ref *sender, Control::EventType controlEvent) { ControlPotentiometer* pControl = (ControlPotentiometer*)sender; // Change value of label. diff --git a/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlPotentiometerTest/CCControlPotentiometerTest.h b/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlPotentiometerTest/CCControlPotentiometerTest.h index 177b3d2a31..219c9e1df1 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlPotentiometerTest/CCControlPotentiometerTest.h +++ b/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlPotentiometerTest/CCControlPotentiometerTest.h @@ -35,7 +35,7 @@ public: bool init(); CC_SYNTHESIZE_RETAIN(LabelTTF*, _displayValueLabel, DisplayValueLabel) - void valueChanged(Object *sender, Control::EventType controlEvent); + void valueChanged(Ref *sender, Control::EventType controlEvent); CONTROL_SCENE_CREATE_FUNC(ControlPotentiometerTest) }; diff --git a/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlScene.cpp b/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlScene.cpp index bb7e82f159..e5a009388a 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlScene.cpp +++ b/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlScene.cpp @@ -82,24 +82,24 @@ bool ControlScene::init() return false; } -void ControlScene::toExtensionsMainLayer(Object* sender) +void ControlScene::toExtensionsMainLayer(Ref* sender) { auto scene = new ExtensionsTestScene(); scene->runThisTest(); scene->release(); } -void ControlScene::previousCallback(Object* sender) +void ControlScene::previousCallback(Ref* sender) { Director::getInstance()->replaceScene(ControlSceneManager::sharedControlSceneManager()->previousControlScene()); } -void ControlScene::restartCallback(Object* sender) +void ControlScene::restartCallback(Ref* sender) { Director::getInstance()->replaceScene(ControlSceneManager::sharedControlSceneManager()->currentControlScene()); } -void ControlScene::nextCallback(Object* sender) +void ControlScene::nextCallback(Ref* sender) { Director::getInstance()->replaceScene(ControlSceneManager::sharedControlSceneManager()->nextControlScene()); } diff --git a/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlScene.h b/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlScene.h index 3ca532d095..f3f261c866 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlScene.h +++ b/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlScene.h @@ -60,10 +60,10 @@ public: ~ControlScene(); bool init(); // Menu Callbacks - void toExtensionsMainLayer(Object* sender); - void previousCallback(Object* sender); - void restartCallback(Object* sender); - void nextCallback(Object* sender); + void toExtensionsMainLayer(Ref* sender); + void previousCallback(Ref* sender); + void restartCallback(Ref* sender); + void nextCallback(Ref* sender); /** Title label of the scene. */ CC_SYNTHESIZE_RETAIN(LabelTTF*, _sceneTitleLabel, SceneTitleLabel) diff --git a/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSceneManager.h b/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSceneManager.h index 3eb912624a..0f84376faa 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSceneManager.h +++ b/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSceneManager.h @@ -30,7 +30,7 @@ USING_NS_CC; -class ControlSceneManager : public cocos2d::Object +class ControlSceneManager : public cocos2d::Ref { public: ControlSceneManager(); diff --git a/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp b/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp index 67312e3084..15986bea2c 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp +++ b/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp @@ -80,7 +80,7 @@ bool ControlSliderTest::init() return false; } -void ControlSliderTest::valueChanged(Object *sender, Control::EventType controlEvent) +void ControlSliderTest::valueChanged(Ref *sender, Control::EventType controlEvent) { ControlSlider* pSlider = (ControlSlider*)sender; // Change value of label. diff --git a/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.h b/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.h index 7aa6650658..bcbdc2eee8 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.h +++ b/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.h @@ -31,7 +31,7 @@ public: ControlSliderTest(); virtual ~ControlSliderTest(); bool init(); - void valueChanged(Object *sender, Control::EventType controlEvent); + void valueChanged(Ref *sender, Control::EventType controlEvent); protected: LabelTTF* _displayValueLabel; CONTROL_SCENE_CREATE_FUNC(ControlSliderTest) diff --git a/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlStepperTest/CCControlStepperTest.cpp b/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlStepperTest/CCControlStepperTest.cpp index d0f2e25662..a954a73c36 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlStepperTest/CCControlStepperTest.cpp +++ b/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlStepperTest/CCControlStepperTest.cpp @@ -87,7 +87,7 @@ ControlStepper *ControlStepperTest::makeControlStepper() return ControlStepper::create(minusSprite, plusSprite); } -void ControlStepperTest::valueChanged(Object *sender, Control::EventType controlEvent) +void ControlStepperTest::valueChanged(Ref *sender, Control::EventType controlEvent) { ControlStepper* pControl = (ControlStepper*)sender; // Change value of label. diff --git a/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlStepperTest/CCControlStepperTest.h b/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlStepperTest/CCControlStepperTest.h index 1442f335e7..05a9f6d77e 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlStepperTest/CCControlStepperTest.h +++ b/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlStepperTest/CCControlStepperTest.h @@ -38,7 +38,7 @@ public: ControlStepper* makeControlStepper(); /** Callback for the change value. */ - void valueChanged(Object *sender, Control::EventType controlEvent); + void valueChanged(Ref *sender, Control::EventType controlEvent); protected: CC_SYNTHESIZE_RETAIN(LabelTTF*, _displayValueLabel, DisplayValueLabel) CONTROL_SCENE_CREATE_FUNC(ControlStepperTest) diff --git a/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.cpp b/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.cpp index 8902e70aa0..dd724930e8 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.cpp +++ b/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.cpp @@ -83,7 +83,7 @@ bool ControlSwitchTest::init() return false; } -void ControlSwitchTest::valueChanged(Object* sender, Control::EventType controlEvent) +void ControlSwitchTest::valueChanged(Ref* sender, Control::EventType controlEvent) { ControlSwitch* pSwitch = (ControlSwitch*)sender; if (pSwitch->isOn()) diff --git a/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.h b/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.h index d6443b9fe1..183298df43 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.h +++ b/tests/test-cpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.h @@ -32,7 +32,7 @@ public: virtual ~ControlSwitchTest(); bool init(); /** Callback for the change value. */ - void valueChanged(Object* sender, Control::EventType controlEvent); + void valueChanged(Ref* sender, Control::EventType controlEvent); LabelTTF *_displayValueLabel; CONTROL_SCENE_CREATE_FUNC(ControlSwitchTest) }; diff --git a/tests/test-cpp/Classes/ExtensionsTest/EditBoxTest/EditBoxTest.cpp b/tests/test-cpp/Classes/ExtensionsTest/EditBoxTest/EditBoxTest.cpp index eb788bb2b2..0bf1506237 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/EditBoxTest/EditBoxTest.cpp +++ b/tests/test-cpp/Classes/ExtensionsTest/EditBoxTest/EditBoxTest.cpp @@ -86,7 +86,7 @@ EditBoxTest::~EditBoxTest() } -void EditBoxTest::toExtensionsMainLayer(cocos2d::Object *sender) +void EditBoxTest::toExtensionsMainLayer(cocos2d::Ref *sender) { auto scene = new ExtensionsTestScene(); scene->runThisTest(); diff --git a/tests/test-cpp/Classes/ExtensionsTest/EditBoxTest/EditBoxTest.h b/tests/test-cpp/Classes/ExtensionsTest/EditBoxTest/EditBoxTest.h index 640e359775..6e35298159 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/EditBoxTest/EditBoxTest.h +++ b/tests/test-cpp/Classes/ExtensionsTest/EditBoxTest/EditBoxTest.h @@ -17,7 +17,7 @@ class EditBoxTest : public cocos2d::Layer, public cocos2d::extension::EditBoxDel public: EditBoxTest(); virtual ~EditBoxTest(); - void toExtensionsMainLayer(cocos2d::Object *sender); + void toExtensionsMainLayer(cocos2d::Ref *sender); virtual void editBoxEditingDidBegin(cocos2d::extension::EditBox* editBox); virtual void editBoxEditingDidEnd(cocos2d::extension::EditBox* editBox); diff --git a/tests/test-cpp/Classes/ExtensionsTest/ExtensionsTest.cpp b/tests/test-cpp/Classes/ExtensionsTest/ExtensionsTest.cpp index 393f64ff47..4d67b8ab08 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/ExtensionsTest.cpp +++ b/tests/test-cpp/Classes/ExtensionsTest/ExtensionsTest.cpp @@ -32,11 +32,11 @@ enum static struct { const char *name; - std::function callback; + std::function callback; } g_extensionsTests[] = { - { "NotificationCenterTest", [](Object* sender) { runNotificationCenterTest(); } + { "NotificationCenterTest", [](Ref* sender) { runNotificationCenterTest(); } }, - { "Scale9SpriteTest", [](Object* sender) { + { "Scale9SpriteTest", [](Ref* sender) { auto scene = new S9SpriteTestScene(); if (scene) { @@ -45,12 +45,12 @@ static struct { } } }, - { "CCControlButtonTest", [](Object *sender){ + { "CCControlButtonTest", [](Ref *sender){ ControlSceneManager* pManager = ControlSceneManager::sharedControlSceneManager(); auto scene = pManager->currentControlScene(); Director::getInstance()->replaceScene(scene); }}, - { "CocosBuilderTest", [](Object *sender) { + { "CocosBuilderTest", [](Ref *sender) { auto scene = new CocosBuilderTestScene(); if (scene) { @@ -59,34 +59,34 @@ static struct { } }}, #if (CC_TARGET_PLATFORM != CC_PLATFORM_EMSCRIPTEN) && (CC_TARGET_PLATFORM != CC_PLATFORM_NACL) - { "HttpClientTest", [](Object *sender){ runHttpClientTest();} + { "HttpClientTest", [](Ref *sender){ runHttpClientTest();} }, #endif #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) - { "WebSocketTest", [](Object *sender){ runWebSocketTest();} + { "WebSocketTest", [](Ref *sender){ runWebSocketTest();} }, - { "SocketIOTest", [](Object *sender){ runSocketIOTest();} + { "SocketIOTest", [](Ref *sender){ runSocketIOTest();} }, #endif #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_TIZEN) - { "EditBoxTest", [](Object *sender){ runEditBoxTest();} + { "EditBoxTest", [](Ref *sender){ runEditBoxTest();} }, #endif - { "TableViewTest", [](Object *sender){ runTableViewTest();} + { "TableViewTest", [](Ref *sender){ runTableViewTest();} }, - { "CocoStudioArmatureTest", [](Object *sender) { ArmatureTestScene *scene = new ArmatureTestScene(); + { "CocoStudioArmatureTest", [](Ref *sender) { ArmatureTestScene *scene = new ArmatureTestScene(); scene->runThisTest(); scene->release(); } }, - { "CocoStudioComponentsTest", [](Object *sender) { runComponentsTestLayerTest(); } + { "CocoStudioComponentsTest", [](Ref *sender) { runComponentsTestLayerTest(); } }, - { "CocoStudioSceneTest", [](Object *sender) { SceneEditorTestScene *scene = new SceneEditorTestScene(); + { "CocoStudioSceneTest", [](Ref *sender) { SceneEditorTestScene *scene = new SceneEditorTestScene(); scene->runThisTest(); scene->release(); } }, - { "CocoStudioGUITest", [](Object *sender) + { "CocoStudioGUITest", [](Ref *sender) { CocosGUITestScene* pScene = new CocosGUITestScene(); pScene->runThisTest(); diff --git a/tests/test-cpp/Classes/ExtensionsTest/NetworkTest/HttpClientTest.cpp b/tests/test-cpp/Classes/ExtensionsTest/NetworkTest/HttpClientTest.cpp index 22658d5fb0..f9717f508b 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/NetworkTest/HttpClientTest.cpp +++ b/tests/test-cpp/Classes/ExtensionsTest/NetworkTest/HttpClientTest.cpp @@ -70,7 +70,7 @@ HttpClientTest::~HttpClientTest() HttpClient::destroyInstance(); } -void HttpClientTest::onMenuGetTestClicked(cocos2d::Object *sender) +void HttpClientTest::onMenuGetTestClicked(cocos2d::Ref *sender) { // test 1 { @@ -115,7 +115,7 @@ void HttpClientTest::onMenuGetTestClicked(cocos2d::Object *sender) } -void HttpClientTest::onMenuPostTestClicked(cocos2d::Object *sender) +void HttpClientTest::onMenuPostTestClicked(cocos2d::Ref *sender) { // test 1 { @@ -156,7 +156,7 @@ void HttpClientTest::onMenuPostTestClicked(cocos2d::Object *sender) _labelStatusCode->setString("waiting..."); } -void HttpClientTest::onMenuPostBinaryTestClicked(cocos2d::Object *sender) +void HttpClientTest::onMenuPostBinaryTestClicked(cocos2d::Ref *sender) { HttpRequest* request = new HttpRequest(); request->setUrl("http://httpbin.org/post"); @@ -177,7 +177,7 @@ void HttpClientTest::onMenuPostBinaryTestClicked(cocos2d::Object *sender) -void HttpClientTest::onMenuPutTestClicked(Object *sender) +void HttpClientTest::onMenuPutTestClicked(Ref *sender) { // test 1 { @@ -218,7 +218,7 @@ void HttpClientTest::onMenuPutTestClicked(Object *sender) _labelStatusCode->setString("waiting..."); } -void HttpClientTest::onMenuDeleteTestClicked(Object *sender) +void HttpClientTest::onMenuDeleteTestClicked(Ref *sender) { // test 1 { @@ -282,7 +282,7 @@ void HttpClientTest::onHttpRequestCompleted(HttpClient *sender, HttpResponse *re printf("\n"); } -void HttpClientTest::toExtensionsMainLayer(cocos2d::Object *sender) +void HttpClientTest::toExtensionsMainLayer(cocos2d::Ref *sender) { auto scene = new ExtensionsTestScene(); scene->runThisTest(); diff --git a/tests/test-cpp/Classes/ExtensionsTest/NetworkTest/HttpClientTest.h b/tests/test-cpp/Classes/ExtensionsTest/NetworkTest/HttpClientTest.h index 774793e660..237ee35f92 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/NetworkTest/HttpClientTest.h +++ b/tests/test-cpp/Classes/ExtensionsTest/NetworkTest/HttpClientTest.h @@ -10,14 +10,14 @@ class HttpClientTest : public cocos2d::Layer public: HttpClientTest(); virtual ~HttpClientTest(); - void toExtensionsMainLayer(cocos2d::Object *sender); + void toExtensionsMainLayer(cocos2d::Ref *sender); //Menu Callbacks - void onMenuGetTestClicked(cocos2d::Object *sender); - void onMenuPostTestClicked(cocos2d::Object *sender); - void onMenuPostBinaryTestClicked(cocos2d::Object *sender); - void onMenuPutTestClicked(cocos2d::Object *sender); - void onMenuDeleteTestClicked(cocos2d::Object *sender); + void onMenuGetTestClicked(cocos2d::Ref *sender); + void onMenuPostTestClicked(cocos2d::Ref *sender); + void onMenuPostBinaryTestClicked(cocos2d::Ref *sender); + void onMenuPutTestClicked(cocos2d::Ref *sender); + void onMenuDeleteTestClicked(cocos2d::Ref *sender); //Http Response Callback void onHttpRequestCompleted(cocos2d::network::HttpClient *sender, cocos2d::network::HttpResponse *response); diff --git a/tests/test-cpp/Classes/ExtensionsTest/NetworkTest/SocketIOTest.cpp b/tests/test-cpp/Classes/ExtensionsTest/NetworkTest/SocketIOTest.cpp index 3f40ff4b5d..54b46a2c6d 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/NetworkTest/SocketIOTest.cpp +++ b/tests/test-cpp/Classes/ExtensionsTest/NetworkTest/SocketIOTest.cpp @@ -124,7 +124,7 @@ void SocketIOTestLayer::echotest(SIOClient *client, const std::string& data) { } -void SocketIOTestLayer::toExtensionsMainLayer(cocos2d::Object *sender) +void SocketIOTestLayer::toExtensionsMainLayer(cocos2d::Ref *sender) { ExtensionsTestScene *scene = new ExtensionsTestScene(); scene->runThisTest(); @@ -135,7 +135,7 @@ void SocketIOTestLayer::toExtensionsMainLayer(cocos2d::Object *sender) } -void SocketIOTestLayer::onMenuSIOClientClicked(cocos2d::Object *sender) +void SocketIOTestLayer::onMenuSIOClientClicked(cocos2d::Ref *sender) { //create a client by using this static method, url does not need to contain the protocol _sioClient = SocketIO::connect(*this, "ws://channon.us:3000"); @@ -148,7 +148,7 @@ void SocketIOTestLayer::onMenuSIOClientClicked(cocos2d::Object *sender) } -void SocketIOTestLayer::onMenuSIOEndpointClicked(cocos2d::Object *sender) +void SocketIOTestLayer::onMenuSIOEndpointClicked(cocos2d::Ref *sender) { //repeat the same connection steps for the namespace "testpoint" _sioEndpoint = SocketIO::connect(*this, "ws://channon.us:3000/testpoint"); @@ -161,7 +161,7 @@ void SocketIOTestLayer::onMenuSIOEndpointClicked(cocos2d::Object *sender) } -void SocketIOTestLayer::onMenuTestMessageClicked(cocos2d::Object *sender) +void SocketIOTestLayer::onMenuTestMessageClicked(cocos2d::Ref *sender) { //check that the socket is != NULL before sending or emitting events //the client should be NULL either before initialization and connection or after disconnect @@ -169,14 +169,14 @@ void SocketIOTestLayer::onMenuTestMessageClicked(cocos2d::Object *sender) } -void SocketIOTestLayer::onMenuTestMessageEndpointClicked(cocos2d::Object *sender) +void SocketIOTestLayer::onMenuTestMessageEndpointClicked(cocos2d::Ref *sender) { if(_sioEndpoint != NULL) _sioEndpoint->send("Hello Socket.IO!"); } -void SocketIOTestLayer::onMenuTestEventClicked(cocos2d::Object *sender) +void SocketIOTestLayer::onMenuTestEventClicked(cocos2d::Ref *sender) { //check that the socket is != NULL before sending or emitting events //the client should be NULL either before initialization and connection or after disconnect @@ -184,21 +184,21 @@ void SocketIOTestLayer::onMenuTestEventClicked(cocos2d::Object *sender) } -void SocketIOTestLayer::onMenuTestEventEndpointClicked(cocos2d::Object *sender) +void SocketIOTestLayer::onMenuTestEventEndpointClicked(cocos2d::Ref *sender) { if(_sioEndpoint != NULL) _sioEndpoint->emit("echotest","[{\"name\":\"myname\",\"type\":\"mytype\"}]"); } -void SocketIOTestLayer::onMenuTestClientDisconnectClicked(cocos2d::Object *sender) +void SocketIOTestLayer::onMenuTestClientDisconnectClicked(cocos2d::Ref *sender) { if(_sioClient != NULL) _sioClient->disconnect(); } -void SocketIOTestLayer::onMenuTestEndpointDisconnectClicked(cocos2d::Object *sender) +void SocketIOTestLayer::onMenuTestEndpointDisconnectClicked(cocos2d::Ref *sender) { if(_sioEndpoint != NULL) _sioEndpoint->disconnect(); diff --git a/tests/test-cpp/Classes/ExtensionsTest/NetworkTest/SocketIOTest.h b/tests/test-cpp/Classes/ExtensionsTest/NetworkTest/SocketIOTest.h index ee4f4540d5..f1e59073e3 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/NetworkTest/SocketIOTest.h +++ b/tests/test-cpp/Classes/ExtensionsTest/NetworkTest/SocketIOTest.h @@ -25,17 +25,17 @@ public: virtual void onClose(cocos2d::network::SIOClient* client); virtual void onError(cocos2d::network::SIOClient* client, const std::string& data); - void toExtensionsMainLayer(cocos2d::Object *sender); + void toExtensionsMainLayer(cocos2d::Ref *sender); - void onMenuSIOClientClicked(cocos2d::Object *sender); - void onMenuTestMessageClicked(cocos2d::Object *sender); - void onMenuTestEventClicked(cocos2d::Object *sender); - void onMenuTestClientDisconnectClicked(cocos2d::Object *sender); + void onMenuSIOClientClicked(cocos2d::Ref *sender); + void onMenuTestMessageClicked(cocos2d::Ref *sender); + void onMenuTestEventClicked(cocos2d::Ref *sender); + void onMenuTestClientDisconnectClicked(cocos2d::Ref *sender); - void onMenuSIOEndpointClicked(cocos2d::Object *sender); - void onMenuTestMessageEndpointClicked(cocos2d::Object *sender); - void onMenuTestEventEndpointClicked(cocos2d::Object *sender); - void onMenuTestEndpointDisconnectClicked(cocos2d::Object *sender); + void onMenuSIOEndpointClicked(cocos2d::Ref *sender); + void onMenuTestMessageEndpointClicked(cocos2d::Ref *sender); + void onMenuTestEventEndpointClicked(cocos2d::Ref *sender); + void onMenuTestEndpointDisconnectClicked(cocos2d::Ref *sender); void testevent(cocos2d::network::SIOClient *client, const std::string& data); diff --git a/tests/test-cpp/Classes/ExtensionsTest/NetworkTest/WebSocketTest.cpp b/tests/test-cpp/Classes/ExtensionsTest/NetworkTest/WebSocketTest.cpp index d04259101b..1679bd76ce 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/NetworkTest/WebSocketTest.cpp +++ b/tests/test-cpp/Classes/ExtensionsTest/NetworkTest/WebSocketTest.cpp @@ -191,7 +191,7 @@ void WebSocketTestLayer::onError(network::WebSocket* ws, const network::WebSocke } } -void WebSocketTestLayer::toExtensionsMainLayer(cocos2d::Object *sender) +void WebSocketTestLayer::toExtensionsMainLayer(cocos2d::Ref *sender) { auto scene = new ExtensionsTestScene(); scene->runThisTest(); @@ -199,7 +199,7 @@ void WebSocketTestLayer::toExtensionsMainLayer(cocos2d::Object *sender) } // Menu Callbacks -void WebSocketTestLayer::onMenuSendTextClicked(cocos2d::Object *sender) +void WebSocketTestLayer::onMenuSendTextClicked(cocos2d::Ref *sender) { if (_wsiSendText->getReadyState() == network::WebSocket::State::OPEN) { @@ -214,7 +214,7 @@ void WebSocketTestLayer::onMenuSendTextClicked(cocos2d::Object *sender) } } -void WebSocketTestLayer::onMenuSendBinaryClicked(cocos2d::Object *sender) +void WebSocketTestLayer::onMenuSendBinaryClicked(cocos2d::Ref *sender) { if (_wsiSendBinary->getReadyState() == network::WebSocket::State::OPEN) { diff --git a/tests/test-cpp/Classes/ExtensionsTest/NetworkTest/WebSocketTest.h b/tests/test-cpp/Classes/ExtensionsTest/NetworkTest/WebSocketTest.h index ce1529eef0..8b937ad1e6 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/NetworkTest/WebSocketTest.h +++ b/tests/test-cpp/Classes/ExtensionsTest/NetworkTest/WebSocketTest.h @@ -26,11 +26,11 @@ public: virtual void onClose(cocos2d::network::WebSocket* ws); virtual void onError(cocos2d::network::WebSocket* ws, const cocos2d::network::WebSocket::ErrorCode& error); - void toExtensionsMainLayer(cocos2d::Object *sender); + void toExtensionsMainLayer(cocos2d::Ref *sender); // Menu Callbacks - void onMenuSendTextClicked(cocos2d::Object *sender); - void onMenuSendBinaryClicked(cocos2d::Object *sender); + void onMenuSendTextClicked(cocos2d::Ref *sender); + void onMenuSendBinaryClicked(cocos2d::Ref *sender); private: cocos2d::network::WebSocket* _wsiSendText; diff --git a/tests/test-cpp/Classes/ExtensionsTest/NotificationCenterTest/NotificationCenterTest.cpp b/tests/test-cpp/Classes/ExtensionsTest/NotificationCenterTest/NotificationCenterTest.cpp index f847090b47..94c94ce8a8 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/NotificationCenterTest/NotificationCenterTest.cpp +++ b/tests/test-cpp/Classes/ExtensionsTest/NotificationCenterTest/NotificationCenterTest.cpp @@ -18,7 +18,7 @@ public: static Light* lightWithFile(const char* name); void setIsConnectToSwitch(bool bConnectToSwitch); - void switchStateChanged(Object* obj); + void switchStateChanged(Ref* obj); void updateLightState(); private: @@ -59,7 +59,7 @@ void Light::setIsConnectToSwitch(bool bConnectToSwitch) updateLightState(); } -void Light::switchStateChanged(Object* obj) +void Light::switchStateChanged(Ref* obj) { s_bSwitchOn = obj == 0x00 ? false : true; updateLightState(); @@ -126,7 +126,7 @@ NotificationCenterTest::NotificationCenterTest() light->setIsConnectToSwitch(bConnected); } - NotificationCenter::getInstance()->postNotification(MSG_SWITCH_STATE, (Object*)(intptr_t)item->getSelectedIndex()); + NotificationCenter::getInstance()->postNotification(MSG_SWITCH_STATE, (Ref*)(intptr_t)item->getSelectedIndex()); /* for testing removeAllObservers */ NotificationCenter::getInstance()->addObserver(this, callfuncO_selector(NotificationCenterTest::doNothing), "random-observer1", NULL); @@ -134,7 +134,7 @@ NotificationCenterTest::NotificationCenterTest() NotificationCenter::getInstance()->addObserver(this, callfuncO_selector(NotificationCenterTest::doNothing), "random-observer3", NULL); } -void NotificationCenterTest::toExtensionsMainLayer(cocos2d::Object* sender) +void NotificationCenterTest::toExtensionsMainLayer(cocos2d::Ref* sender) { /* for testing removeAllObservers */ int CC_UNUSED numObserversRemoved = NotificationCenter::getInstance()->removeAllObservers(this); @@ -145,14 +145,14 @@ void NotificationCenterTest::toExtensionsMainLayer(cocos2d::Object* sender) scene->release(); } -void NotificationCenterTest::toggleSwitch(Object *sender) +void NotificationCenterTest::toggleSwitch(Ref *sender) { auto item = (MenuItemToggle*)sender; int index = item->getSelectedIndex(); - NotificationCenter::getInstance()->postNotification(MSG_SWITCH_STATE, (Object*)(intptr_t)index); + NotificationCenter::getInstance()->postNotification(MSG_SWITCH_STATE, (Ref*)(intptr_t)index); } -void NotificationCenterTest::connectToSwitch(Object *sender) +void NotificationCenterTest::connectToSwitch(Ref *sender) { auto item = (MenuItemToggle*)sender; bool bConnected = item->getSelectedIndex() == 0 ? false : true; @@ -160,7 +160,7 @@ void NotificationCenterTest::connectToSwitch(Object *sender) pLight->setIsConnectToSwitch(bConnected); } -void NotificationCenterTest::doNothing(cocos2d::Object *sender) +void NotificationCenterTest::doNothing(cocos2d::Ref *sender) { } diff --git a/tests/test-cpp/Classes/ExtensionsTest/NotificationCenterTest/NotificationCenterTest.h b/tests/test-cpp/Classes/ExtensionsTest/NotificationCenterTest/NotificationCenterTest.h index 55d6d002ca..2a7368abb5 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/NotificationCenterTest/NotificationCenterTest.h +++ b/tests/test-cpp/Classes/ExtensionsTest/NotificationCenterTest/NotificationCenterTest.h @@ -7,10 +7,10 @@ class NotificationCenterTest : public cocos2d::Layer { public: NotificationCenterTest(); - void toExtensionsMainLayer(cocos2d::Object* sender); - void toggleSwitch(cocos2d::Object *sender); - void connectToSwitch(cocos2d::Object *sender); - void doNothing(cocos2d::Object *sender); + void toExtensionsMainLayer(cocos2d::Ref* sender); + void toggleSwitch(cocos2d::Ref *sender); + void connectToSwitch(cocos2d::Ref *sender); + void doNothing(cocos2d::Ref *sender); private: bool _showImage; }; diff --git a/tests/test-cpp/Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.cpp b/tests/test-cpp/Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.cpp index ab8ddfc1ad..51e5c4d6b5 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.cpp +++ b/tests/test-cpp/Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.cpp @@ -99,7 +99,7 @@ void S9SpriteTestDemo::onEnter() CCLOG("sprite frames added to sprite frame cache..."); } -void S9SpriteTestDemo::restartCallback(Object* sender) +void S9SpriteTestDemo::restartCallback(Ref* sender) { auto s = new S9SpriteTestScene(); s->addChild( restartAction() ); @@ -107,7 +107,7 @@ void S9SpriteTestDemo::restartCallback(Object* sender) s->release(); } -void S9SpriteTestDemo::nextCallback(Object* sender) +void S9SpriteTestDemo::nextCallback(Ref* sender) { auto s = new S9SpriteTestScene(); s->addChild( nextAction() ); @@ -115,7 +115,7 @@ void S9SpriteTestDemo::nextCallback(Object* sender) s->release(); } -void S9SpriteTestDemo::backCallback(Object* sender) +void S9SpriteTestDemo::backCallback(Ref* sender) { auto s = new S9SpriteTestScene(); s->addChild( backAction() ); diff --git a/tests/test-cpp/Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.h b/tests/test-cpp/Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.h index d2d73f9a53..38ba427149 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.h +++ b/tests/test-cpp/Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.h @@ -40,9 +40,9 @@ class S9SpriteTestDemo : public BaseTest public: virtual void onEnter(); - virtual void restartCallback(Object* sender); - virtual void nextCallback(Object* sender); - virtual void backCallback(Object* sender); + virtual void restartCallback(Ref* sender); + virtual void nextCallback(Ref* sender); + virtual void backCallback(Ref* sender); }; // S9BatchNodeBasic diff --git a/tests/test-cpp/Classes/ExtensionsTest/TableViewTest/TableViewTestScene.cpp b/tests/test-cpp/Classes/ExtensionsTest/TableViewTest/TableViewTestScene.cpp index 917225c14b..2b6e26b005 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/TableViewTest/TableViewTestScene.cpp +++ b/tests/test-cpp/Classes/ExtensionsTest/TableViewTest/TableViewTestScene.cpp @@ -48,7 +48,7 @@ bool TableViewTestLayer::init() return true; } -void TableViewTestLayer::toExtensionsMainLayer(cocos2d::Object *sender) +void TableViewTestLayer::toExtensionsMainLayer(cocos2d::Ref *sender) { ExtensionsTestScene *scene = new ExtensionsTestScene(); scene->runThisTest(); diff --git a/tests/test-cpp/Classes/ExtensionsTest/TableViewTest/TableViewTestScene.h b/tests/test-cpp/Classes/ExtensionsTest/TableViewTest/TableViewTestScene.h index fb406ef91d..134c276928 100644 --- a/tests/test-cpp/Classes/ExtensionsTest/TableViewTest/TableViewTestScene.h +++ b/tests/test-cpp/Classes/ExtensionsTest/TableViewTest/TableViewTestScene.h @@ -11,7 +11,7 @@ class TableViewTestLayer : public cocos2d::Layer, public cocos2d::extension::Tab public: virtual bool init(); - void toExtensionsMainLayer(cocos2d::Object *sender); + void toExtensionsMainLayer(cocos2d::Ref *sender); CREATE_FUNC(TableViewTestLayer); diff --git a/tests/test-cpp/Classes/FileUtilsTest/FileUtilsTest.cpp b/tests/test-cpp/Classes/FileUtilsTest/FileUtilsTest.cpp index cb28f2fd06..c947f25983 100644 --- a/tests/test-cpp/Classes/FileUtilsTest/FileUtilsTest.cpp +++ b/tests/test-cpp/Classes/FileUtilsTest/FileUtilsTest.cpp @@ -52,7 +52,7 @@ void FileUtilsDemo::onEnter() BaseTest::onEnter(); } -void FileUtilsDemo::backCallback(Object* sender) +void FileUtilsDemo::backCallback(Ref* sender) { auto scene = new FileUtilsTestScene(); auto layer = backAction(); @@ -62,7 +62,7 @@ void FileUtilsDemo::backCallback(Object* sender) scene->release(); } -void FileUtilsDemo::nextCallback(Object* sender) +void FileUtilsDemo::nextCallback(Ref* sender) { auto scene = new FileUtilsTestScene(); auto layer = nextAction(); @@ -72,7 +72,7 @@ void FileUtilsDemo::nextCallback(Object* sender) scene->release(); } -void FileUtilsDemo::restartCallback(Object* sender) +void FileUtilsDemo::restartCallback(Ref* sender) { auto scene = new FileUtilsTestScene(); auto layer = restartAction(); diff --git a/tests/test-cpp/Classes/FileUtilsTest/FileUtilsTest.h b/tests/test-cpp/Classes/FileUtilsTest/FileUtilsTest.h index 40e99abb04..59a5fa4468 100644 --- a/tests/test-cpp/Classes/FileUtilsTest/FileUtilsTest.h +++ b/tests/test-cpp/Classes/FileUtilsTest/FileUtilsTest.h @@ -18,9 +18,9 @@ public: virtual void onEnter(); virtual std::string title() const override; virtual std::string subtitle() const override; - void backCallback(Object* sender); - void nextCallback(Object* sender); - void restartCallback(Object* sender); + void backCallback(Ref* sender); + void nextCallback(Ref* sender); + void restartCallback(Ref* sender); }; class TestResolutionDirectories : public FileUtilsDemo diff --git a/tests/test-cpp/Classes/FontTest/FontTest.cpp b/tests/test-cpp/Classes/FontTest/FontTest.cpp index 76293bf41b..e3a011d952 100644 --- a/tests/test-cpp/Classes/FontTest/FontTest.cpp +++ b/tests/test-cpp/Classes/FontTest/FontTest.cpp @@ -139,12 +139,12 @@ void FontTest::showFont(const char *pFont) this->addChild(top, 0, kTagLabel4); } -void FontTest::backCallback(Object* sender) +void FontTest::backCallback(Ref* sender) { showFont(backAction()); } -void FontTest::nextCallback(Object* sender) +void FontTest::nextCallback(Ref* sender) { showFont(nextAction()); } @@ -154,7 +154,7 @@ std::string FontTest::title() const return "Font test"; } -void FontTest::restartCallback(Object* sender) +void FontTest::restartCallback(Ref* sender) { showFont(restartAction()); } diff --git a/tests/test-cpp/Classes/FontTest/FontTest.h b/tests/test-cpp/Classes/FontTest/FontTest.h index 3e1cddd668..f970b273ba 100644 --- a/tests/test-cpp/Classes/FontTest/FontTest.h +++ b/tests/test-cpp/Classes/FontTest/FontTest.h @@ -17,9 +17,9 @@ public: FontTest(); void showFont(const char *pFont); - void restartCallback(Object* sender); - void nextCallback(Object* sender); - void backCallback(Object* sender); + void restartCallback(Ref* sender); + void nextCallback(Ref* sender); + void backCallback(Ref* sender); virtual std::string title() const override; CREATE_FUNC(FontTest); diff --git a/tests/test-cpp/Classes/IntervalTest/IntervalTest.cpp b/tests/test-cpp/Classes/IntervalTest/IntervalTest.cpp index 3771b1e2aa..6723c3a89d 100644 --- a/tests/test-cpp/Classes/IntervalTest/IntervalTest.cpp +++ b/tests/test-cpp/Classes/IntervalTest/IntervalTest.cpp @@ -57,7 +57,7 @@ IntervalLayer::IntervalLayer() addChild(sprite); sprite->runAction( RepeatForever::create(Sequence::create(jump, jump->reverse(), NULL) )); // pause button - auto item1 = MenuItemFont::create("Pause", [&](Object* sender) { + auto item1 = MenuItemFont::create("Pause", [&](Ref* sender) { if(Director::getInstance()->isPaused()) Director::getInstance()->resume(); else diff --git a/tests/test-cpp/Classes/LabelTest/LabelTest.cpp b/tests/test-cpp/Classes/LabelTest/LabelTest.cpp index 416d928ea5..1060ebbcb1 100644 --- a/tests/test-cpp/Classes/LabelTest/LabelTest.cpp +++ b/tests/test-cpp/Classes/LabelTest/LabelTest.cpp @@ -129,7 +129,7 @@ void AtlasDemo::onEnter() BaseTest::onEnter(); } -void AtlasDemo::restartCallback(Object* sender) +void AtlasDemo::restartCallback(Ref* sender) { auto s = new AtlasTestScene(); s->addChild(restartAtlasAction()); @@ -138,7 +138,7 @@ void AtlasDemo::restartCallback(Object* sender) s->release(); } -void AtlasDemo::nextCallback(Object* sender) +void AtlasDemo::nextCallback(Ref* sender) { auto s = new AtlasTestScene(); s->addChild( nextAtlasAction() ); @@ -146,7 +146,7 @@ void AtlasDemo::nextCallback(Object* sender) s->release(); } -void AtlasDemo::backCallback(Object* sender) +void AtlasDemo::backCallback(Ref* sender) { auto s = new AtlasTestScene(); s->addChild( backAtlasAction() ); @@ -1001,37 +1001,37 @@ void LabelTTFTest::updateAlignment() this->addChild(_plabel); } -void LabelTTFTest::setAlignmentLeft(Object* sender) +void LabelTTFTest::setAlignmentLeft(Ref* sender) { _horizAlign = TextHAlignment::LEFT; this->updateAlignment(); } -void LabelTTFTest::setAlignmentCenter(Object* sender) +void LabelTTFTest::setAlignmentCenter(Ref* sender) { _horizAlign = TextHAlignment::CENTER; this->updateAlignment(); } -void LabelTTFTest::setAlignmentRight(Object* sender) +void LabelTTFTest::setAlignmentRight(Ref* sender) { _horizAlign = TextHAlignment::RIGHT; this->updateAlignment(); } -void LabelTTFTest::setAlignmentTop(Object* sender) +void LabelTTFTest::setAlignmentTop(Ref* sender) { _vertAlign = TextVAlignment::TOP; this->updateAlignment(); } -void LabelTTFTest::setAlignmentMiddle(Object* sender) +void LabelTTFTest::setAlignmentMiddle(Ref* sender) { _vertAlign = TextVAlignment::CENTER; this->updateAlignment(); } -void LabelTTFTest::setAlignmentBottom(Object* sender) +void LabelTTFTest::setAlignmentBottom(Ref* sender) { _vertAlign = TextVAlignment::BOTTOM; this->updateAlignment(); @@ -1234,7 +1234,7 @@ std::string BitmapFontMultiLineAlignment::subtitle() const return ""; } -void BitmapFontMultiLineAlignment::stringChanged(cocos2d::Object *sender) +void BitmapFontMultiLineAlignment::stringChanged(cocos2d::Ref *sender) { auto item = (MenuItemFont*)sender; item->setColor(Color3B::RED); @@ -1260,7 +1260,7 @@ void BitmapFontMultiLineAlignment::stringChanged(cocos2d::Object *sender) this->snapArrowsToEdge(); } -void BitmapFontMultiLineAlignment::alignmentChanged(cocos2d::Object *sender) +void BitmapFontMultiLineAlignment::alignmentChanged(cocos2d::Ref *sender) { auto item = static_cast(sender); item->setColor(Color3B::RED); diff --git a/tests/test-cpp/Classes/LabelTest/LabelTest.h b/tests/test-cpp/Classes/LabelTest/LabelTest.h index dd892ee8d9..851570af9d 100644 --- a/tests/test-cpp/Classes/LabelTest/LabelTest.h +++ b/tests/test-cpp/Classes/LabelTest/LabelTest.h @@ -19,9 +19,9 @@ public: virtual std::string subtitle() const override; virtual void onEnter(); - void restartCallback(Object* sender); - void nextCallback(Object* sender); - void backCallback(Object* sender); + void restartCallback(Ref* sender); + void nextCallback(Ref* sender); + void backCallback(Ref* sender); }; @@ -226,12 +226,12 @@ public: virtual std::string title() const override; virtual std::string subtitle() const override; private: - void setAlignmentLeft(Object* sender); - void setAlignmentCenter(Object* sender); - void setAlignmentRight(Object* sender); - void setAlignmentTop(Object* sender); - void setAlignmentMiddle(Object* sender); - void setAlignmentBottom(Object* sender); + void setAlignmentLeft(Ref* sender); + void setAlignmentCenter(Ref* sender); + void setAlignmentRight(Ref* sender); + void setAlignmentTop(Ref* sender); + void setAlignmentMiddle(Ref* sender); + void setAlignmentBottom(Ref* sender); void updateAlignment(); const char* getCurrentAlignment(); private: @@ -278,8 +278,8 @@ public: void snapArrowsToEdge(); virtual std::string title() const override; virtual std::string subtitle() const override; - void stringChanged(Object *sender); - void alignmentChanged(Object *sender); + void stringChanged(Ref *sender); + void alignmentChanged(Ref *sender); void onTouchesBegan(const std::vector& touches, Event *event); void onTouchesEnded(const std::vector& touches, Event *event); void onTouchesMoved(const std::vector& touches, Event *event); diff --git a/tests/test-cpp/Classes/LabelTest/LabelTestNew.cpp b/tests/test-cpp/Classes/LabelTest/LabelTestNew.cpp index 768acb4d35..d4c4d589a5 100644 --- a/tests/test-cpp/Classes/LabelTest/LabelTestNew.cpp +++ b/tests/test-cpp/Classes/LabelTest/LabelTestNew.cpp @@ -135,7 +135,7 @@ void AtlasDemoNew::onEnter() BaseTest::onEnter(); } -void AtlasDemoNew::restartCallback(Object* sender) +void AtlasDemoNew::restartCallback(Ref* sender) { auto s = new AtlasTestSceneNew(); s->addChild(restartAtlasActionNew()); @@ -144,7 +144,7 @@ void AtlasDemoNew::restartCallback(Object* sender) s->release(); } -void AtlasDemoNew::nextCallback(Object* sender) +void AtlasDemoNew::nextCallback(Ref* sender) { auto s = new AtlasTestSceneNew(); s->addChild( nextAtlasActionNew() ); @@ -152,7 +152,7 @@ void AtlasDemoNew::nextCallback(Object* sender) s->release(); } -void AtlasDemoNew::backCallback(Object* sender) +void AtlasDemoNew::backCallback(Ref* sender) { auto s = new AtlasTestSceneNew(); s->addChild( backAtlasActionNew() ); @@ -762,7 +762,7 @@ std::string LabelFNTMultiLineAlignment::subtitle() const return ""; } -void LabelFNTMultiLineAlignment::stringChanged(cocos2d::Object *sender) +void LabelFNTMultiLineAlignment::stringChanged(cocos2d::Ref *sender) { auto item = (MenuItemFont*)sender; item->setColor(Color3B::RED); @@ -788,7 +788,7 @@ void LabelFNTMultiLineAlignment::stringChanged(cocos2d::Object *sender) this->snapArrowsToEdge(); } -void LabelFNTMultiLineAlignment::alignmentChanged(cocos2d::Object *sender) +void LabelFNTMultiLineAlignment::alignmentChanged(cocos2d::Ref *sender) { auto item = static_cast(sender); item->setColor(Color3B::RED); @@ -1068,19 +1068,19 @@ void LabelTTFDynamicAlignment::updateAlignment() } } -void LabelTTFDynamicAlignment::setAlignmentLeft(Object* sender) +void LabelTTFDynamicAlignment::setAlignmentLeft(Ref* sender) { _horizAlign = TextHAlignment::LEFT; this->updateAlignment(); } -void LabelTTFDynamicAlignment::setAlignmentCenter(Object* sender) +void LabelTTFDynamicAlignment::setAlignmentCenter(Ref* sender) { _horizAlign = TextHAlignment::CENTER; this->updateAlignment(); } -void LabelTTFDynamicAlignment::setAlignmentRight(Object* sender) +void LabelTTFDynamicAlignment::setAlignmentRight(Ref* sender) { _horizAlign = TextHAlignment::RIGHT; this->updateAlignment(); diff --git a/tests/test-cpp/Classes/LabelTest/LabelTestNew.h b/tests/test-cpp/Classes/LabelTest/LabelTestNew.h index 9abc6dac16..638d3b891b 100644 --- a/tests/test-cpp/Classes/LabelTest/LabelTestNew.h +++ b/tests/test-cpp/Classes/LabelTest/LabelTestNew.h @@ -20,9 +20,9 @@ public: virtual std::string subtitle() const override; virtual void onEnter(); - void restartCallback(Object* sender); - void nextCallback(Object* sender); - void backCallback(Object* sender); + void restartCallback(Ref* sender); + void nextCallback(Ref* sender); + void backCallback(Ref* sender); }; class LabelTTFAlignmentNew : public AtlasDemoNew @@ -190,8 +190,8 @@ public: void snapArrowsToEdge(); virtual std::string title() const override; virtual std::string subtitle() const override; - void stringChanged(Object *sender); - void alignmentChanged(Object *sender); + void stringChanged(Ref *sender); + void alignmentChanged(Ref *sender); void onTouchesBegan(const std::vector& touches, Event *event); void onTouchesEnded(const std::vector& touches, Event *event); void onTouchesMoved(const std::vector& touches, Event *event); @@ -276,9 +276,9 @@ public: private: - void setAlignmentLeft(Object* sender); - void setAlignmentCenter(Object* sender); - void setAlignmentRight(Object* sender); + void setAlignmentLeft(Ref* sender); + void setAlignmentCenter(Ref* sender); + void setAlignmentRight(Ref* sender); void updateAlignment(); Label * _label; diff --git a/tests/test-cpp/Classes/LayerTest/LayerTest.cpp b/tests/test-cpp/Classes/LayerTest/LayerTest.cpp index 0bbb8cc63a..8e8e2b327a 100644 --- a/tests/test-cpp/Classes/LayerTest/LayerTest.cpp +++ b/tests/test-cpp/Classes/LayerTest/LayerTest.cpp @@ -86,7 +86,7 @@ void LayerTest::onEnter() BaseTest::onEnter(); } -void LayerTest::restartCallback(Object* sender) +void LayerTest::restartCallback(Ref* sender) { auto s = new LayerTestScene(); s->addChild(restartAction()); @@ -95,7 +95,7 @@ void LayerTest::restartCallback(Object* sender) s->release(); } -void LayerTest::nextCallback(Object* sender) +void LayerTest::nextCallback(Ref* sender) { auto s = new LayerTestScene(); s->addChild( nextAction() ); @@ -103,7 +103,7 @@ void LayerTest::nextCallback(Object* sender) s->release(); } -void LayerTest::backCallback(Object* sender) +void LayerTest::backCallback(Ref* sender) { auto s = new LayerTestScene(); s->addChild( backAction() ); @@ -600,7 +600,7 @@ LayerGradientTest::LayerGradientTest() menu->setPosition(Point(s.width / 2, 100)); } -void LayerGradientTest::toggleItem(Object *sender) +void LayerGradientTest::toggleItem(Ref *sender) { auto gradient = static_cast( getChildByTag(kTagLayer) ); gradient->setCompressedInterpolation(! gradient->isCompressedInterpolation()); @@ -709,7 +709,7 @@ void LayerIgnoreAnchorPointPos::onEnter() menu->setPosition(Point(s.width/2, s.height/2)); } -void LayerIgnoreAnchorPointPos::onToggle(Object* pObject) +void LayerIgnoreAnchorPointPos::onToggle(Ref* pObject) { auto layer = this->getChildByTag(kLayerIgnoreAnchorPoint); bool ignore = layer->isIgnoreAnchorPointForPosition(); @@ -757,7 +757,7 @@ void LayerIgnoreAnchorPointRot::onEnter() menu->setPosition(Point(s.width/2, s.height/2)); } -void LayerIgnoreAnchorPointRot::onToggle(Object* pObject) +void LayerIgnoreAnchorPointRot::onToggle(Ref* pObject) { auto layer = this->getChildByTag(kLayerIgnoreAnchorPoint); bool ignore = layer->isIgnoreAnchorPointForPosition(); @@ -808,7 +808,7 @@ void LayerIgnoreAnchorPointScale::onEnter() menu->setPosition(Point(s.width/2, s.height/2)); } -void LayerIgnoreAnchorPointScale::onToggle(Object* pObject) +void LayerIgnoreAnchorPointScale::onToggle(Ref* pObject) { auto layer = this->getChildByTag(kLayerIgnoreAnchorPoint); bool ignore = layer->isIgnoreAnchorPointForPosition(); diff --git a/tests/test-cpp/Classes/LayerTest/LayerTest.h b/tests/test-cpp/Classes/LayerTest/LayerTest.h index 61b4f6fc2c..04cb598c3c 100644 --- a/tests/test-cpp/Classes/LayerTest/LayerTest.h +++ b/tests/test-cpp/Classes/LayerTest/LayerTest.h @@ -18,9 +18,9 @@ public: virtual std::string subtitle() const override; virtual void onEnter(); - void restartCallback(Object* sender); - void nextCallback(Object* sender); - void backCallback(Object* sender); + void restartCallback(Ref* sender); + void nextCallback(Ref* sender); + void backCallback(Ref* sender); }; class LayerTestCascadingOpacityA : public LayerTest @@ -114,7 +114,7 @@ public: void onTouchesMoved(const std::vector& touches, Event *event); virtual std::string title() const override; virtual std::string subtitle() const override; - void toggleItem(cocos2d::Object *sender); + void toggleItem(cocos2d::Ref *sender); }; class LayerGradientTest2 : public LayerTest @@ -140,7 +140,7 @@ class LayerIgnoreAnchorPointPos : public LayerTest public: CREATE_FUNC(LayerIgnoreAnchorPointPos); virtual void onEnter(); - void onToggle(Object* pObject); + void onToggle(Ref* pObject); virtual std::string title() const override; virtual std::string subtitle() const override; }; @@ -150,7 +150,7 @@ class LayerIgnoreAnchorPointRot : public LayerTest public: CREATE_FUNC(LayerIgnoreAnchorPointRot); virtual void onEnter(); - void onToggle(Object* pObject); + void onToggle(Ref* pObject); virtual std::string title() const override; virtual std::string subtitle() const override; }; @@ -160,7 +160,7 @@ class LayerIgnoreAnchorPointScale : public LayerTest public: CREATE_FUNC(LayerIgnoreAnchorPointScale); virtual void onEnter(); - void onToggle(Object* pObject); + void onToggle(Ref* pObject); virtual std::string title() const override; virtual std::string subtitle() const override; }; diff --git a/tests/test-cpp/Classes/MenuTest/MenuTest.cpp b/tests/test-cpp/Classes/MenuTest/MenuTest.cpp index f4da9b94c8..712935683b 100644 --- a/tests/test-cpp/Classes/MenuTest/MenuTest.cpp +++ b/tests/test-cpp/Classes/MenuTest/MenuTest.cpp @@ -76,7 +76,7 @@ MenuLayerMainMenu::MenuLayerMainMenu() item3->setColor( Color3B(200,200,255) ); // Font Item - auto item4 = MenuItemFont::create("I toggle enable items", [&](Object *sender) { + auto item4 = MenuItemFont::create("I toggle enable items", [&](Ref *sender) { _disabledItem->setEnabled(! _disabledItem->isEnabled() ); }); @@ -156,12 +156,12 @@ MenuLayerMainMenu::~MenuLayerMainMenu() _disabledItem->release(); } -void MenuLayerMainMenu::menuCallback(Object* sender) +void MenuLayerMainMenu::menuCallback(Ref* sender) { static_cast(_parent)->switchTo(1); } -void MenuLayerMainMenu::menuCallbackConfig(Object* sender) +void MenuLayerMainMenu::menuCallbackConfig(Ref* sender) { static_cast(_parent)->switchTo(3); } @@ -173,7 +173,7 @@ void MenuLayerMainMenu::allowTouches(float dt) log("TOUCHES ALLOWED AGAIN"); } -void MenuLayerMainMenu::menuCallbackDisabled(Object* sender) +void MenuLayerMainMenu::menuCallbackDisabled(Ref* sender) { // hijack all touch events for 5 seconds _eventDispatcher->setPriority(_touchListener, -1); @@ -181,23 +181,23 @@ void MenuLayerMainMenu::menuCallbackDisabled(Object* sender) log("TOUCHES DISABLED FOR 5 SECONDS"); } -void MenuLayerMainMenu::menuCallback2(Object* sender) +void MenuLayerMainMenu::menuCallback2(Ref* sender) { static_cast(_parent)->switchTo(2); } -void MenuLayerMainMenu::menuCallbackBugsTest(Object *pSender) +void MenuLayerMainMenu::menuCallbackBugsTest(Ref *pSender) { static_cast(_parent)->switchTo(4); } -void MenuLayerMainMenu::onQuit(Object* sender) +void MenuLayerMainMenu::onQuit(Ref* sender) { //[[Director sharedDirector] end]; //getCocosApp()->exit(); } -void MenuLayerMainMenu::menuMovingCallback(Object *pSender) +void MenuLayerMainMenu::menuMovingCallback(Ref *pSender) { static_cast(_parent)->switchTo(5); } @@ -286,12 +286,12 @@ void MenuLayer2::alignMenusV() } } -void MenuLayer2::menuCallback(Object* sender) +void MenuLayer2::menuCallback(Ref* sender) { static_cast(_parent)->switchTo(0); } -void MenuLayer2::menuCallbackOpacity(Object* sender) +void MenuLayer2::menuCallbackOpacity(Ref* sender) { auto menu = static_cast( static_cast(sender)->getParent() ); GLubyte opacity = menu->getOpacity(); @@ -301,7 +301,7 @@ void MenuLayer2::menuCallbackOpacity(Object* sender) menu->setOpacity(128); } -void MenuLayer2::menuCallbackAlign(Object* sender) +void MenuLayer2::menuCallbackAlign(Ref* sender) { _alignedH = ! _alignedH; @@ -322,12 +322,12 @@ MenuLayer3::MenuLayer3() MenuItemFont::setFontSize(28); auto label = LabelBMFont::create("Enable AtlasItem", "fonts/bitmapFontTest3.fnt"); - auto item1 = MenuItemLabel::create(label, [&](Object *sender) { + auto item1 = MenuItemLabel::create(label, [&](Ref *sender) { //CCLOG("Label clicked. Toogling AtlasSprite"); _disabledItem->setEnabled( ! _disabledItem->isEnabled() ); _disabledItem->stopAllActions(); }); - auto item2 = MenuItemFont::create("--- Go Back ---", [&](Object *sender) { + auto item2 = MenuItemFont::create("--- Go Back ---", [&](Ref *sender) { static_cast(_parent)->switchTo(0); }); @@ -336,7 +336,7 @@ MenuLayer3::MenuLayer3() auto spriteDisabled = Sprite::create(s_MenuItem, Rect(0,23*0,115,23)); - auto item3 = MenuItemSprite::create(spriteNormal, spriteSelected, spriteDisabled, [](Object *sender) { + auto item3 = MenuItemSprite::create(spriteNormal, spriteSelected, spriteDisabled, [](Ref *sender) { log("sprite clicked!"); }); _disabledItem = item3; item3->retain(); @@ -455,12 +455,12 @@ MenuLayer4::~MenuLayer4() { } -void MenuLayer4::menuCallback(Object* sender) +void MenuLayer4::menuCallback(Ref* sender) { //CCLOG("selected item: %x index:%d", dynamic_cast(sender)->selectedItem(), dynamic_cast(sender)->selectedIndex() ); } -void MenuLayer4::backCallback(Object* sender) +void MenuLayer4::backCallback(Ref* sender) { static_cast(_parent)->switchTo(0); } @@ -480,7 +480,7 @@ BugsTest::BugsTest() menu->setPosition(Point(s.width/2, s.height/2)); } -void BugsTest::issue1410MenuCallback(Object *sender) +void BugsTest::issue1410MenuCallback(Ref *sender) { auto menu = static_cast( static_cast(sender)->getParent() ); menu->setEnabled(false); @@ -489,7 +489,7 @@ void BugsTest::issue1410MenuCallback(Object *sender) log("NO CRASHES"); } -void BugsTest::issue1410v2MenuCallback(cocos2d::Object *pSender) +void BugsTest::issue1410v2MenuCallback(cocos2d::Ref *pSender) { auto menu = static_cast( static_cast(pSender)->getParent() ); menu->setEnabled(true); @@ -498,7 +498,7 @@ void BugsTest::issue1410v2MenuCallback(cocos2d::Object *pSender) log("NO CRASHES. AND MENU SHOULD STOP WORKING"); } -void BugsTest::backMenuCallback(cocos2d::Object *pSender) +void BugsTest::backMenuCallback(cocos2d::Ref *pSender) { static_cast(_parent)->switchTo(0); } @@ -533,7 +533,7 @@ RemoveMenuItemWhenMove::RemoveMenuItemWhenMove() } -void RemoveMenuItemWhenMove::goBack(Object *pSender) +void RemoveMenuItemWhenMove::goBack(Ref *pSender) { static_cast(_parent)->switchTo(0); } diff --git a/tests/test-cpp/Classes/MenuTest/MenuTest.h b/tests/test-cpp/Classes/MenuTest/MenuTest.h index 1910968546..c2dadd5f1c 100644 --- a/tests/test-cpp/Classes/MenuTest/MenuTest.h +++ b/tests/test-cpp/Classes/MenuTest/MenuTest.h @@ -46,14 +46,14 @@ public: void onTouchMoved(Touch *touch, Event * event); void allowTouches(float dt); - void menuCallback(Object* sender); - void menuCallbackConfig(Object* sender); - void menuCallbackDisabled(Object* sender); - void menuCallback2(Object* sender); - void menuCallbackPriorityTest(Object* sender); - void menuCallbackBugsTest(Object *pSender); - void onQuit(Object* sender); - void menuMovingCallback(Object *pSender); + void menuCallback(Ref* sender); + void menuCallbackConfig(Ref* sender); + void menuCallbackDisabled(Ref* sender); + void menuCallback2(Ref* sender); + void menuCallbackPriorityTest(Ref* sender); + void menuCallbackBugsTest(Ref *pSender); + void onQuit(Ref* sender); + void menuMovingCallback(Ref *pSender); //CREATE_NODE(MenuLayer1); }; @@ -72,9 +72,9 @@ public: ~MenuLayer2(); public: - void menuCallback(Object* sender); - void menuCallbackOpacity(Object* sender); - void menuCallbackAlign(Object* sender); + void menuCallback(Ref* sender); + void menuCallbackOpacity(Ref* sender); + void menuCallbackAlign(Ref* sender); //CREATE_NODE(MenuLayer2); }; @@ -98,8 +98,8 @@ public: ~MenuLayer4(); public: - void menuCallback(Object* sender); - void backCallback(Object* sender); + void menuCallback(Ref* sender); + void backCallback(Ref* sender); //CREATE_NODE(MenuLayer4); }; @@ -109,9 +109,9 @@ class BugsTest : public Layer public: BugsTest(); - void issue1410MenuCallback(Object *pSender); - void issue1410v2MenuCallback(Object *pSender); - void backMenuCallback(Object *pSender); + void issue1410MenuCallback(Ref *pSender); + void issue1410v2MenuCallback(Ref *pSender); + void backMenuCallback(Ref *pSender); }; class RemoveMenuItemWhenMove : public Layer @@ -122,7 +122,7 @@ public: bool onTouchBegan(Touch *touch, Event *event); void onTouchMoved(Touch *touch, Event *event); - void goBack(Object *pSender); + void goBack(Ref *pSender); private: MenuItemFont *item; diff --git a/tests/test-cpp/Classes/MotionStreakTest/MotionStreakTest.cpp b/tests/test-cpp/Classes/MotionStreakTest/MotionStreakTest.cpp index 07160237a3..b719c7b140 100644 --- a/tests/test-cpp/Classes/MotionStreakTest/MotionStreakTest.cpp +++ b/tests/test-cpp/Classes/MotionStreakTest/MotionStreakTest.cpp @@ -222,13 +222,13 @@ void MotionStreakTest::onEnter() menuMode->setPosition(Point(s.width/2, s.height/4)); } -void MotionStreakTest::modeCallback(Object *pSender) +void MotionStreakTest::modeCallback(Ref *pSender) { bool fastMode = streak->isFastMode(); streak->setFastMode(! fastMode); } -void MotionStreakTest::restartCallback(Object* sender) +void MotionStreakTest::restartCallback(Ref* sender) { auto s = new MotionStreakTestScene();//CCScene::create(); s->addChild(restartMotionAction()); @@ -237,7 +237,7 @@ void MotionStreakTest::restartCallback(Object* sender) s->release(); } -void MotionStreakTest::nextCallback(Object* sender) +void MotionStreakTest::nextCallback(Ref* sender) { auto s = new MotionStreakTestScene();//CCScene::create(); s->addChild( nextMotionAction() ); @@ -245,7 +245,7 @@ void MotionStreakTest::nextCallback(Object* sender) s->release(); } -void MotionStreakTest::backCallback(Object* sender) +void MotionStreakTest::backCallback(Ref* sender) { auto s = new MotionStreakTestScene;//CCScene::create(); s->addChild( backMotionAction() ); diff --git a/tests/test-cpp/Classes/MotionStreakTest/MotionStreakTest.h b/tests/test-cpp/Classes/MotionStreakTest/MotionStreakTest.h index a0f4f23501..836d6226e6 100644 --- a/tests/test-cpp/Classes/MotionStreakTest/MotionStreakTest.h +++ b/tests/test-cpp/Classes/MotionStreakTest/MotionStreakTest.h @@ -17,10 +17,10 @@ public: virtual std::string subtitle() const override; virtual void onEnter(); - void restartCallback(Object* sender); - void nextCallback(Object* sender); - void backCallback(Object* sender); - void modeCallback(Object* sender); + void restartCallback(Ref* sender); + void nextCallback(Ref* sender); + void backCallback(Ref* sender); + void modeCallback(Ref* sender); protected: MotionStreak *streak; }; diff --git a/tests/test-cpp/Classes/NewEventDispatcherTest/NewEventDispatcherTest.cpp b/tests/test-cpp/Classes/NewEventDispatcherTest/NewEventDispatcherTest.cpp index 1495970cec..8b3d0a7cd2 100644 --- a/tests/test-cpp/Classes/NewEventDispatcherTest/NewEventDispatcherTest.cpp +++ b/tests/test-cpp/Classes/NewEventDispatcherTest/NewEventDispatcherTest.cpp @@ -77,7 +77,7 @@ void EventDispatcherTestDemo::onEnter() BaseTest::onEnter(); } -void EventDispatcherTestDemo::backCallback(Object* sender) +void EventDispatcherTestDemo::backCallback(Ref* sender) { auto scene = new EventDispatcherTestScene(); auto layer = backAction(); @@ -87,7 +87,7 @@ void EventDispatcherTestDemo::backCallback(Object* sender) scene->release(); } -void EventDispatcherTestDemo::nextCallback(Object* sender) +void EventDispatcherTestDemo::nextCallback(Ref* sender) { auto scene = new EventDispatcherTestScene(); auto layer = nextAction(); @@ -97,7 +97,7 @@ void EventDispatcherTestDemo::nextCallback(Object* sender) scene->release(); } -void EventDispatcherTestDemo::restartCallback(Object* sender) +void EventDispatcherTestDemo::restartCallback(Ref* sender) { auto scene = new EventDispatcherTestScene(); auto layer = restartAction(); @@ -181,13 +181,13 @@ void TouchableSpriteTest::onEnter() _eventDispatcher->addEventListenerWithSceneGraphPriority(listener1->clone(), sprite3); - auto removeAllTouchItem = MenuItemFont::create("Remove All Touch Listeners", [this](Object* sender){ + auto removeAllTouchItem = MenuItemFont::create("Remove All Touch Listeners", [this](Ref* sender){ auto senderItem = static_cast(sender); senderItem->setString("Only Next item could be clicked"); _eventDispatcher->removeEventListeners(EventListener::Type::TOUCH_ONE_BY_ONE); - auto nextItem = MenuItemFont::create("Next", [=](Object* sender){ + auto nextItem = MenuItemFont::create("Next", [=](Ref* sender){ nextCallback(nullptr); }); @@ -370,7 +370,7 @@ void RemoveListenerWhenDispatching::onEnter() addChild(statusLabel); std::shared_ptr enable(new bool(true)); // Enable/Disable item - auto toggleItem = MenuItemToggle::createWithCallback([=](Object* sender){ + auto toggleItem = MenuItemToggle::createWithCallback([=](Ref* sender){ if (*enable) { _eventDispatcher->removeEventListener(listener1); @@ -428,7 +428,7 @@ void CustomEventTest::onEnter() _eventDispatcher->addEventListenerWithFixedPriority(_listener, 1); - auto sendItem = MenuItemFont::create("Send Custom Event 1", [=](Object* sender){ + auto sendItem = MenuItemFont::create("Send Custom Event 1", [=](Ref* sender){ static int count = 0; ++count; char* buf = new char[10]; @@ -454,7 +454,7 @@ void CustomEventTest::onEnter() _eventDispatcher->addEventListenerWithFixedPriority(_listener2, 1); - auto sendItem2 = MenuItemFont::create("Send Custom Event 2", [=](Object* sender){ + auto sendItem2 = MenuItemFont::create("Send Custom Event 2", [=](Ref* sender){ static int count = 0; ++count; char* buf = new char[10]; @@ -670,7 +670,7 @@ void RemoveListenerAfterAddingTest::onEnter() { EventDispatcherTestDemo::onEnter(); - auto item1 = MenuItemFont::create("Click Me 1", [this](Object* sender){ + auto item1 = MenuItemFont::create("Click Me 1", [this](Ref* sender){ auto listener = EventListenerTouchOneByOne::create(); listener->onTouchBegan = [](Touch* touch, Event* event) -> bool{ CCASSERT(false, "Should not come here!"); @@ -684,7 +684,7 @@ void RemoveListenerAfterAddingTest::onEnter() item1->setPosition(VisibleRect::center() + Point(0, 80)); auto addNextButton = [this](){ - auto next = MenuItemFont::create("Please Click Me To Reset!", [this](Object* sender){ + auto next = MenuItemFont::create("Please Click Me To Reset!", [this](Ref* sender){ this->restartCallback(nullptr); }); next->setPosition(VisibleRect::center() + Point(0, -40)); @@ -695,7 +695,7 @@ void RemoveListenerAfterAddingTest::onEnter() this->addChild(menu); }; - auto item2 = MenuItemFont::create("Click Me 2", [=](Object* sender){ + auto item2 = MenuItemFont::create("Click Me 2", [=](Ref* sender){ auto listener = EventListenerTouchOneByOne::create(); listener->onTouchBegan = [](Touch* touch, Event* event) -> bool{ CCASSERT(false, "Should not come here!"); @@ -710,7 +710,7 @@ void RemoveListenerAfterAddingTest::onEnter() item2->setPosition(VisibleRect::center() + Point(0, 40)); - auto item3 = MenuItemFont::create("Click Me 3", [=](Object* sender){ + auto item3 = MenuItemFont::create("Click Me 3", [=](Ref* sender){ auto listener = EventListenerTouchOneByOne::create(); listener->onTouchBegan = [](Touch* touch, Event* event) -> bool{ CCASSERT(false, "Should not come here!"); diff --git a/tests/test-cpp/Classes/NewEventDispatcherTest/NewEventDispatcherTest.h b/tests/test-cpp/Classes/NewEventDispatcherTest/NewEventDispatcherTest.h index bb5b33b502..e379e95721 100644 --- a/tests/test-cpp/Classes/NewEventDispatcherTest/NewEventDispatcherTest.h +++ b/tests/test-cpp/Classes/NewEventDispatcherTest/NewEventDispatcherTest.h @@ -25,9 +25,9 @@ public: virtual void onEnter() override; virtual std::string title() const override; virtual std::string subtitle() const override; - void backCallback(Object* sender); - void nextCallback(Object* sender); - void restartCallback(Object* sender); + void backCallback(Ref* sender); + void nextCallback(Ref* sender); + void restartCallback(Ref* sender); }; diff --git a/tests/test-cpp/Classes/NewRendererTest/NewRendererTest.cpp b/tests/test-cpp/Classes/NewRendererTest/NewRendererTest.cpp index c88c2a28e1..dbbffa9baf 100644 --- a/tests/test-cpp/Classes/NewRendererTest/NewRendererTest.cpp +++ b/tests/test-cpp/Classes/NewRendererTest/NewRendererTest.cpp @@ -104,7 +104,7 @@ void MultiSceneTest::onEnter() BaseTest::onEnter(); } -void MultiSceneTest::restartCallback(Object *sender) +void MultiSceneTest::restartCallback(Ref *sender) { auto s = new NewRendererTestScene(); s->addChild(restartTest()); @@ -113,7 +113,7 @@ void MultiSceneTest::restartCallback(Object *sender) s->release(); } -void MultiSceneTest::nextCallback(Object *sender) +void MultiSceneTest::nextCallback(Ref *sender) { auto s = new NewRendererTestScene(); s->addChild(nextTest()); @@ -122,7 +122,7 @@ void MultiSceneTest::nextCallback(Object *sender) s->release(); } -void MultiSceneTest::backCallback(Object *sender) +void MultiSceneTest::backCallback(Ref *sender) { auto s = new NewRendererTestScene(); s->addChild(prevTest()); diff --git a/tests/test-cpp/Classes/NewRendererTest/NewRendererTest.h b/tests/test-cpp/Classes/NewRendererTest/NewRendererTest.h index caf133f7ff..86325e6b52 100644 --- a/tests/test-cpp/Classes/NewRendererTest/NewRendererTest.h +++ b/tests/test-cpp/Classes/NewRendererTest/NewRendererTest.h @@ -29,9 +29,9 @@ public: virtual std::string subtitle() const override; virtual void onEnter(); - void restartCallback(Object* sender); - void nextCallback(Object* sender); - void backCallback(Object* sender); + void restartCallback(Ref* sender); + void nextCallback(Ref* sender); + void backCallback(Ref* sender); protected: MultiSceneTest(); diff --git a/tests/test-cpp/Classes/NodeTest/NodeTest.cpp b/tests/test-cpp/Classes/NodeTest/NodeTest.cpp index 32feb6f27d..f3e32b6a60 100644 --- a/tests/test-cpp/Classes/NodeTest/NodeTest.cpp +++ b/tests/test-cpp/Classes/NodeTest/NodeTest.cpp @@ -121,7 +121,7 @@ void TestCocosNodeDemo::onEnter() BaseTest::onEnter(); } -void TestCocosNodeDemo::restartCallback(Object* sender) +void TestCocosNodeDemo::restartCallback(Ref* sender) { auto s = new CocosNodeTestScene();//CCScene::create(); s->addChild(restartCocosNodeAction()); @@ -130,7 +130,7 @@ void TestCocosNodeDemo::restartCallback(Object* sender) s->release(); } -void TestCocosNodeDemo::nextCallback(Object* sender) +void TestCocosNodeDemo::nextCallback(Ref* sender) { auto s = new CocosNodeTestScene();//CCScene::create(); s->addChild( nextCocosNodeAction() ); @@ -138,7 +138,7 @@ void TestCocosNodeDemo::nextCallback(Object* sender) s->release(); } -void TestCocosNodeDemo::backCallback(Object* sender) +void TestCocosNodeDemo::backCallback(Ref* sender) { auto s = new CocosNodeTestScene();//CCScene::create(); s->addChild( backCocosNodeAction() ); diff --git a/tests/test-cpp/Classes/NodeTest/NodeTest.h b/tests/test-cpp/Classes/NodeTest/NodeTest.h index 334e2df08a..0c0b6ca705 100644 --- a/tests/test-cpp/Classes/NodeTest/NodeTest.h +++ b/tests/test-cpp/Classes/NodeTest/NodeTest.h @@ -38,9 +38,9 @@ public: virtual std::string subtitle() const override; virtual void onEnter(); - void restartCallback(Object* sender); - void nextCallback(Object* sender); - void backCallback(Object* sender); + void restartCallback(Ref* sender); + void nextCallback(Ref* sender); + void backCallback(Ref* sender); protected: TestCocosNodeDemo(); diff --git a/tests/test-cpp/Classes/ParallaxTest/ParallaxTest.cpp b/tests/test-cpp/Classes/ParallaxTest/ParallaxTest.cpp index 80f2ce193c..e742a36d75 100644 --- a/tests/test-cpp/Classes/ParallaxTest/ParallaxTest.cpp +++ b/tests/test-cpp/Classes/ParallaxTest/ParallaxTest.cpp @@ -301,7 +301,7 @@ void ParallaxDemo::onEnter() BaseTest::onEnter(); } -void ParallaxDemo::restartCallback(Object* sender) +void ParallaxDemo::restartCallback(Ref* sender) { auto s = new ParallaxTestScene(); s->addChild(restartParallaxAction()); @@ -310,7 +310,7 @@ void ParallaxDemo::restartCallback(Object* sender) s->release(); } -void ParallaxDemo::nextCallback(Object* sender) +void ParallaxDemo::nextCallback(Ref* sender) { auto s = new ParallaxTestScene(); s->addChild( nextParallaxAction() ); @@ -318,7 +318,7 @@ void ParallaxDemo::nextCallback(Object* sender) s->release(); } -void ParallaxDemo::backCallback(Object* sender) +void ParallaxDemo::backCallback(Ref* sender) { auto s = new ParallaxTestScene(); s->addChild( backParallaxAction() ); diff --git a/tests/test-cpp/Classes/ParallaxTest/ParallaxTest.h b/tests/test-cpp/Classes/ParallaxTest/ParallaxTest.h index 57945c8552..f536f0699a 100644 --- a/tests/test-cpp/Classes/ParallaxTest/ParallaxTest.h +++ b/tests/test-cpp/Classes/ParallaxTest/ParallaxTest.h @@ -16,9 +16,9 @@ public: virtual std::string title() const override; virtual void onEnter(); - void restartCallback(Object* sender); - void nextCallback(Object* sender); - void backCallback(Object* sender); + void restartCallback(Ref* sender); + void nextCallback(Ref* sender); + void backCallback(Ref* sender); }; class Parallax1 : public ParallaxDemo diff --git a/tests/test-cpp/Classes/ParticleTest/ParticleTest.cpp b/tests/test-cpp/Classes/ParticleTest/ParticleTest.cpp index bf1480b1a9..5ff2d34e6b 100644 --- a/tests/test-cpp/Classes/ParticleTest/ParticleTest.cpp +++ b/tests/test-cpp/Classes/ParticleTest/ParticleTest.cpp @@ -1153,7 +1153,7 @@ void ParticleDemo::update(float dt) } } -void ParticleDemo::toggleCallback(Object* sender) +void ParticleDemo::toggleCallback(Ref* sender) { if (_emitter != NULL) { @@ -1166,7 +1166,7 @@ void ParticleDemo::toggleCallback(Object* sender) } } -void ParticleDemo::restartCallback(Object* sender) +void ParticleDemo::restartCallback(Ref* sender) { if (_emitter != NULL) { @@ -1174,7 +1174,7 @@ void ParticleDemo::restartCallback(Object* sender) } } -void ParticleDemo::nextCallback(Object* sender) +void ParticleDemo::nextCallback(Ref* sender) { auto s = new ParticleTestScene(); s->addChild( nextParticleAction() ); @@ -1182,7 +1182,7 @@ void ParticleDemo::nextCallback(Object* sender) s->release(); } -void ParticleDemo::backCallback(Object* sender) +void ParticleDemo::backCallback(Ref* sender) { auto s = new ParticleTestScene(); s->addChild( backParticleAction() ); diff --git a/tests/test-cpp/Classes/ParticleTest/ParticleTest.h b/tests/test-cpp/Classes/ParticleTest/ParticleTest.h index 5bee04114a..328ab33d4d 100644 --- a/tests/test-cpp/Classes/ParticleTest/ParticleTest.h +++ b/tests/test-cpp/Classes/ParticleTest/ParticleTest.h @@ -28,10 +28,10 @@ public: virtual std::string title() const override; virtual std::string subtitle() const override; - void restartCallback(Object* sender); - void nextCallback(Object* sender); - void backCallback(Object* sender); - void toggleCallback(Object* sender); + void restartCallback(Ref* sender); + void nextCallback(Ref* sender); + void backCallback(Ref* sender); + void toggleCallback(Ref* sender); void onTouchesBegan(const std::vector& touches, Event *event); void onTouchesMoved(const std::vector& touches, Event *event); diff --git a/tests/test-cpp/Classes/PerformanceTest/PerformanceAllocTest.cpp b/tests/test-cpp/Classes/PerformanceTest/PerformanceAllocTest.cpp index fb552e2bb9..6559aec82e 100644 --- a/tests/test-cpp/Classes/PerformanceTest/PerformanceAllocTest.cpp +++ b/tests/test-cpp/Classes/PerformanceTest/PerformanceAllocTest.cpp @@ -112,7 +112,7 @@ void PerformceAllocScene::initWithQuantityOfNodes(unsigned int nNodes) quantityOfNodes = nNodes; MenuItemFont::setFontSize(65); - auto decrease = MenuItemFont::create(" - ", [&](Object *sender) { + auto decrease = MenuItemFont::create(" - ", [&](Ref *sender) { quantityOfNodes -= kNodesIncrease; if( quantityOfNodes < 0 ) quantityOfNodes = 0; @@ -124,7 +124,7 @@ void PerformceAllocScene::initWithQuantityOfNodes(unsigned int nNodes) srand(0); }); decrease->setColor(Color3B(0,200,20)); - auto increase = MenuItemFont::create(" + ", [&](Object *sender) { + auto increase = MenuItemFont::create(" + ", [&](Ref *sender) { quantityOfNodes += kNodesIncrease; if( quantityOfNodes > kMaxNodes ) quantityOfNodes = kMaxNodes; diff --git a/tests/test-cpp/Classes/PerformanceTest/PerformanceContainerTest.cpp b/tests/test-cpp/Classes/PerformanceTest/PerformanceContainerTest.cpp index d40bb1aa7c..c8ac4a63a4 100644 --- a/tests/test-cpp/Classes/PerformanceTest/PerformanceContainerTest.cpp +++ b/tests/test-cpp/Classes/PerformanceTest/PerformanceContainerTest.cpp @@ -114,7 +114,7 @@ void PerformanceContainerScene::initWithQuantityOfNodes(unsigned int nNodes) quantityOfNodes = nNodes; MenuItemFont::setFontSize(65); - auto decrease = MenuItemFont::create(" - ", [&](Object *sender) { + auto decrease = MenuItemFont::create(" - ", [&](Ref *sender) { quantityOfNodes -= kNodesIncrease; if( quantityOfNodes < 0 ) quantityOfNodes = 0; @@ -128,7 +128,7 @@ void PerformanceContainerScene::initWithQuantityOfNodes(unsigned int nNodes) decrease->setColor(Color3B(0,200,20)); _decrease = decrease; - auto increase = MenuItemFont::create(" + ", [&](Object *sender) { + auto increase = MenuItemFont::create(" + ", [&](Ref *sender) { quantityOfNodes += kNodesIncrease; if( quantityOfNodes > kMaxNodes ) quantityOfNodes = kMaxNodes; @@ -173,7 +173,7 @@ void PerformanceContainerScene::initWithQuantityOfNodes(unsigned int nNodes) toggleItems.pushBack(MenuItemFont::create(f.name)); } - auto toggle = MenuItemToggle::createWithCallback([this](Object* sender){ + auto toggle = MenuItemToggle::createWithCallback([this](Ref* sender){ auto toggle = static_cast(sender); this->_type = toggle->getSelectedIndex(); auto label = static_cast(this->getChildByTag(TAG_SUBTITLE)); @@ -185,7 +185,7 @@ void PerformanceContainerScene::initWithQuantityOfNodes(unsigned int nNodes) toggle->setPosition(VisibleRect::left()); _toggle = toggle; - auto start = MenuItemFont::create("start", [this](Object* sender){ + auto start = MenuItemFont::create("start", [this](Ref* sender){ auto director = Director::getInstance(); auto sched = director->getScheduler(); @@ -204,7 +204,7 @@ void PerformanceContainerScene::initWithQuantityOfNodes(unsigned int nNodes) start->setPosition(VisibleRect::right() + Point(0, 40)); _startItem = start; - auto stop = MenuItemFont::create("stop", [this](Object* sender){ + auto stop = MenuItemFont::create("stop", [this](Ref* sender){ auto director = Director::getInstance(); auto sched = director->getScheduler(); @@ -559,7 +559,7 @@ void ArrayPerfTest::generateTestFunctions() } } , { "getIndexOfObject", [=](){ Array* nodeVector = createArray(); - Object* objToGet = nodeVector->getObjectAtIndex(quantityOfNodes/3); + Ref* objToGet = nodeVector->getObjectAtIndex(quantityOfNodes/3); ssize_t index = 0; CC_PROFILER_START(this->profilerName()); for( int i=0; igetObjectAtIndex(quantityOfNodes/3); + Ref* objToGet = nodeVector->getObjectAtIndex(quantityOfNodes/3); CC_PROFILER_START(this->profilerName()); for( int i=0; igetObjectAtIndex(quantityOfNodes / 3); - Object* swapNode2 = nodeVector->getObjectAtIndex(quantityOfNodes / 3 * 2); + Ref* swapNode1 = nodeVector->getObjectAtIndex(quantityOfNodes / 3); + Ref* swapNode2 = nodeVector->getObjectAtIndex(quantityOfNodes / 3 * 2); CC_PROFILER_START(this->profilerName()); for( int i=0; iprofilerName()); CCARRAY_FOREACH(nodeVector, obj) @@ -967,7 +967,7 @@ void DictionaryStringKeyPerfTest::generateTestFunctions() CC_PROFILER_STOP(this->profilerName()); std::string allKeysString; - Object* obj; + Ref* obj; CCARRAY_FOREACH(keys, obj) { auto key = static_cast(obj); @@ -1000,7 +1000,7 @@ void DictionaryStringKeyPerfTest::generateTestFunctions() CC_PROFILER_STOP(this->profilerName()); std::string allKeysString; - Object* obj; + Ref* obj; CCARRAY_FOREACH(keys, obj) { auto key = static_cast(obj); @@ -1283,7 +1283,7 @@ void DictionaryIntKeyPerfTest::generateTestFunctions() CC_PROFILER_STOP(this->profilerName()); int allKeysInt = 0; - Object* obj; + Ref* obj; CCARRAY_FOREACH(keys, obj) { auto key = static_cast(obj); @@ -1316,7 +1316,7 @@ void DictionaryIntKeyPerfTest::generateTestFunctions() CC_PROFILER_STOP(this->profilerName()); int allKeysInt = 0; - Object* obj; + Ref* obj; CCARRAY_FOREACH(keys, obj) { auto key = static_cast(obj); diff --git a/tests/test-cpp/Classes/PerformanceTest/PerformanceEventDispatcherTest.cpp b/tests/test-cpp/Classes/PerformanceTest/PerformanceEventDispatcherTest.cpp index bb4d3d5c3c..af0a9e850b 100644 --- a/tests/test-cpp/Classes/PerformanceTest/PerformanceEventDispatcherTest.cpp +++ b/tests/test-cpp/Classes/PerformanceTest/PerformanceEventDispatcherTest.cpp @@ -112,7 +112,7 @@ void PerformanceEventDispatcherScene::initWithQuantityOfNodes(unsigned int nNode _quantityOfNodes = nNodes; MenuItemFont::setFontSize(65); - auto decrease = MenuItemFont::create(" - ", [&](Object *sender) { + auto decrease = MenuItemFont::create(" - ", [&](Ref *sender) { _quantityOfNodes -= kNodesIncrease; if( _quantityOfNodes < 0 ) _quantityOfNodes = 0; @@ -126,7 +126,7 @@ void PerformanceEventDispatcherScene::initWithQuantityOfNodes(unsigned int nNode decrease->setColor(Color3B(0,200,20)); _decrease = decrease; - auto increase = MenuItemFont::create(" + ", [&](Object *sender) { + auto increase = MenuItemFont::create(" + ", [&](Ref *sender) { _quantityOfNodes += kNodesIncrease; if( _quantityOfNodes > kMaxNodes ) _quantityOfNodes = kMaxNodes; @@ -189,7 +189,7 @@ void PerformanceEventDispatcherScene::initWithQuantityOfNodes(unsigned int nNode this->_lastRenderedCount = 0; }; - auto toggle = MenuItemToggle::createWithCallback([=](Object* sender){ + auto toggle = MenuItemToggle::createWithCallback([=](Ref* sender){ auto toggle = static_cast(sender); this->_type = toggle->getSelectedIndex(); auto label = static_cast(this->getChildByTag(TAG_SUBTITLE)); @@ -202,7 +202,7 @@ void PerformanceEventDispatcherScene::initWithQuantityOfNodes(unsigned int nNode toggle->setPosition(VisibleRect::left()); _toggle = toggle; - auto start = MenuItemFont::create("start", [this](Object* sender){ + auto start = MenuItemFont::create("start", [this](Ref* sender){ auto director = Director::getInstance(); auto sched = director->getScheduler(); @@ -221,7 +221,7 @@ void PerformanceEventDispatcherScene::initWithQuantityOfNodes(unsigned int nNode start->setPosition(VisibleRect::right() + Point(0, 40)); _startItem = start; - auto stop = MenuItemFont::create("stop", [=](Object* sender){ + auto stop = MenuItemFont::create("stop", [=](Ref* sender){ auto director = Director::getInstance(); auto sched = director->getScheduler(); diff --git a/tests/test-cpp/Classes/PerformanceTest/PerformanceLabelTest.cpp b/tests/test-cpp/Classes/PerformanceTest/PerformanceLabelTest.cpp index 374f0948a5..e8602018dc 100644 --- a/tests/test-cpp/Classes/PerformanceTest/PerformanceLabelTest.cpp +++ b/tests/test-cpp/Classes/PerformanceTest/PerformanceLabelTest.cpp @@ -32,7 +32,7 @@ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor // LabelMenuLayer // //////////////////////////////////////////////////////// -void LabelMenuLayer::restartCallback(Object* sender) +void LabelMenuLayer::restartCallback(Ref* sender) { if ( LabelMainScene::_s_autoTest ) { @@ -43,7 +43,7 @@ void LabelMenuLayer::restartCallback(Object* sender) PerformBasicLayer::restartCallback(sender); } -void LabelMenuLayer::nextCallback(Object* sender) +void LabelMenuLayer::nextCallback(Ref* sender) { if ( LabelMainScene::_s_autoTest ) { @@ -54,7 +54,7 @@ void LabelMenuLayer::nextCallback(Object* sender) PerformBasicLayer::nextCallback(sender); } -void LabelMenuLayer::backCallback(Object* sender) +void LabelMenuLayer::backCallback(Ref* sender) { if ( LabelMainScene::_s_autoTest ) { @@ -182,7 +182,7 @@ void LabelMainScene::updateNodes() } } -void LabelMainScene::onIncrease(Object* sender) +void LabelMainScene::onIncrease(Ref* sender) { if( _quantityNodes >= kMaxNodes) return; @@ -254,7 +254,7 @@ void LabelMainScene::onIncrease(Object* sender) updateNodes(); } -void LabelMainScene::onDecrease(Object* sender) +void LabelMainScene::onDecrease(Ref* sender) { if( _quantityNodes <= 0 ) return; @@ -419,7 +419,7 @@ void LabelMainScene::finishAutoTest() log("Label performance test is finish "); } -void LabelMainScene::onAutoTest(Object* sender) +void LabelMainScene::onAutoTest(Ref* sender) { LabelMainScene::_s_autoTest = !LabelMainScene::_s_autoTest; MenuItemFont* menuItem = dynamic_cast(sender); diff --git a/tests/test-cpp/Classes/PerformanceTest/PerformanceLabelTest.h b/tests/test-cpp/Classes/PerformanceTest/PerformanceLabelTest.h index 8d4040a0f9..6deca05e39 100644 --- a/tests/test-cpp/Classes/PerformanceTest/PerformanceLabelTest.h +++ b/tests/test-cpp/Classes/PerformanceTest/PerformanceLabelTest.h @@ -11,9 +11,9 @@ public: { } - virtual void restartCallback(Object* sender) override; - virtual void nextCallback(Object* sender) override; - virtual void backCallback(Object* sender) override; + virtual void restartCallback(Ref* sender) override; + virtual void nextCallback(Ref* sender) override; + virtual void backCallback(Ref* sender) override; virtual void showCurrentTest() override; }; @@ -28,15 +28,15 @@ public: void initWithSubTest(int nodes); void updateNodes(); - void onIncrease(Object* sender); - void onDecrease(Object* sender); + void onIncrease(Ref* sender); + void onDecrease(Ref* sender); int getSubTestNum() { return 1; } int getNodesNum() { return _quantityNodes; } void updateAutoTest(float dt); void updateText(float dt); - void onAutoTest(Object* sender); + void onAutoTest(Ref* sender); void autoShowLabelTests(int curCase,int nodes); diff --git a/tests/test-cpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp b/tests/test-cpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp index 46ebde1222..3876465ad9 100644 --- a/tests/test-cpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp +++ b/tests/test-cpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp @@ -141,7 +141,7 @@ void NodeChildrenMainScene::initWithQuantityOfNodes(unsigned int nNodes) quantityOfNodes = nNodes; MenuItemFont::setFontSize(65); - auto decrease = MenuItemFont::create(" - ", [&](Object *sender) { + auto decrease = MenuItemFont::create(" - ", [&](Ref *sender) { quantityOfNodes -= kNodesIncrease; if( quantityOfNodes < 0 ) quantityOfNodes = 0; @@ -153,7 +153,7 @@ void NodeChildrenMainScene::initWithQuantityOfNodes(unsigned int nNodes) srand(0); }); decrease->setColor(Color3B(0,200,20)); - auto increase = MenuItemFont::create(" + ", [&](Object *sender) { + auto increase = MenuItemFont::create(" + ", [&](Ref *sender) { quantityOfNodes += kNodesIncrease; if( quantityOfNodes > kMaxNodes ) quantityOfNodes = kMaxNodes; @@ -286,7 +286,7 @@ void IterateSpriteSheetForLoop::update(float dt) for( const auto &object : children ) { - auto o = static_cast(object); + auto o = static_cast(object); auto sprite = static_cast(o); sprite->setVisible(false); } diff --git a/tests/test-cpp/Classes/PerformanceTest/PerformanceParticleTest.cpp b/tests/test-cpp/Classes/PerformanceTest/PerformanceParticleTest.cpp index 378935e826..468fe4afe8 100644 --- a/tests/test-cpp/Classes/PerformanceTest/PerformanceParticleTest.cpp +++ b/tests/test-cpp/Classes/PerformanceTest/PerformanceParticleTest.cpp @@ -79,7 +79,7 @@ void ParticleMainScene::initWithSubTest(int asubtest, int particles) quantityParticles = particles; MenuItemFont::setFontSize(65); - auto decrease = MenuItemFont::create(" - ", [&](Object *sender) { + auto decrease = MenuItemFont::create(" - ", [&](Ref *sender) { quantityParticles -= kNodesIncrease; if( quantityParticles < 0 ) quantityParticles = 0; @@ -88,7 +88,7 @@ void ParticleMainScene::initWithSubTest(int asubtest, int particles) createParticleSystem(); }); decrease->setColor(Color3B(0,200,20)); - auto increase = MenuItemFont::create(" + ", [&](Object *sender) { + auto increase = MenuItemFont::create(" + ", [&](Ref *sender) { quantityParticles += kNodesIncrease; if( quantityParticles > kMaxParticles ) quantityParticles = kMaxParticles; @@ -246,7 +246,7 @@ void ParticleMainScene::createParticleSystem() Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA8888); } -void ParticleMainScene::testNCallback(Object* sender) +void ParticleMainScene::testNCallback(Ref* sender) { subtestNumber = static_cast(sender)->getTag(); diff --git a/tests/test-cpp/Classes/PerformanceTest/PerformanceParticleTest.h b/tests/test-cpp/Classes/PerformanceTest/PerformanceParticleTest.h index b9e85ec360..ee8e5c0531 100644 --- a/tests/test-cpp/Classes/PerformanceTest/PerformanceParticleTest.h +++ b/tests/test-cpp/Classes/PerformanceTest/PerformanceParticleTest.h @@ -18,7 +18,7 @@ public: void step(float dt); void createParticleSystem(); - void testNCallback(Object* sender); + void testNCallback(Ref* sender); void updateQuantityLabel(); int getSubTestNum() { return subtestNumber; } int getParticlesNum() { return quantityParticles; } diff --git a/tests/test-cpp/Classes/PerformanceTest/PerformanceScenarioTest.cpp b/tests/test-cpp/Classes/PerformanceTest/PerformanceScenarioTest.cpp index 6b0c7f4b31..324c7e2f1c 100644 --- a/tests/test-cpp/Classes/PerformanceTest/PerformanceScenarioTest.cpp +++ b/tests/test-cpp/Classes/PerformanceTest/PerformanceScenarioTest.cpp @@ -111,7 +111,7 @@ void ScenarioTest::performTests() // add decrease & increase menu item MenuItemFont::setFontSize(65); - auto decrease = MenuItemFont::create(" - ", [&](Object *sender) { + auto decrease = MenuItemFont::create(" - ", [&](Ref *sender) { int idx = _itemToggle->getSelectedIndex(); switch (idx) { case 0: @@ -129,7 +129,7 @@ void ScenarioTest::performTests() }); decrease->setPosition(Point(origin.x + s.width / 2 - 80, origin.y + 80)); decrease->setColor(Color3B(0,200,20)); - auto increase = MenuItemFont::create(" + ", [&](Object *sender) { + auto increase = MenuItemFont::create(" + ", [&](Ref *sender) { int idx = _itemToggle->getSelectedIndex(); switch (idx) { case 0: diff --git a/tests/test-cpp/Classes/PerformanceTest/PerformanceSpriteTest.cpp b/tests/test-cpp/Classes/PerformanceTest/PerformanceSpriteTest.cpp index b6672ceae6..1116337d5d 100644 --- a/tests/test-cpp/Classes/PerformanceTest/PerformanceSpriteTest.cpp +++ b/tests/test-cpp/Classes/PerformanceTest/PerformanceSpriteTest.cpp @@ -286,7 +286,7 @@ void SubTest::removeByTag(int tag) // SpriteMenuLayer // //////////////////////////////////////////////////////// -void SpriteMenuLayer::restartCallback(Object* sender) +void SpriteMenuLayer::restartCallback(Ref* sender) { if ( SpriteMainScene::_s_autoTest ) { @@ -296,7 +296,7 @@ void SpriteMenuLayer::restartCallback(Object* sender) PerformBasicLayer::restartCallback(sender); } -void SpriteMenuLayer::nextCallback(Object* sender) +void SpriteMenuLayer::nextCallback(Ref* sender) { if ( SpriteMainScene::_s_autoTest ) { @@ -306,7 +306,7 @@ void SpriteMenuLayer::nextCallback(Object* sender) PerformBasicLayer::nextCallback(sender); } -void SpriteMenuLayer::backCallback(Object* sender) +void SpriteMenuLayer::backCallback(Ref* sender) { if ( SpriteMainScene::_s_autoTest ) { @@ -488,7 +488,7 @@ SpriteMainScene::~SpriteMainScene() } } -void SpriteMainScene::testNCallback(Object* sender) +void SpriteMainScene::testNCallback(Ref* sender) { if (SpriteMainScene::_s_autoTest) { @@ -514,7 +514,7 @@ void SpriteMainScene::updateNodes() } } -void SpriteMainScene::onIncrease(Object* sender) +void SpriteMainScene::onIncrease(Ref* sender) { if( quantityNodes >= kMaxNodes) return; @@ -529,7 +529,7 @@ void SpriteMainScene::onIncrease(Object* sender) updateNodes(); } -void SpriteMainScene::onDecrease(Object* sender) +void SpriteMainScene::onDecrease(Ref* sender) { if( quantityNodes <= 0 ) @@ -728,7 +728,7 @@ void SpriteMainScene::finishAutoTest() log("Sprite performance test is finish "); } -void SpriteMainScene::onAutoTest(Object* sender) +void SpriteMainScene::onAutoTest(Ref* sender) { SpriteMainScene::_s_autoTest = !SpriteMainScene::_s_autoTest; MenuItemFont* menuItem = dynamic_cast(sender); diff --git a/tests/test-cpp/Classes/PerformanceTest/PerformanceSpriteTest.h b/tests/test-cpp/Classes/PerformanceTest/PerformanceSpriteTest.h index 0aa21356c7..e60a63410b 100644 --- a/tests/test-cpp/Classes/PerformanceTest/PerformanceSpriteTest.h +++ b/tests/test-cpp/Classes/PerformanceTest/PerformanceSpriteTest.h @@ -51,9 +51,9 @@ public: { } - virtual void restartCallback(Object* sender); - virtual void nextCallback(Object* sender); - virtual void backCallback(Object* sender); + virtual void restartCallback(Ref* sender); + virtual void nextCallback(Ref* sender); + virtual void backCallback(Ref* sender); virtual void showCurrentTest(); }; @@ -67,9 +67,9 @@ public: void initWithSubTest(int nSubTest, int nNodes); void updateNodes(); - void testNCallback(Object* sender); - void onIncrease(Object* sender); - void onDecrease(Object* sender); + void testNCallback(Ref* sender); + void onIncrease(Ref* sender); + void onDecrease(Ref* sender); virtual void doTest(Sprite* sprite) = 0; @@ -79,7 +79,7 @@ public: virtual void onEnter(); virtual void onExit(); void updateAutoTest(float dt); - void onAutoTest(Object* sender); + void onAutoTest(Ref* sender); static bool _s_autoTest; static int _s_nSpriteCurCase; diff --git a/tests/test-cpp/Classes/PerformanceTest/PerformanceTest.cpp b/tests/test-cpp/Classes/PerformanceTest/PerformanceTest.cpp index ee39fef1ba..9142085c74 100644 --- a/tests/test-cpp/Classes/PerformanceTest/PerformanceTest.cpp +++ b/tests/test-cpp/Classes/PerformanceTest/PerformanceTest.cpp @@ -20,20 +20,20 @@ enum struct { const char *name; - std::function callback; + std::function callback; } g_testsName[] = { - { "Alloc Test", [](Object*sender){runAllocPerformanceTest(); } }, - { "NodeChildren Test", [](Object*sender){runNodeChildrenTest();} }, - { "Particle Test",[](Object*sender){runParticleTest();} }, - { "Sprite Perf Test",[](Object*sender){runSpriteTest();} }, - { "Texture Perf Test",[](Object*sender){runTextureTest();} }, - { "Touches Perf Test",[](Object*sender){runTouchesTest();} }, - { "Label Perf Test",[](Object*sender){runLabelTest();} }, - { "Renderer Perf Test",[](Object*sender){runRendererTest();} }, - { "Container Perf Test", [](Object* sender ) { runContainerPerformanceTest(); } }, - { "EventDispatcher Perf Test", [](Object* sender ) { runEventDispatcherPerformanceTest(); } }, - { "Scenario Perf Test", [](Object* sender ) { runScenarioTest(); } }, + { "Alloc Test", [](Ref*sender){runAllocPerformanceTest(); } }, + { "NodeChildren Test", [](Ref*sender){runNodeChildrenTest();} }, + { "Particle Test",[](Ref*sender){runParticleTest();} }, + { "Sprite Perf Test",[](Ref*sender){runSpriteTest();} }, + { "Texture Perf Test",[](Ref*sender){runTextureTest();} }, + { "Touches Perf Test",[](Ref*sender){runTouchesTest();} }, + { "Label Perf Test",[](Ref*sender){runLabelTest();} }, + { "Renderer Perf Test",[](Ref*sender){runRendererTest();} }, + { "Container Perf Test", [](Ref* sender ) { runContainerPerformanceTest(); } }, + { "EventDispatcher Perf Test", [](Ref* sender ) { runEventDispatcherPerformanceTest(); } }, + { "Scenario Perf Test", [](Ref* sender ) { runScenarioTest(); } }, }; static const int g_testMax = sizeof(g_testsName)/sizeof(g_testsName[0]); @@ -172,7 +172,7 @@ void PerformBasicLayer::onEnter() addChild(menu); } -void PerformBasicLayer::toMainLayer(Object* sender) +void PerformBasicLayer::toMainLayer(Ref* sender) { auto scene = new PerformanceTestScene(); scene->runThisTest(); @@ -180,12 +180,12 @@ void PerformBasicLayer::toMainLayer(Object* sender) scene->release(); } -void PerformBasicLayer::restartCallback(Object* sender) +void PerformBasicLayer::restartCallback(Ref* sender) { showCurrentTest(); } -void PerformBasicLayer::nextCallback(Object* sender) +void PerformBasicLayer::nextCallback(Ref* sender) { _curCase++; _curCase = _curCase % _maxCases; @@ -193,7 +193,7 @@ void PerformBasicLayer::nextCallback(Object* sender) showCurrentTest(); } -void PerformBasicLayer::backCallback(Object* sender) +void PerformBasicLayer::backCallback(Ref* sender) { _curCase--; if( _curCase < 0 ) diff --git a/tests/test-cpp/Classes/PerformanceTest/PerformanceTest.h b/tests/test-cpp/Classes/PerformanceTest/PerformanceTest.h index 7e874beec7..58eed41aa0 100644 --- a/tests/test-cpp/Classes/PerformanceTest/PerformanceTest.h +++ b/tests/test-cpp/Classes/PerformanceTest/PerformanceTest.h @@ -26,12 +26,12 @@ public: virtual void onEnter() override; - virtual void restartCallback(Object* sender); - virtual void nextCallback(Object* sender); - virtual void backCallback(Object* sender); + virtual void restartCallback(Ref* sender); + virtual void nextCallback(Ref* sender); + virtual void backCallback(Ref* sender); virtual void showCurrentTest() = 0; - virtual void toMainLayer(Object* sender); + virtual void toMainLayer(Ref* sender); protected: bool _controlMenuVisible; diff --git a/tests/test-cpp/Classes/PerformanceTest/PerformanceTouchesTest.cpp b/tests/test-cpp/Classes/PerformanceTest/PerformanceTouchesTest.cpp index d5483404cb..56df888fd4 100644 --- a/tests/test-cpp/Classes/PerformanceTest/PerformanceTouchesTest.cpp +++ b/tests/test-cpp/Classes/PerformanceTest/PerformanceTouchesTest.cpp @@ -249,7 +249,7 @@ void TouchesPerformTest3::onEnter() } auto emitEventlabel = LabelTTF::create("Emit Touch Event", "", 24); - auto menuItem = MenuItemLabel::create(emitEventlabel, [this](Object* sender){ + auto menuItem = MenuItemLabel::create(emitEventlabel, [this](Ref* sender){ CC_PROFILER_PURGE_ALL(); diff --git a/tests/test-cpp/Classes/PhysicsTest/PhysicsTest.cpp b/tests/test-cpp/Classes/PhysicsTest/PhysicsTest.cpp index 45392a3ce9..5daa2d8273 100644 --- a/tests/test-cpp/Classes/PhysicsTest/PhysicsTest.cpp +++ b/tests/test-cpp/Classes/PhysicsTest/PhysicsTest.cpp @@ -115,7 +115,7 @@ std::string PhysicsDemo::subtitle() const return ""; } -void PhysicsDemo::restartCallback(Object* sender) +void PhysicsDemo::restartCallback(Ref* sender) { auto s = new PhysicsTestScene(); s->addChild( restart() ); @@ -123,7 +123,7 @@ void PhysicsDemo::restartCallback(Object* sender) s->release(); } -void PhysicsDemo::nextCallback(Object* sender) +void PhysicsDemo::nextCallback(Ref* sender) { auto s = new PhysicsTestScene(); s->addChild( next() ); @@ -131,7 +131,7 @@ void PhysicsDemo::nextCallback(Object* sender) s->release(); } -void PhysicsDemo::backCallback(Object* sender) +void PhysicsDemo::backCallback(Ref* sender) { auto s = new PhysicsTestScene(); s->addChild( back() ); @@ -178,7 +178,7 @@ Sprite* PhysicsDemo::addGrossiniAtPosition(Point p, float scale/* = 1.0*/) } -void PhysicsDemo::toggleDebugCallback(Object* sender) +void PhysicsDemo::toggleDebugCallback(Ref* sender) { if (_scene != nullptr) { @@ -521,7 +521,7 @@ void PhysicsDemoRayCast::onEnter() scheduleUpdate(); } -void PhysicsDemoRayCast::changeModeCallback(Object* sender) +void PhysicsDemoRayCast::changeModeCallback(Ref* sender) { _mode = (_mode + 1) % 3; diff --git a/tests/test-cpp/Classes/PhysicsTest/PhysicsTest.h b/tests/test-cpp/Classes/PhysicsTest/PhysicsTest.h index 31f3e6fbdb..51e91510be 100644 --- a/tests/test-cpp/Classes/PhysicsTest/PhysicsTest.h +++ b/tests/test-cpp/Classes/PhysicsTest/PhysicsTest.h @@ -44,10 +44,10 @@ public: virtual std::string title() const override; virtual std::string subtitle() const override; - void restartCallback(Object* sender); - void nextCallback(Object* sender); - void backCallback(Object* sender); - void toggleDebugCallback(Object* sender); + void restartCallback(Ref* sender); + void nextCallback(Ref* sender); + void backCallback(Ref* sender); + void toggleDebugCallback(Ref* sender); Sprite* addGrossiniAtPosition(Point p, float scale = 1.0); Sprite* makeBall(Point point, float radius, PhysicsMaterial material = PHYSICSBODY_MATERIAL_DEFAULT); @@ -108,7 +108,7 @@ public: void update(float delta) override; void onTouchesEnded(const std::vector& touches, Event* event); - void changeModeCallback(Object* sender); + void changeModeCallback(Ref* sender); bool anyRay(PhysicsWorld& world, const PhysicsRayCastInfo& info, void* data); diff --git a/tests/test-cpp/Classes/ReleasePoolTest/ReleasePoolTest.cpp b/tests/test-cpp/Classes/ReleasePoolTest/ReleasePoolTest.cpp index 061e0f1d19..47b229029a 100644 --- a/tests/test-cpp/Classes/ReleasePoolTest/ReleasePoolTest.cpp +++ b/tests/test-cpp/Classes/ReleasePoolTest/ReleasePoolTest.cpp @@ -2,7 +2,7 @@ using namespace cocos2d; -class TestObject : public Object +class TestObject : public Ref { public: TestObject() : _name(""){} diff --git a/tests/test-cpp/Classes/RenderTextureTest/RenderTextureTest.cpp b/tests/test-cpp/Classes/RenderTextureTest/RenderTextureTest.cpp index 4203356b7c..aa0317bd03 100644 --- a/tests/test-cpp/Classes/RenderTextureTest/RenderTextureTest.cpp +++ b/tests/test-cpp/Classes/RenderTextureTest/RenderTextureTest.cpp @@ -51,7 +51,7 @@ void RenderTextureTest::onEnter() BaseTest::onEnter(); } -void RenderTextureTest::restartCallback(Object* sender) +void RenderTextureTest::restartCallback(Ref* sender) { auto s = new RenderTextureScene(); s->addChild(restartTestCase()); @@ -60,7 +60,7 @@ void RenderTextureTest::restartCallback(Object* sender) s->release(); } -void RenderTextureTest::nextCallback(Object* sender) +void RenderTextureTest::nextCallback(Ref* sender) { auto s = new RenderTextureScene(); s->addChild( nextTestCase() ); @@ -68,7 +68,7 @@ void RenderTextureTest::nextCallback(Object* sender) s->release(); } -void RenderTextureTest::backCallback(Object* sender) +void RenderTextureTest::backCallback(Ref* sender) { auto s = new RenderTextureScene(); s->addChild( backTestCase() ); @@ -126,12 +126,12 @@ std::string RenderTextureSave::subtitle() const return "Press 'Save Image' to create an snapshot of the render texture"; } -void RenderTextureSave::clearImage(cocos2d::Object *sender) +void RenderTextureSave::clearImage(cocos2d::Ref *sender) { _target->clear(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1()); } -void RenderTextureSave::saveImage(cocos2d::Object *sender) +void RenderTextureSave::saveImage(cocos2d::Ref *sender) { static int counter = 0; @@ -578,7 +578,7 @@ RenderTextureTargetNode::RenderTextureTargetNode() menu->setPosition(Point(s.width/2, s.height/2)); } -void RenderTextureTargetNode::touched(Object* sender) +void RenderTextureTargetNode::touched(Ref* sender) { if (renderTexture->getClearFlags() == 0) { diff --git a/tests/test-cpp/Classes/RenderTextureTest/RenderTextureTest.h b/tests/test-cpp/Classes/RenderTextureTest/RenderTextureTest.h index 32ee7c111d..2139f1fecd 100644 --- a/tests/test-cpp/Classes/RenderTextureTest/RenderTextureTest.h +++ b/tests/test-cpp/Classes/RenderTextureTest/RenderTextureTest.h @@ -13,9 +13,9 @@ public: virtual std::string title() const override; virtual std::string subtitle() const override; - void restartCallback(Object* sender); - void nextCallback(Object* sender); - void backCallback(Object* sender); + void restartCallback(Ref* sender); + void nextCallback(Ref* sender); + void backCallback(Ref* sender); }; class RenderTextureSave : public RenderTextureTest @@ -27,8 +27,8 @@ public: virtual std::string title() const override; virtual std::string subtitle() const override; void onTouchesMoved(const std::vector& touches, Event* event); - void clearImage(Object *pSender); - void saveImage(Object *pSender); + void clearImage(Ref *pSender); + void saveImage(Ref *pSender); private: RenderTexture *_target; @@ -113,7 +113,7 @@ public: virtual std::string title() const override; virtual std::string subtitle() const override; - void touched(Object* sender); + void touched(Ref* sender); }; class SpriteRenderTextureBug : public RenderTextureTest diff --git a/tests/test-cpp/Classes/SceneTest/SceneTest.cpp b/tests/test-cpp/Classes/SceneTest/SceneTest.cpp index aabbcd3846..bb4b02b558 100644 --- a/tests/test-cpp/Classes/SceneTest/SceneTest.cpp +++ b/tests/test-cpp/Classes/SceneTest/SceneTest.cpp @@ -60,7 +60,7 @@ SceneTestLayer1::~SceneTestLayer1() //NSLog(@"SceneTestLayer1 - dealloc"); } -void SceneTestLayer1::onPushScene(Object* sender) +void SceneTestLayer1::onPushScene(Ref* sender) { auto scene = new SceneTestScene(); auto layer = new SceneTestLayer2(); @@ -70,7 +70,7 @@ void SceneTestLayer1::onPushScene(Object* sender) layer->release(); } -void SceneTestLayer1::onPushSceneTran(Object* sender) +void SceneTestLayer1::onPushSceneTran(Ref* sender) { auto scene = new SceneTestScene(); auto layer = new SceneTestLayer2(); @@ -82,7 +82,7 @@ void SceneTestLayer1::onPushSceneTran(Object* sender) } -void SceneTestLayer1::onQuit(Object* sender) +void SceneTestLayer1::onQuit(Ref* sender) { //getCocosApp()->exit(); //CCDirector::getInstance()->poscene(); @@ -130,12 +130,12 @@ void SceneTestLayer2::testDealloc(float dt) // onReplaceScene(this); } -void SceneTestLayer2::onGoBack(Object* sender) +void SceneTestLayer2::onGoBack(Ref* sender) { Director::getInstance()->popScene(); } -void SceneTestLayer2::onReplaceScene(Object* sender) +void SceneTestLayer2::onReplaceScene(Ref* sender) { auto scene = new SceneTestScene(); auto layer = SceneTestLayer3::create(); @@ -145,7 +145,7 @@ void SceneTestLayer2::onReplaceScene(Object* sender) } -void SceneTestLayer2::onReplaceSceneTran(Object* sender) +void SceneTestLayer2::onReplaceSceneTran(Ref* sender) { auto scene = new SceneTestScene(); auto layer = SceneTestLayer3::create(); @@ -198,24 +198,24 @@ void SceneTestLayer3::testDealloc(float dt) log("Layer3:testDealloc"); } -void SceneTestLayer3::item0Clicked(Object* sender) +void SceneTestLayer3::item0Clicked(Ref* sender) { auto newScene = Scene::create(); newScene->addChild(SceneTestLayer3::create()); Director::getInstance()->pushScene(TransitionFade::create(0.5, newScene, Color3B(0,255,255))); } -void SceneTestLayer3::item1Clicked(Object* sender) +void SceneTestLayer3::item1Clicked(Ref* sender) { Director::getInstance()->popScene(); } -void SceneTestLayer3::item2Clicked(Object* sender) +void SceneTestLayer3::item2Clicked(Ref* sender) { Director::getInstance()->popToRootScene(); } -void SceneTestLayer3::item3Clicked(Object* sender) +void SceneTestLayer3::item3Clicked(Ref* sender) { Director::getInstance()->popToSceneStackLevel(2); } diff --git a/tests/test-cpp/Classes/SceneTest/SceneTest.h b/tests/test-cpp/Classes/SceneTest/SceneTest.h index b79ff0a656..98066c5452 100644 --- a/tests/test-cpp/Classes/SceneTest/SceneTest.h +++ b/tests/test-cpp/Classes/SceneTest/SceneTest.h @@ -14,9 +14,9 @@ public: virtual void onEnterTransitionDidFinish(); void testDealloc(float dt); - void onPushScene(Object* sender); - void onPushSceneTran(Object* sender); - void onQuit(Object* sender); + void onPushScene(Ref* sender); + void onPushSceneTran(Ref* sender); + void onQuit(Ref* sender); //CREATE_NODE(SceneTestLayer1); } ; @@ -28,9 +28,9 @@ public: SceneTestLayer2(); void testDealloc(float dt); - void onGoBack(Object* sender); - void onReplaceScene(Object* sender); - void onReplaceSceneTran(Object* sender); + void onGoBack(Ref* sender); + void onReplaceScene(Ref* sender); + void onReplaceSceneTran(Ref* sender); //CREATE_NODE(SceneTestLayer2); } ; @@ -41,10 +41,10 @@ public: SceneTestLayer3(); bool init(); virtual void testDealloc(float dt); - void item0Clicked(Object* sender); - void item1Clicked(Object* sender); - void item2Clicked(Object* sender); - void item3Clicked(Object* sender); + void item0Clicked(Ref* sender); + void item1Clicked(Ref* sender); + void item2Clicked(Ref* sender); + void item3Clicked(Ref* sender); CREATE_FUNC(SceneTestLayer3) } ; diff --git a/tests/test-cpp/Classes/SchedulerTest/SchedulerTest.cpp b/tests/test-cpp/Classes/SchedulerTest/SchedulerTest.cpp index a7b1f6da48..8d5d5453f7 100644 --- a/tests/test-cpp/Classes/SchedulerTest/SchedulerTest.cpp +++ b/tests/test-cpp/Classes/SchedulerTest/SchedulerTest.cpp @@ -68,7 +68,7 @@ void SchedulerTestLayer::onEnter() BaseTest::onEnter(); } -void SchedulerTestLayer::backCallback(Object* sender) +void SchedulerTestLayer::backCallback(Ref* sender) { auto scene = new SchedulerTestScene(); auto layer = backSchedulerTest(); @@ -78,7 +78,7 @@ void SchedulerTestLayer::backCallback(Object* sender) scene->release(); } -void SchedulerTestLayer::nextCallback(Object* sender) +void SchedulerTestLayer::nextCallback(Ref* sender) { auto scene = new SchedulerTestScene(); auto layer = nextSchedulerTest(); @@ -88,7 +88,7 @@ void SchedulerTestLayer::nextCallback(Object* sender) scene->release(); } -void SchedulerTestLayer::restartCallback(Object* sender) +void SchedulerTestLayer::restartCallback(Ref* sender) { auto scene = new SchedulerTestScene(); auto layer = restartSchedulerTest(); @@ -435,7 +435,9 @@ void SchedulerUnscheduleAllHard::onExit() if(!_actionManagerActive) { // Restore the director's action manager. auto director = Director::getInstance(); - director->getScheduler()->scheduleUpdateForTarget(director->getActionManager(), Scheduler::PRIORITY_SYSTEM, false); + director->getScheduler()->scheduleUpdate([director](float dt){ + director->getActionManager()->update(dt); + }, director->getActionManager(), Scheduler::PRIORITY_SYSTEM, false); } SchedulerTestLayer::onExit(); @@ -658,7 +660,7 @@ void SchedulerUpdate::removeUpdates(float dt) for (auto& c : children) { - auto obj = static_cast(c); + auto obj = static_cast(c); auto node = static_cast(obj); if (! node) @@ -834,7 +836,7 @@ ControlSlider* SchedulerTimeScale::sliderCtl() return slider; } -void SchedulerTimeScale::sliderAction(Object* sender, Control::EventType controlEvent) +void SchedulerTimeScale::sliderAction(Ref* sender, Control::EventType controlEvent) { ControlSlider* pSliderCtl = static_cast(sender); float scale; @@ -926,7 +928,7 @@ ControlSlider *TwoSchedulers::sliderCtl() return slider; } -void TwoSchedulers::sliderAction(Object* sender, Control::EventType controlEvent) +void TwoSchedulers::sliderAction(Ref* sender, Control::EventType controlEvent) { float scale; @@ -969,11 +971,15 @@ void TwoSchedulers::onEnter() // Create a new scheduler, and link it to the main scheduler sched1 = new Scheduler(); - defaultScheduler->scheduleUpdateForTarget(sched1, 0, false); + defaultScheduler->scheduleUpdate([this](float dt){ + this->sched1->update(dt); + }, sched1, 0, false); // Create a new ActionManager, and link it to the new scheudler actionManager1 = new ActionManager(); - sched1->scheduleUpdateForTarget(actionManager1, 0, false); + sched1->scheduleUpdate([this](float dt){ + this->actionManager1->update(dt); + }, actionManager1, 0, false); for( unsigned int i=0; i < 10; i++ ) { @@ -995,11 +1001,15 @@ void TwoSchedulers::onEnter() // Create a new scheduler, and link it to the main scheduler sched2 = new Scheduler();; - defaultScheduler->scheduleUpdateForTarget(sched2, 0, false); + defaultScheduler->scheduleUpdate([this](float dt){ + this->sched2->update(dt); + }, sched2, 0, false); // Create a new ActionManager, and link it to the new scheudler actionManager2 = new ActionManager(); - sched2->scheduleUpdateForTarget(actionManager2, 0, false); + sched2->scheduleUpdate([this](float dt){ + this->actionManager2->update(dt); + }, actionManager2, 0, false); for( unsigned int i=0; i < 10; i++ ) { auto sprite = Sprite::create("Images/grossinis_sister2.png"); diff --git a/tests/test-cpp/Classes/SchedulerTest/SchedulerTest.h b/tests/test-cpp/Classes/SchedulerTest/SchedulerTest.h index 6a428869e1..fb1782453a 100644 --- a/tests/test-cpp/Classes/SchedulerTest/SchedulerTest.h +++ b/tests/test-cpp/Classes/SchedulerTest/SchedulerTest.h @@ -16,9 +16,9 @@ public: virtual std::string title() const override; virtual std::string subtitle() const override; - void backCallback(Object* sender); - void nextCallback(Object* sender); - void restartCallback(Object* sender); + void backCallback(Ref* sender); + void nextCallback(Ref* sender); + void restartCallback(Ref* sender); }; // class SchedulerTestLayer : Layer @@ -79,7 +79,7 @@ public: void pause(float dt); void resume(float dt); private: - Vector _pausedTargets; + Vector _pausedTargets; }; class SchedulerPauseResumeAllUser : public SchedulerTestLayer @@ -99,7 +99,7 @@ public: void pause(float dt); void resume(float dt); private: - Vector _pausedTargets; + Vector _pausedTargets; }; class SchedulerUnscheduleAll : public SchedulerTestLayer @@ -258,7 +258,7 @@ public: virtual std::string title() const override; virtual std::string subtitle() const override; ControlSlider* sliderCtl(); - void sliderAction(Object* sender, Control::EventType controlEvent); + void sliderAction(Ref* sender, Control::EventType controlEvent); ControlSlider* _sliderCtl; }; @@ -273,7 +273,7 @@ public: virtual std::string subtitle() const override; void onEnter(); ControlSlider* sliderCtl(); - void sliderAction(Object* sender, Control::EventType controlEvent); + void sliderAction(Ref* sender, Control::EventType controlEvent); Scheduler *sched1; Scheduler *sched2; ActionManager *actionManager1; diff --git a/tests/test-cpp/Classes/ShaderTest/ShaderTest.cpp b/tests/test-cpp/Classes/ShaderTest/ShaderTest.cpp index c219f88f4a..0377617ae5 100644 --- a/tests/test-cpp/Classes/ShaderTest/ShaderTest.cpp +++ b/tests/test-cpp/Classes/ShaderTest/ShaderTest.cpp @@ -64,7 +64,7 @@ ShaderTestDemo::ShaderTestDemo() } -void ShaderTestDemo::backCallback(Object* sender) +void ShaderTestDemo::backCallback(Ref* sender) { auto s = new ShaderTestScene(); s->addChild( backAction() ); @@ -72,7 +72,7 @@ void ShaderTestDemo::backCallback(Object* sender) s->release(); } -void ShaderTestDemo::nextCallback(Object* sender) +void ShaderTestDemo::nextCallback(Ref* sender) { auto s = new ShaderTestScene();//CCScene::create(); s->addChild( nextAction() ); @@ -90,7 +90,7 @@ std::string ShaderTestDemo::subtitle() const return ""; } -void ShaderTestDemo::restartCallback(Object* sender) +void ShaderTestDemo::restartCallback(Ref* sender) { auto s = new ShaderTestScene(); s->addChild(restartAction()); @@ -636,7 +636,7 @@ bool ShaderBlur::init() return false; } -void ShaderBlur::sliderAction(Object* sender, Control::EventType controlEvent) +void ShaderBlur::sliderAction(Ref* sender, Control::EventType controlEvent) { ControlSlider* pSlider = (ControlSlider*)sender; _blurSprite->setBlurSize(pSlider->getValue()); diff --git a/tests/test-cpp/Classes/ShaderTest/ShaderTest.h b/tests/test-cpp/Classes/ShaderTest/ShaderTest.h index 741b0bb66f..9c28c6769b 100644 --- a/tests/test-cpp/Classes/ShaderTest/ShaderTest.h +++ b/tests/test-cpp/Classes/ShaderTest/ShaderTest.h @@ -15,9 +15,9 @@ public: virtual std::string title() const override; virtual std::string subtitle() const override; - void restartCallback(Object* sender); - void nextCallback(Object* sender); - void backCallback(Object* sender); + void restartCallback(Ref* sender); + void nextCallback(Ref* sender); + void backCallback(Ref* sender); CREATE_FUNC(ShaderTestDemo); }; @@ -91,7 +91,7 @@ public: virtual std::string subtitle() const override; virtual bool init(); ControlSlider* createSliderCtl(); - void sliderAction(Object* sender, Control::EventType controlEvent); + void sliderAction(Ref* sender, Control::EventType controlEvent); protected: SpriteBlur* _blurSprite; ControlSlider* _sliderCtl; diff --git a/tests/test-cpp/Classes/ShaderTest/ShaderTest2.cpp b/tests/test-cpp/Classes/ShaderTest/ShaderTest2.cpp index 9fb0ff3d87..755f2ce57c 100644 --- a/tests/test-cpp/Classes/ShaderTest/ShaderTest2.cpp +++ b/tests/test-cpp/Classes/ShaderTest/ShaderTest2.cpp @@ -61,21 +61,21 @@ ShaderTestDemo2::ShaderTestDemo2() } -void ShaderTestDemo2::backCallback(Object* sender) +void ShaderTestDemo2::backCallback(Ref* sender) { auto s = ShaderTestScene2::create(); s->addChild( ShaderTest2::backAction() ); Director::getInstance()->replaceScene(s); } -void ShaderTestDemo2::nextCallback(Object* sender) +void ShaderTestDemo2::nextCallback(Ref* sender) { auto s = ShaderTestScene2::create(); s->addChild( ShaderTest2::nextAction() ); Director::getInstance()->replaceScene(s); } -void ShaderTestDemo2::restartCallback(Object* sender) +void ShaderTestDemo2::restartCallback(Ref* sender) { auto s = ShaderTestScene2::create(); s->addChild(ShaderTest2::restartAction()); @@ -113,7 +113,7 @@ public: void setBackgroundNotification(); void draw(); - void listenBackToForeground(Object *obj); + void listenBackToForeground(Ref *obj); protected: virtual void buildCustomUniforms() = 0; diff --git a/tests/test-cpp/Classes/ShaderTest/ShaderTest2.h b/tests/test-cpp/Classes/ShaderTest/ShaderTest2.h index 9b63b46a27..75118fab6b 100644 --- a/tests/test-cpp/Classes/ShaderTest/ShaderTest2.h +++ b/tests/test-cpp/Classes/ShaderTest/ShaderTest2.h @@ -11,9 +11,9 @@ class ShaderTestDemo2 : public BaseTest public: ShaderTestDemo2(void); virtual std::string title() const { return "Shader Sprite!";} - void restartCallback(Object* sender); - void nextCallback(Object* sender); - void backCallback(Object* sender); + void restartCallback(Ref* sender); + void nextCallback(Ref* sender); + void backCallback(Ref* sender); }; class ShaderTestScene2 : public TestScene diff --git a/tests/test-cpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id b/tests/test-cpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id index e747e4ff8e..a0be51dd8c 100644 --- a/tests/test-cpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id +++ b/tests/test-cpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id @@ -1 +1 @@ -c098eac3962854bc7d1981ec16aad7d2907c0e33 \ No newline at end of file +dc22a9c6f7fee22f731cfe145212770b9a43b393 \ No newline at end of file diff --git a/tests/test-cpp/Classes/SpriteTest/SpriteTest.h b/tests/test-cpp/Classes/SpriteTest/SpriteTest.h index 05d171675f..ac232f7a86 100644 --- a/tests/test-cpp/Classes/SpriteTest/SpriteTest.h +++ b/tests/test-cpp/Classes/SpriteTest/SpriteTest.h @@ -39,9 +39,9 @@ public: SpriteTestDemo(void); virtual ~SpriteTestDemo(void); - void restartCallback(Object* sender); - void nextCallback(Object* sender); - void backCallback(Object* sender); + void restartCallback(Ref* sender); + void nextCallback(Ref* sender); + void backCallback(Ref* sender); // overrides virtual std::string title() const override; diff --git a/tests/test-cpp/Classes/TextInputTest/TextInputTest.cpp b/tests/test-cpp/Classes/TextInputTest/TextInputTest.cpp index 58ad739040..1d83603770 100644 --- a/tests/test-cpp/Classes/TextInputTest/TextInputTest.cpp +++ b/tests/test-cpp/Classes/TextInputTest/TextInputTest.cpp @@ -78,7 +78,7 @@ TextInputTest::TextInputTest() } -void TextInputTest::restartCallback(Object* sender) +void TextInputTest::restartCallback(Ref* sender) { auto s = new TextInputTestScene(); s->addChild(restartTextInputTest()); @@ -87,7 +87,7 @@ void TextInputTest::restartCallback(Object* sender) s->release(); } -void TextInputTest::nextCallback(Object* sender) +void TextInputTest::nextCallback(Ref* sender) { auto s = new TextInputTestScene(); s->addChild( nextTextInputTest() ); @@ -95,7 +95,7 @@ void TextInputTest::nextCallback(Object* sender) s->release(); } -void TextInputTest::backCallback(Object* sender) +void TextInputTest::backCallback(Ref* sender) { auto s = new TextInputTestScene(); s->addChild( backTextInputTest() ); diff --git a/tests/test-cpp/Classes/TextInputTest/TextInputTest.h b/tests/test-cpp/Classes/TextInputTest/TextInputTest.h index cc4bd10a0b..ec4ab40e34 100644 --- a/tests/test-cpp/Classes/TextInputTest/TextInputTest.h +++ b/tests/test-cpp/Classes/TextInputTest/TextInputTest.h @@ -15,9 +15,9 @@ class TextInputTest : public BaseTest public: TextInputTest(); - void restartCallback(Object* sender); - void nextCallback(Object* sender); - void backCallback(Object* sender); + void restartCallback(Ref* sender); + void nextCallback(Ref* sender); + void backCallback(Ref* sender); virtual std::string title() const; void addKeyboardNotificationLayer(KeyboardNotificationLayer * layer); diff --git a/tests/test-cpp/Classes/Texture2dTest/Texture2dTest.cpp b/tests/test-cpp/Classes/Texture2dTest/Texture2dTest.cpp index a4121f8825..fddc12ab41 100644 --- a/tests/test-cpp/Classes/Texture2dTest/Texture2dTest.cpp +++ b/tests/test-cpp/Classes/Texture2dTest/Texture2dTest.cpp @@ -166,21 +166,21 @@ TextureDemo::~TextureDemo() log("%s\n", textureCache->getCachedTextureInfo().c_str()); } -void TextureDemo::restartCallback(Object* sender) +void TextureDemo::restartCallback(Ref* sender) { auto s = TextureTestScene::create(); s->addChild(restartTextureTest()); Director::getInstance()->replaceScene(s); } -void TextureDemo::nextCallback(Object* sender) +void TextureDemo::nextCallback(Ref* sender) { auto s = TextureTestScene::create(); s->addChild(nextTextureTest()); Director::getInstance()->replaceScene(s); } -void TextureDemo::backCallback(Object* sender) +void TextureDemo::backCallback(Ref* sender) { auto s = TextureTestScene::create(); s->addChild(backTextureTest()); @@ -1924,7 +1924,7 @@ void TextureMemoryAlloc::onEnter() menu2->setPosition(Point(s.width/2, s.height/4)); } -void TextureMemoryAlloc::changeBackgroundVisible(cocos2d::Object *sender) +void TextureMemoryAlloc::changeBackgroundVisible(cocos2d::Ref *sender) { if (_background) { @@ -1932,7 +1932,7 @@ void TextureMemoryAlloc::changeBackgroundVisible(cocos2d::Object *sender) } } -void TextureMemoryAlloc::updateImage(cocos2d::Object *sender) +void TextureMemoryAlloc::updateImage(cocos2d::Ref *sender) { if (_background) { diff --git a/tests/test-cpp/Classes/Texture2dTest/Texture2dTest.h b/tests/test-cpp/Classes/Texture2dTest/Texture2dTest.h index c331e0d254..e65170675a 100644 --- a/tests/test-cpp/Classes/Texture2dTest/Texture2dTest.h +++ b/tests/test-cpp/Classes/Texture2dTest/Texture2dTest.h @@ -39,9 +39,9 @@ public: virtual std::string subtitle() const override; virtual void onEnter(); - void restartCallback(Object* sender); - void nextCallback(Object* sender); - void backCallback(Object* sender); + void restartCallback(Ref* sender); + void nextCallback(Ref* sender); + void backCallback(Ref* sender); }; class TextureTIFF : public TextureDemo @@ -504,8 +504,8 @@ public: virtual void onEnter(); virtual std::string title() const override; virtual std::string subtitle() const override; - void updateImage(Object *sender); - void changeBackgroundVisible(Object *sender); + void updateImage(Ref *sender); + void changeBackgroundVisible(Ref *sender); private: Sprite *_background; }; diff --git a/tests/test-cpp/Classes/TileMapTest/TileMapTest.cpp b/tests/test-cpp/Classes/TileMapTest/TileMapTest.cpp index 3142023399..cc67b6d984 100644 --- a/tests/test-cpp/Classes/TileMapTest/TileMapTest.cpp +++ b/tests/test-cpp/Classes/TileMapTest/TileMapTest.cpp @@ -118,7 +118,7 @@ void TileDemo::onEnter() BaseTest::onEnter(); } -void TileDemo::restartCallback(Object* sender) +void TileDemo::restartCallback(Ref* sender) { auto s = new TileMapTestScene(); s->addChild(restartTileMapAction()); @@ -127,7 +127,7 @@ void TileDemo::restartCallback(Object* sender) s->release(); } -void TileDemo::nextCallback(Object* sender) +void TileDemo::nextCallback(Ref* sender) { auto s = new TileMapTestScene(); s->addChild( nextTileMapAction() ); @@ -135,7 +135,7 @@ void TileDemo::nextCallback(Object* sender) s->release(); } -void TileDemo::backCallback(Object* sender) +void TileDemo::backCallback(Ref* sender) { auto s = new TileMapTestScene(); s->addChild( backTileMapAction() ); diff --git a/tests/test-cpp/Classes/TileMapTest/TileMapTest.h b/tests/test-cpp/Classes/TileMapTest/TileMapTest.h index 234c7b2e00..003b8f9598 100644 --- a/tests/test-cpp/Classes/TileMapTest/TileMapTest.h +++ b/tests/test-cpp/Classes/TileMapTest/TileMapTest.h @@ -15,9 +15,9 @@ public: virtual std::string subtitle() const override; virtual void onEnter(); - void restartCallback(Object* sender); - void nextCallback(Object* sender); - void backCallback(Object* sender); + void restartCallback(Ref* sender); + void nextCallback(Ref* sender); + void backCallback(Ref* sender); void onTouchesMoved(const std::vector& touches, Event *event); }; diff --git a/tests/test-cpp/Classes/TransitionsTest/TransitionsTest.cpp b/tests/test-cpp/Classes/TransitionsTest/TransitionsTest.cpp index 7c71d0799e..16a6c1e862 100644 --- a/tests/test-cpp/Classes/TransitionsTest/TransitionsTest.cpp +++ b/tests/test-cpp/Classes/TransitionsTest/TransitionsTest.cpp @@ -298,7 +298,7 @@ TestLayer1::~TestLayer1(void) } -void TestLayer1::restartCallback(Object* sender) +void TestLayer1::restartCallback(Ref* sender) { auto s = new TransitionsTestScene(); @@ -314,7 +314,7 @@ void TestLayer1::restartCallback(Object* sender) } } -void TestLayer1::nextCallback(Object* sender) +void TestLayer1::nextCallback(Ref* sender) { s_nSceneIdx++; s_nSceneIdx = s_nSceneIdx % MAX_LAYER; @@ -333,7 +333,7 @@ void TestLayer1::nextCallback(Object* sender) } } -void TestLayer1::backCallback(Object* sender) +void TestLayer1::backCallback(Ref* sender) { s_nSceneIdx--; int total = MAX_LAYER; @@ -427,7 +427,7 @@ TestLayer2::~TestLayer2() } -void TestLayer2::restartCallback(Object* sender) +void TestLayer2::restartCallback(Ref* sender) { auto s = new TransitionsTestScene(); @@ -443,7 +443,7 @@ void TestLayer2::restartCallback(Object* sender) } } -void TestLayer2::nextCallback(Object* sender) +void TestLayer2::nextCallback(Ref* sender) { s_nSceneIdx++; s_nSceneIdx = s_nSceneIdx % MAX_LAYER; @@ -462,7 +462,7 @@ void TestLayer2::nextCallback(Object* sender) } } -void TestLayer2::backCallback(Object* sender) +void TestLayer2::backCallback(Ref* sender) { s_nSceneIdx--; int total = MAX_LAYER; diff --git a/tests/test-cpp/Classes/TransitionsTest/TransitionsTest.h b/tests/test-cpp/Classes/TransitionsTest/TransitionsTest.h index c923409816..77cb3bc41e 100644 --- a/tests/test-cpp/Classes/TransitionsTest/TransitionsTest.h +++ b/tests/test-cpp/Classes/TransitionsTest/TransitionsTest.h @@ -42,9 +42,9 @@ public: TestLayer1(void); ~TestLayer1(void); - void restartCallback(Object* sender); - void nextCallback(Object* sender); - void backCallback(Object* sender); + void restartCallback(Ref* sender); + void nextCallback(Ref* sender); + void backCallback(Ref* sender); void step(float dt); @@ -60,9 +60,9 @@ public: TestLayer2(void); ~TestLayer2(void); - void restartCallback(Object* sender); - void nextCallback(Object* sender); - void backCallback(Object* sender); + void restartCallback(Ref* sender); + void nextCallback(Ref* sender); + void backCallback(Ref* sender); void step(float dt); diff --git a/tests/test-cpp/Classes/UnitTest/UnitTest.cpp b/tests/test-cpp/Classes/UnitTest/UnitTest.cpp index 20c2767b76..86933366b0 100644 --- a/tests/test-cpp/Classes/UnitTest/UnitTest.cpp +++ b/tests/test-cpp/Classes/UnitTest/UnitTest.cpp @@ -64,7 +64,7 @@ std::string UnitTestDemo::subtitle() const return ""; } -void UnitTestDemo::restartCallback(Object* sender) +void UnitTestDemo::restartCallback(Ref* sender) { auto s = new UnitTestScene(); s->addChild( restartAction() ); @@ -72,7 +72,7 @@ void UnitTestDemo::restartCallback(Object* sender) s->release(); } -void UnitTestDemo::nextCallback(Object* sender) +void UnitTestDemo::nextCallback(Ref* sender) { auto s = new UnitTestScene(); s->addChild( nextAction() ); @@ -80,7 +80,7 @@ void UnitTestDemo::nextCallback(Object* sender) s->release(); } -void UnitTestDemo::backCallback(Object* sender) +void UnitTestDemo::backCallback(Ref* sender) { auto s = new UnitTestScene(); s->addChild( backAction() ); diff --git a/tests/test-cpp/Classes/UnitTest/UnitTest.h b/tests/test-cpp/Classes/UnitTest/UnitTest.h index f969b11249..a116a58a58 100644 --- a/tests/test-cpp/Classes/UnitTest/UnitTest.h +++ b/tests/test-cpp/Classes/UnitTest/UnitTest.h @@ -19,9 +19,9 @@ public: virtual std::string title() const override; virtual std::string subtitle() const override; - virtual void restartCallback(Object* sender) override; - virtual void nextCallback(Object* sender) override; - virtual void backCallback(Object* sender) override; + virtual void restartCallback(Ref* sender) override; + virtual void nextCallback(Ref* sender) override; + virtual void backCallback(Ref* sender) override; }; //------------------------------------- diff --git a/tests/test-cpp/Classes/ZwoptexTest/ZwoptexTest.cpp b/tests/test-cpp/Classes/ZwoptexTest/ZwoptexTest.cpp index 1bbe291c2d..6687de06da 100644 --- a/tests/test-cpp/Classes/ZwoptexTest/ZwoptexTest.cpp +++ b/tests/test-cpp/Classes/ZwoptexTest/ZwoptexTest.cpp @@ -61,21 +61,21 @@ void ZwoptexTest::onEnter() BaseTest::onEnter(); } -void ZwoptexTest::restartCallback(Object* sender) +void ZwoptexTest::restartCallback(Ref* sender) { auto s = ZwoptexTestScene::create(); s->addChild(restartZwoptexTest()); Director::getInstance()->replaceScene(s); } -void ZwoptexTest::nextCallback(Object* sender) +void ZwoptexTest::nextCallback(Ref* sender) { auto s = ZwoptexTestScene::create(); s->addChild(nextZwoptexTest()); Director::getInstance()->replaceScene(s); } -void ZwoptexTest::backCallback(Object* sender) +void ZwoptexTest::backCallback(Ref* sender) { auto s = ZwoptexTestScene::create(); s->addChild(backZwoptexTest()); diff --git a/tests/test-cpp/Classes/ZwoptexTest/ZwoptexTest.h b/tests/test-cpp/Classes/ZwoptexTest/ZwoptexTest.h index a336154e48..aafdf51e4f 100644 --- a/tests/test-cpp/Classes/ZwoptexTest/ZwoptexTest.h +++ b/tests/test-cpp/Classes/ZwoptexTest/ZwoptexTest.h @@ -9,9 +9,9 @@ class ZwoptexTest : public BaseTest public: virtual void onEnter(); - void restartCallback(Object* sender); - void nextCallback(Object* sender); - void backCallback(Object* sender); + void restartCallback(Ref* sender); + void nextCallback(Ref* sender); + void backCallback(Ref* sender); virtual std::string title() const override; virtual std::string subtitle() const override; diff --git a/tests/test-cpp/Classes/controller.cpp b/tests/test-cpp/Classes/controller.cpp index f1f04ae2a2..3b85a9d847 100644 --- a/tests/test-cpp/Classes/controller.cpp +++ b/tests/test-cpp/Classes/controller.cpp @@ -150,7 +150,7 @@ TestController::~TestController() { } -void TestController::menuCallback(Object * sender) +void TestController::menuCallback(Ref * sender) { Director::getInstance()->purgeCachedData(); @@ -168,7 +168,7 @@ void TestController::menuCallback(Object * sender) } } -void TestController::closeCallback(Object * sender) +void TestController::closeCallback(Ref * sender) { Director::getInstance()->end(); #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) diff --git a/tests/test-cpp/Classes/controller.h b/tests/test-cpp/Classes/controller.h index 19947f20d5..37a190ef46 100644 --- a/tests/test-cpp/Classes/controller.h +++ b/tests/test-cpp/Classes/controller.h @@ -11,8 +11,8 @@ public: TestController(); ~TestController(); - void menuCallback(Object * sender); - void closeCallback(Object * sender); + void menuCallback(Ref * sender); + void closeCallback(Ref * sender); bool onTouchBegan(Touch* touches, Event *event); void onTouchMoved(Touch* touches, Event *event); diff --git a/tests/test-cpp/Classes/testBasic.cpp b/tests/test-cpp/Classes/testBasic.cpp index 54ba218a0a..4ce2c03d04 100644 --- a/tests/test-cpp/Classes/testBasic.cpp +++ b/tests/test-cpp/Classes/testBasic.cpp @@ -19,7 +19,7 @@ TestScene::TestScene(bool bPortrait, bool physics/* = false*/) } } -void testScene_callback( Object *sender ) +void testScene_callback(Ref *sender ) { auto scene = Scene::create(); diff --git a/tools/bindings-generator b/tools/bindings-generator index 14dab059dc..1ab5822935 160000 --- a/tools/bindings-generator +++ b/tools/bindings-generator @@ -1 +1 @@ -Subproject commit 14dab059dc8a20992c6e76ba8296a67601078d5b +Subproject commit 1ab5822935148df5af3a4654f6dbe844183a2372 diff --git a/tools/tojs/cocos2dx.ini b/tools/tojs/cocos2dx.ini index 32ed7f22ff..6e9c10f693 100644 --- a/tools/tojs/cocos2dx.ini +++ b/tools/tojs/cocos2dx.ini @@ -7,6 +7,8 @@ prefix = cocos2dx # all classes will be embedded in that namespace target_namespace = cc +cpp_namespace = cocos2d + android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include android_flags = -D_SIZE_T_DEFINED_ @@ -26,7 +28,7 @@ headers = %(cocosdir)s/cocos/2d/cocos2d.h %(cocosdir)s/cocos/audio/include/Simpl # what classes to produce code for. You can use regular expressions here. When testing the regular # expression, it will be enclosed in "^$", like this: "^Menu*$". -classes = New.* Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set SimpleAudioEngine Scheduler Timer Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode MotionStreak TextFieldTTF EGLViewProtocol EGLView Component __NodeRGBA __LayerRGBA SAXParser +classes = New.* Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set SimpleAudioEngine Scheduler Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode MotionStreak TextFieldTTF EGLViewProtocol EGLView Component __NodeRGBA __LayerRGBA SAXParser classes_need_extend = Node Layer.* Sprite MenuItemFont Scene DrawNode @@ -47,14 +49,14 @@ skip = Node::[^setPosition$ setGLServerState description getUserObject .*UserDat LayerColor::[getBlendFunc setBlendFunc], ParticleSystem::[getBlendFunc setBlendFunc], DrawNode::[getBlendFunc setBlendFunc drawPolygon listenBackToForeground], - Director::[getAccelerometer (g|s)et.*Dispatcher getOpenGLView getProjection getFrustum getRenderer], + Director::[getAccelerometer (g|s)et.*Dispatcher getOpenGLView getProjection getFrustum getRenderer getConsole], Layer.*::[didAccelerate (g|s)etBlendFunc keyPressed keyReleased], Menu.*::[.*Target getSubItems create initWithItems alignItemsInRows alignItemsInColumns], MenuItem.*::[create setCallback initWithCallback], Copying::[*], LabelProtocol::[*], LabelTextFormatProtocol::[*], - Label::[getLettersInfo createWithTTF setTTFConfig], + Label::[getLettersInfo createWithTTF setTTFConfig getFontAtlas], .*Delegate::[*], PoolManager::[*], Texture2D::[initWithPVRTCData addPVRTCImage releaseData setTexParameters initWithData keepData getPixelFormatInfoMap], @@ -63,7 +65,7 @@ skip = Node::[^setPosition$ setGLServerState description getUserObject .*UserDat Thread::[*], Profiler::[*], ProfilingTimer::[*], - CallFunc::[create initWithFunction], + CallFunc::[create initWithFunction (g|s)etTargetCallback], SAXParser::[(?!(init))], SAXDelegator::[*], Color3bObject::[*], @@ -103,14 +105,14 @@ skip = Node::[^setPosition$ setGLServerState description getUserObject .*UserDat CardinalSpline.*::[create actionWithDuration setPoints], Scheduler::[pause resume unschedule schedule update isTargetPaused], TextureCache::[addPVRTCImage addImageAsync], - Timer::[getSelector createWithScriptHandler], *::[copyWith.* onEnter.* onExit.* ^description$ getObjectType onTouch.* onAcc.* onKey.* onRegisterTouchListener], FileUtils::[(g|s)etSearchResolutionsOrder$ (g|s)etSearchPaths$ getFileData getDataFromFile getWritablePath setPopupNotify destroyInstance getFullPathCache], Application::[^application.* ^run$], Camera::[getEyeXYZ getCenterXYZ getUpXYZ], ccFontDefinition::[*], NewTextureAtlas::[*], - RenderTexture::[listenToBackground listenToForeground] + RenderTexture::[listenToBackground listenToForeground], + TextFieldTTF::[(g|s)etDelegate] rename_functions = SpriteFrameCache::[addSpriteFramesWithFile=addSpriteFrames getSpriteFrameByName=getSpriteFrame], MenuItemFont::[setFontNameObj=setFontName setFontSizeObj=setFontSize getFontSizeObj=getFontSize getFontNameObj=getFontName], @@ -139,7 +141,7 @@ remove_prefix = classes_have_no_parents = Node Director SimpleAudioEngine FileUtils TMXMapInfo Application EGLViewProtocol SAXParser # base classes which will be skipped when their sub-classes found them. -base_classes_to_skip = Object Clonable +base_classes_to_skip = Ref Clonable # classes that create no constructor # Set is special and we will use a hand-written constructor diff --git a/tools/tojs/cocos2dx_builder.ini b/tools/tojs/cocos2dx_builder.ini index 1e48bfd7aa..6a5764fed0 100644 --- a/tools/tojs/cocos2dx_builder.ini +++ b/tools/tojs/cocos2dx_builder.ini @@ -37,7 +37,7 @@ classes = CCBReader.* CCBAnimationManager.* # functions from all classes. skip = CCBReader::[^CCBReader$ addOwnerCallbackName isJSControlled readByte getCCBMemberVariableAssigner readFloat getCCBSelectorResolver toLowerCase lastPathComponent deletePathExtension endsWith concat getResolutionScale getAnimatedProperties readBool readInt addOwnerCallbackNode addDocumentCallbackName readCachedString readNodeGraphFromData addDocumentCallbackNode getLoadedSpriteSheet initWithData readFileWithCleanUp getOwner$ readNodeGraphFromFile createSceneWithNodeGraphFromFile getAnimationManagers$ setAnimationManagers], - CCBAnimationManager::[setAnimationCompletedCallback addNode], + CCBAnimationManager::[setAnimationCompletedCallback addNode getSequences getDelegate], .*Delegate::[*], .*Loader.*::[*], *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType .*HSV onTouch.* onAcc.* onKey.* onRegisterTouchListener] @@ -54,7 +54,7 @@ remove_prefix = classes_have_no_parents = # base classes which will be skipped when their sub-classes found them. -base_classes_to_skip = Object +base_classes_to_skip = Ref # classes that create no constructor # Set is special and we will use a hand-written constructor diff --git a/tools/tojs/cocos2dx_extension.ini b/tools/tojs/cocos2dx_extension.ini index 9c131621f5..0c50c1179c 100644 --- a/tools/tojs/cocos2dx_extension.ini +++ b/tools/tojs/cocos2dx_extension.ini @@ -62,7 +62,7 @@ remove_prefix = classes_have_no_parents = # base classes which will be skipped when their sub-classes found them. -base_classes_to_skip = Object +base_classes_to_skip = Ref # classes that create no constructor # Set is special and we will use a hand-written constructor diff --git a/tools/tojs/cocos2dx_gui.ini b/tools/tojs/cocos2dx_gui.ini index 0659c3469f..206b3ec28d 100644 --- a/tools/tojs/cocos2dx_gui.ini +++ b/tools/tojs/cocos2dx_gui.ini @@ -56,7 +56,7 @@ remove_prefix = classes_have_no_parents = Helper # base classes which will be skipped when their sub-classes found them. -base_classes_to_skip = Object +base_classes_to_skip = Ref # classes that create no constructor # Set is special and we will use a hand-written constructor diff --git a/tools/tojs/cocos2dx_studio.ini b/tools/tojs/cocos2dx_studio.ini index 4d4e9e6e60..83b140d0db 100644 --- a/tools/tojs/cocos2dx_studio.ini +++ b/tools/tojs/cocos2dx_studio.ini @@ -27,7 +27,7 @@ headers = %(cocosdir)s/cocos/editor-support/cocostudio/CocoStudio.h # what classes to produce code for. You can use regular expressions here. When testing the regular # expression, it will be enclosed in "^$", like this: "^Menu*$". -classes = Armature ArmatureAnimation Skin Bone ColliderDetector ColliderBody ArmatureDataManager InputDelegate ComController ComAudio ComAttribute ComRender ActionManagerEx SceneReader GUIReader BatchNode ActionObject BaseData Tween ColliderFilter DisplayManager +classes = Armature ArmatureAnimation Skin Bone ColliderDetector ColliderBody ArmatureDataManager InputDelegate ComController ComAudio ComAttribute ComRender ActionManagerEx SceneReader GUIReader BatchNode ActionObject BaseData Tween ColliderFilter DisplayManager ProcessBase # what should we skip? in the format ClassName::[function function] # ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also @@ -36,7 +36,7 @@ classes = Armature ArmatureAnimation Skin Bone ColliderDetector ColliderBody Arm # will apply to all class names. This is a convenience wildcard to be able to skip similar named # functions from all classes. -skip = *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType .*HSV onTouch.* onAcc.* onKey.* onRegisterTouchListener (s|g)etBlendFunc (s|g)etUserObject ccTouch.*], +skip = *::[createInstance ^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType .*HSV onTouch.* onAcc.* onKey.* onRegisterTouchListener (s|g)etBlendFunc (s|g)etUserObject ccTouch.*], InputDelegate::[didAccelerate on.*], GUIReader::[storeFileDesignSize getFileDesignSize], ComAttribute::[getDict], @@ -70,7 +70,7 @@ remove_prefix = classes_have_no_parents = InputDelegate SceneReader # base classes which will be skipped when their sub-classes found them. -base_classes_to_skip = Object ProcessBase +base_classes_to_skip = Ref # classes that create no constructor # Set is special and we will use a hand-written constructor diff --git a/tools/tolua/cocos2dx.ini b/tools/tolua/cocos2dx.ini index a4cf9a39e3..cc89c809f5 100644 --- a/tools/tolua/cocos2dx.ini +++ b/tools/tolua/cocos2dx.ini @@ -26,7 +26,7 @@ headers = %(cocosdir)s/cocos/2d/cocos2d.h %(cocosdir)s/cocos/audio/include/Simpl # what classes to produce code for. You can use regular expressions here. When testing the regular # expression, it will be enclosed in "^$", like this: "^Menu*$". -classes = New.* Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set SimpleAudioEngine Scheduler Timer Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode MotionStreak ^Object$ UserDefault EGLViewProtocol EGLView Image Event(?!.*(Physics).*).* Component +classes = New.* Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set SimpleAudioEngine Scheduler Timer Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode MotionStreak ^Ref$ UserDefault EGLViewProtocol EGLView Image Event(?!.*(Physics).*).* Component # what should we skip? in the format ClassName::[function function] # ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also @@ -106,7 +106,7 @@ skip = Node::[setGLServerState description getUserObject .*UserData getGLServerS Application::[^application.* ^run$], Camera::[getEyeXYZ getCenterXYZ getUpXYZ], ccFontDefinition::[*], - Object::[autorelease isEqual acceptVisitor update], + Ref::[autorelease isEqual acceptVisitor update], UserDefault::[getInstance (s|g)etDataForKey], EGLViewProtocol::[setTouchDelegate], EGLView::[end swapBuffers], diff --git a/tools/tolua/cocos2dx_extension.ini b/tools/tolua/cocos2dx_extension.ini index 248894593e..88effd6ec6 100644 --- a/tools/tolua/cocos2dx_extension.ini +++ b/tools/tolua/cocos2dx_extension.ini @@ -63,7 +63,7 @@ remove_prefix = classes_have_no_parents = # base classes which will be skipped when their sub-classes found them. -base_classes_to_skip = Object ProcessBase +base_classes_to_skip = Ref ProcessBase # classes that create no constructor # Set is special and we will use a hand-written constructor diff --git a/tools/tolua/cocos2dx_gui.ini b/tools/tolua/cocos2dx_gui.ini index 876afe3252..c15a4d0c05 100644 --- a/tools/tolua/cocos2dx_gui.ini +++ b/tools/tolua/cocos2dx_gui.ini @@ -57,7 +57,7 @@ remove_prefix = classes_have_no_parents = Helper # base classes which will be skipped when their sub-classes found them. -base_classes_to_skip = Object +base_classes_to_skip = Ref # classes that create no constructor # Set is special and we will use a hand-written constructor diff --git a/tools/tolua/cocos2dx_spine.ini b/tools/tolua/cocos2dx_spine.ini index 1cb6f5f3f7..6e644777f5 100644 --- a/tools/tolua/cocos2dx_spine.ini +++ b/tools/tolua/cocos2dx_spine.ini @@ -50,7 +50,7 @@ remove_prefix = classes_have_no_parents = # base classes which will be skipped when their sub-classes found them. -base_classes_to_skip = Object ProcessBase +base_classes_to_skip = Ref ProcessBase # classes that create no constructor # Set is special and we will use a hand-written constructor diff --git a/tools/tolua/cocos2dx_studio.ini b/tools/tolua/cocos2dx_studio.ini index 455f5da0ad..737ad22f98 100644 --- a/tools/tolua/cocos2dx_studio.ini +++ b/tools/tolua/cocos2dx_studio.ini @@ -68,7 +68,7 @@ remove_prefix = classes_have_no_parents = # base classes which will be skipped when their sub-classes found them. -base_classes_to_skip = Object ProcessBase +base_classes_to_skip = Ref ProcessBase # classes that create no constructor # Set is special and we will use a hand-written constructor