From 387ea1899c9738d877c9d61879a5b21c9724b6d6 Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 25 Jul 2013 15:03:44 +0800 Subject: [PATCH] issue #2404: Disabling warning of invoking deprecated methods in engine. Rename CCCallFuncND to __CCCallFuncND, and add deprecated typedef CCCallFuncND. Only disable warning for CCActionInstant.cpp and CCMenuItem.cpp #if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) #pragma GCC diagnostic ignored "-Wdeprecated-declarations" #elif _MSC_VER >= 1400 //vs 2005 or higher #pragma warning (push) #pragma warning (disable: 4996) #endif #if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) #pragma GCC diagnostic warning "-Wdeprecated-declarations" #elif _MSC_VER >= 1400 //vs 2005 or higher #pragma warning (pop) #endif --- cocos2dx/actions/CCActionInstant.cpp | 52 ++++++++++++++++------------ cocos2dx/actions/CCActionInstant.h | 32 +++++++++-------- cocos2dx/include/CCDeprecated.h | 2 ++ cocos2dx/menu_nodes/CCMenuItem.cpp | 13 +++++++ 4 files changed, 62 insertions(+), 37 deletions(-) diff --git a/cocos2dx/actions/CCActionInstant.cpp b/cocos2dx/actions/CCActionInstant.cpp index 01d0106833..b08af1d1e2 100644 --- a/cocos2dx/actions/CCActionInstant.cpp +++ b/cocos2dx/actions/CCActionInstant.cpp @@ -29,6 +29,13 @@ #include "sprite_nodes/CCSprite.h" #include "script_support/CCScriptSupport.h" +#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#elif _MSC_VER >= 1400 //vs 2005 or higher +#pragma warning (push) +#pragma warning (disable: 4996) +#endif + NS_CC_BEGIN // // InstantAction @@ -476,13 +483,10 @@ CallFuncN * CallFuncN::clone() const // // CallFuncND // -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) -#pragma warning (push) -#pragma warning (disable: 4996) -#endif -CCCallFuncND * CCCallFuncND::create(Object* selectorTarget, SEL_CallFuncND selector, void* d) + +__CCCallFuncND * __CCCallFuncND::create(Object* selectorTarget, SEL_CallFuncND selector, void* d) { - CCCallFuncND* pRet = new CCCallFuncND(); + __CCCallFuncND* pRet = new __CCCallFuncND(); if (pRet && pRet->initWithTarget(selectorTarget, selector, d)) { pRet->autorelease(); @@ -493,7 +497,7 @@ CCCallFuncND * CCCallFuncND::create(Object* selectorTarget, SEL_CallFuncND selec return NULL; } -bool CCCallFuncND::initWithTarget(Object* selectorTarget, SEL_CallFuncND selector, void* d) +bool __CCCallFuncND::initWithTarget(Object* selectorTarget, SEL_CallFuncND selector, void* d) { if (CallFunc::initWithTarget(selectorTarget)) { @@ -505,7 +509,7 @@ bool CCCallFuncND::initWithTarget(Object* selectorTarget, SEL_CallFuncND selecto return false; } -void CCCallFuncND::execute() +void __CCCallFuncND::execute() { if (_callFuncND) { @@ -513,10 +517,10 @@ void CCCallFuncND::execute() } } -CCCallFuncND * CCCallFuncND::clone() const +__CCCallFuncND * __CCCallFuncND::clone() const { // no copy constructor - auto a = new CCCallFuncND(); + auto a = new __CCCallFuncND(); if( _selectorTarget) { @@ -530,26 +534,26 @@ CCCallFuncND * CCCallFuncND::clone() const // // CallFuncO // -CCCallFuncO::CCCallFuncO() : +__CCCallFuncO::__CCCallFuncO() : _object(NULL) { } -CCCallFuncO::~CCCallFuncO() +__CCCallFuncO::~__CCCallFuncO() { CC_SAFE_RELEASE(_object); } -void CCCallFuncO::execute() +void __CCCallFuncO::execute() { if (_callFuncO) { (_selectorTarget->*_callFuncO)(_object); } } -CCCallFuncO * CCCallFuncO::create(Object* selectorTarget, SEL_CallFuncO selector, Object* object) +__CCCallFuncO * __CCCallFuncO::create(Object* selectorTarget, SEL_CallFuncO selector, Object* object) { - CCCallFuncO *pRet = new CCCallFuncO(); + __CCCallFuncO *pRet = new __CCCallFuncO(); if (pRet && pRet->initWithTarget(selectorTarget, selector, object)) { pRet->autorelease(); @@ -560,7 +564,7 @@ CCCallFuncO * CCCallFuncO::create(Object* selectorTarget, SEL_CallFuncO selector return NULL; } -bool CCCallFuncO::initWithTarget(Object* selectorTarget, SEL_CallFuncO selector, Object* object) +bool __CCCallFuncO::initWithTarget(Object* selectorTarget, SEL_CallFuncO selector, Object* object) { if (CallFunc::initWithTarget(selectorTarget)) { @@ -574,10 +578,10 @@ bool CCCallFuncO::initWithTarget(Object* selectorTarget, SEL_CallFuncO selector, return false; } -CCCallFuncO * CCCallFuncO::clone() const +__CCCallFuncO * __CCCallFuncO::clone() const { // no copy constructor - auto a = new CCCallFuncO(); + auto a = new __CCCallFuncO(); if( _selectorTarget) { @@ -588,12 +592,12 @@ CCCallFuncO * CCCallFuncO::clone() const return a; } -Object* CCCallFuncO::getObject() const +Object* __CCCallFuncO::getObject() const { return _object; } -void CCCallFuncO::setObject(Object* obj) +void __CCCallFuncO::setObject(Object* obj) { if (obj != _object) { @@ -603,8 +607,10 @@ void CCCallFuncO::setObject(Object* obj) } } -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) +NS_CC_END + +#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) +#pragma GCC diagnostic warning "-Wdeprecated-declarations" +#elif _MSC_VER >= 1400 //vs 2005 or higher #pragma warning (pop) #endif - -NS_CC_END diff --git a/cocos2dx/actions/CCActionInstant.h b/cocos2dx/actions/CCActionInstant.h index e034ceae1f..aaf8998dda 100644 --- a/cocos2dx/actions/CCActionInstant.h +++ b/cocos2dx/actions/CCActionInstant.h @@ -347,24 +347,26 @@ protected: * ND means: Node and Data. Data is void *, so it could be anything. */ -class CC_DLL CC_DEPRECATED_ATTRIBUTE CCCallFuncND : public CallFunc +class CC_DLL __CCCallFuncND : public CallFunc { public: /** creates the action with the callback and the data to pass as an argument */ - static CCCallFuncND * create(Object* selectorTarget, SEL_CallFuncND selector, void* d); + CC_DEPRECATED_ATTRIBUTE static __CCCallFuncND * create(Object* selectorTarget, SEL_CallFuncND selector, void* d); virtual long getClassTypeInfo() { static const long id = cocos2d::getHashCodeByString(typeid(cocos2d::CallFunc).name()); return id; } +protected: /** initializes the action with the callback and the data to pass as an argument */ bool initWithTarget(Object* selectorTarget, SEL_CallFuncND selector, void* d); +public: // // Overrides // - virtual CCCallFuncND* clone() const override; + virtual __CCCallFuncND* clone() const override; virtual void execute() override; protected: @@ -380,33 +382,35 @@ protected: @since v0.99.5 */ -class CC_DLL CC_DEPRECATED_ATTRIBUTE CCCallFuncO : public CallFunc, public TypeInfo +class CC_DLL __CCCallFuncO : public CallFunc, public TypeInfo { public: /** creates the action with the callback typedef void (Object::*SEL_CallFuncO)(Object*); */ - static CCCallFuncO * create(Object* selectorTarget, SEL_CallFuncO selector, Object* object); + CC_DEPRECATED_ATTRIBUTE static __CCCallFuncO * create(Object* selectorTarget, SEL_CallFuncO selector, Object* object); - CCCallFuncO(); - virtual ~CCCallFuncO(); - - /** initializes the action with the callback - - typedef void (Object::*SEL_CallFuncO)(Object*); - */ - bool initWithTarget(Object* selectorTarget, SEL_CallFuncO selector, Object* object); + __CCCallFuncO(); + virtual ~__CCCallFuncO(); virtual long getClassTypeInfo() { static const long id = cocos2d::getHashCodeByString(typeid(cocos2d::CallFunc).name()); return id; } +protected: + /** initializes the action with the callback + + typedef void (Object::*SEL_CallFuncO)(Object*); + */ + bool initWithTarget(Object* selectorTarget, SEL_CallFuncO selector, Object* object); + +public: // // Overrides // - virtual CCCallFuncO* clone() const override; + virtual __CCCallFuncO* clone() const override; virtual void execute() override; Object* getObject() const; diff --git a/cocos2dx/include/CCDeprecated.h b/cocos2dx/include/CCDeprecated.h index d4ac8f52ad..3c49dab190 100644 --- a/cocos2dx/include/CCDeprecated.h +++ b/cocos2dx/include/CCDeprecated.h @@ -623,6 +623,8 @@ CC_DEPRECATED_ATTRIBUTE typedef FlipY CCFlipY; CC_DEPRECATED_ATTRIBUTE typedef Place CCPlace; CC_DEPRECATED_ATTRIBUTE typedef CallFunc CCCallFunc; CC_DEPRECATED_ATTRIBUTE typedef CallFuncN CCCallFuncN; +CC_DEPRECATED_ATTRIBUTE typedef __CCCallFuncND CCCallFuncND; +CC_DEPRECATED_ATTRIBUTE typedef __CCCallFuncO CCCallFuncO; CC_DEPRECATED_ATTRIBUTE typedef GridAction CCGridAction; CC_DEPRECATED_ATTRIBUTE typedef Grid3DAction CCGrid3DAction; CC_DEPRECATED_ATTRIBUTE typedef TiledGrid3DAction CCTiledGrid3DAction; diff --git a/cocos2dx/menu_nodes/CCMenuItem.cpp b/cocos2dx/menu_nodes/CCMenuItem.cpp index 2bfbf933c5..37747938e9 100644 --- a/cocos2dx/menu_nodes/CCMenuItem.cpp +++ b/cocos2dx/menu_nodes/CCMenuItem.cpp @@ -33,6 +33,13 @@ THE SOFTWARE. #include #include +#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#elif _MSC_VER >= 1400 //vs 2005 or higher +#pragma warning (push) +#pragma warning (disable: 4996) +#endif + NS_CC_BEGIN static unsigned int _globalFontSize = kItemSize; @@ -986,3 +993,9 @@ MenuItem* MenuItemToggle::getSelectedItem() } NS_CC_END + +#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) +#pragma GCC diagnostic warning "-Wdeprecated-declarations" +#elif _MSC_VER >= 1400 //vs 2005 or higher +#pragma warning (pop) +#endif