Initializing Array after it was constructed.

This commit is contained in:
James Chen 2013-08-22 10:15:47 +08:00
parent cd7773ba0e
commit 1ee7790f0e
10 changed files with 44 additions and 13 deletions

View File

@ -177,6 +177,7 @@ public:
{ {
_state = SAX_ARRAY; _state = SAX_ARRAY;
_array = new Array(); _array = new Array();
_array->init();
if (_resultType == SAX_RESULT_ARRAY && _rootArray == NULL) if (_resultType == SAX_RESULT_ARRAY && _rootArray == NULL)
{ {
_rootArray = _array; _rootArray = _array;

View File

@ -354,15 +354,18 @@ Array* FileUtilsIOS::createArrayWithContentsOfFile(const std::string& filename)
// pPath = [[NSBundle mainBundle] pathForResource:pPath ofType:pathExtension]; // pPath = [[NSBundle mainBundle] pathForResource:pPath ofType:pathExtension];
// fixing cannot read data using Array::createWithContentsOfFile // fixing cannot read data using Array::createWithContentsOfFile
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(filename.c_str()); std::string fullPath = FileUtils::getInstance()->fullPathForFilename(filename.c_str());
NSString* pPath = [NSString stringWithUTF8String:fullPath.c_str()]; NSString* path = [NSString stringWithUTF8String:fullPath.c_str()];
NSArray* pArray = [NSArray arrayWithContentsOfFile:pPath]; NSArray* array = [NSArray arrayWithContentsOfFile:path];
Array* pRet = new Array(); Array* ret = new Array();
for (id value in pArray) { ret->init();
addItemToArray(value, pRet);
for (id value in array)
{
addItemToArray(value, ret);
} }
return pRet; return ret;
} }
NS_CC_END NS_CC_END

View File

@ -337,15 +337,17 @@ Array* FileUtilsMac::createArrayWithContentsOfFile(const std::string& filename)
// pPath = [[NSBundle mainBundle] pathForResource:pPath ofType:pathExtension]; // pPath = [[NSBundle mainBundle] pathForResource:pPath ofType:pathExtension];
// fixing cannot read data using Array::createWithContentsOfFile // fixing cannot read data using Array::createWithContentsOfFile
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(filename.c_str()); std::string fullPath = FileUtils::getInstance()->fullPathForFilename(filename.c_str());
NSString* pPath = [NSString stringWithUTF8String:fullPath.c_str()]; NSString* path = [NSString stringWithUTF8String:fullPath.c_str()];
NSArray* pArray = [NSArray arrayWithContentsOfFile:pPath]; NSArray* array = [NSArray arrayWithContentsOfFile:path];
Array* pRet = new Array(); Array* ret = new Array();
for (id value in pArray) { ret->init();
addItemToArray(value, pRet);
for (id value in array) {
addItemToArray(value, ret);
} }
return pRet; return ret;
} }

View File

