mirror of https://github.com/axmolengine/axmol.git
No throws in cocos2d-x code
This commit is contained in:
parent
e52ca38619
commit
10b71464a7
|
@ -61,7 +61,7 @@ unsigned int MarchingSquare::findFirstNoneTransparentPixel()
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw "image is all transparent!";
|
CCASSERT(false, "image is all transparent!");
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char MarchingSquare::getAlphaAt(const unsigned int i)
|
unsigned char MarchingSquare::getAlphaAt(const unsigned int i)
|
||||||
|
@ -235,10 +235,13 @@ void MarchingSquare::marchSquare(int startx, int starty)
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
CCLOG("case 0 at x:%d, y:%d, coming from %d, %d", curx, cury, prevx, prevy);
|
CCLOG("case 0 at x:%d, y:%d, coming from %d, %d", curx, cury, prevx, prevy);
|
||||||
throw "this shoudln't happen";
|
CCASSERT(false, "this shoudln't happen");
|
||||||
|
break;
|
||||||
case 15:
|
case 15:
|
||||||
CCLOG("case 15 at x:%d, y:%d, coming from %d, %d", curx, cury, prevx, prevy);
|
CCLOG("case 15 at x:%d, y:%d, coming from %d, %d", curx, cury, prevx, prevy);
|
||||||
throw "this shoudln't happen";
|
CCASSERT(false, "this shoudln't happen");
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
//little optimization
|
//little optimization
|
||||||
// if previous direction is same as current direction,
|
// if previous direction is same as current direction,
|
||||||
|
@ -266,8 +269,7 @@ void MarchingSquare::marchSquare(int startx, int starty)
|
||||||
prevx = stepx;
|
prevx = stepx;
|
||||||
prevy = stepy;
|
prevy = stepy;
|
||||||
problem = false;
|
problem = false;
|
||||||
if(count > totalPixel)
|
CCASSERT(count <= totalPixel, "oh no, marching square cannot find starting position");
|
||||||
throw "oh no, marching square cannot find starting position";
|
|
||||||
} while(curx != startx || cury != starty);
|
} while(curx != startx || cury != starty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
#include <new>
|
#include <new>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
|
|
||||||
|
#include "base/ccMacros.h"
|
||||||
|
|
||||||
USING_NS_CC_ALLOCATOR;
|
USING_NS_CC_ALLOCATOR;
|
||||||
|
|
||||||
#if CC_ENABLE_ALLOCATOR
|
#if CC_ENABLE_ALLOCATOR
|
||||||
|
@ -43,10 +45,13 @@ namespace
|
||||||
void* operator new[] (std::size_t size)
|
void* operator new[] (std::size_t size)
|
||||||
{
|
{
|
||||||
void* ptr = global.allocate(size);
|
void* ptr = global.allocate(size);
|
||||||
#if CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID
|
CCASSERT(ptr, "No memory");
|
||||||
if (nullptr == ptr)
|
|
||||||
throw std::bad_alloc();
|
// dissabling exceptions since cocos2d-x doesn't use them
|
||||||
#endif
|
//#if CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID
|
||||||
|
// if (nullptr == ptr)
|
||||||
|
// throw std::bad_alloc();
|
||||||
|
//#endif
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,10 +59,13 @@ void* operator new[] (std::size_t size)
|
||||||
void* operator new(std::size_t size)
|
void* operator new(std::size_t size)
|
||||||
{
|
{
|
||||||
void* ptr = global.allocate(size);
|
void* ptr = global.allocate(size);
|
||||||
#if CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID
|
CCASSERT(ptr, "No memory");
|
||||||
if (nullptr == ptr)
|
|
||||||
throw std::bad_alloc();
|
// dissabling exceptions since cocos2d-x doesn't use them
|
||||||
#endif
|
//#if CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID
|
||||||
|
// if (nullptr == ptr)
|
||||||
|
// throw std::bad_alloc();
|
||||||
|
//#endif
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -606,32 +606,20 @@ void InnerActionFrame::onEnter(Frame *nextFrame, int currentFrameIndex)
|
||||||
|
|
||||||
void InnerActionFrame::setStartFrameIndex(int frameIndex)
|
void InnerActionFrame::setStartFrameIndex(int frameIndex)
|
||||||
{
|
{
|
||||||
if(_enterWithName)
|
CCASSERT(_enterWithName, " cannot setStartFrameIndex when enterWithName is set");
|
||||||
{
|
|
||||||
CCLOG(" cannot set start when enter frame with name. setEnterWithName false firstly!");
|
|
||||||
throw std::exception();
|
|
||||||
}
|
|
||||||
_startFrameIndex = frameIndex;
|
_startFrameIndex = frameIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InnerActionFrame::setEndFrameIndex(int frameIndex)
|
void InnerActionFrame::setEndFrameIndex(int frameIndex)
|
||||||
{
|
{
|
||||||
if(_enterWithName)
|
CCASSERT(_enterWithName, " cannot setEndFrameIndex when enterWithName is set");
|
||||||
{
|
|
||||||
CCLOG(" cannot set end when enter frame with name. setEnterWithName false firstly!");
|
|
||||||
throw std::exception();
|
|
||||||
}
|
|
||||||
_endFrameIndex = frameIndex;
|
_endFrameIndex = frameIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InnerActionFrame::setAnimationName(const std::string& animationName)
|
void InnerActionFrame::setAnimationName(const std::string& animationName)
|
||||||
{
|
{
|
||||||
if(!_enterWithName)
|
CCASSERT(!_enterWithName, " cannot set aniamtioname when enter frame with index. setEnterWithName true firstly!");
|
||||||
{
|
|
||||||
CCLOG(" cannot set aniamtioname when enter frame with index. setEnterWithName true firstly!");
|
|
||||||
throw std::exception();
|
|
||||||
}
|
|
||||||
_animationName = animationName;
|
_animationName = animationName;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,6 @@ class RootTests : public TestList
|
||||||
public:
|
public:
|
||||||
RootTests()
|
RootTests()
|
||||||
{
|
{
|
||||||
addTest("SpritePolygon", [](){return new (std::nothrow) SpritePolygonTest(); });
|
|
||||||
addTest("ActionManager", [](){return new (std::nothrow) ActionManagerTests(); });
|
addTest("ActionManager", [](){return new (std::nothrow) ActionManagerTests(); });
|
||||||
addTest("Actions - Basic", [](){ return new (std::nothrow) ActionsTests(); });
|
addTest("Actions - Basic", [](){ return new (std::nothrow) ActionsTests(); });
|
||||||
addTest("Actions - Ease", [](){return new (std::nothrow) ActionsEaseTests(); });
|
addTest("Actions - Ease", [](){return new (std::nothrow) ActionsEaseTests(); });
|
||||||
|
@ -66,6 +65,7 @@ public:
|
||||||
addTest("Node: Spine", [](){return new SpineTests(); });
|
addTest("Node: Spine", [](){return new SpineTests(); });
|
||||||
addTest("Node: Sprite", [](){return new SpriteTests(); });
|
addTest("Node: Sprite", [](){return new SpriteTests(); });
|
||||||
addTest("Node: Sprite3D", [](){ return new Sprite3DTests(); });
|
addTest("Node: Sprite3D", [](){ return new Sprite3DTests(); });
|
||||||
|
addTest("Node: SpritePolygon", [](){return new (std::nothrow) SpritePolygonTest(); });
|
||||||
addTest("Node: Terrain", [](){ return new TerrainTests(); });
|
addTest("Node: Terrain", [](){ return new TerrainTests(); });
|
||||||
addTest("Node: TileMap", [](){return new TileMapTests(); });
|
addTest("Node: TileMap", [](){return new TileMapTests(); });
|
||||||
addTest("Node: FastTileMap", [](){return new FastTileMapTests(); });
|
addTest("Node: FastTileMap", [](){return new FastTileMapTests(); });
|
||||||
|
|
Loading…
Reference in New Issue