Merge pull request #3455 from ricardoquesada/dictionary_array_fixes

Dictionary array fixes
This commit is contained in:
minggo 2013-08-21 21:52:00 -07:00
commit edc2bf14c7
65 changed files with 385 additions and 304 deletions

View File

@ -115,7 +115,7 @@ bool Director::init(void)
_notificationNode = nullptr;
_scenesStack = new Array();
_scenesStack->init();
_scenesStack->initWithCapacity(15);
// projection delegate if "Custom" projection is used
_projectionDelegate = nullptr;
@ -168,7 +168,7 @@ bool Director::init(void)
Director::~Director(void)
{
CCLOG("cocos2d: deallocing Director %p", this);
CCLOGINFO("deallocing Director: %p", this);
CC_SAFE_RELEASE(_FPSLabel);
CC_SAFE_RELEASE(_SPFLabel);

View File

@ -43,7 +43,7 @@ Action::Action()
Action::~Action()
{
CCLOGINFO("cocos2d: deallocing");
CCLOGINFO("deallocing Action: %p - tag: %i", this, _tag);
}
const char* Action::description() const

View File

@ -89,6 +89,8 @@ PointArray* PointArray::clone() const
PointArray::~PointArray()
{
CCLOGINFO("deallocing PointArray: %p", this);
vector<Point*>::iterator iter;
for (iter = _controlPoints->begin(); iter != _controlPoints->end(); ++iter)
{

View File

@ -58,7 +58,7 @@ ActionManager::ActionManager(void)
ActionManager::~ActionManager(void)
{
CCLOGINFO("cocos2d: deallocing %p", this);
CCLOGINFO("deallocing ActionManager: %p", this);
removeAllActions();
}

View File

@ -105,7 +105,7 @@ Node::Node(void)
Node::~Node()
{
CCLOGINFO( "cocos2d: deallocing: %p", this );
CCLOGINFO( "deallocing Node: %p - tag: %i", this, _tag );
if (_updateScriptHandler)
{

View File

@ -347,6 +347,7 @@ void Array::reduceMemoryFootprint()
Array::~Array()
{
CCLOGINFO("deallocing Array: %p - len: %d", this, count() );
}
Array* Array::clone() const
@ -394,12 +395,6 @@ Array::Array()
// init();
}
Array::Array(unsigned int capacity)
: data(nullptr)
{
initWithCapacity(capacity);
}
Array* Array::create()
{
Array* array = new Array();
@ -609,16 +604,19 @@ bool Array::isEqualToArray(Array* otherArray)
void Array::addObject(Object* object)
{
CCASSERT(data, "Array not initialized");
ccArrayAppendObjectWithResize(data, object);
}
void Array::addObjectsFromArray(Array* otherArray)
{
CCASSERT(data, "Array not initialized");
ccArrayAppendArrayWithResize(data, otherArray->data);
}
void Array::insertObject(Object* object, int index)
{
CCASSERT(data, "Array not initialized");
ccArrayInsertObjectAtIndex(data, object, index);
}
@ -721,6 +719,8 @@ void Array::reduceMemoryFootprint()
Array::~Array()
{
CCLOGINFO("deallocing Array: %p - len: %d", this, count() );
ccArrayFree(data);
}
@ -757,16 +757,6 @@ void Array::acceptVisitor(DataVisitor &visitor)
visitor.visit(this);
}
Array::iterator Array::begin()
{
return Array::ArrayIterator(0, this);
}
Array::iterator Array::end()
{
return Array::ArrayIterator(count(), this);
}
#endif // uses ccArray
NS_CC_END

View File

@ -404,99 +404,18 @@ public:
const_iterator cbegin() { return data.cbegin(); }
const_iterator cend() { return data.cend(); }
#else
class ArrayIterator : public std::iterator<std::input_iterator_tag, Object*>
{
public:
ArrayIterator(int index, Array *array) : _index(index), _parent(array) {}
ArrayIterator(const ArrayIterator& arrayIterator) : _index(arrayIterator._index), _parent(arrayIterator._parent) {}
ArrayIterator& operator++()
{
++_index;
return *this;
}
ArrayIterator operator++(int dummy)
{
ArrayIterator tmp(*this);
++_index;
return tmp;
}
ArrayIterator& operator--()
{
--_index;
return *this;
}
ArrayIterator operator--(int dummy)
{
ArrayIterator tmp(*this);
--_index;
return tmp;
}
int operator-(const ArrayIterator& rhs) const
{
return _index - rhs._index;
}
ArrayIterator operator-(int d)
{
_index -= d;
return *this;
}
const ArrayIterator& operator-=(int d)
{
_index -= d;
return *this;
}
ArrayIterator operator+(int d)
{
_index += d;
return *this;
}
const ArrayIterator& operator+=(int d)
{
_index += d;
return *this;
}
// add these function to make compiler happy when using std::sort(), it is meaningless
bool operator>=(const ArrayIterator& rhs) const { return false; }
bool operator<=(const ArrayIterator& rhs) const { return false; }
bool operator>(const ArrayIterator& rhs) const { return false; }
bool operator<(const ArrayIterator& rhs) const { return false; }
bool operator==(const ArrayIterator& rhs) { return _index == rhs._index; }
bool operator!=(const ArrayIterator& rhs) { return _index != rhs._index; }
reference operator*() { return _parent->data->arr[_index]; }
value_type operator->() { return _parent->data->arr[_index];; }
private:
int _index;
Array *_parent;
};
// functions for range-based loop
typedef ArrayIterator iterator;
typedef ArrayIterator const_iterator;
iterator begin();
iterator end();
#endif
public:
#if CC_USE_ARRAY_VECTOR
std::vector<RCPtr<Object>> data;
#else
Object** begin() { return &data->arr[0]; }
Object** end() { return &data->arr[data->num]; }
ccArray* data;
#endif
//protected:
Array();
Array(unsigned int capacity);
};
// end of data_structure group

View File

@ -36,6 +36,7 @@ AutoreleasePool::AutoreleasePool()
AutoreleasePool::~AutoreleasePool()
{
CCLOGINFO("deallocing AutoreleasePool: %p", this);
CC_SAFE_DELETE(_managedObjectArray);
}
@ -113,6 +114,7 @@ PoolManager::PoolManager()
PoolManager::~PoolManager()
{
CCLOGINFO("deallocing PoolManager: %p", this);
finalize();
// we only release the last autorelease pool here

View File

@ -1,5 +1,30 @@
/****************************************************************************
Copyright (c) 2010-2012 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 <string.h>
#include "CCData.h"
#include "platform/CCCommon.h"
NS_CC_BEGIN
@ -19,6 +44,7 @@ Data::Data(Data *pData)
Data::~Data()
{
CCLOGINFO("deallocing Data: %p", this);
CC_SAFE_DELETE_ARRAY(_bytes);
}

View File

@ -1,3 +1,26 @@
/****************************************************************************
Copyright (c) 2010-2012 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__

View File

@ -63,7 +63,7 @@ DictElement::DictElement(intptr_t iKey, Object* pObject)
DictElement::~DictElement()
{
CCLOGINFO("deallocing DictElement: %p", this);
}
// -----------------------------------------------------------------------
@ -78,6 +78,7 @@ Dictionary::Dictionary()
Dictionary::~Dictionary()
{
CCLOGINFO("deallocing Dictionary: %p", this);
removeAllObjects();
}
@ -358,12 +359,17 @@ Object* Dictionary::randomObject()
Dictionary* Dictionary::create()
{
Dictionary* pRet = new Dictionary();
if (pRet != NULL)
Dictionary* ret = new Dictionary();
if (ret && ret->init() )
{
pRet->autorelease();
ret->autorelease();
}
return pRet;
return ret;
}
bool Dictionary::init()
{
return true;
}
Dictionary* Dictionary::createWithDictionary(Dictionary* srcDict)
@ -383,9 +389,7 @@ void Dictionary::acceptVisitor(DataVisitor &visitor)
Dictionary* Dictionary::createWithContentsOfFile(const char *pFileName)
{
Dictionary* pRet = createWithContentsOfFileThreadSafe(pFileName);
pRet->autorelease();
return pRet;
return createWithContentsOfFileThreadSafe(pFileName);
}
bool Dictionary::writeToFile(const char *fullPath)
@ -395,8 +399,7 @@ bool Dictionary::writeToFile(const char *fullPath)
Dictionary* Dictionary::clone() const
{
Dictionary* newDict = new Dictionary();
newDict->autorelease();
Dictionary* newDict = Dictionary::create();
DictElement* element = NULL;
Object* tmpObj = NULL;

View File

@ -172,7 +172,7 @@ public:
class CC_DLL Dictionary : public Object, public Clonable
{
public:
/**
/**
* The constructor of Dictionary.
*/
Dictionary();
@ -182,6 +182,8 @@ public:
*/
~Dictionary();
/** Initializes the dictionary. It returns true if the initializations was successful. */
bool init();
/**
* Get the count of elements in Dictionary.
*

View File

@ -1,7 +1,32 @@
/****************************************************************************
Copyright (c) 2010-2012 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 __CCINTEGER_H__
#define __CCINTEGER_H__
#include "CCObject.h"
#include "platform/CCCommon.h"
NS_CC_BEGIN
@ -13,10 +38,6 @@ NS_CC_BEGIN
class CC_DLL Integer : public Object, public Clonable
{
public:
Integer(int v)
: _value(v) {}
int getValue() const {return _value;}
static Integer* create(int v)
{
Integer* pRet = new Integer(v);
@ -24,10 +45,19 @@ public:
return pRet;
}
Integer(int v)
: _value(v) {}
int getValue() const {return _value;}
virtual ~Integer() {
CCLOGINFO("deallocing ~Integer: %p", this);
}
/* override functions */
virtual void acceptVisitor(DataVisitor &visitor) { visitor.visit(this); }
Integer* clone() const
// overrides
virtual Integer* clone() const override
{
return Integer::create(_value);
}

View File

@ -1,3 +1,27 @@
/****************************************************************************
Copyright (c) 2010-2012 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 "CCString.h"
#include "platform/CCFileUtils.h"
#include "ccMacros.h"
@ -26,7 +50,9 @@ String::String(const String& str)
{}
String::~String()
{
{
CCLOGINFO("deallocing String: %p", this);
_string.clear();
}

View File

@ -93,7 +93,7 @@ void Grabber::afterRender(cocos2d::Texture2D *texture)
Grabber::~Grabber()
{
CCLOGINFO("cocos2d: deallocing %p", this);
CCLOGINFO("deallocing Grabber: %p", this);
glDeleteFramebuffers(1, &_FBO);
}

View File

@ -148,7 +148,7 @@ bool GridBase::initWithSize(const Size& gridSize)
GridBase::~GridBase(void)
{
CCLOGINFO("cocos2d: deallocing %p", this);
CCLOGINFO("deallocing GridBase: %p", this);
//TODO: ? why 2.0 comments this line setActive(false);
CC_SAFE_RELEASE(_texture);

View File

@ -31,13 +31,13 @@ NS_CC_BEGIN
Label* Label::createWithTTF( const char* label, const char* fontFilePath, int fontSize, int lineSize, TextHAlignment alignment, GlyphCollection glyphs, const char *customGlyphs )
{
FontAtlas *tempAtlas = FontAtlasCache::getFontAtlasTTF(fontFilePath, fontSize, glyphs, customGlyphs);
FontAtlas *tmpAtlas = FontAtlasCache::getFontAtlasTTF(fontFilePath, fontSize, glyphs, customGlyphs);
if (!tempAtlas)
if (!tmpAtlas)
return nullptr;
// create the actual label
Label* templabel = Label::createWithAtlas(tempAtlas, alignment, lineSize);
Label* templabel = Label::createWithAtlas(tmpAtlas, alignment, lineSize);
if (templabel)
{
@ -53,12 +53,12 @@ Label* Label::createWithTTF( const char* label, const char* fontFilePath, int fo
Label* Label::createWithBMFont( const char* label, const char* bmfontFilePath, TextHAlignment alignment, int lineSize)
{
FontAtlas *tempAtlas = FontAtlasCache::getFontAtlasFNT(bmfontFilePath);
FontAtlas *tmpAtlas = FontAtlasCache::getFontAtlasFNT(bmfontFilePath);
if (!tempAtlas)
if (!tmpAtlas)
return 0;
Label* templabel = Label::createWithAtlas(tempAtlas, alignment, lineSize);
Label* templabel = Label::createWithAtlas(tmpAtlas, alignment, lineSize);
if (templabel)
{
@ -73,9 +73,9 @@ Label* Label::createWithBMFont( const char* label, const char* bmfontFilePath, T
return 0;
}
Label* Label::createWithAtlas(FontAtlas *pAtlas, TextHAlignment alignment, int lineSize)
Label* Label::createWithAtlas(FontAtlas *atlas, TextHAlignment alignment, int lineSize)
{
Label *ret = new Label(pAtlas, alignment);
Label *ret = new Label(atlas, alignment);
if (!ret)
return 0;
@ -94,24 +94,28 @@ Label* Label::createWithAtlas(FontAtlas *pAtlas, TextHAlignment alignment, int l
return ret;
}
Label::Label(FontAtlas *pAtlas, TextHAlignment alignment): _currentUTF8String(0),
_originalUTF8String(0),
_fontAtlas(pAtlas),
_alignment(alignment),
_lineBreakWithoutSpaces(false),
_advances(0),
_displayedColor(Color3B::WHITE),
_realColor(Color3B::WHITE),
_cascadeColorEnabled(true),
_cascadeOpacityEnabled(true),
_displayedOpacity(255),
_realOpacity(255),
_isOpacityModifyRGB(false)
Label::Label(FontAtlas *atlas, TextHAlignment alignment)
: _currentUTF8String(0)
, _originalUTF8String(0)
, _fontAtlas(atlas)
, _alignment(alignment)
, _lineBreakWithoutSpaces(false)
, _advances(0)
, _displayedColor(Color3B::WHITE)
, _realColor(Color3B::WHITE)
, _cascadeColorEnabled(true)
, _cascadeOpacityEnabled(true)
, _displayedOpacity(255)
, _realOpacity(255)
, _isOpacityModifyRGB(false)
{
}
Label::~Label()
{
CC_SAFE_RELEASE(_spriteArray);
CC_SAFE_RELEASE(_spriteArrayCache);
if (_currentUTF8String)
delete [] _currentUTF8String;
@ -124,6 +128,12 @@ Label::~Label()
bool Label::init()
{
_spriteArray = Array::createWithCapacity(30);
_spriteArrayCache = Array::createWithCapacity(30);
_spriteArray->retain();
_spriteArrayCache->retain();
return true;
}
@ -253,12 +263,12 @@ void Label::alignText()
void Label::hideAllLetters()
{
Object* Obj = NULL;
CCARRAY_FOREACH(&_spriteArray, Obj)
CCARRAY_FOREACH(_spriteArray, Obj)
{
((Sprite *)Obj)->setVisible(false);
}
CCARRAY_FOREACH(&_spriteArrayCache, Obj)
CCARRAY_FOREACH(_spriteArrayCache, Obj)
{
((Sprite *)Obj)->setVisible(false);
}
@ -431,21 +441,21 @@ Sprite * Label::updateSpriteForLetter(Sprite *spriteToUpdate, unsigned short int
void Label::moveAllSpritesToCache()
{
Object* pObj = NULL;
CCARRAY_FOREACH(&_spriteArray, pObj)
CCARRAY_FOREACH(_spriteArray, pObj)
{
((Sprite *)pObj)->removeFromParent();
_spriteArrayCache.addObject(pObj);
_spriteArrayCache->addObject(pObj);
}
_spriteArray.removeAllObjects();
_spriteArray->removeAllObjects();
}
Sprite * Label::getSprite()
{
if (_spriteArrayCache.count())
if (_spriteArrayCache->count())
{
Sprite *retSprite = (Sprite *) _spriteArrayCache.getLastObject();
_spriteArrayCache.removeLastObject();
Sprite *retSprite = static_cast<Sprite *>( _spriteArrayCache->getLastObject() );
_spriteArrayCache->removeLastObject();
return retSprite;
}
else
@ -460,7 +470,7 @@ Sprite * Label::getSprite()
Sprite * Label::getSpriteChild(int ID)
{
Object* pObj = NULL;
CCARRAY_FOREACH(&_spriteArray, pObj)
CCARRAY_FOREACH(_spriteArray, pObj)
{
Sprite *pSprite = (Sprite *)pObj;
if ( pSprite->getTag() == ID)
@ -471,9 +481,9 @@ Sprite * Label::getSpriteChild(int ID)
return 0;
}
Array * Label::getChildrenLetters()
Array* Label::getChildrenLetters()
{
return &_spriteArray;
return _spriteArray;
}
Sprite * Label::getSpriteForChar(unsigned short int theChar, int spriteIndexHint)
@ -493,7 +503,7 @@ Sprite * Label::getSpriteForChar(unsigned short int theChar, int spriteIndexHint
if (retSprite)
retSprite->setTag(spriteIndexHint);
_spriteArray.addObject(retSprite);
_spriteArray->addObject(retSprite);
}
// the sprite is now visible

View File

@ -139,8 +139,8 @@ private:
Sprite * getSpriteForLetter(unsigned short int newLetter);
Sprite * updateSpriteForLetter(Sprite *spriteToUpdate, unsigned short int newLetter);
Array _spriteArray;
Array _spriteArrayCache;
Array * _spriteArray;
Array * _spriteArrayCache;
float _commonLineHeight;
bool _lineBreakWithoutSpaces;
float _width;

View File

@ -69,6 +69,7 @@ CCBMFontConfiguration* FNTConfigLoadFile( const char *fntFile)
if( s_pConfigurations == NULL )
{
s_pConfigurations = new Dictionary();
s_pConfigurations->init();
}
pRet = static_cast<CCBMFontConfiguration*>( s_pConfigurations->objectForKey(fntFile) );
@ -140,7 +141,7 @@ CCBMFontConfiguration::CCBMFontConfiguration()
CCBMFontConfiguration::~CCBMFontConfiguration()
{
CCLOGINFO( "cocos2d: deallocing CCBMFontConfiguration %p", this );
CCLOGINFO( "deallocing CCBMFontConfiguration: %p", this );
this->purgeFontDefDictionary();
this->purgeKerningDictionary();
_atlasName.clear();

View File

@ -25,7 +25,7 @@ THE SOFTWARE.
#ifndef __CCACCELEROMETER_DELEGATE_H__
#define __CCACCELEROMETER_DELEGATE_H__
#include "CCCommon.h"
#include "platform/CCCommon.h"
NS_CC_BEGIN
/**

View File

@ -51,7 +51,7 @@ extern "C"
#endif
#include "ccMacros.h"
#include "CCCommon.h"
#include "platform/CCCommon.h"
#include "CCStdC.h"
#include "CCFileUtils.h"
#include "CCConfiguration.h"

View File

@ -25,7 +25,7 @@
#define __CCSAXPARSER_H__
#include "CCPlatformConfig.h"
#include "CCCommon.h"
#include "platform/CCCommon.h"
NS_CC_BEGIN

View File

@ -25,7 +25,7 @@ THE SOFTWARE.
#ifndef __CC_PLATFORM_THREAD_H__
#define __CC_PLATFORM_THREAD_H__
#include "CCCommon.h"
#include "platform/CCCommon.h"
#include "CCPlatformMacros.h"
NS_CC_BEGIN

View File

@ -22,7 +22,7 @@
THE SOFTWARE.
****************************************************************************/
#include "CCCommon.h"
#include "platform/CCCommon.h"
#include <stdarg.h>
#include <stdio.h>

View File

@ -33,7 +33,6 @@
#import "CCES2Renderer.h"
#import "OpenGL_Internal.h"
@implementation CCES2Renderer
@synthesize context=context_;
@ -207,7 +206,7 @@
- (void)dealloc
{
NSLog(@"cocos2d: deallocing %@", self);
// CCLOGINFO("deallocing CCES2Renderer: %p", self);
// Tear down GL
if (defaultFramebuffer_) {

View File

@ -65,6 +65,7 @@ static void addItemToArray(id item, Array *pArray)
// add dictionary value into array
if ([item isKindOfClass:[NSDictionary class]]) {
Dictionary* pDictItem = new Dictionary();
pDictItem->init();
for (id subKey in [item allKeys]) {
id subValue = [item objectForKey:subKey];
addValueToDict(subKey, subValue, pDictItem);
@ -130,6 +131,7 @@ static void addValueToDict(id key, id value, Dictionary* pDict)
// the value is a new dictionary
if ([value isKindOfClass:[NSDictionary class]]) {
Dictionary* pSubDict = new Dictionary();
pSubDict->init();
for (id subKey in [value allKeys]) {
id subValue = [value objectForKey:subKey];
addValueToDict(subKey, subValue, pSubDict);
@ -314,7 +316,7 @@ Dictionary* FileUtilsIOS::createDictionaryWithContentsOfFile(const std::string&
if (pDict != nil)
{
Dictionary* pRet = new Dictionary();
Dictionary* pRet = Dictionary::create();
for (id key in [pDict allKeys]) {
id value = [pDict objectForKey:key];
addValueToDict(key, value, pRet);

View File

@ -25,7 +25,7 @@ THE SOFTWARE.
#import "CCImage.h"
#import "CCFileUtils.h"
#import "CCCommon.h"
#import "platform/CCCommon.h"
#import <string>
#import <Foundation/Foundation.h>

View File

@ -59,7 +59,7 @@ static id s_sharedDirectorCaller;
-(void) dealloc
{
s_sharedDirectorCaller = nil;
CCLOG("cocos2d: deallocing DirectorCaller %p", self);
CCLOGINFO("deallocing DirectorCaller: %p", self);
if (displayLink) {
CVDisplayLinkRelease(displayLink);
}

View File

@ -53,7 +53,7 @@ EGLView::EGLView(void)
EGLView::~EGLView(void)
{
CCLOG("cocos2d: deallocing EGLView %p", this);
CCLOGINFO("deallocing EGLView: %p", this);
s_sharedView = NULL;
}

View File

@ -38,13 +38,13 @@ NS_CC_BEGIN
static void addValueToDict(id key, id value, Dictionary* pDict);
static void addObjectToNSDict(const char*key, Object* object, NSMutableDictionary *dict);
static void addItemToArray(id item, Array *pArray)
static void addItemToArray(id item, Array *array)
{
// add string value into array
if ([item isKindOfClass:[NSString class]]) {
String* pValue = new String([item UTF8String]);
pArray->addObject(pValue);
array->addObject(pValue);
pValue->release();
return;
}
@ -54,7 +54,7 @@ static void addItemToArray(id item, Array *pArray)
NSString* pStr = [item stringValue];
String* pValue = new String([pStr UTF8String]);
pArray->addObject(pValue);
array->addObject(pValue);
pValue->release();
return;
}
@ -62,24 +62,25 @@ static void addItemToArray(id item, Array *pArray)
// add dictionary value into array
if ([item isKindOfClass:[NSDictionary class]]) {
Dictionary* pDictItem = new Dictionary();
pDictItem->init();
for (id subKey in [item allKeys]) {
id subValue = [item objectForKey:subKey];
addValueToDict(subKey, subValue, pDictItem);
}
pArray->addObject(pDictItem);
array->addObject(pDictItem);
pDictItem->release();
return;
}
// add array value into array
if ([item isKindOfClass:[NSArray class]]) {
Array *pArrayItem = new Array();
pArrayItem->init();
Array *arrayItem = new Array();
arrayItem->initWithCapacity( [item count] );
for (id subItem in item) {
addItemToArray(subItem, pArrayItem);
addItemToArray(subItem, arrayItem);
}
pArray->addObject(pArrayItem);
pArrayItem->release();
array->addObject(arrayItem);
arrayItem->release();
return;
}
}
@ -157,13 +158,13 @@ static void addValueToDict(id key, id value, Dictionary* pDict)
// the value is a array
if ([value isKindOfClass:[NSArray class]]) {
Array *pArray = new Array();
pArray->init();
Array *array = new Array();
array->initWithCapacity([value count]);
for (id item in value) {
addItemToArray(item, pArray);
addItemToArray(item, array);
}
pDict->setObject(pArray, pKey.c_str());
pArray->release();
pDict->setObject(array, pKey.c_str());
array->release();
return;
}
}
@ -304,7 +305,7 @@ Dictionary* FileUtilsMac::createDictionaryWithContentsOfFile(const std::string&
NSString* pPath = [NSString stringWithUTF8String:fullPath.c_str()];
NSDictionary* pDict = [NSDictionary dictionaryWithContentsOfFile:pPath];
Dictionary* pRet = new Dictionary();
Dictionary* pRet = Dictionary::create();
for (id key in [pDict allKeys]) {
id value = [pDict objectForKey:key];
addValueToDict(key, value, pRet);
@ -337,12 +338,10 @@ Array* FileUtilsMac::createArrayWithContentsOfFile(const std::string& filename)
// pPath = [[NSBundle mainBundle] pathForResource:pPath ofType:pathExtension];
// fixing cannot read data using Array::createWithContentsOfFile
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(filename.c_str());
NSString* path = [NSString stringWithUTF8String:fullPath.c_str()];
NSArray* array = [NSArray arrayWithContentsOfFile:path];
Array* ret = new Array();
ret->init();
NSString* pPath = [NSString stringWithUTF8String:fullPath.c_str()];
NSArray* array = [NSArray arrayWithContentsOfFile:pPath];
Array* ret = Array::createWithCapacity( [array count] );
for (id value in array) {
addItemToArray(value, ret);
}

View File

@ -201,7 +201,7 @@ static CCEAGLView *view;
- (void) dealloc
{
CCLOGINFO(@"cocos2d: deallocing CCEAGLView %@", self);
CCLOGINFO("deallocing CCEAGLView: %p", self);
[super dealloc];
}

View File

@ -82,7 +82,7 @@ GLProgram::GLProgram()
GLProgram::~GLProgram()
{
CCLOGINFO("cocos2d: %s %d deallocing %p", __FUNCTION__, __LINE__, this);
CCLOGINFO("%s %d deallocing GLProgram: %p", __FUNCTION__, __LINE__, this);
// there is no need to delete the shaders. They should have been already deleted.
CCASSERT(_vertShader == 0, "Vertex Shaders should have been already deleted");

View File

@ -83,13 +83,15 @@ ShaderCache::ShaderCache()
ShaderCache::~ShaderCache()
{
CCLOGINFO("cocos2d deallocing %p", this);
CCLOGINFO("deallocing ShaderCache: %p", this);
_programs->release();
}
bool ShaderCache::init()
{
_programs = new Dictionary();
_programs = Dictionary::create();
_programs->retain();
loadDefaultShaders();
return true;
}

View File

@ -50,7 +50,7 @@ bool AnimationFrame::initWithSpriteFrame(SpriteFrame* spriteFrame, float delayUn
AnimationFrame::~AnimationFrame()
{
CCLOGINFO( "cocos2d: deallocing %p", this);
CCLOGINFO( "deallocing AnimationFrame: %p", this);
CC_SAFE_RELEASE(_spriteFrame);
CC_SAFE_RELEASE(_userInfo);
@ -159,7 +159,7 @@ Animation::Animation()
Animation::~Animation(void)
{
CCLOGINFO("cocos2d, deallocing %p", this);
CCLOGINFO("deallocing Animation: %p", this);
CC_SAFE_RELEASE(_frames);
}

View File

@ -55,7 +55,8 @@ void AnimationCache::destroyInstance()
bool AnimationCache::init()
{
_animations = new Dictionary();
_animations = new Dictionary;
_animations->init();
return true;
}
@ -66,7 +67,7 @@ AnimationCache::AnimationCache()
AnimationCache::~AnimationCache()
{
CCLOGINFO("cocos2d: deallocing %p", this);
CCLOGINFO("deallocing AnimationCache: %p", this);
CC_SAFE_RELEASE(_animations);
}

View File

@ -116,7 +116,7 @@ bool SpriteFrame::initWithTextureFilename(const char* filename, const Rect& rect
SpriteFrame::~SpriteFrame(void)
{
CCLOGINFO("cocos2d: deallocing %p", this);
CCLOGINFO("deallocing SpriteFrame: %p", this);
CC_SAFE_RELEASE(_texture);
}

View File

@ -64,7 +64,9 @@ void SpriteFrameCache::destroyInstance()
bool SpriteFrameCache::init(void)
{
_spriteFrames= new Dictionary();
_spriteFrames->init();
_spriteFramesAliases = new Dictionary();
_spriteFramesAliases->init();
_loadedFileNames = new std::set<std::string>();
return true;
}

View File

@ -79,6 +79,7 @@ void Profiler::releaseAllTimers()
bool Profiler::init()
{
_activeTimers = new Dictionary();
_activeTimers->init();
return true;
}

View File

@ -437,7 +437,7 @@ Texture2D::~Texture2D()
VolatileTexture::removeTexture(this);
#endif
CCLOGINFO("cocos2d: deallocing Texture2D %u.", _name);
CCLOGINFO("deallocing Texture2D: %p - id=%u", this, _name);
CC_SAFE_RELEASE(_shaderProgram);
if(_name)

View File

@ -53,7 +53,7 @@ TextureAtlas::TextureAtlas()
TextureAtlas::~TextureAtlas()
{
CCLOGINFO("cocos2d: TextureAtlas deallocing %p.", this);
CCLOGINFO("deallocing TextureAtlas: %p", this);
CC_SAFE_FREE(_quads);
CC_SAFE_FREE(_indices);

View File

@ -72,14 +72,17 @@ TextureCache::TextureCache()
, _imageInfoQueue(nullptr)
, _needQuit(false)
, _asyncRefCount(0)
, _textures(new Dictionary())
{
CCASSERT(_sharedTextureCache == nullptr, "Attempted to allocate a second instance of a singleton.");
_textures = new Dictionary();
_textures->init();
}
TextureCache::~TextureCache()
{
CCLOGINFO("cocos2d: deallocing TextureCache: %p", this);
CCLOGINFO("deallocing TextureCache: %p", this);
CC_SAFE_RELEASE(_textures);

View File

@ -38,11 +38,12 @@ TMXObjectGroup::TMXObjectGroup()
_objects = Array::create();
_objects->retain();
_properties = new Dictionary();
_properties->init();
}
TMXObjectGroup::~TMXObjectGroup()
{
CCLOGINFO( "cocos2d: deallocing: %p", this);
CCLOGINFO("deallocing TMXObjectGroup: %p", this);
CC_SAFE_RELEASE(_objects);
CC_SAFE_RELEASE(_properties);
}

View File

@ -56,12 +56,13 @@ TMXLayerInfo::TMXLayerInfo()
, _maxGID(0)
, _offset(Point::ZERO)
{
_properties= new Dictionary();;
_properties = new Dictionary();
_properties->init();
}
TMXLayerInfo::~TMXLayerInfo()
{
CCLOGINFO("cocos2d: deallocing: %p", this);
CCLOGINFO("deallocing TMXLayerInfo: %p", this);
CC_SAFE_RELEASE(_properties);
if( _ownTiles && _tiles )
{
@ -93,7 +94,7 @@ TMXTilesetInfo::TMXTilesetInfo()
TMXTilesetInfo::~TMXTilesetInfo()
{
CCLOGINFO("cocos2d: deallocing: %p", this);
CCLOGINFO("deallocing TMXTilesetInfo: %p", this);
}
Rect TMXTilesetInfo::rectForGID(unsigned int gid)
@ -157,7 +158,9 @@ void TMXMapInfo::internalInit(const char* tmxFileName, const char* resourcePath)
_objectGroups->retain();
_properties = new Dictionary();
_properties->init();
_tileProperties = new Dictionary();
_tileProperties->init();
// tmp vars
_currentString = "";
@ -194,7 +197,7 @@ TMXMapInfo::TMXMapInfo()
TMXMapInfo::~TMXMapInfo()
{
CCLOGINFO("cocos2d: deallocing: %p", this);
CCLOGINFO("deallocing TMXMapInfo: %p", this);
CC_SAFE_RELEASE(_tilesets);
CC_SAFE_RELEASE(_layers);
CC_SAFE_RELEASE(_properties);
@ -368,6 +371,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts)
{
TMXTilesetInfo* info = (TMXTilesetInfo*)pTMXMapInfo->getTilesets()->getLastObject();
Dictionary *dict = new Dictionary();
dict->init();
pTMXMapInfo->setParentGID(info->_firstGid + atoi(valueForKey("id", attributeDict)));
pTMXMapInfo->getTileProperties()->setObject(dict, pTMXMapInfo->getParentGID());
CC_SAFE_RELEASE(dict);
@ -502,6 +506,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts)
// The value for "type" was blank or not a valid class name
// Create an instance of TMXObjectInfo to store the object and its properties
Dictionary *dict = new Dictionary();
dict->init();
// Parse everything automatically
const char* pArray[] = {"name", "type", "width", "height", "gid"};
@ -618,7 +623,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts)
const char* value = valueForKey("points", attributeDict);
if(value)
{
Array* pPointsArray = new Array;
Array* pointsArray = Array::createWithCapacity(10);
// parse points string into a space-separated set of points
stringstream pointsStream(value);
@ -630,7 +635,8 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts)
string xStr,yStr;
char buffer[32] = {0};
Dictionary* pPointDict = new Dictionary;
Dictionary* pointDict = new Dictionary;
pointDict->init();
// set x
if(std::getline(pointStream, xStr, ','))
@ -639,7 +645,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts)
sprintf(buffer, "%d", x);
String* pStr = new String(buffer);
pStr->autorelease();
pPointDict->setObject(pStr, "x");
pointDict->setObject(pStr, "x");
}
// set y
@ -649,16 +655,15 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts)
sprintf(buffer, "%d", y);
String* pStr = new String(buffer);
pStr->autorelease();
pPointDict->setObject(pStr, "y");
pointDict->setObject(pStr, "y");
}
// add to points array
pPointsArray->addObject(pPointDict);
pPointDict->release();
pointsArray->addObject(pointDict);
pointDict->release();
}
dict->setObject(pPointsArray, "points");
pPointsArray->release();
dict->setObject(pointsArray, "points");
}
}
else if (elementName == "polyline")

View File

@ -56,6 +56,7 @@ bool TileMapAtlas::initWithTileFile(const char *tile, const char *mapFile, int t
if( AtlasNode::initWithTileFile(tile, tileWidth, tileHeight, _itemsToRender) )
{
_posToAtlasIndex = new Dictionary();
_posToAtlasIndex->init();
this->updateAtlasValues();
this->setContentSize(Size((float)(_TGAInfo->width*_itemWidth),
(float)(_TGAInfo->height*_itemHeight)));

View File

@ -84,10 +84,12 @@ Armature::Armature()
Armature::~Armature(void)
{
CCLOGINFO("deallocing Armature: %p", this);
if(NULL != _boneDic)
{
_boneDic->removeAllObjects();
CC_SAFE_DELETE(_boneDic);
CC_SAFE_RELEASE(_boneDic);
}
if (NULL != _topBoneList)
{
@ -115,12 +117,13 @@ bool Armature::init(const char *name)
_animation = new ArmatureAnimation();
_animation->init(this);
CC_SAFE_DELETE(_boneDic);
CC_SAFE_RELEASE(_boneDic);
_boneDic = new Dictionary();
_boneDic->init();
CC_SAFE_DELETE(_topBoneList);
_topBoneList = new Array();
_topBoneList->init();
_topBoneList = Array::create();
_topBoneList->retain();
_blendFunc = BlendFunc::ALPHA_PREMULTIPLIED;
@ -145,7 +148,7 @@ bool Armature::init(const char *name)
DictElement *_element = NULL;
Dictionary *boneDataDic = &armatureData->boneDataDic;
Dictionary *boneDataDic = armatureData->boneDataDic;
CCDICT_FOREACH(boneDataDic, _element)
{
Bone *bone = createBone(_element->getStrKey());
@ -158,7 +161,7 @@ bool Armature::init(const char *name)
CC_BREAK_IF(!movData);
MovementBoneData *movBoneData = movData->getMovementBoneData(bone->getName().c_str());
CC_BREAK_IF(!movBoneData || movBoneData->frameList.count() <= 0);
CC_BREAK_IF(!movBoneData || movBoneData->frameList->count() <= 0);
FrameData *frameData = movBoneData->getFrameData(0);
CC_BREAK_IF(!frameData);

View File

@ -57,6 +57,8 @@ ArmatureAnimation::ArmatureAnimation()
ArmatureAnimation::~ArmatureAnimation(void)
{
CCLOGINFO("deallocing ArmatureAnimation: %p", this);
CC_SAFE_RELEASE_NULL(_tweenList);
CC_SAFE_RELEASE_NULL(_animationData);
}
@ -185,10 +187,10 @@ void ArmatureAnimation::play(const char *animationName, int durationTo, int dura
CCDICT_FOREACH(dict, element)
{
Bone *bone = (Bone *)element->getObject();
movementBoneData = (MovementBoneData *)_movementData->movBoneDataDic.objectForKey(bone->getName());
movementBoneData = (MovementBoneData *)_movementData->movBoneDataDic->objectForKey(bone->getName());
Tween *tween = bone->getTween();
if(movementBoneData && movementBoneData->frameList.count() > 0)
if(movementBoneData && movementBoneData->frameList->count() > 0)
{
_tweenList->addObject(tween);
tween->play(movementBoneData, durationTo, durationTween, loop, tweenEasing);

View File

@ -110,7 +110,7 @@ void Tween::play(MovementBoneData *movementBoneData, int durationTo, int duratio
setMovementBoneData(movementBoneData);
if (_movementBoneData->frameList.count() == 1)
if (_movementBoneData->frameList->count() == 1)
{
_loopType = SINGLE_FRAME;
FrameData *_nextKeyFrame = _movementBoneData->getFrameData(0);
@ -128,7 +128,7 @@ void Tween::play(MovementBoneData *movementBoneData, int durationTo, int duratio
_rawDuration = _movementBoneData->duration;
_fromIndex = _toIndex = 0;
}
else if (_movementBoneData->frameList.count() > 1)
else if (_movementBoneData->frameList->count() > 1)
{
if (loop)
{
@ -383,7 +383,7 @@ float Tween::updateFrameData(float currentPrecent, bool activeFrame)
* Get frame length, if _toIndex >= _length, then set _toIndex to 0, start anew.
* _toIndex is next index will play
*/
int length = _movementBoneData->frameList.count();
int length = _movementBoneData->frameList->count();
do
{
betweenDuration = _movementBoneData->getFrameData(_toIndex)->duration;

View File

@ -209,22 +209,24 @@ BoneData::BoneData(void)
BoneData::~BoneData(void)
{
CC_SAFE_RELEASE(displayDataList);
}
bool BoneData::init()
{
displayDataList.init();
displayDataList = new Array;
displayDataList->init();
return true;
}
void BoneData::addDisplayData(DisplayData *displayData)
{
displayDataList.addObject(displayData);
displayDataList->addObject(displayData);
}
DisplayData *BoneData::getDisplayData(int index)
{
return (DisplayData *)displayDataList.getObjectAtIndex(index);
return static_cast<DisplayData *>( displayDataList->getObjectAtIndex(index) );
}
ArmatureData::ArmatureData()
@ -233,22 +235,30 @@ ArmatureData::ArmatureData()
ArmatureData::~ArmatureData()
{
CC_SAFE_RELEASE(boneList);
CC_SAFE_RELEASE(boneDataDic);
}
bool ArmatureData::init()
{
return boneList.init();
boneList = new Array;
boneList->init();
boneDataDic = new Dictionary;
boneDataDic->init();
return true;
}
void ArmatureData::addBoneData(BoneData *boneData)
{
boneDataDic.setObject(boneData, boneData->name);
boneList.addObject(boneData);
boneDataDic->setObject(boneData, boneData->name);
boneList->addObject(boneData);
}
BoneData *ArmatureData::getBoneData(const char *boneName)
{
return (BoneData *)boneDataDic.objectForKey(boneName);
return static_cast<BoneData *>( boneDataDic->objectForKey(boneName) );
}
FrameData::FrameData(void)
@ -282,30 +292,31 @@ MovementBoneData::MovementBoneData()
, duration(0)
, name("")
{
frameList = new Array;
frameList->init();
}
MovementBoneData::~MovementBoneData(void)
{
CC_SAFE_RELEASE(frameList);
}
bool MovementBoneData::init()
{
return frameList.init();
return true;
}
void MovementBoneData::addFrameData(FrameData *frameData)
{
frameList.addObject(frameData);
frameList->addObject(frameData);
duration += frameData->duration;
}
FrameData *MovementBoneData::getFrameData(int index)
{
return (FrameData *)frameList.getObjectAtIndex(index);
return static_cast<FrameData *>( frameList->getObjectAtIndex(index) );
}
MovementData::MovementData(void)
: name("")
, duration(0)
@ -314,30 +325,36 @@ MovementData::MovementData(void)
, loop(true)
, tweenEasing(Linear)
{
movBoneDataDic = new Dictionary;
movBoneDataDic->init();
}
MovementData::~MovementData(void)
{
CC_SAFE_RELEASE(movBoneDataDic);
}
void MovementData::addMovementBoneData(MovementBoneData *movBoneData)
{
movBoneDataDic.setObject(movBoneData, movBoneData->name);
movBoneDataDic->setObject(movBoneData, movBoneData->name);
}
MovementBoneData *MovementData::getMovementBoneData(const char *boneName)
{
return (MovementBoneData *)movBoneDataDic.objectForKey(boneName);
return static_cast<MovementBoneData *>( movBoneDataDic->objectForKey(boneName) );
}
AnimationData::AnimationData(void)
{
movementDataDic = new Dictionary;
movementDataDic->init();
}
AnimationData::~AnimationData(void)
{
CC_SAFE_RELEASE(movementDataDic);
}
void AnimationData::release()
@ -352,33 +369,36 @@ void AnimationData::retain()
void AnimationData::addMovement(MovementData *movData)
{
movementDataDic.setObject(movData, movData->name);
movementDataDic->setObject(movData, movData->name);
movementNames.push_back(movData->name);
}
MovementData *AnimationData::getMovement(const char *movementName)
{
return (MovementData *)movementDataDic.objectForKey(movementName);
return (MovementData *)movementDataDic->objectForKey(movementName);
}
int AnimationData::getMovementCount()
{
return movementDataDic.count();
return movementDataDic->count();
}
ContourData::ContourData()
{
vertexList = new Array;
vertexList->init();
}
ContourData::~ContourData()
{
CC_SAFE_RELEASE(vertexList);
}
bool ContourData::init()
{
return vertexList.init();
return true;
}
TextureData::TextureData()
@ -388,25 +408,28 @@ TextureData::TextureData()
, pivotY(0.5f)
, name("")
{
contourDataList = new Array;
contourDataList->init();
}
TextureData::~TextureData()
{
CC_SAFE_RELEASE(contourDataList);
}
bool TextureData::init()
{
return contourDataList.init();
return true;
}
void TextureData::addContourData(ContourData *contourData)
{
contourDataList.addObject(contourData);
contourDataList->addObject(contourData);
}
ContourData *TextureData::getContourData(int index)
{
return (ContourData *)contourDataList.getObjectAtIndex(index);
return static_cast<ContourData *>( contourDataList->getObjectAtIndex(index) );
}

View File

@ -244,7 +244,7 @@ public:
public:
std::string name; //! the bone's name
std::string parentName; //! the bone parent's name
Array displayDataList; //! save DisplayData informations for the Bone
Array *displayDataList; //! save DisplayData informations for the Bone
};
@ -266,8 +266,8 @@ public:
BoneData *getBoneData(const char *boneName);
public:
std::string name;
Dictionary boneDataDic;
Array boneList;
Dictionary *boneDataDic;
Array *boneList;
};
@ -318,7 +318,7 @@ public:
float duration; //! this Bone in this movement will last _duration frames
std::string name; //! bone name
Array frameList;
Array *frameList;
};
@ -363,7 +363,7 @@ public:
* Dictionary to save movment bone data.
* Key type is std::string, value type is MovementBoneData *.
*/
Dictionary movBoneDataDic;
Dictionary *movBoneDataDic;
};
@ -388,7 +388,7 @@ public:
int getMovementCount();
public:
std::string name;
Dictionary movementDataDic;
Dictionary *movementDataDic;
std::vector<std::string> movementNames;
};
@ -418,7 +418,7 @@ public:
virtual bool init();
public:
Array vertexList; //! Save contour vertex info, vertex saved in a Point
Array *vertexList; //! Save contour vertex info, vertex saved in a Point
};
@ -449,7 +449,7 @@ public:
std::string name; //! The texture's name
Array contourDataList;
Array *contourDataList;
};

View File

@ -153,12 +153,12 @@ void DisplayFactory::createSpriteDisplay(Bone *bone, DecorativeDisplay *decoDisp
decoDisplay->setDisplay(skin);
#if ENABLE_PHYSICS_DETECT
if (textureData && textureData->contourDataList.count() > 0)
if (textureData && textureData->contourDataList->count() > 0)
{
//! create ContourSprite
ColliderDetector *colliderDetector = ColliderDetector::create(bone);
colliderDetector->addContourDataList(&textureData->contourDataList);
colliderDetector->addContourDataList(textureData->contourDataList);
decoDisplay->setColliderDetector(colliderDetector);
}

View File

@ -210,7 +210,7 @@ DecorativeDisplay *DisplayManager::getCurrentDecorativeDisplay()
DecorativeDisplay *DisplayManager::getDecorativeDisplayByIndex( int index)
{
return (DecorativeDisplay *)_decoDisplayList->getObjectAtIndex(index);
return static_cast<DecorativeDisplay *>( _decoDisplayList->getObjectAtIndex(index) );
}
void DisplayManager::initDisplayList(BoneData *boneData)
@ -222,7 +222,7 @@ void DisplayManager::initDisplayList(BoneData *boneData)
CS_RETURN_IF(!boneData);
Object *object = NULL;
Array *displayDataList = &boneData->displayDataList;
Array *displayDataList = boneData->displayDataList;
CCARRAY_FOREACH(displayDataList, object)
{
DisplayData *displayData = static_cast<DisplayData *>(object);

View File

@ -299,7 +299,7 @@ Texture2DMutable::Texture2DMutable(void)
Texture2DMutable::~Texture2DMutable(void)
{
CCLOGINFO("cocos2d: deallocing %p", this);
CCLOGINFO("deallocing Texture2DMutable: %p", this);
CC_SAFE_DELETE(image_);

View File

@ -93,10 +93,10 @@ bool ColliderDetector::init(Bone *bone)
void ColliderDetector::addContourData(ContourData *contourData)
{
const Array *array = &contourData->vertexList;
const Array *array = contourData->vertexList;
Object *object = NULL;
b2Vec2 *b2bv = new b2Vec2[contourData->vertexList.count()];
b2Vec2 *b2bv = new b2Vec2[contourData->vertexList->count()];
int i = 0;
CCARRAY_FOREACH(array, object)
@ -107,7 +107,7 @@ void ColliderDetector::addContourData(ContourData *contourData)
}
b2PolygonShape polygon;
polygon.Set(b2bv, contourData->vertexList.count());
polygon.Set(b2bv, contourData->vertexList->count());
CC_SAFE_DELETE(b2bv);
@ -183,7 +183,7 @@ void ColliderDetector::updateTransform(AffineTransform &t)
b2PolygonShape *shape = (b2PolygonShape *)body->GetFixtureList()->GetShape();
//! update every vertex
const Array *array = &contourData->vertexList;
const Array *array = contourData->vertexList;
Object *object = NULL;
int i = 0;
CCARRAY_FOREACH(array, object)

View File

@ -57,11 +57,13 @@ ArmatureDataManager::ArmatureDataManager(void)
ArmatureDataManager::~ArmatureDataManager(void)
{
CCLOGINFO("deallocing ArmatureDataManager: %p", this);
removeAll();
CC_SAFE_DELETE(_animationDatas);
CC_SAFE_DELETE(_armarureDatas);
CC_SAFE_DELETE(_textureDatas);
CC_SAFE_RELEASE(_animationDatas);
CC_SAFE_RELEASE(_armarureDatas);
CC_SAFE_RELEASE(_textureDatas);
}
void ArmatureDataManager::purgeArmatureSystem()
@ -77,17 +79,17 @@ bool ArmatureDataManager::init()
bool bRet = false;
do
{
_armarureDatas = Dictionary::create();
_armarureDatas = new Dictionary;
CCASSERT(_armarureDatas, "create ArmatureDataManager::_armarureDatas fail!");
_armarureDatas->retain();
_armarureDatas->init();
_animationDatas = Dictionary::create();
_animationDatas = new Dictionary;
CCASSERT(_animationDatas, "create ArmatureDataManager::_animationDatas fail!");
_animationDatas->retain();
_animationDatas->init();
_textureDatas = Dictionary::create();
_textureDatas = new Dictionary;
CCASSERT(_textureDatas, "create ArmatureDataManager::_textureDatas fail!");
_textureDatas->retain();
_textureDatas->init();
bRet = true;
}

View File

@ -785,7 +785,7 @@ ContourData *DataReaderHelper::decodeContour(tinyxml2::XMLElement *contourXML)
vertexDataXML->QueryFloatAttribute(A_Y, &vertex->y);
vertex->y = -vertex->y;
contourData->vertexList.addObject(vertex);
contourData->vertexList->addObject(vertex);
vertexDataXML = vertexDataXML->NextSiblingElement(CONTOUR_VERTEX);
}
@ -1079,7 +1079,7 @@ TextureData *DataReaderHelper::decodeTexture(cs::CSJsonDictionary &json)
for (int i = 0; i < length; i++)
{
cs::CSJsonDictionary *dic = json.getSubItemFromArray(CONTOUR_DATA, i);
textureData->contourDataList.addObject(decodeContour(*dic));
textureData->contourDataList->addObject(decodeContour(*dic));
delete dic;
}
@ -1101,7 +1101,7 @@ ContourData *DataReaderHelper::decodeContour(cs::CSJsonDictionary &json)
vertex->x = dic->getItemFloatValue(A_X, 0);
vertex->y = dic->getItemFloatValue(A_Y, 0);
contourData->vertexList.addObject(vertex);
contourData->vertexList->addObject(vertex);
vertex->release();
delete dic;

View File

@ -173,6 +173,7 @@ TextureAtlas *SpriteFrameCacheHelper::getTextureAtlas(const char *displayName)
SpriteFrameCacheHelper::SpriteFrameCacheHelper()
{
_display2TextureAtlas = new Dictionary();
_display2TextureAtlas->init();
}
SpriteFrameCacheHelper::~SpriteFrameCacheHelper()

View File

@ -37,7 +37,9 @@ bool CCBAnimationManager::init()
_sequences = new Array();
_sequences->init();
_nodeSequences = new Dictionary();
_nodeSequences->init();
_baseValues = new Dictionary();
_baseValues->init();
_documentOutletNames = new Array();
_documentOutletNames->init();
@ -58,6 +60,7 @@ bool CCBAnimationManager::init()
_keyframeCallbacks->init();
_keyframeCallFuncs = new Dictionary();
_keyframeCallFuncs->init();
_target = NULL;
_animationCompleteCallbackFunc = NULL;

View File

@ -16,7 +16,7 @@ bool CCBSequenceProperty::init()
{
_keyframes = new Array();
_keyframes->init();
return true;
}

View File

@ -11,6 +11,7 @@ NS_CC_EXT_BEGIN
NodeLoader::NodeLoader()
{
_customProperties = new Dictionary();
_customProperties->init();
}
NodeLoader::~NodeLoader()

View File

@ -78,7 +78,8 @@ bool Control::init()
// Set the touch dispatcher priority by default to 1
this->setTouchPriority(1);
// Initialise the tables
_dispatchTable = new Dictionary();
_dispatchTable = new Dictionary();
_dispatchTable->init();
return true;
}

View File

@ -185,7 +185,8 @@ void ScrollView::setTouchEnabled(bool e)
{
_dragging = false;
_touchMoved = false;
if(_touches)_touches->removeAllObjects();
if(_touches)
_touches->removeAllObjects();
}
}

View File

@ -107,7 +107,7 @@ SIOClientImpl::~SIOClientImpl()
{
if (_connected) disconnect();
CC_SAFE_DELETE(_clients);
CC_SAFE_RELEASE(_clients);
CC_SAFE_DELETE(_ws);
}
@ -600,7 +600,7 @@ SocketIO::SocketIO()
SocketIO::~SocketIO(void)
{
CC_SAFE_DELETE(_sockets);
CC_SAFE_RELEASE(_sockets);
delete _inst;
}

View File

@ -45,7 +45,7 @@ void ProjectileController::update(float delta)
projectile->getContentSize().width,
projectile->getContentSize().height);
auto targetsToDelete =new Array;
auto targetsToDelete = Array::createWithCapacity(20);
Object* jt = NULL;
CCARRAY_FOREACH(_targets, jt)
{
@ -71,8 +71,6 @@ void ProjectileController::update(float delta)
bool isDied = targetsToDelete->count() > 0;
targetsToDelete->release();
if (isDied)
{
die();

View File

@ -18,17 +18,8 @@ SceneController::SceneController(void)
SceneController::~SceneController(void)
{
if (_targets)
{
_targets->release();
_targets = NULL;
}
if (_projectiles)
{
_projectiles->release();
_projectiles = NULL;
}
CC_SAFE_RELEASE(_targets);
CC_SAFE_RELEASE(_projectiles);
}
bool SceneController::init()
@ -40,8 +31,11 @@ void SceneController::onEnter()
{
_fAddTargetTime = 1.0f;
_targets = new Array;
_projectiles = new Array;
_targets = Array::createWithCapacity(10);
_projectiles = Array::createWithCapacity(10);
_targets->retain();
_projectiles->retain();
((ComAudio*)(_owner->getComponent("Audio")))->playBackgroundMusic("background-music-aac.wav", true);
((ComAttribute*)(_owner->getComponent("ComAttribute")))->setInt("KillCount", 0);
@ -49,8 +43,6 @@ void SceneController::onEnter()
void SceneController::onExit()
{
}
void SceneController::update(float delta)

View File

@ -140,6 +140,8 @@ void NodeChildrenMainScene::initWithQuantityOfNodes(unsigned int nNodes)
updateQuantityLabel();
updateQuantityOfNodes();
CC_PROFILER_PURGE_ALL();
});
decrease->setColor(Color3B(0,200,20));
auto increase = MenuItemFont::create(" + ", [&](Object *sender) {
@ -149,6 +151,8 @@ void NodeChildrenMainScene::initWithQuantityOfNodes(unsigned int nNodes)
updateQuantityLabel();
updateQuantityOfNodes();
CC_PROFILER_PURGE_ALL();
});
increase->setColor(Color3B(0,200,20));