mirror of https://github.com/axmolengine/axmol.git
issue #2387: Using static_cast instead of C style cast while iterating CCDictionary.
This commit is contained in:
parent
9b9fe67d25
commit
596c4c3cf2
|
@ -53,7 +53,7 @@ class Dictionary;
|
|||
* {
|
||||
* const char*key = pElement->getStrKey();
|
||||
* // You certainly know the type of value, so we assume that it's a Sprite.
|
||||
* Sprite* pSprite = (Sprite*)pElement->getObject();
|
||||
* Sprite* pSprite = static_cast<Sprite*>(pElement->getObject());
|
||||
* // ......
|
||||
* }
|
||||
* @endcode
|
||||
|
@ -138,7 +138,7 @@ public:
|
|||
* It's also safe to remove elements while traversing.
|
||||
*/
|
||||
#define CCDICT_FOREACH(__dict__, __el__) \
|
||||
DictElement* pTmp##__dict__##__el__ = NULL; \
|
||||
DictElement* pTmp##__dict__##__el__ = nullptr; \
|
||||
if (__dict__) \
|
||||
HASH_ITER(hh, (__dict__)->_elements, __el__, pTmp##__dict__##__el__)
|
||||
|
||||
|
|
|
@ -97,8 +97,8 @@ void AnimationCache::parseVersion1(Dictionary* animations)
|
|||
DictElement* pElement = NULL;
|
||||
CCDICT_FOREACH(animations, pElement)
|
||||
{
|
||||
Dictionary* animationDict = (Dictionary*)pElement->getObject();
|
||||
Array* frameNames = (Array*)animationDict->objectForKey("frames");
|
||||
Dictionary* animationDict = static_cast<Dictionary*>(pElement->getObject());
|
||||
Array* frameNames = static_cast<Array*>(animationDict->objectForKey("frames"));
|
||||
float delay = animationDict->valueForKey("delay")->floatValue();
|
||||
Animation* animation = NULL;
|
||||
|
||||
|
@ -151,12 +151,12 @@ void AnimationCache::parseVersion2(Dictionary* animations)
|
|||
CCDICT_FOREACH(animations, pElement)
|
||||
{
|
||||
const char* name = pElement->getStrKey();
|
||||
Dictionary* animationDict = (Dictionary*)pElement->getObject();
|
||||
Dictionary* animationDict = static_cast<Dictionary*>(pElement->getObject());
|
||||
|
||||
const String* loops = animationDict->valueForKey("loops");
|
||||
bool restoreOriginalFrame = animationDict->valueForKey("restoreOriginalFrame")->boolValue();
|
||||
|
||||
Array* frameArray = (Array*)animationDict->objectForKey("frames");
|
||||
Array* frameArray = static_cast<Array*>(animationDict->objectForKey("frames"));
|
||||
|
||||
if ( frameArray == NULL ) {
|
||||
CCLOG("cocos2d: AnimationCache: Animation '%s' found in dictionary without any frames - cannot add to animation cache.", name);
|
||||
|
|
|
@ -103,9 +103,9 @@ void SpriteFrameCache::addSpriteFramesWithDictionary(Dictionary* dictionary, Tex
|
|||
DictElement* pElement = NULL;
|
||||
CCDICT_FOREACH(framesDict, pElement)
|
||||
{
|
||||
Dictionary* frameDict = (Dictionary*)pElement->getObject();
|
||||
Dictionary* frameDict = static_cast<Dictionary*>(pElement->getObject());
|
||||
std::string spriteFrameName = pElement->getStrKey();
|
||||
SpriteFrame* spriteFrame = (SpriteFrame*)_spriteFrames->objectForKey(spriteFrameName);
|
||||
SpriteFrame* spriteFrame = static_cast<SpriteFrame*>(_spriteFrames->objectForKey(spriteFrameName));
|
||||
if (spriteFrame)
|
||||
{
|
||||
continue;
|
||||
|
@ -299,7 +299,7 @@ void SpriteFrameCache::removeUnusedSpriteFrames(void)
|
|||
DictElement* pElement = NULL;
|
||||
CCDICT_FOREACH(_spriteFrames, pElement)
|
||||
{
|
||||
SpriteFrame* spriteFrame = (SpriteFrame*)pElement->getObject();
|
||||
SpriteFrame* spriteFrame = static_cast<SpriteFrame*>(pElement->getObject());
|
||||
if( spriteFrame->retainCount() == 1 )
|
||||
{
|
||||
CCLOG("cocos2d: SpriteFrameCache: removing unused frame: %s", pElement->getStrKey());
|
||||
|
@ -360,7 +360,7 @@ void SpriteFrameCache::removeSpriteFramesFromFile(const char* plist)
|
|||
|
||||
void SpriteFrameCache::removeSpriteFramesFromDictionary(Dictionary* dictionary)
|
||||
{
|
||||
Dictionary* framesDict = (Dictionary*)dictionary->objectForKey("frames");
|
||||
Dictionary* framesDict = static_cast<Dictionary*>(dictionary->objectForKey("frames"));
|
||||
Array* keysToRemove = Array::create();
|
||||
|
||||
DictElement* pElement = NULL;
|
||||
|
@ -383,7 +383,7 @@ void SpriteFrameCache::removeSpriteFramesFromTexture(Texture2D* texture)
|
|||
CCDICT_FOREACH(_spriteFrames, pElement)
|
||||
{
|
||||
string key = pElement->getStrKey();
|
||||
SpriteFrame* frame = (SpriteFrame*)_spriteFrames->objectForKey(key.c_str());
|
||||
SpriteFrame* frame = static_cast<SpriteFrame*>(_spriteFrames->objectForKey(key.c_str()));
|
||||
if (frame && (frame->getTexture() == texture))
|
||||
{
|
||||
keysToRemove->addObject(String::create(pElement->getStrKey()));
|
||||
|
|
|
@ -84,7 +84,7 @@ void Profiler::displayTimers()
|
|||
DictElement* pElement = NULL;
|
||||
CCDICT_FOREACH(_activeTimers, pElement)
|
||||
{
|
||||
ProfilingTimer* timer = (ProfilingTimer*)pElement->getObject();
|
||||
ProfilingTimer* timer = static_cast<ProfilingTimer*>(pElement->getObject());
|
||||
CCLog("%s", timer->description());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -538,7 +538,7 @@ void TextureCache::removeUnusedTextures()
|
|||
CCDICT_FOREACH(_textures, pElement)
|
||||
{
|
||||
CCLOG("cocos2d: TextureCache: texture: %s", pElement->getStrKey());
|
||||
Texture2D *value = (Texture2D*)pElement->getObject();
|
||||
Texture2D *value = static_cast<Texture2D*>(pElement->getObject());
|
||||
if (value->retainCount() == 1)
|
||||
{
|
||||
CCLOG("cocos2d: TextureCache: removing unused texture: %s", pElement->getStrKey());
|
||||
|
@ -557,7 +557,7 @@ void TextureCache::removeUnusedTextures()
|
|||
CCDICT_FOREACH(_textures, pElement)
|
||||
{
|
||||
CCLOG("cocos2d: TextureCache: texture: %s", pElement->getStrKey());
|
||||
Texture2D *value = (Texture2D*)pElement->getObject();
|
||||
Texture2D *value = static_cast<Texture2D*>(pElement->getObject());
|
||||
if (value->retainCount() == 1)
|
||||
{
|
||||
elementToRemove.push_back(pElement);
|
||||
|
@ -615,7 +615,7 @@ void TextureCache::dumpCachedTextureInfo()
|
|||
DictElement* pElement = NULL;
|
||||
CCDICT_FOREACH(_textures, pElement)
|
||||
{
|
||||
Texture2D* tex = (Texture2D*)pElement->getObject();
|
||||
Texture2D* tex = static_cast<Texture2D*>(pElement->getObject());
|
||||
unsigned int bpp = tex->bitsPerPixelForFormat();
|
||||
// Each texture takes up width * height * bytesPerPixel bytes.
|
||||
unsigned int bytes = tex->getPixelsWide() * tex->getPixelsHigh() * bpp / 8;
|
||||
|
|
|
@ -87,7 +87,7 @@ void SpriteFrameCacheHelper::addSpriteFrameFromDict(Dictionary *dictionary, Text
|
|||
DictElement *pElement = NULL;
|
||||
CCDICT_FOREACH(framesDict, pElement)
|
||||
{
|
||||
Dictionary *frameDict = (Dictionary *)pElement->getObject();
|
||||
Dictionary *frameDict = static_cast<Dictionary*>(pElement->getObject());
|
||||
std::string spriteFrameName = pElement->getStrKey();
|
||||
|
||||
_display2ImageMap[spriteFrameName] = imagePath;
|
||||
|
|
|
@ -742,7 +742,7 @@ void CCBAnimationManager::runAnimationsForSequenceIdTweenDuration(int nSeqId, fl
|
|||
DictElement* pElement = NULL;
|
||||
CCDICT_FOREACH(mNodeSequences, pElement)
|
||||
{
|
||||
Node *node = (Node*)pElement->getIntKey();
|
||||
Node *node = reinterpret_cast<Node*>(pElement->getIntKey());
|
||||
node->stopAllActions();
|
||||
|
||||
// Refer to CCBReader::readKeyframe() for the real type of value
|
||||
|
@ -758,7 +758,7 @@ void CCBAnimationManager::runAnimationsForSequenceIdTweenDuration(int nSeqId, fl
|
|||
CCDICT_FOREACH(seqNodeProps, pElement1)
|
||||
{
|
||||
const char *propName = pElement1->getStrKey();
|
||||
CCBSequenceProperty *seqProp = (CCBSequenceProperty*)seqNodeProps->objectForKey(propName);
|
||||
CCBSequenceProperty *seqProp = static_cast<CCBSequenceProperty*>(seqNodeProps->objectForKey(propName));
|
||||
seqNodePropNames.insert(propName);
|
||||
|
||||
setFirstFrame(node, seqProp, fTweenDuration);
|
||||
|
|
|
@ -294,7 +294,7 @@ Node* CCBReader::readNodeGraphFromData(Data *pData, Object *pOwner, const Size &
|
|||
CCDICT_FOREACH(animationManagers, pElement)
|
||||
{
|
||||
Node* pNode = (Node*)pElement->getIntKey();
|
||||
CCBAnimationManager* manager = (CCBAnimationManager*)animationManagers->objectForKey((intptr_t)pNode);
|
||||
CCBAnimationManager* manager = static_cast<CCBAnimationManager*>(animationManagers->objectForKey((intptr_t)pNode));
|
||||
pNode->setUserObject(manager);
|
||||
|
||||
if (jsControlled)
|
||||
|
@ -714,11 +714,11 @@ Node * CCBReader::readNodeGraph(Node * pParent) {
|
|||
DictElement* pElement;
|
||||
CCDICT_FOREACH(pCustomPropeties, pElement)
|
||||
{
|
||||
customAssigned = targetAsCCBMemberVariableAssigner->onAssignCCBCustomProperty(target, pElement->getStrKey(), (CCBValue*)pElement->getObject());
|
||||
customAssigned = targetAsCCBMemberVariableAssigner->onAssignCCBCustomProperty(target, pElement->getStrKey(), static_cast<CCBValue*>(pElement->getObject()));
|
||||
|
||||
if(!customAssigned && this->mCCBMemberVariableAssigner != NULL)
|
||||
{
|
||||
customAssigned = this->mCCBMemberVariableAssigner->onAssignCCBCustomProperty(target, pElement->getStrKey(), (CCBValue*)pElement->getObject());
|
||||
customAssigned = this->mCCBMemberVariableAssigner->onAssignCCBCustomProperty(target, pElement->getStrKey(), static_cast<CCBValue*>(pElement->getObject()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -251,7 +251,7 @@ void ControlButton::setPreferredSize(Size size)
|
|||
DictElement * item = NULL;
|
||||
CCDICT_FOREACH(_backgroundSpriteDispatchTable, item)
|
||||
{
|
||||
Scale9Sprite* sprite = (Scale9Sprite*)item->getObject();
|
||||
Scale9Sprite* sprite = static_cast<Scale9Sprite*>(item->getObject());
|
||||
sprite->setPreferredSize(size);
|
||||
}
|
||||
}
|
||||
|
@ -719,7 +719,7 @@ void ControlButton::setOpacity(GLubyte opacity)
|
|||
DictElement * item = NULL;
|
||||
CCDICT_FOREACH(_backgroundSpriteDispatchTable, item)
|
||||
{
|
||||
Scale9Sprite* sprite = (Scale9Sprite*)item->getObject();
|
||||
Scale9Sprite* sprite = static_cast<Scale9Sprite*>(item->getObject());
|
||||
sprite->setOpacity(opacity);
|
||||
}
|
||||
}
|
||||
|
@ -736,7 +736,7 @@ void ControlButton::setColor(const Color3B & color)
|
|||
DictElement * item = NULL;
|
||||
CCDICT_FOREACH(_backgroundSpriteDispatchTable, item)
|
||||
{
|
||||
Scale9Sprite* sprite = (Scale9Sprite*)item->getObject();
|
||||
Scale9Sprite* sprite = static_cast<Scale9Sprite*>(item->getObject());
|
||||
sprite->setColor(color);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue