Skip to content

Commit

Permalink
Using std::swap instead of CC_SWAP
Browse files Browse the repository at this point in the history
CC_SWAP is deprecated. Use `std::swap` instead.
  • Loading branch information
ricardoquesada committed Nov 16, 2014
1 parent a893cc9 commit dcc4c46
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 11 deletions.
5 changes: 4 additions & 1 deletion cocos/2d/CCParticleSystemQuad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ THE SOFTWARE.


#include "2d/CCParticleSystemQuad.h"

#include <algorithm>

#include "2d/CCSpriteFrame.h"
#include "2d/CCParticleBatchNode.h"
#include "renderer/CCTextureAtlas.h"
Expand Down Expand Up @@ -172,7 +175,7 @@ void ParticleSystemQuad::initTexCoordsWithRect(const Rect& pointRect)
#endif // ! CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL

// Important. Texture in cocos2d are inverted, so the Y component should be inverted
CC_SWAP( top, bottom, float);
std::swap(top, bottom);

V3F_C4B_T2F_Quad *quads = nullptr;
unsigned int start = 0, end = 0;
Expand Down
4 changes: 3 additions & 1 deletion cocos/2d/CCProgressTimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ THE SOFTWARE.
****************************************************************************/
#include "2d/CCProgressTimer.h"

#include <algorithm>

#include "base/ccMacros.h"
#include "base/CCDirector.h"
#include "2d/CCSprite.h"
Expand Down Expand Up @@ -159,7 +161,7 @@ Tex2F ProgressTimer::textureCoordFromAlphaPoint(Vec2 alpha)
Vec2 max = Vec2(quad.tr.texCoords.u,quad.tr.texCoords.v);
// Fix bug #1303 so that progress timer handles sprite frame texture rotation
if (_sprite->isTextureRectRotated()) {
CC_SWAP(alpha.x, alpha.y, float);
std::swap(alpha.x, alpha.y);
}
return Tex2F(min.x * (1.f - alpha.x) + max.x * alpha.x, min.y * (1.f - alpha.y) + max.y * alpha.y);
}
Expand Down
10 changes: 6 additions & 4 deletions cocos/2d/CCSprite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ THE SOFTWARE.

#include "2d/CCSprite.h"

#include <algorithm>

#include "2d/CCSpriteBatchNode.h"
#include "2d/CCAnimationCache.h"
#include "2d/CCSpriteFrame.h"
Expand Down Expand Up @@ -438,12 +440,12 @@ void Sprite::setTextureCoords(Rect rect)

if (_flippedX)
{
CC_SWAP(top, bottom, float);
std::swap(top, bottom);
}

if (_flippedY)
{
CC_SWAP(left, right, float);
std::swap(left, right);
}

_quad.bl.texCoords.u = left;
Expand Down Expand Up @@ -471,12 +473,12 @@ void Sprite::setTextureCoords(Rect rect)

if(_flippedX)
{
CC_SWAP(left,right,float);
std::swap(left, right);
}

if(_flippedY)
{
CC_SWAP(top,bottom,float);
std::swap(top, bottom);
}

_quad.bl.texCoords.u = left;
Expand Down
1 change: 1 addition & 0 deletions cocos/base/ccMacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ THE SOFTWARE.

/** @def CC_SWAP
simple macro that swaps 2 variables
@deprecated use std::swap() instead
*/
#define CC_SWAP(x, y, type) \
{ type temp = (x); \
Expand Down
10 changes: 6 additions & 4 deletions download-deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
#
# ./download-deps.py
#
# Download Cocos2D-X resources from github (https://github.com/cocos2d/cocos2d-x-3rd-party-libs-bin) and extract from ZIP
# Downloads Cocos2D-x 3rd party dependencies from github:
# https://github.com/cocos2d/cocos2d-x-3rd-party-libs-bin) and extracts the zip
# file
#
# Helps prevent repo bloat due to large binary files since they can
# be hosted separately.
# Having the dependencies outside the official cocos2d-x repo helps prevent
# bloating the repo.
#

"""****************************************************************************
Expand Down Expand Up @@ -183,7 +185,7 @@ def unpack_zipfile(self, extract_dir):
else:
# file
data = z.read(info.filename)
f = open(target,'wb')
f = open(target, 'wb')
try:
f.write(data)
finally:
Expand Down
2 changes: 1 addition & 1 deletion tests/cpp-tests/Classes/SpriteTest/SpriteTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2403,7 +2403,7 @@ void SpriteHybrid::reparentSprite(float dt)
Vector<Node*> retArray(250);

if( _usingSpriteBatchNode )
CC_SWAP(p1,p2, Node*);
std::swap(p1, p2);

////----CCLOG("New parent is: %x", p2);

Expand Down

0 comments on commit dcc4c46

Please sign in to comment.