From 23574172ffceb38552b36a5e8d5a0f47ba8b2b80 Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 14 Jun 2012 16:05:58 +0800 Subject: [PATCH] issue #1324: Added create() for static member functions that new an autorelease object, updated cocoa folder. --- cocos2dx/CCCamera.cpp | 2 +- cocos2dx/CCScheduler.cpp | 2 +- cocos2dx/actions/CCAction.cpp | 2 +- cocos2dx/actions/CCActionInterval.cpp | 2 +- cocos2dx/base_nodes/CCNode.cpp | 4 +- cocos2dx/cocoa/CCArray.cpp | 78 ++++++++++++++++--- cocos2dx/cocoa/CCArray.h | 49 ++++++++++-- cocos2dx/cocoa/CCData.cpp | 75 ------------------ cocos2dx/cocoa/CCData.h | 51 ------------ cocos2dx/cocoa/CCDictionary.cpp | 43 +++++++--- cocos2dx/cocoa/CCDictionary.h | 27 ++++++- cocos2dx/cocoa/CCInteger.h | 8 +- cocos2dx/cocoa/CCString.cpp | 42 ++++++++-- cocos2dx/cocoa/CCString.h | 39 ++++++++-- .../extensions/CCBReader/CCBReader_v2.cpp | 2 +- .../CCControlExtension/CCControl.cpp | 2 +- .../CCControlExtension/CCControlButton.cpp | 2 +- .../CCNotificationCenter.cpp | 2 +- cocos2dx/include/cocos2d.h | 1 - .../keypad_dispatcher/CCKeypadDispatcher.cpp | 2 +- cocos2dx/label_nodes/CCLabelAtlas.cpp | 2 +- cocos2dx/label_nodes/CCLabelBMFont.cpp | 4 +- cocos2dx/label_nodes/CCLabelTTF.cpp | 2 +- .../CCLayer.cpp | 4 +- cocos2dx/menu_nodes/CCMenu.cpp | 2 +- cocos2dx/menu_nodes/CCMenuItem.cpp | 4 +- cocos2dx/misc_nodes/CCRenderTexture.h | 1 - cocos2dx/particle_nodes/CCParticleSystem.cpp | 2 +- cocos2dx/platform/CCImageCommon_cpp.h | 4 +- cocos2dx/platform/CCPlatformMacros.h | 2 +- cocos2dx/platform/CCSAXParser.cpp | 2 +- cocos2dx/proj.win32/cocos2d-win32.vcproj | 8 -- cocos2dx/shaders/CCGLProgram.cpp | 8 +- cocos2dx/sprite_nodes/CCAnimation.cpp | 4 +- cocos2dx/sprite_nodes/CCAnimationCache.cpp | 6 +- cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp | 14 ++-- cocos2dx/support/image_support/TGAlib.cpp | 2 +- cocos2dx/support/zip_support/ZipUtils.cpp | 2 +- cocos2dx/textures/CCTexture2D.cpp | 2 +- cocos2dx/textures/CCTextureAtlas.cpp | 2 +- cocos2dx/textures/CCTextureCache.cpp | 13 ++-- cocos2dx/textures/CCTexturePVR.cpp | 3 +- cocos2dx/textures/CCTexturePVR.h | 3 - .../tileMap_parallax_nodes/CCTMXLayer.cpp | 2 +- .../CCTMXObjectGroup.cpp | 2 +- .../tileMap_parallax_nodes/CCTMXXMLParser.cpp | 14 +--- .../tileMap_parallax_nodes/CCTMXXMLParser.h | 3 - .../tileMap_parallax_nodes/CCTileMapAtlas.cpp | 6 +- .../touch_dispatcher/CCTouchDispatcher.cpp | 6 +- .../CCControlButtonTest.cpp | 20 ++--- .../CCControlColourPickerTest.cpp | 2 +- .../CCControlSliderTest.cpp | 2 +- tests/tests/LabelTest/LabelTest.cpp | 6 +- .../PerformanceNodeChildrenTest.cpp | 6 +- tests/tests/ShaderTest/ShaderTest.cpp | 4 +- .../SpriteTest/SpriteTest.cpp.REMOVED.git-id | 2 +- tests/tests/TileMapTest/TileMapTest.cpp | 2 +- tests/tests/TouchesTest/TouchesTest.cpp | 2 +- 58 files changed, 326 insertions(+), 284 deletions(-) delete mode 100644 cocos2dx/cocoa/CCData.cpp delete mode 100644 cocos2dx/cocoa/CCData.h diff --git a/cocos2dx/CCCamera.cpp b/cocos2dx/CCCamera.cpp index 5b4cd0e8c9..7637779267 100644 --- a/cocos2dx/CCCamera.cpp +++ b/cocos2dx/CCCamera.cpp @@ -46,7 +46,7 @@ CCCamera::~CCCamera(void) const char* CCCamera::description(void) { - return CCString::stringWithFormat("", m_fCenterX, m_fCenterY, m_fCenterZ)->getCString(); + return CCString::createWithFormat("", m_fCenterX, m_fCenterY, m_fCenterZ)->getCString(); } void CCCamera::init(void) diff --git a/cocos2dx/CCScheduler.cpp b/cocos2dx/CCScheduler.cpp index 72bcd0d762..0ac01bac5d 100644 --- a/cocos2dx/CCScheduler.cpp +++ b/cocos2dx/CCScheduler.cpp @@ -604,7 +604,7 @@ unsigned int CCScheduler::scheduleScriptFunc(unsigned int nHandler, float fInter CCSchedulerScriptHandlerEntry* pEntry = CCSchedulerScriptHandlerEntry::entryWithHandler(nHandler, fInterval, bPaused); if (!m_pScriptHandlerEntries) { - m_pScriptHandlerEntries = CCArray::arrayWithCapacity(20); + m_pScriptHandlerEntries = CCArray::create(20); m_pScriptHandlerEntries->retain(); } m_pScriptHandlerEntries->addObject(pEntry); diff --git a/cocos2dx/actions/CCAction.cpp b/cocos2dx/actions/CCAction.cpp index 2d0bf2d621..45b60b6821 100644 --- a/cocos2dx/actions/CCAction.cpp +++ b/cocos2dx/actions/CCAction.cpp @@ -64,7 +64,7 @@ CCAction* CCAction::create() const char* CCAction::description() { - return CCString::stringWithFormat("", m_nTag)->getCString(); + return CCString::createWithFormat("", m_nTag)->getCString(); } CCObject* CCAction::copyWithZone(CCZone *pZone) diff --git a/cocos2dx/actions/CCActionInterval.cpp b/cocos2dx/actions/CCActionInterval.cpp index dc10b21cc2..3f9e1ab6a7 100644 --- a/cocos2dx/actions/CCActionInterval.cpp +++ b/cocos2dx/actions/CCActionInterval.cpp @@ -2531,7 +2531,7 @@ void CCAnimate::update(float t) CCActionInterval* CCAnimate::reverse(void) { CCArray* pOldArray = m_pAnimation->getFrames(); - CCArray* pNewArray = CCArray::arrayWithCapacity(pOldArray->count()); + CCArray* pNewArray = CCArray::create(pOldArray->count()); CCARRAY_VERIFY_TYPE(pOldArray, CCAnimationFrame*); diff --git a/cocos2dx/base_nodes/CCNode.cpp b/cocos2dx/base_nodes/CCNode.cpp index 8b709a830a..6b1c7b914b 100644 --- a/cocos2dx/base_nodes/CCNode.cpp +++ b/cocos2dx/base_nodes/CCNode.cpp @@ -462,13 +462,13 @@ void CCNode::cleanup() const char* CCNode::description() { - return CCString::stringWithFormat("", m_nTag)->getCString(); + return CCString::createWithFormat("", m_nTag)->getCString(); } // lazy allocs void CCNode::childrenAlloc(void) { - m_pChildren = CCArray::arrayWithCapacity(4); + m_pChildren = CCArray::create(4); m_pChildren->retain(); } diff --git a/cocos2dx/cocoa/CCArray.cpp b/cocos2dx/cocoa/CCArray.cpp index c390878178..314f3e3ba9 100644 --- a/cocos2dx/cocoa/CCArray.cpp +++ b/cocos2dx/cocoa/CCArray.cpp @@ -40,7 +40,12 @@ CCArray::CCArray(unsigned int capacity) initWithCapacity(capacity); } -CCArray* CCArray::array() +// CCArray* CCArray::array() +// { +// return CCArray::create(); +// } + +CCArray* CCArray::create() { CCArray* pArray = new CCArray(); @@ -56,7 +61,12 @@ CCArray* CCArray::array() return pArray; } -CCArray* CCArray::arrayWithObject(CCObject* pObject) +// CCArray* CCArray::arrayWithObject(CCObject* pObject) +// { +// return CCArray::createWithObject(pObject); +// } + +CCArray* CCArray::createWithObject(CCObject* pObject) { CCArray* pArray = new CCArray(); @@ -72,12 +82,38 @@ CCArray* CCArray::arrayWithObject(CCObject* pObject) return pArray; } -CCArray* CCArray::arrayWithObjects(CCObject* pObject, ...) +// CCArray* CCArray::arrayWithObjects(CCObject* pObject, ...) +// { +// va_list args; +// va_start(args,pObject); +// +// CCArray* pArray = create(); +// if (pArray && pObject) +// { +// pArray->addObject(pObject); +// CCObject *i = va_arg(args, CCObject*); +// while(i) +// { +// pArray->addObject(i); +// i = va_arg(args, CCObject*); +// } +// } +// else +// { +// CC_SAFE_DELETE(pArray); +// } +// +// va_end(args); +// +// return pArray; +// } + +CCArray* CCArray::create(CCObject* pObject, ...) { va_list args; va_start(args,pObject); - - CCArray* pArray = array(); + + CCArray* pArray = create(); if (pArray && pObject) { pArray->addObject(pObject); @@ -94,11 +130,16 @@ CCArray* CCArray::arrayWithObjects(CCObject* pObject, ...) } va_end(args); - + return pArray; } -CCArray* CCArray::arrayWithCapacity(unsigned int capacity) +// CCArray* CCArray::arrayWithCapacity(unsigned int capacity) +// { +// return CCArray::create(capacity); +// } + +CCArray* CCArray::create(unsigned int capacity) { CCArray* pArray = new CCArray(); @@ -114,16 +155,26 @@ CCArray* CCArray::arrayWithCapacity(unsigned int capacity) return pArray; } -CCArray* CCArray::arrayWithArray(CCArray* otherArray) +// CCArray* CCArray::arrayWithArray(CCArray* otherArray) +// { +// return CCArray::create(otherArray); +// } + +CCArray* CCArray::create(CCArray* otherArray) { CCArray* pRet = (CCArray*)otherArray->copy(); pRet->autorelease(); return pRet; } -CCArray* CCArray::arrayWithContentsOfFile(const char* pFileName) +// CCArray* CCArray::arrayWithContentsOfFile(const char* pFileName) +// { +// return CCArray::createWithContentsOfFile(pFileName); +// } + +CCArray* CCArray::createWithContentsOfFile(const char* pFileName) { - CCArray* pRet = arrayWithContentsOfFileThreadSafe(pFileName); + CCArray* pRet = createWithContentsOfFileThreadSafe(pFileName); if (pRet != NULL) { pRet->autorelease(); @@ -133,7 +184,12 @@ CCArray* CCArray::arrayWithContentsOfFile(const char* pFileName) extern CCArray* ccFileUtils_arrayWithContentsOfFileThreadSafe(const char* pFileName); -CCArray* CCArray::arrayWithContentsOfFileThreadSafe(const char* pFileName) +// CCArray* CCArray::arrayWithContentsOfFileThreadSafe(const char* pFileName) +// { +// return CCArray::createWithContentsOfFileThreadSafe(pFileName); +// } + +CCArray* CCArray::createWithContentsOfFileThreadSafe(const char* pFileName) { return ccFileUtils_arrayWithContentsOfFileThreadSafe(pFileName); } diff --git a/cocos2dx/cocoa/CCArray.h b/cocos2dx/cocoa/CCArray.h index 500cd82585..3642bd8da0 100644 --- a/cocos2dx/cocoa/CCArray.h +++ b/cocos2dx/cocoa/CCArray.h @@ -110,28 +110,63 @@ public: ~CCArray(); /* static functions */ + /** Create an array + @warning: This interface will be deprecated in future. + */ + //static CCArray* array(); + /** Create an array with one object + @warning: This interface will be deprecated in future. + */ + //static CCArray* arrayWithObject(CCObject* pObject); + /** Create an array with some objects + @warning: This interface will be deprecated in future. + */ + //static CCArray* arrayWithObjects(CCObject* pObject, ...); + /** Create an array with capacity + @warning: This interface will be deprecated in future. + */ + //static CCArray* arrayWithCapacity(unsigned int capacity); + /** Create an array with an existing array + @warning: This interface will be deprecated in future. + */ + //static CCArray* arrayWithArray(CCArray* otherArray); + /** + @brief Generate a CCArray pointer by file + @param pFileName The file name of *.plist file + @return The CCArray pointer generated from the file + @warning: This interface will be deprecated in future. + */ + //static CCArray* arrayWithContentsOfFile(const char* pFileName); + + /* + @brief The same meaning as arrayWithContentsOfFile(), but it doesn't call autorelease, so the + invoker should call release(). + @warning: This interface will be deprecated in future. + */ + //static CCArray* arrayWithContentsOfFileThreadSafe(const char* pFileName); + /** Create an array */ - static CCArray* array(); + static CCArray* create(); /** Create an array with one object */ - static CCArray* arrayWithObject(CCObject* pObject); + static CCArray* createWithObject(CCObject* pObject); /** Create an array with some objects */ - static CCArray* arrayWithObjects(CCObject* pObject, ...); + static CCArray* create(CCObject* pObject, ...); /** Create an array with capacity */ - static CCArray* arrayWithCapacity(unsigned int capacity); + static CCArray* create(unsigned int capacity); /** Create an array with an existing array */ - static CCArray* arrayWithArray(CCArray* otherArray); + static CCArray* create(CCArray* otherArray); /** @brief Generate a CCArray pointer by file @param pFileName The file name of *.plist file @return The CCArray pointer generated from the file */ - static CCArray* arrayWithContentsOfFile(const char* pFileName); + static CCArray* createWithContentsOfFile(const char* pFileName); /* @brief The same meaning as arrayWithContentsOfFile(), but it doesn't call autorelease, so the invoker should call release(). */ - static CCArray* arrayWithContentsOfFileThreadSafe(const char* pFileName); + static CCArray* createWithContentsOfFileThreadSafe(const char* pFileName); /** Initializes an array */ bool init(); diff --git a/cocos2dx/cocoa/CCData.cpp b/cocos2dx/cocoa/CCData.cpp deleted file mode 100644 index 89b390ce1d..0000000000 --- a/cocos2dx/cocoa/CCData.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - - -#include "CCData.h" -#include "CCFileUtils.h" - -#include - -using namespace std; - -NS_CC_BEGIN - -CCData::CCData(void) -: m_pData(NULL) -{ -} - -CCData::~CCData(void) -{ - CC_SAFE_DELETE_ARRAY(m_pData); -} - -CCData* CCData::dataWithContentsOfFile(const string &strPath) -{ - unsigned long nSize; - unsigned char *pBuffer = CCFileUtils::sharedFileUtils()->sharedFileUtils()->getFileData(strPath.c_str(), "rb", &nSize); - - if (! pBuffer) - { - return NULL; - } - - CCData *pRet = new CCData(); - pRet->m_pData = new char[nSize]; - memcpy(pRet->m_pData, pBuffer, nSize); - - return pRet; -} - -void* CCData::bytes(void) -{ - return m_pData; -} - -//@todo implement -CCData* CCData::dataWithBytes(unsigned char *pBytes, int size) -{ - CC_UNUSED_PARAM(pBytes); - CC_UNUSED_PARAM(size); - return NULL; -} - -NS_CC_END diff --git a/cocos2dx/cocoa/CCData.h b/cocos2dx/cocoa/CCData.h deleted file mode 100644 index cfbd20e6d9..0000000000 --- a/cocos2dx/cocoa/CCData.h +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - -#ifndef __CCDATA_H__ -#define __CCDATA_H__ - -#include "CCObject.h" -#include - -NS_CC_BEGIN - -class CC_DLL CCData : public CCObject -{ -public: - CCData(void); - ~CCData(void); - - void* bytes(void); - -public: - static CCData* dataWithBytes(unsigned char *pBytes, int size); - static CCData* dataWithContentsOfFile(const std::string &strPath); - -private: - char *m_pData; -}; - -NS_CC_END - -#endif //__CCDATA_H__ diff --git a/cocos2dx/cocoa/CCDictionary.cpp b/cocos2dx/cocoa/CCDictionary.cpp index e83591c114..97be4a3e1f 100644 --- a/cocos2dx/cocoa/CCDictionary.cpp +++ b/cocos2dx/cocoa/CCDictionary.cpp @@ -28,7 +28,8 @@ CCArray* CCDictionary::allKeys() { int iKeyCount = this->count(); if (iKeyCount <= 0) return NULL; - CCArray* pArray = CCArray::arrayWithCapacity(iKeyCount); + + CCArray* pArray = CCArray::create(iKeyCount); CCDictElement *pElement, *tmp; if (m_eDictType == kCCDictStr) @@ -57,7 +58,7 @@ CCArray* CCDictionary::allKeysForObject(CCObject* object) { int iKeyCount = this->count(); if (iKeyCount <= 0) return NULL; - CCArray* pArray = CCArray::array(); + CCArray* pArray = CCArray::create(); CCDictElement *pElement, *tmp; @@ -68,8 +69,8 @@ CCArray* CCDictionary::allKeysForObject(CCObject* object) if (object == pElement->m_pObject) { CCString* pOneKey = new CCString(pElement->m_szKey); - pOneKey->autorelease(); pArray->addObject(pOneKey); + pOneKey->release(); } } } @@ -80,8 +81,8 @@ CCArray* CCDictionary::allKeysForObject(CCObject* object) if (object == pElement->m_pObject) { CCInteger* pOneKey = new CCInteger(pElement->m_iKey); - pOneKey->autorelease(); pArray->addObject(pOneKey); + pOneKey->release(); } } } @@ -123,7 +124,7 @@ const CCString* CCDictionary::valueForKey(const std::string& key) CCString* pStr = (CCString*)objectForKey(key); if (pStr == NULL) { - pStr = CCString::stringWithCString(""); + pStr = CCString::create(""); } return pStr; } @@ -133,7 +134,7 @@ const CCString* CCDictionary::valueForKey(int key) CCString* pStr = (CCString*)objectForKey(key); if (pStr == NULL) { - pStr = CCString::stringWithCString(""); + pStr = CCString::create(""); } return pStr; } @@ -291,7 +292,12 @@ CCObject* CCDictionary::copyWithZone(CCZone* pZone) return pNewDict; } -CCDictionary* CCDictionary::dictionary() +// CCDictionary* CCDictionary::dictionary() +// { +// return CCDictionary::create(); +// } + +CCDictionary* CCDictionary::create() { CCDictionary* pRet = new CCDictionary(); if (pRet != NULL) @@ -301,7 +307,12 @@ CCDictionary* CCDictionary::dictionary() return pRet; } -CCDictionary* CCDictionary::dictionaryWithDictionary(CCDictionary* srcDict) +// CCDictionary* CCDictionary::dictionaryWithDictionary(CCDictionary* srcDict) +// { +// return CCDictionary::createWithDictionary(srcDict); +// } + +CCDictionary* CCDictionary::createWithDictionary(CCDictionary* srcDict) { CCDictionary* pNewDict = (CCDictionary*)srcDict->copy(); pNewDict->autorelease(); @@ -310,14 +321,24 @@ CCDictionary* CCDictionary::dictionaryWithDictionary(CCDictionary* srcDict) extern CCDictionary* ccFileUtils_dictionaryWithContentsOfFileThreadSafe(const char *pFileName); -CCDictionary* CCDictionary::dictionaryWithContentsOfFileThreadSafe(const char *pFileName) +// CCDictionary* CCDictionary::dictionaryWithContentsOfFileThreadSafe(const char *pFileName) +// { +// return CCDictionary::createWithContentsOfFileThreadSafe(pFileName); +// } + +CCDictionary* CCDictionary::createWithContentsOfFileThreadSafe(const char *pFileName) { return ccFileUtils_dictionaryWithContentsOfFileThreadSafe(pFileName); } -CCDictionary* CCDictionary::dictionaryWithContentsOfFile(const char *pFileName) +// CCDictionary* CCDictionary::dictionaryWithContentsOfFile(const char *pFileName) +// { +// return CCDictionary::createWithContentsOfFile(pFileName); +// } + +CCDictionary* CCDictionary::createWithContentsOfFile(const char *pFileName) { - CCDictionary* pRet = dictionaryWithContentsOfFileThreadSafe(pFileName); + CCDictionary* pRet = createWithContentsOfFileThreadSafe(pFileName); pRet->autorelease(); return pRet; } diff --git a/cocos2dx/cocoa/CCDictionary.h b/cocos2dx/cocoa/CCDictionary.h index c4d22030c0..bc8c66044b 100644 --- a/cocos2dx/cocoa/CCDictionary.h +++ b/cocos2dx/cocoa/CCDictionary.h @@ -136,21 +136,40 @@ public: virtual CCObject* copyWithZone(CCZone* pZone); /* static functions */ - static CCDictionary* dictionary(); + //@warning: This interface will be deprecated in future. + //static CCDictionary* dictionary(); - static CCDictionary* dictionaryWithDictionary(CCDictionary* srcDict); + //static CCDictionary* dictionaryWithDictionary(CCDictionary* srcDict); + /** + @brief Generate a CCDictionary pointer by file + @param pFileName The file name of *.plist file + @return The CCDictionary pointer generated from the file + @warning: This interface will be deprecated in future. + */ + //static CCDictionary* dictionaryWithContentsOfFile(const char *pFileName); + + /* + @brief The same meaning as dictionaryWithContentsOfFile(), but it doesn't call autorelease, so the + invoker should call release(). + @warning: This interface will be deprecated in future. + */ + //static CCDictionary* dictionaryWithContentsOfFileThreadSafe(const char *pFileName); + + static CCDictionary* create(); + + static CCDictionary* createWithDictionary(CCDictionary* srcDict); /** @brief Generate a CCDictionary pointer by file @param pFileName The file name of *.plist file @return The CCDictionary pointer generated from the file */ - static CCDictionary* dictionaryWithContentsOfFile(const char *pFileName); + static CCDictionary* createWithContentsOfFile(const char *pFileName); /* @brief The same meaning as dictionaryWithContentsOfFile(), but it doesn't call autorelease, so the invoker should call release(). */ - static CCDictionary* dictionaryWithContentsOfFileThreadSafe(const char *pFileName); + static CCDictionary* createWithContentsOfFileThreadSafe(const char *pFileName); private: void setObjectUnSafe(CCObject* pObject, const std::string& key); diff --git a/cocos2dx/cocoa/CCInteger.h b/cocos2dx/cocoa/CCInteger.h index 7779b92858..f098e6b5bf 100644 --- a/cocos2dx/cocoa/CCInteger.h +++ b/cocos2dx/cocoa/CCInteger.h @@ -12,7 +12,13 @@ public: : m_nValue(v) {} int getValue() const {return m_nValue;} - static CCInteger* integerWithInt(int v) + // @warning: This interface will be deprecated in future. +// static CCInteger* integerWithInt(int v) +// { +// return CCInteger::create(v); +// } + + static CCInteger* create(int v) { CCInteger* pRet = new CCInteger(v); pRet->autorelease(); diff --git a/cocos2dx/cocoa/CCString.cpp b/cocos2dx/cocoa/CCString.cpp index bc3747c21b..e712cc11a2 100644 --- a/cocos2dx/cocoa/CCString.cpp +++ b/cocos2dx/cocoa/CCString.cpp @@ -145,14 +145,24 @@ bool CCString::isEqual(const CCObject* pObject) return bRet; } -CCString* CCString::stringWithCString(const char* pStr) +// CCString* CCString::stringWithCString(const char* pStr) +// { +// return CCString::create(pStr); +// } + +CCString* CCString::create(const char* pStr) { CCString* pRet = new CCString(pStr); pRet->autorelease(); return pRet; } -CCString* CCString::stringWithData(unsigned char* pData, unsigned long nLen) +// CCString* CCString::stringWithData(unsigned char* pData, unsigned long nLen) +// { +// return CCString::createWithData(pData, nLen); +// } + +CCString* CCString::createWithData(unsigned char* pData, unsigned long nLen) { CCString* pRet = NULL; if (pData != NULL && nLen > 0) @@ -162,16 +172,27 @@ CCString* CCString::stringWithData(unsigned char* pData, unsigned long nLen) { pStr[nLen] = '\0'; memcpy(pStr, pData, nLen); - pRet = CCString::stringWithCString(pStr); + pRet = CCString::create(pStr); free(pStr); } } return pRet; } -CCString* CCString::stringWithFormat(const char* format, ...) +// CCString* CCString::stringWithFormat(const char* format, ...) +// { +// CCString* pRet = CCString::create(""); +// va_list ap; +// va_start(ap, format); +// pRet->initWithFormatAndValist(format, ap); +// va_end(ap); +// +// return pRet; +// } + +CCString* CCString::createWithFormat(const char* format, ...) { - CCString* pRet = CCString::stringWithCString(""); + CCString* pRet = CCString::create(""); va_list ap; va_start(ap, format); pRet->initWithFormatAndValist(format, ap); @@ -180,13 +201,18 @@ CCString* CCString::stringWithFormat(const char* format, ...) return pRet; } -CCString* CCString::stringWithContentsOfFile(const char* pszFileName) +// CCString* CCString::stringWithContentsOfFile(const char* pszFileName) +// { +// return CCString::createWithContentsOfFile(pszFileName); +// } + +CCString* CCString::createWithContentsOfFile(const char* pszFileName) { unsigned long size = 0; unsigned char* pData = 0; CCString* pRet = NULL; - pData = CCFileUtils::sharedFileUtils()->sharedFileUtils()->getFileData(pszFileName, "rb", &size); - pRet = stringWithData(pData, size); + pData = CCFileUtils::sharedFileUtils()->getFileData(pszFileName, "rb", &size); + pRet = CCString::createWithData(pData, size); CC_SAFE_DELETE_ARRAY(pData); return pRet; } diff --git a/cocos2dx/cocoa/CCString.h b/cocos2dx/cocoa/CCString.h index abb41043ca..beedd83184 100644 --- a/cocos2dx/cocoa/CCString.h +++ b/cocos2dx/cocoa/CCString.h @@ -74,27 +74,56 @@ public: /** create a string with c string * @return A CCString pointer which is an autorelease object pointer, * it means that you needn't do a release operation unless you retain it. + @warning: This interface will be deprecated in future. */ - static CCString* stringWithCString(const char* pStr); + //static CCString* stringWithCString(const char* pStr); + + /** create a string with format, it's similar with the c function 'sprintf', the default buffer size is (1024*100) bytes, + * if you want to change it, you should modify the kMaxStringLen macro in CCString.cpp file. + * @return A CCString pointer which is an autorelease object pointer, + * it means that you needn't do a release operation unless you retain it. + @warning: This interface will be deprecated in future. + */ + //static CCString* stringWithFormat(const char* format, ...); + + /** create a string with binary data + * @return A CCString pointer which is an autorelease object pointer, + * it means that you needn't do a release operation unless you retain it. + @warning: This interface will be deprecated in future. + */ + //static CCString* stringWithData(unsigned char* pData, unsigned long nLen); + + /** create a string with a file, + * @return A CCString pointer which is an autorelease object pointer, + * it means that you needn't do a release operation unless you retain it. + @warning: This interface will be deprecated in future. + */ + //static CCString* stringWithContentsOfFile(const char* pszFileName); + + /** create a string with c string + * @return A CCString pointer which is an autorelease object pointer, + * it means that you needn't do a release operation unless you retain it. + */ + static CCString* create(const char* pStr); /** create a string with format, it's similar with the c function 'sprintf', the default buffer size is (1024*100) bytes, * if you want to change it, you should modify the kMaxStringLen macro in CCString.cpp file. * @return A CCString pointer which is an autorelease object pointer, * it means that you needn't do a release operation unless you retain it. */ - static CCString* stringWithFormat(const char* format, ...); + static CCString* createWithFormat(const char* format, ...); /** create a string with binary data * @return A CCString pointer which is an autorelease object pointer, * it means that you needn't do a release operation unless you retain it. */ - static CCString* stringWithData(unsigned char* pData, unsigned long nLen); + static CCString* createWithData(unsigned char* pData, unsigned long nLen); /** create a string with a file, * @return A CCString pointer which is an autorelease object pointer, * it means that you needn't do a release operation unless you retain it. */ - static CCString* stringWithContentsOfFile(const char* pszFileName); + static CCString* createWithContentsOfFile(const char* pszFileName); private: @@ -105,7 +134,7 @@ public: std::string m_sString; }; -#define CCStringMake(str) CCString::stringWithCString(str) +#define CCStringMake(str) CCString::create(str) #define ccs CCStringMake diff --git a/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp b/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp index 4ee9d33d4f..d299b8bd21 100644 --- a/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp +++ b/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp @@ -763,7 +763,7 @@ CCNode* CCBReader::nodeGraphFromFile(const char* file, CCNode* owner) ccbFileDir = ccbFilePath.substr(0, lastSlash) + "/"; } - CCDictionary* dict = CCDictionary::dictionaryWithContentsOfFile(ccbFilePath.c_str()); + CCDictionary* dict = CCDictionary::createWithContentsOfFile(ccbFilePath.c_str()); CCAssert(dict != NULL, "CCBReader: file not found"); return nodeGraphFromDictionary(dict, NULL, ccbFileDir.c_str(), owner); } diff --git a/cocos2dx/extensions/CCControlExtension/CCControl.cpp b/cocos2dx/extensions/CCControlExtension/CCControl.cpp index 3af099067a..18abe39d7a 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControl.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControl.cpp @@ -293,7 +293,7 @@ CCArray* CCControl::dispatchListforControlEvent(CCControlEvent controlEvent) // If the invocation list does not exist for the dispatch table, we create it if (invocationList == NULL) { - invocationList = CCArray::arrayWithCapacity(1); + invocationList = CCArray::create(1); dispatchTable->setObject(invocationList, controlEvent); } return invocationList; diff --git a/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp b/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp index e1bc56441e..e0bcabc416 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp @@ -99,7 +99,7 @@ bool CCControlButton::initWithLabelAndBackgroundSprite(CCNode* node, CCScale9Spr // Initialize the dispatch table - CCString* tempString = CCString::stringWithCString(label->getString()); + CCString* tempString = CCString::create(label->getString()); //tempString->autorelease(); setTitleForState(tempString, CCControlStateNormal); setTitleColorForState(rgbaLabel->getColor(), CCControlStateNormal); diff --git a/cocos2dx/extensions/CCNotificationCenter/CCNotificationCenter.cpp b/cocos2dx/extensions/CCNotificationCenter/CCNotificationCenter.cpp index 9521a03943..9acc3110df 100644 --- a/cocos2dx/extensions/CCNotificationCenter/CCNotificationCenter.cpp +++ b/cocos2dx/extensions/CCNotificationCenter/CCNotificationCenter.cpp @@ -34,7 +34,7 @@ static CCNotificationCenter *s_sharedNotifCenter = NULL; CCNotificationCenter::CCNotificationCenter() { - m_observers = CCArray::arrayWithCapacity(3); + m_observers = CCArray::create(3); m_observers->retain(); } diff --git a/cocos2dx/include/cocos2d.h b/cocos2dx/include/cocos2d.h index d3bcff4233..789ed06bf4 100755 --- a/cocos2dx/include/cocos2d.h +++ b/cocos2dx/include/cocos2d.h @@ -61,7 +61,6 @@ THE SOFTWARE. #include "CCAutoreleasePool.h" #include "CCInteger.h" #include "CCString.h" -#include "CCData.h" #include "CCNS.h" #include "CCZone.h" diff --git a/cocos2dx/keypad_dispatcher/CCKeypadDispatcher.cpp b/cocos2dx/keypad_dispatcher/CCKeypadDispatcher.cpp index 4ca25e0573..d2ccb7186f 100644 --- a/cocos2dx/keypad_dispatcher/CCKeypadDispatcher.cpp +++ b/cocos2dx/keypad_dispatcher/CCKeypadDispatcher.cpp @@ -37,7 +37,7 @@ CCKeypadDispatcher::CCKeypadDispatcher() , m_bToAdd(false) , m_bToRemove(false) { - m_pDelegates = CCArray::array(); + m_pDelegates = CCArray::create(); m_pDelegates->retain(); m_pHandlersToAdd = ccCArrayNew(8); diff --git a/cocos2dx/label_nodes/CCLabelAtlas.cpp b/cocos2dx/label_nodes/CCLabelAtlas.cpp index 18b4974b62..7532b7e3d3 100644 --- a/cocos2dx/label_nodes/CCLabelAtlas.cpp +++ b/cocos2dx/label_nodes/CCLabelAtlas.cpp @@ -95,7 +95,7 @@ CCLabelAtlas* CCLabelAtlas::create(const char *string, const char *fntFile) bool CCLabelAtlas::initWithString(const char *theString, const char *fntFile) { - CCDictionary *dict = CCDictionary::dictionaryWithContentsOfFile(CCFileUtils::sharedFileUtils()->sharedFileUtils()->fullPathFromRelativePath(fntFile)); + CCDictionary *dict = CCDictionary::createWithContentsOfFile(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(fntFile)); CCAssert(((CCString*)dict->objectForKey("version"))->intValue() == 1, "Unsupported version. Upgrade cocos2d version"); diff --git a/cocos2dx/label_nodes/CCLabelBMFont.cpp b/cocos2dx/label_nodes/CCLabelBMFont.cpp index baa5d91439..a3ba1529c5 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.cpp +++ b/cocos2dx/label_nodes/CCLabelBMFont.cpp @@ -452,7 +452,7 @@ CCBMFontConfiguration::~CCBMFontConfiguration() const char* CCBMFontConfiguration::description(void) { - return CCString::stringWithFormat( + return CCString::createWithFormat( "", this, HASH_COUNT(m_pFontDefDictionary), @@ -486,7 +486,7 @@ void CCBMFontConfiguration::purgeFontDefDictionary() bool CCBMFontConfiguration::parseConfigFile(const char *controlFile) { std::string fullpath = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(controlFile); - CCString *contents = CCString::stringWithContentsOfFile(fullpath.c_str()); + CCString *contents = CCString::createWithContentsOfFile(fullpath.c_str()); CCAssert(contents, "CCBMFontConfiguration::parseConfigFile | Open file error."); diff --git a/cocos2dx/label_nodes/CCLabelTTF.cpp b/cocos2dx/label_nodes/CCLabelTTF.cpp index 1c6cf41699..351b9e9eb5 100644 --- a/cocos2dx/label_nodes/CCLabelTTF.cpp +++ b/cocos2dx/label_nodes/CCLabelTTF.cpp @@ -145,7 +145,7 @@ const char* CCLabelTTF::getString(void) const char* CCLabelTTF::description() { - return CCString::stringWithFormat("", m_pFontName->c_str(), m_fFontSize)->getCString(); + return CCString::createWithFormat("", m_pFontName->c_str(), m_fFontSize)->getCString(); } CCTextAlignment CCLabelTTF::getHorizontalAlignment() diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp index b8d055e25d..73ee4bbeec 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp @@ -800,7 +800,7 @@ void CCLayerMultiplex::addLayer(CCLayer* layer) bool CCLayerMultiplex::initWithLayer(CCLayer* layer) { - m_pLayers = CCArray::array(); + m_pLayers = CCArray::create(); m_pLayers->retain(); m_pLayers->addObject(layer); m_nEnabledLayer = 0; @@ -810,7 +810,7 @@ bool CCLayerMultiplex::initWithLayer(CCLayer* layer) bool CCLayerMultiplex::initWithLayers(CCLayer *layer, va_list params) { - m_pLayers = CCArray::arrayWithCapacity(5); + m_pLayers = CCArray::create(5); m_pLayers->retain(); m_pLayers->addObject(layer); diff --git a/cocos2dx/menu_nodes/CCMenu.cpp b/cocos2dx/menu_nodes/CCMenu.cpp index 4cabca4272..82f6245e8d 100644 --- a/cocos2dx/menu_nodes/CCMenu.cpp +++ b/cocos2dx/menu_nodes/CCMenu.cpp @@ -128,7 +128,7 @@ bool CCMenu::initWithItems(CCMenuItem* item, va_list args) CCArray* pArray = NULL; if( item ) { - pArray = CCArray::arrayWithObject(item); + pArray = CCArray::create(item, NULL); CCMenuItem *i = va_arg(args, CCMenuItem*); while(i) { diff --git a/cocos2dx/menu_nodes/CCMenuItem.cpp b/cocos2dx/menu_nodes/CCMenuItem.cpp index b9b4bbf2ac..d9a351f7ed 100644 --- a/cocos2dx/menu_nodes/CCMenuItem.cpp +++ b/cocos2dx/menu_nodes/CCMenuItem.cpp @@ -816,7 +816,7 @@ CCMenuItemToggle * CCMenuItemToggle::create(CCObject* target, SEL_MenuHandler se bool CCMenuItemToggle::initWithTarget(CCObject* target, SEL_MenuHandler selector, CCMenuItem* item, va_list args) { CCMenuItem::initWithTarget(target, selector); - this->m_pSubItems = CCArray::array(); + this->m_pSubItems = CCArray::create(); this->m_pSubItems->retain(); int z = 0; CCMenuItem *i = item; @@ -847,7 +847,7 @@ CCMenuItemToggle* CCMenuItemToggle::create(CCMenuItem *item) bool CCMenuItemToggle::initWithItem(CCMenuItem *item) { CCMenuItem::initWithTarget(NULL, NULL); - this->m_pSubItems = CCArray::array(); + this->m_pSubItems = CCArray::create(); this->m_pSubItems->retain(); m_pSubItems->addObject(item); m_uSelectedIndex = UINT_MAX; diff --git a/cocos2dx/misc_nodes/CCRenderTexture.h b/cocos2dx/misc_nodes/CCRenderTexture.h index 1a1a4851a8..30370412d2 100644 --- a/cocos2dx/misc_nodes/CCRenderTexture.h +++ b/cocos2dx/misc_nodes/CCRenderTexture.h @@ -25,7 +25,6 @@ THE SOFTWARE. #ifndef __CCRENDER_TEXTURE_H__ #define __CCRENDER_TEXTURE_H__ -#include "CCData.h" #include "CCNode.h" #include "CCSprite.h" #include "kazmath/mat4.h" diff --git a/cocos2dx/particle_nodes/CCParticleSystem.cpp b/cocos2dx/particle_nodes/CCParticleSystem.cpp index 9ecd15da76..3bc36bc19b 100644 --- a/cocos2dx/particle_nodes/CCParticleSystem.cpp +++ b/cocos2dx/particle_nodes/CCParticleSystem.cpp @@ -156,7 +156,7 @@ bool CCParticleSystem::initWithFile(const char *plistFile) { bool bRet = false; m_sPlistFile = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(plistFile); - CCDictionary *dict = CCDictionary::dictionaryWithContentsOfFileThreadSafe(m_sPlistFile.c_str()); + CCDictionary *dict = CCDictionary::createWithContentsOfFileThreadSafe(m_sPlistFile.c_str()); CCAssert( dict != NULL, "Particles: file not found"); bRet = this->initWithDictionary(dict); diff --git a/cocos2dx/platform/CCImageCommon_cpp.h b/cocos2dx/platform/CCImageCommon_cpp.h index 80e7788683..cf0a451e36 100644 --- a/cocos2dx/platform/CCImageCommon_cpp.h +++ b/cocos2dx/platform/CCImageCommon_cpp.h @@ -97,7 +97,7 @@ bool CCImage::initWithImageFile(const char * strPath, EImageFormat eImgFmt/* = e CC_UNUSED_PARAM(eImgFmt); unsigned long nSize; - unsigned char *pBuffer = CCFileUtils::sharedFileUtils()->sharedFileUtils()->getFileData(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(strPath), "rb", &nSize); + unsigned char *pBuffer = CCFileUtils::sharedFileUtils()->getFileData(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(strPath), "rb", &nSize); return initWithImageData(pBuffer, nSize, eImgFmt); } @@ -107,7 +107,7 @@ bool CCImage::initWithImageFileThreadSafe(const char *fullpath, EImageFormat ima CC_UNUSED_PARAM(imageType); unsigned long nSize; - unsigned char *pBuffer = CCFileUtils::sharedFileUtils()->sharedFileUtils()->getFileData(fullpath, "rb", &nSize); + unsigned char *pBuffer = CCFileUtils::sharedFileUtils()->getFileData(fullpath, "rb", &nSize); return initWithImageData(pBuffer, nSize, imageType); } diff --git a/cocos2dx/platform/CCPlatformMacros.h b/cocos2dx/platform/CCPlatformMacros.h index b1d5a458c8..2e7e21fcf5 100644 --- a/cocos2dx/platform/CCPlatformMacros.h +++ b/cocos2dx/platform/CCPlatformMacros.h @@ -167,7 +167,7 @@ public: virtual void set##funName(varType var) \ #define CC_BREAK_IF(cond) if(cond) break #define __CCLOGWITHFUNCTION(s, ...) \ - CCLog("%s : %s",__FUNCTION__, CCString::stringWithFormat(s, ##__VA_ARGS__)->getCString()) + CCLog("%s : %s",__FUNCTION__, CCString::createWithFormat(s, ##__VA_ARGS__)->getCString()) // cocos2d debug #if !defined(COCOS2D_DEBUG) || COCOS2D_DEBUG == 0 diff --git a/cocos2dx/platform/CCSAXParser.cpp b/cocos2dx/platform/CCSAXParser.cpp index 3c7c9cbd3d..a351d8099a 100644 --- a/cocos2dx/platform/CCSAXParser.cpp +++ b/cocos2dx/platform/CCSAXParser.cpp @@ -84,7 +84,7 @@ bool CCSAXParser::parse(const char* pXMLData, unsigned int uDataLength) bool CCSAXParser::parse(const char *pszFile) { unsigned long size; - char *pBuffer = (char*)CCFileUtils::sharedFileUtils()->sharedFileUtils()->getFileData(pszFile, "rt", &size); + char *pBuffer = (char*)CCFileUtils::sharedFileUtils()->getFileData(pszFile, "rt", &size); if (!pBuffer) { diff --git a/cocos2dx/proj.win32/cocos2d-win32.vcproj b/cocos2dx/proj.win32/cocos2d-win32.vcproj index fb354843a5..96cc4a5e72 100755 --- a/cocos2dx/proj.win32/cocos2d-win32.vcproj +++ b/cocos2dx/proj.win32/cocos2d-win32.vcproj @@ -231,14 +231,6 @@ RelativePath="..\cocoa\CCAutoreleasePool.h" > - - - - diff --git a/cocos2dx/shaders/CCGLProgram.cpp b/cocos2dx/shaders/CCGLProgram.cpp index 7c32c832a8..94e464a8e3 100644 --- a/cocos2dx/shaders/CCGLProgram.cpp +++ b/cocos2dx/shaders/CCGLProgram.cpp @@ -116,15 +116,15 @@ bool CCGLProgram::initWithVertexShaderByteArray(const GLchar* vShaderByteArray, bool CCGLProgram::initWithVertexShaderFilename(const char* vShaderFilename, const char* fShaderFilename) { - const GLchar * vertexSource = (GLchar*) CCString::stringWithContentsOfFile(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(vShaderFilename))->getCString(); - const GLchar * fragmentSource = (GLchar*) CCString::stringWithContentsOfFile(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(fShaderFilename))->getCString(); + const GLchar * vertexSource = (GLchar*) CCString::createWithContentsOfFile(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(vShaderFilename))->getCString(); + const GLchar * fragmentSource = (GLchar*) CCString::createWithContentsOfFile(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(fShaderFilename))->getCString(); return initWithVertexShaderByteArray(vertexSource, fragmentSource); } const char* CCGLProgram::description() { - return CCString::stringWithFormat("", this, m_uProgram, m_uVertShader, m_uFragShader)->getCString(); + return CCString::createWithFormat("", this, m_uProgram, m_uVertShader, m_uFragShader)->getCString(); } bool CCGLProgram::compileShader(GLuint * shader, GLenum type, const GLchar* source) @@ -219,7 +219,7 @@ const char* CCGLProgram::logForOpenGLObject(GLuint object, GLInfoFunction infoFu char *logBytes = (char*)malloc(logLength); logFunc(object, logLength, &charsWritten, logBytes); - CCString* log = CCString::stringWithCString(logBytes); + CCString* log = CCString::create(logBytes); free(logBytes); return log->getCString(); diff --git a/cocos2dx/sprite_nodes/CCAnimation.cpp b/cocos2dx/sprite_nodes/CCAnimation.cpp index 0bc2681b17..2f908fbcfb 100644 --- a/cocos2dx/sprite_nodes/CCAnimation.cpp +++ b/cocos2dx/sprite_nodes/CCAnimation.cpp @@ -133,7 +133,7 @@ bool CCAnimation::initWithSpriteFrames(CCArray *pFrames, float delay/* = 0.0f*/) m_uLoops = 1; m_fDelayPerUnit = delay; - CCArray* pTmpFrames = CCArray::array(); + CCArray* pTmpFrames = CCArray::create(); setFrames(pTmpFrames); if (pFrames != NULL) @@ -161,7 +161,7 @@ bool CCAnimation::initWithAnimationFrames(CCArray* arrayOfAnimationFrames, float m_fDelayPerUnit = delayPerUnit; m_uLoops = loops; - setFrames(CCArray::arrayWithArray(arrayOfAnimationFrames)); + setFrames(CCArray::create(arrayOfAnimationFrames)); CCObject* pObj = NULL; CCARRAY_FOREACH(m_pFrames, pObj) diff --git a/cocos2dx/sprite_nodes/CCAnimationCache.cpp b/cocos2dx/sprite_nodes/CCAnimationCache.cpp index c490674e90..bba721d5f5 100644 --- a/cocos2dx/sprite_nodes/CCAnimationCache.cpp +++ b/cocos2dx/sprite_nodes/CCAnimationCache.cpp @@ -108,7 +108,7 @@ void CCAnimationCache::parseVersion1(CCDictionary* animations) continue; } - CCArray* frames = CCArray::arrayWithCapacity(frameNames->count()); + CCArray* frames = CCArray::create(frameNames->count()); frames->retain(); CCObject* pObj = NULL; @@ -164,7 +164,7 @@ void CCAnimationCache::parseVersion2(CCDictionary* animations) } // Array of AnimationFrames - CCArray* array = CCArray::arrayWithCapacity(frameArray->count()); + CCArray* array = CCArray::create(frameArray->count()); array->retain(); CCObject* pObj = NULL; @@ -245,7 +245,7 @@ void CCAnimationCache::addAnimationsWithFile(const char* plist) CCAssert( plist, "Invalid texture file name"); const char* path = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(plist); - CCDictionary* dict = CCDictionary::dictionaryWithContentsOfFile(path); + CCDictionary* dict = CCDictionary::createWithContentsOfFile(path); CCAssert( dict, "CCAnimationCache: File could not be found"); diff --git a/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp b/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp index 97a3695446..f574e9fcc5 100644 --- a/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp @@ -203,7 +203,7 @@ void CCSpriteFrameCache::addSpriteFramesWithDictionary(CCDictionary* dictionary, void CCSpriteFrameCache::addSpriteFramesWithFile(const char *pszPlist, CCTexture2D *pobTexture) { const char *pszPath = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(pszPlist); - CCDictionary *dict = CCDictionary::dictionaryWithContentsOfFileThreadSafe(pszPath); + CCDictionary *dict = CCDictionary::createWithContentsOfFileThreadSafe(pszPath); addSpriteFramesWithDictionary(dict, pobTexture); @@ -232,7 +232,7 @@ void CCSpriteFrameCache::addSpriteFramesWithFile(const char *pszPlist) if (m_pLoadedFileNames->find(pszPlist) == m_pLoadedFileNames->end()) { const char *pszPath = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(pszPlist); - CCDictionary *dict = CCDictionary::dictionaryWithContentsOfFileThreadSafe(pszPath); + CCDictionary *dict = CCDictionary::createWithContentsOfFileThreadSafe(pszPath); string texturePath(""); @@ -343,7 +343,7 @@ void CCSpriteFrameCache::removeSpriteFrameByName(const char *pszName) void CCSpriteFrameCache::removeSpriteFramesFromFile(const char* plist) { const char* path = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(plist); - CCDictionary* dict = CCDictionary::dictionaryWithContentsOfFileThreadSafe(path); + CCDictionary* dict = CCDictionary::createWithContentsOfFileThreadSafe(path); removeSpriteFramesFromDictionary((CCDictionary*)dict); @@ -360,14 +360,14 @@ void CCSpriteFrameCache::removeSpriteFramesFromFile(const char* plist) void CCSpriteFrameCache::removeSpriteFramesFromDictionary(CCDictionary* dictionary) { CCDictionary* framesDict = (CCDictionary*)dictionary->objectForKey("frames"); - CCArray* keysToRemove = CCArray::array(); + CCArray* keysToRemove = CCArray::create(); CCDictElement* pElement = NULL; CCDICT_FOREACH(framesDict, pElement) { if (m_pSpriteFrames->objectForKey(pElement->getStrKey())) { - keysToRemove->addObject(CCString::stringWithCString(pElement->getStrKey())); + keysToRemove->addObject(CCString::create(pElement->getStrKey())); } } @@ -376,7 +376,7 @@ void CCSpriteFrameCache::removeSpriteFramesFromDictionary(CCDictionary* dictiona void CCSpriteFrameCache::removeSpriteFramesFromTexture(CCTexture2D* texture) { - CCArray* keysToRemove = CCArray::array(); + CCArray* keysToRemove = CCArray::create(); CCDictElement* pElement = NULL; CCDICT_FOREACH(m_pSpriteFrames, pElement) @@ -385,7 +385,7 @@ void CCSpriteFrameCache::removeSpriteFramesFromTexture(CCTexture2D* texture) CCSpriteFrame* frame = (CCSpriteFrame*)m_pSpriteFrames->objectForKey(key.c_str()); if (frame && (frame->getTexture() == texture)) { - keysToRemove->addObject(CCString::stringWithCString(pElement->getStrKey())); + keysToRemove->addObject(CCString::create(pElement->getStrKey())); } } diff --git a/cocos2dx/support/image_support/TGAlib.cpp b/cocos2dx/support/image_support/TGAlib.cpp index 9cfce7ffe6..7f97cfafe0 100644 --- a/cocos2dx/support/image_support/TGAlib.cpp +++ b/cocos2dx/support/image_support/TGAlib.cpp @@ -199,7 +199,7 @@ tImageTGA * tgaLoad(const char *pszFilename) tImageTGA *info = NULL; unsigned long nSize; - unsigned char *pBuffer = CCFileUtils::sharedFileUtils()->sharedFileUtils()->getFileData(pszFilename, "rb", &nSize); + unsigned char *pBuffer = CCFileUtils::sharedFileUtils()->getFileData(pszFilename, "rb", &nSize); do { diff --git a/cocos2dx/support/zip_support/ZipUtils.cpp b/cocos2dx/support/zip_support/ZipUtils.cpp index f8217f7639..ece5c179e5 100644 --- a/cocos2dx/support/zip_support/ZipUtils.cpp +++ b/cocos2dx/support/zip_support/ZipUtils.cpp @@ -217,7 +217,7 @@ namespace cocos2d unsigned char *compressed = NULL; int fileLen = 0; - compressed = CCFileUtils::sharedFileUtils()->sharedFileUtils()->getFileData(path, "rb", (unsigned long *)(&fileLen)); + compressed = CCFileUtils::sharedFileUtils()->getFileData(path, "rb", (unsigned long *)(&fileLen)); // int fileLen = CCFileUtils::sharedFileUtils()->ccLoadFileIntoMemory( path, &compressed ); if( fileLen < 0 ) diff --git a/cocos2dx/textures/CCTexture2D.cpp b/cocos2dx/textures/CCTexture2D.cpp index d16a409a46..9e93d0c515 100644 --- a/cocos2dx/textures/CCTexture2D.cpp +++ b/cocos2dx/textures/CCTexture2D.cpp @@ -248,7 +248,7 @@ bool CCTexture2D::initWithData(const void *data, CCTexture2DPixelFormat pixelFor const char* CCTexture2D::description(void) { - return CCString::stringWithFormat("", m_uName, m_uPixelsWide, m_uPixelsHigh, m_fMaxS, m_fMaxT)->getCString(); + return CCString::createWithFormat("", m_uName, m_uPixelsWide, m_uPixelsHigh, m_fMaxS, m_fMaxT)->getCString(); } // implementation CCTexture2D (Image) diff --git a/cocos2dx/textures/CCTextureAtlas.cpp b/cocos2dx/textures/CCTextureAtlas.cpp index 8ce755d087..1ef0c59c81 100644 --- a/cocos2dx/textures/CCTextureAtlas.cpp +++ b/cocos2dx/textures/CCTextureAtlas.cpp @@ -209,7 +209,7 @@ void CCTextureAtlas::listenBackToForeground(CCObject *obj) const char* CCTextureAtlas::description() { - return CCString::stringWithFormat("", m_uTotalQuads)->getCString(); + return CCString::createWithFormat("", m_uTotalQuads)->getCString(); } diff --git a/cocos2dx/textures/CCTextureCache.cpp b/cocos2dx/textures/CCTextureCache.cpp index 8bb6cf5fe1..2eb64308d6 100644 --- a/cocos2dx/textures/CCTextureCache.cpp +++ b/cocos2dx/textures/CCTextureCache.cpp @@ -32,7 +32,6 @@ THE SOFTWARE. #include "CCTextureCache.h" #include "CCTexture2D.h" #include "ccMacros.h" -#include "CCData.h" #include "CCDirector.h" #include "platform/platform.h" #include "CCFileUtils.h" @@ -235,7 +234,7 @@ void CCTextureCache::purgeSharedTextureCache() const char* CCTextureCache::description() { - return CCString::stringWithFormat("", m_pTextures->count())->getCString(); + return CCString::createWithFormat("", m_pTextures->count())->getCString(); } CCDictionary* CCTextureCache::snapshotTextures() @@ -440,7 +439,7 @@ CCTexture2D * CCTextureCache::addImage(const char * path) CCImage image; unsigned long nSize; - unsigned char *pBuffer = CCFileUtils::sharedFileUtils()->sharedFileUtils()->getFileData(fullpath.c_str(), "rb", &nSize); + unsigned char *pBuffer = CCFileUtils::sharedFileUtils()->getFileData(fullpath.c_str(), "rb", &nSize); CC_BREAK_IF(! image.initWithImageData((void*)pBuffer, nSize, eImageFormat)); texture = new CCTexture2D(); @@ -488,10 +487,12 @@ CCTexture2D* CCTextureCache::addPVRTCImage(const char* path, int bpp, bool hasAl // Split up directory and filename std::string fullpath( CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(path) ); - CCData * data = CCData::dataWithContentsOfFile(fullpath); + unsigned long nLen = 0; + unsigned char* pData = CCFileUtils::sharedFileUtils()->getFileData(fullpath.c_str(), "rb", &nLen); + texture = new CCTexture2D(); - if( texture->initWithPVRTCData(data->bytes(), 0, bpp, hasAlpha, width, + if( texture->initWithPVRTCData(pData, 0, bpp, hasAlpha, width, (bpp==2 ? kCCTexture2DPixelFormat_PVRTC2 : kCCTexture2DPixelFormat_PVRTC4))) { m_pTextures->setObject(texture, temp.c_str()); @@ -851,7 +852,7 @@ void VolatileTexture::reloadAllTextures() else { unsigned long nSize; - unsigned char *pBuffer = CCFileUtils::sharedFileUtils()->sharedFileUtils()->getFileData(vt->m_strFileName.c_str(), "rb", &nSize); + unsigned char *pBuffer = CCFileUtils::sharedFileUtils()->getFileData(vt->m_strFileName.c_str(), "rb", &nSize); if (image.initWithImageData((void*)pBuffer, nSize, vt->m_FmtImage)) diff --git a/cocos2dx/textures/CCTexturePVR.cpp b/cocos2dx/textures/CCTexturePVR.cpp index c440773815..85167905df 100755 --- a/cocos2dx/textures/CCTexturePVR.cpp +++ b/cocos2dx/textures/CCTexturePVR.cpp @@ -27,7 +27,6 @@ THE SOFTWARE. #include "CCTexture2D.h" #include "CCTexturePVR.h" #include "ccMacros.h" -#include "CCData.h" #include "CCConfiguration.h" #include "support/ccUtils.h" #include "CCStdC.h" @@ -402,7 +401,7 @@ bool CCTexturePVR::initWithContentsOfFile(const char* path) } else { - pvrdata = CCFileUtils::sharedFileUtils()->sharedFileUtils()->getFileData(path, "rb", (unsigned long *)(&pvrlen)); + pvrdata = CCFileUtils::sharedFileUtils()->getFileData(path, "rb", (unsigned long *)(&pvrlen)); } if (pvrlen < 0) diff --git a/cocos2dx/textures/CCTexturePVR.h b/cocos2dx/textures/CCTexturePVR.h index 583cd5d212..70ce55544a 100644 --- a/cocos2dx/textures/CCTexturePVR.h +++ b/cocos2dx/textures/CCTexturePVR.h @@ -33,9 +33,6 @@ THE SOFTWARE. NS_CC_BEGIN -//Forward definition for CCData -class CCData; - /** @brief Structure which can tell where mimap begins and how long is it */ diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp b/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp index 2ac1a5e95c..cf962bd06b 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp @@ -75,7 +75,7 @@ bool CCTMXLayer::initWithTilesetInfo(CCTMXTilesetInfo *tilesetInfo, CCTMXLayerIn m_uMinGID = layerInfo->m_uMinGID; m_uMaxGID = layerInfo->m_uMaxGID; m_cOpacity = layerInfo->m_cOpacity; - setProperties(CCDictionary::dictionaryWithDictionary(layerInfo->getProperties())); + setProperties(CCDictionary::createWithDictionary(layerInfo->getProperties())); m_fContentScaleFactor = CCDirector::sharedDirector()->getContentScaleFactor(); // tilesetInfo diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXObjectGroup.cpp b/cocos2dx/tileMap_parallax_nodes/CCTMXObjectGroup.cpp index 84f4a406ea..ff74ded472 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXObjectGroup.cpp +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXObjectGroup.cpp @@ -35,7 +35,7 @@ CCTMXObjectGroup::CCTMXObjectGroup() :m_tPositionOffset(CCPointZero) ,m_sGroupName("") { - m_pObjects = CCArray::array(); + m_pObjects = CCArray::create(); m_pObjects->retain(); m_pProperties = new CCDictionary(); } diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXXMLParser.cpp b/cocos2dx/tileMap_parallax_nodes/CCTMXXMLParser.cpp index b32a1011d1..c58ba1b371 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXXMLParser.cpp +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXXMLParser.cpp @@ -28,7 +28,6 @@ THE SOFTWARE. #include #include "CCTMXXMLParser.h" #include "CCTMXTiledMap.h" -#include "CCData.h" #include "ccMacros.h" #include "CCFileUtils.h" #include "support/zip_support/ZipUtils.h" @@ -150,10 +149,10 @@ CCTMXMapInfo * CCTMXMapInfo::formatWithXML(const char* tmxString, const char* re void CCTMXMapInfo::internalInit(const char* tmxFileName, const char* resourcePath) { - m_pTilesets = CCArray::array(); + m_pTilesets = CCArray::create(); m_pTilesets->retain(); - m_pLayers = CCArray::array(); + m_pLayers = CCArray::create(); m_pLayers->retain(); if (tmxFileName != NULL) @@ -166,7 +165,7 @@ void CCTMXMapInfo::internalInit(const char* tmxFileName, const char* resourcePat m_sResources = resourcePath; } - m_pObjectGroups = CCArray::arrayWithCapacity(4); + m_pObjectGroups = CCArray::create(4); m_pObjectGroups->retain(); m_pProperties = new CCDictionary(); @@ -284,13 +283,6 @@ bool CCTMXMapInfo::parseXMLString(const char *xmlString) return parser.parse(xmlString, len); } -bool CCTMXMapInfo::parseXMLData(const CCData* data) -{ - //TODO: implementation. - CCAssert(false, "not implement!"); - return false; -} - bool CCTMXMapInfo::parseXMLFile(const char *xmlFilename) { CCSAXParser parser; diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXXMLParser.h b/cocos2dx/tileMap_parallax_nodes/CCTMXXMLParser.h index dcc8cd1e64..7dacf16fdb 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXXMLParser.h +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXXMLParser.h @@ -37,7 +37,6 @@ THE SOFTWARE. NS_CC_BEGIN -class CCData; class CCTMXObjectGroup; /** @file @@ -181,8 +180,6 @@ public: bool parseXMLFile(const char *xmlFilename); /* initalises parsing of an XML string, either a tmx (Map) string or tsx (Tileset) string */ bool parseXMLString(const char *xmlString); - /* handles the work of parsing for parseXMLFile: and parseXMLString: */ - bool parseXMLData(const CCData* data); CCDictionary* getTileProperties(); void setTileProperties(CCDictionary* tileProperties); diff --git a/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.cpp b/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.cpp index 96bc83f4fa..a14274fc3f 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.cpp +++ b/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.cpp @@ -157,7 +157,7 @@ void CCTileMapAtlas::setTile(const ccColor3B& tile, const ccGridSize& position) // XXX: this method consumes a lot of memory // XXX: a tree of something like that shall be impolemented - CCInteger *num = (CCInteger*)m_pPosToAtlasIndex->objectForKey(CCString::stringWithFormat("%d,%d", position.x, position.y)->getCString()); + CCInteger *num = (CCInteger*)m_pPosToAtlasIndex->objectForKey(CCString::createWithFormat("%d,%d", position.x, position.y)->getCString()); this->updateAtlasValueAt(position, tile, num->getValue()); } } @@ -251,8 +251,8 @@ void CCTileMapAtlas::updateAtlasValues() { this->updateAtlasValueAt(ccg(x,y), value, total); - CCString *key = CCString::stringWithFormat("%d,%d", x,y); - CCInteger *num = CCInteger::integerWithInt(total); + CCString *key = CCString::createWithFormat("%d,%d", x,y); + CCInteger *num = CCInteger::create(total); m_pPosToAtlasIndex->setObject(num, key->getCString()); total++; diff --git a/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp b/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp index 544276241c..3435c5ccea 100644 --- a/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp +++ b/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp @@ -67,11 +67,11 @@ void CCTouchDispatcher::setDispatchEvents(bool bDispatchEvents) bool CCTouchDispatcher::init(void) { m_bDispatchEvents = true; - m_pTargetedHandlers = CCArray::arrayWithCapacity(8); + m_pTargetedHandlers = CCArray::create(8); m_pTargetedHandlers->retain(); - m_pStandardHandlers = CCArray::arrayWithCapacity(4); + m_pStandardHandlers = CCArray::create(4); m_pStandardHandlers->retain(); - m_pHandlersToAdd = CCArray::arrayWithCapacity(8); + m_pHandlersToAdd = CCArray::create(8); m_pHandlersToAdd->retain(); m_pHandlersToRemove = ccCArrayNew(8); diff --git a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp index b08b66ae01..f33e4d4fa2 100644 --- a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp +++ b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp @@ -32,7 +32,7 @@ bool CCControlButtonTest_HelloVariableSize::init() CCSize screenSize = CCDirector::sharedDirector()->getWinSize(); // Defines an array of title to create buttons dynamically - CCArray *stringArray = CCArray::arrayWithObjects( + CCArray *stringArray = CCArray::create( ccs("Hello"), ccs("Variable"), ccs("Size"), @@ -151,42 +151,42 @@ bool CCControlButtonTest_Event::init() void CCControlButtonTest_Event::touchDownAction(CCObject *sender) { - m_pDisplayValueLabel->setString(CCString::stringWithFormat("Touch Down")->getCString()); + m_pDisplayValueLabel->setString(CCString::createWithFormat("Touch Down")->getCString()); } void CCControlButtonTest_Event::touchDragInsideAction(CCObject *sender) { - m_pDisplayValueLabel->setString(CCString::stringWithFormat("Drag Inside")->getCString()); + m_pDisplayValueLabel->setString(CCString::createWithFormat("Drag Inside")->getCString()); } void CCControlButtonTest_Event::touchDragOutsideAction(CCObject *sender) { - m_pDisplayValueLabel->setString(CCString::stringWithFormat("Drag Outside")->getCString()); + m_pDisplayValueLabel->setString(CCString::createWithFormat("Drag Outside")->getCString()); } void CCControlButtonTest_Event::touchDragEnterAction(CCObject *sender) { - m_pDisplayValueLabel->setString(CCString::stringWithFormat("Drag Enter")->getCString()); + m_pDisplayValueLabel->setString(CCString::createWithFormat("Drag Enter")->getCString()); } void CCControlButtonTest_Event::touchDragExitAction(CCObject *sender) { - m_pDisplayValueLabel->setString(CCString::stringWithFormat("Drag Exit")->getCString()); + m_pDisplayValueLabel->setString(CCString::createWithFormat("Drag Exit")->getCString()); } void CCControlButtonTest_Event::touchUpInsideAction(CCObject *sender) { - m_pDisplayValueLabel->setString(CCString::stringWithFormat("Touch Up Inside.")->getCString()); + m_pDisplayValueLabel->setString(CCString::createWithFormat("Touch Up Inside.")->getCString()); } void CCControlButtonTest_Event::touchUpOutsideAction(CCObject *sender) { - m_pDisplayValueLabel->setString(CCString::stringWithFormat("Touch Up Outside.")->getCString()); + m_pDisplayValueLabel->setString(CCString::createWithFormat("Touch Up Outside.")->getCString()); } void CCControlButtonTest_Event::touchCancelAction(CCObject *sender) { - m_pDisplayValueLabel->setString(CCString::stringWithFormat("Touch Cancel")->getCString()); + m_pDisplayValueLabel->setString(CCString::createWithFormat("Touch Cancel")->getCString()); } @@ -209,7 +209,7 @@ bool CCControlButtonTest_Styling::init() for (int j = 0; j < 3; j++) { // Add the buttons - CCControlButton *button = standardButtonWithTitle(CCString::stringWithFormat("%d",rand() % 30)->getCString()); + CCControlButton *button = standardButtonWithTitle(CCString::createWithFormat("%d",rand() % 30)->getCString()); button->setAdjustBackgroundImage(false); // Tells the button that the background image must not be adjust // It'll use the prefered size of the background image button->setPosition(ccp (button->getContentSize().width / 2 + (button->getContentSize().width + space) * i, diff --git a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.cpp b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.cpp index e9fda7c44d..f591024f12 100644 --- a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.cpp +++ b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.cpp @@ -90,7 +90,7 @@ CCControlColourPickerTest::~CCControlColourPickerTest() void CCControlColourPickerTest::colourValueChanged(CCObject *sender) { CCControlColourPicker* pPicker = (CCControlColourPicker*)sender; - m_pColorLabel->setString(CCString::stringWithFormat("#%02X%02X%02X",pPicker->getColorValue().r, pPicker->getColorValue().g, pPicker->getColorValue().b)->getCString()); + m_pColorLabel->setString(CCString::createWithFormat("#%02X%02X%02X",pPicker->getColorValue().r, pPicker->getColorValue().g, pPicker->getColorValue().b)->getCString()); } diff --git a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp index 50c5f8332a..e992f9d6eb 100644 --- a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp +++ b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp @@ -69,6 +69,6 @@ void CCControlSliderTest::valueChanged(CCObject *sender) { CCControlSlider* pSlider = (CCControlSlider*)sender; // Change value of label. - m_pDisplayValueLabel->setString(CCString::stringWithFormat("Slider value = %.02f", pSlider->getValue())->getCString()); + m_pDisplayValueLabel->setString(CCString::createWithFormat("Slider value = %.02f", pSlider->getValue())->getCString()); } diff --git a/tests/tests/LabelTest/LabelTest.cpp b/tests/tests/LabelTest/LabelTest.cpp index 637753efe0..21e21dd7ef 100644 --- a/tests/tests/LabelTest/LabelTest.cpp +++ b/tests/tests/LabelTest/LabelTest.cpp @@ -342,7 +342,7 @@ void LabelAtlasColorTest::step(float dt) m_time += dt; char string[12] = {0}; sprintf(string, "%2.2f Test", m_time); - //std::string string = std::string::stringWithFormat("%2.2f Test", m_time); + //std::string string = std::string::createWithFormat("%2.2f Test", m_time); CCLabelAtlas* label1 = (CCLabelAtlas*)getChildByTag(kTagSprite1); label1->setString(string); @@ -1069,7 +1069,7 @@ const char* LabelTTFTest::getCurrentAlignment() break; } - return CCString::stringWithFormat("Alignment %s %s", vertical, horizontal)->getCString(); + return CCString::createWithFormat("Alignment %s %s", vertical, horizontal)->getCString(); } string LabelTTFTest::title() @@ -1390,7 +1390,7 @@ std::string BMFontOneAtlas::subtitle() /// BMFontUnicode BMFontUnicode::BMFontUnicode() { - CCDictionary *strings = CCDictionary::dictionaryWithContentsOfFile("fonts/strings.xml"); + CCDictionary *strings = CCDictionary::createWithContentsOfFile("fonts/strings.xml"); const char *chinese = ((CCString*)strings->objectForKey("chinese1"))->m_sString.c_str(); const char *japanese = ((CCString*)strings->objectForKey("japanese"))->m_sString.c_str(); const char *spanish = ((CCString*)strings->objectForKey("spanish"))->m_sString.c_str(); diff --git a/tests/tests/PerformanceTest/PerformanceNodeChildrenTest.cpp b/tests/tests/PerformanceTest/PerformanceNodeChildrenTest.cpp index b29281c3cc..a7ded9ab5e 100644 --- a/tests/tests/PerformanceTest/PerformanceNodeChildrenTest.cpp +++ b/tests/tests/PerformanceTest/PerformanceNodeChildrenTest.cpp @@ -376,7 +376,7 @@ void AddSpriteSheet::update(float dt) if( totalToAdd > 0 ) { - CCArray* sprites = CCArray::arrayWithCapacity(totalToAdd); + CCArray* sprites = CCArray::create(totalToAdd); int *zs = new int[totalToAdd]; // Don't include the sprite creation time and random as part of the profiling @@ -440,7 +440,7 @@ void RemoveSpriteSheet::update(float dt) if( totalToAdd > 0 ) { - CCArray* sprites = CCArray::arrayWithCapacity(totalToAdd); + CCArray* sprites = CCArray::create(totalToAdd); // Don't include the sprite creation time as part of the profiling for(int i=0;i 0 ) { - CCArray* sprites = CCArray::arrayWithCapacity(totalToAdd); + CCArray* sprites = CCArray::create(totalToAdd); // Don't include the sprite creation time as part of the profiling for(int i=0;ifullPathFromRelativePath("Shaders/example_Blur.fsh"))->getCString(); CCGLProgram* pProgram = new CCGLProgram(); pProgram->initWithVertexShaderByteArray(ccPositionTextureColor_vert, fragSource); @@ -630,7 +630,7 @@ bool ShaderRetroEffect::init() { if( ShaderTestDemo::init() ) { - GLchar * fragSource = (GLchar*) CCString::stringWithContentsOfFile(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath("Shaders/example_HorizontalColor.fsh"))->getCString(); + GLchar * fragSource = (GLchar*) CCString::createWithContentsOfFile(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath("Shaders/example_HorizontalColor.fsh"))->getCString(); CCGLProgram *p = new CCGLProgram(); p->initWithVertexShaderByteArray(ccPositionTexture_vert, fragSource); diff --git a/tests/tests/SpriteTest/SpriteTest.cpp.REMOVED.git-id b/tests/tests/SpriteTest/SpriteTest.cpp.REMOVED.git-id index 57683d0f9e..9ee094da2e 100644 --- a/tests/tests/SpriteTest/SpriteTest.cpp.REMOVED.git-id +++ b/tests/tests/SpriteTest/SpriteTest.cpp.REMOVED.git-id @@ -1 +1 @@ -6824810bc1cfa5dd0dbf72f9966524b82ebe0a52 \ No newline at end of file +23a3acf70514939732acc9dab32c55a9bfddbc46 \ No newline at end of file diff --git a/tests/tests/TileMapTest/TileMapTest.cpp b/tests/tests/TileMapTest/TileMapTest.cpp index 4cd79dabdc..aee87bfff1 100644 --- a/tests/tests/TileMapTest/TileMapTest.cpp +++ b/tests/tests/TileMapTest/TileMapTest.cpp @@ -1254,7 +1254,7 @@ TMXOrthoFromXMLTest::TMXOrthoFromXMLTest() string resources = "TileMaps"; // partial paths are OK as resource paths. string file = resources + "/orthogonal-test1.tmx"; - CCString* str = CCString::stringWithContentsOfFile(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(file.c_str())); + CCString* str = CCString::createWithContentsOfFile(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(file.c_str())); CCAssert(str != NULL, "Unable to open file"); CCTMXTiledMap *map = CCTMXTiledMap::create(str->getCString() ,resources.c_str()); diff --git a/tests/tests/TouchesTest/TouchesTest.cpp b/tests/tests/TouchesTest/TouchesTest.cpp index fd34bb4f12..4bfcadda60 100644 --- a/tests/tests/TouchesTest/TouchesTest.cpp +++ b/tests/tests/TouchesTest/TouchesTest.cpp @@ -54,7 +54,7 @@ PongLayer::PongLayer() CCTexture2D* paddleTexture = CCTextureCache::sharedTextureCache()->addImage(s_Paddle); - CCArray *paddlesM = CCArray::arrayWithCapacity(4); + CCArray *paddlesM = CCArray::create(4); Paddle* paddle = Paddle::paddleWithTexture(paddleTexture); paddle->setPosition( CCPointMake(m_tWinSize.width/2, 15) );