@ -35,15 +35,28 @@ CCBAnimationManager::CCBAnimationManager()
bool CCBAnimationManager::init() bool CCBAnimationManager::init()
{ {
_sequences = new Array(); _sequences = new Array();
_sequences->init();
_nodeSequences = new Dictionary(); _nodeSequences = new Dictionary();
_baseValues = new Dictionary(); _baseValues = new Dictionary();
_documentOutletNames = new Array(); _documentOutletNames = new Array();
_documentOutletNames->init();
_documentOutletNodes = new Array(); _documentOutletNodes = new Array();
_documentOutletNodes->init();
_documentCallbackNames = new Array(); _documentCallbackNames = new Array();
_documentCallbackNames->init();
_documentCallbackNodes = new Array(); _documentCallbackNodes = new Array();
_documentCallbackNodes->init();
_documentCallbackControlEvents = new Array(); _documentCallbackControlEvents = new Array();
_documentCallbackControlEvents->init();
_keyframeCallbacks = new Array(); _keyframeCallbacks = new Array();
_keyframeCallbacks->init();
_keyframeCallFuncs = new Dictionary(); _keyframeCallFuncs = new Dictionary();
_target = NULL; _target = NULL;

View File

@ -154,8 +154,11 @@ const std::string& CCBReader::getCCBRootPath() const
bool CCBReader::init() bool CCBReader::init()
{ {
_ownerOutletNodes = new Array(); _ownerOutletNodes = new Array();
_ownerOutletNodes->init();
_ownerCallbackNodes = new Array(); _ownerCallbackNodes = new Array();
_ownerCallbackNodes->init();
_ownerOwnerCallbackControlEvents = new Array(); _ownerOwnerCallbackControlEvents = new Array();
_ownerOwnerCallbackControlEvents->init();
// Setup action manager // Setup action manager
CCBAnimationManager *pActionManager = new CCBAnimationManager(); CCBAnimationManager *pActionManager = new CCBAnimationManager();
@ -278,7 +281,9 @@ Node* CCBReader::readNodeGraphFromData(Data *pData, Object *pOwner, const Size &
if(_jsControlled) if(_jsControlled)
{ {
_nodesWithAnimationManagers = new Array(); _nodesWithAnimationManagers = new Array();
_nodesWithAnimationManagers->init();
_animationManagersForNodes = new Array(); _animationManagersForNodes = new Array();
_animationManagersForNodes->init();
} }
DictElement* pElement = NULL; DictElement* pElement = NULL;

View File

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

View File

@ -110,6 +110,8 @@ bool ScrollView::initWithViewSize(Size size, Node *container/* = NULL*/)
setTouchEnabled(true); setTouchEnabled(true);
_touches = new Array(); _touches = new Array();
_touches->init();
_delegate = NULL; _delegate = NULL;
_bounceable = true; _bounceable = true;
_clippingToBounds = true; _clippingToBounds = true;

View File

@ -54,7 +54,9 @@ bool TableView::initWithViewSize(Size size, Node* container/* = NULL*/)
if (ScrollView::initWithViewSize(size,container)) if (ScrollView::initWithViewSize(size,container))
{ {
_cellsUsed = new ArrayForObjectSorting(); _cellsUsed = new ArrayForObjectSorting();
_cellsUsed->init();
_cellsFreed = new ArrayForObjectSorting(); _cellsFreed = new ArrayForObjectSorting();
_cellsFreed->init();
_indices = new std::set<unsigned int>(); _indices = new std::set<unsigned int>();
_vordering = VerticalFillOrder::BOTTOM_UP; _vordering = VerticalFillOrder::BOTTOM_UP;
this->setDirection(Direction::VERTICAL); this->setDirection(Direction::VERTICAL);
@ -122,6 +124,7 @@ void TableView::reloadData()
_indices->clear(); _indices->clear();
_cellsUsed->release(); _cellsUsed->release();
_cellsUsed = new ArrayForObjectSorting(); _cellsUsed = new ArrayForObjectSorting();
_cellsUsed->init();
this->_updateCellPositions(); this->_updateCellPositions();
this->_updateContentSize(); this->_updateContentSize();

View File

@ -1 +1 @@
d17c1939227c62cebcc30a071cf81b12bfa08db3 69358d388dd779c6334c786e53ea14243bfde00b

View File

@ -720,6 +720,7 @@ static JSBool js_cocos2dx_CCControl_addTargetWithActionForControlEvents(JSContex
if (nullptr == nativeDelegateArray) if (nullptr == nativeDelegateArray)
{ {
nativeDelegateArray = new Array(); nativeDelegateArray = new Array();
nativeDelegateArray->init();
cobj->setUserObject(nativeDelegateArray); // The reference of nativeDelegateArray is added to 2 cobj->setUserObject(nativeDelegateArray); // The reference of nativeDelegateArray is added to 2
nativeDelegateArray->release(); // Release nativeDelegateArray to make the reference to 1 nativeDelegateArray->release(); // Release nativeDelegateArray to make the reference to 1
} }