issue #1056: Added CCArray::copyWithZone implementation. CCDictElement bound check.

This commit is contained in:
James Chen 2012-03-20 23:30:18 +08:00
parent 15e03f8b14
commit 7c0af610ff
6 changed files with 22 additions and 17 deletions

View File

@ -130,7 +130,7 @@ void CCAtlasNode::updateAtlasValues()
}
// CCAtlasNode - draw
void CCAtlasNode::draw()
void CCAtlasNode::draw(void)
{
CC_NODE_DRAW_SETUP();

View File

@ -144,7 +144,7 @@ public:
void replaceObjectAtIndex(unsigned int uIndex, CCObject* pObject, bool bReleaseObject = true);
/** TODO: deep copy array. */
virtual CCObject* copyWithZone(CCZone* pZone) {CCAssert(false, "");return NULL;}
virtual CCObject* copyWithZone(CCZone* pZone);
public:
ccArray* data;
CCArray() : data(NULL) {};

View File

@ -87,7 +87,7 @@ public:
*/
virtual void updateAtlasValues();
virtual void draw();
virtual void draw(void);
// CC Texture protocol

View File

@ -52,11 +52,13 @@ public:
inline const char* getStrKey() const
{
CCAssert(m_szKey[0] != '\0', "Should not call this function for integer dictionary");
return m_szKey;
}
inline int getIntKey() const
{
CCAssert(m_szKey[0] == '\0', "Should not call this function for string dictionary");
return m_iKey;
}
@ -75,9 +77,9 @@ private:
}
private:
char m_szKey[256]; /* hash key of string type*/
int m_iKey; /* hash key of integer type */
CCObject* m_pObject;/* hash value */
char m_szKey[256]; /** hash key of string type*/
int m_iKey; /** hash key of integer type */
CCObject* m_pObject;/** hash value */
public:
UT_hash_handle hh; /* makes this class hashable */
friend class CCDictionary;

View File

@ -61,17 +61,8 @@ CCArray* CCArray::arrayWithCapacity(unsigned int capacity)
CCArray* CCArray::arrayWithArray(CCArray* otherArray)
{
CCArray* pArray = new CCArray();
if (pArray && pArray->initWithArray(otherArray))
{
pArray->autorelease();
}
else
{
CC_SAFE_DELETE(pArray);
}
CCArray* pArray = (CCArray*)otherArray->copyWithZone(NULL);
pArray->autorelease();
return pArray;
}
@ -257,4 +248,15 @@ void CCArray::replaceObjectAtIndex(unsigned int uIndex, CCObject* pObject, bool
}
}
CCObject* CCArray::copyWithZone(CCZone* pZone)
{
CCArray* pArray = new CCArray();
if (!(pArray && pArray->initWithArray(this)))
{
CC_SAFE_DELETE(pArray);
}
return pArray;
}
NS_CC_END

View File

@ -523,6 +523,7 @@ void CCTextureAtlas::drawNumberOfQuads(unsigned int n)
void CCTextureAtlas::drawNumberOfQuads(unsigned int n, unsigned int start)
{
if (0 == n) return;
ccGLBindTexture2D( m_pTexture->getName() );
// XXX: update is done in draw... perhaps it should be done in a timer