mirror of https://github.com/axmolengine/axmol.git
Merge branch 'v3' of github.com:cocos2d/cocos2d-x into v3
This commit is contained in:
commit
1071f63ac7
|
@ -5,6 +5,7 @@ cocos2d-x-3.10 December ? 2015
|
|||
[NEW] UI: UIText::clone supports clone the text effect.
|
||||
[NEW] Label: Add methods to query label effect state.
|
||||
|
||||
[REFINE] UI: Slider `setCapInsetProgressBarRebderer` change to `setCapInsetProgressBarRenderer`.
|
||||
[REFINE] UI: RichText support new line element.
|
||||
[REFINE] UI: Set focus to Widget when touched.
|
||||
[REFINE] UI: Change PageView to derived from ListView.
|
||||
|
@ -14,6 +15,7 @@ cocos2d-x-3.10 December ? 2015
|
|||
[REFINE] Mac: Make engine compatible for 32bit Mac.
|
||||
[REFINE] Audio: AudioEngine on Linux replace the original SimpleAudioEngine with a new version of FMOD, now AudioEngine support all platforms!
|
||||
|
||||
[FIX] Network: fix possible websocket crash in its destructor.
|
||||
[FIX] Core: Fix premultiplyAlpha for mipmaps and compressed textures.
|
||||
[FIX] UI: Fix Scale9sprite rendering error when content size smaller than the sum of leftInset and rightInset.
|
||||
[FIX] Win32: Fix EditBox crash when removing an EditBox in a scheduler.
|
||||
|
|
|
@ -63,7 +63,7 @@ PointArray* PointArray::create(ssize_t capacity)
|
|||
|
||||
bool PointArray::initWithCapacity(ssize_t capacity)
|
||||
{
|
||||
_controlPoints = new vector<Vec2*>();
|
||||
_controlPoints = new (std::nothrow) vector<Vec2*>();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ ssize_t PointArray::count() const
|
|||
|
||||
PointArray* PointArray::reverse() const
|
||||
{
|
||||
vector<Vec2*> *newArray = new vector<Vec2*>();
|
||||
vector<Vec2*> *newArray = new (std::nothrow) vector<Vec2*>();
|
||||
vector<Vec2*>::reverse_iterator iter;
|
||||
Vec2 *point = nullptr;
|
||||
for (iter = _controlPoints->rbegin(); iter != _controlPoints->rend(); ++iter)
|
||||
|
|
|
@ -494,7 +494,7 @@ CallFuncN * CallFuncN::clone() const
|
|||
|
||||
__CCCallFuncND * __CCCallFuncND::create(Ref* selectorTarget, SEL_CallFuncND selector, void* d)
|
||||
{
|
||||
__CCCallFuncND* ret = new __CCCallFuncND();
|
||||
__CCCallFuncND* ret = new (std::nothrow) __CCCallFuncND();
|
||||
|
||||
if (ret && ret->initWithTarget(selectorTarget, selector, d)) {
|
||||
ret->autorelease();
|
||||
|
@ -528,7 +528,7 @@ void __CCCallFuncND::execute()
|
|||
__CCCallFuncND * __CCCallFuncND::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new __CCCallFuncND();
|
||||
auto a = new (std::nothrow) __CCCallFuncND();
|
||||
|
||||
if( _selectorTarget)
|
||||
{
|
||||
|
@ -561,7 +561,7 @@ void __CCCallFuncO::execute()
|
|||
|
||||
__CCCallFuncO * __CCCallFuncO::create(Ref* selectorTarget, SEL_CallFuncO selector, Ref* object)
|
||||
{
|
||||
__CCCallFuncO *ret = new __CCCallFuncO();
|
||||
__CCCallFuncO *ret = new (std::nothrow) __CCCallFuncO();
|
||||
|
||||
if (ret && ret->initWithTarget(selectorTarget, selector, object)) {
|
||||
ret->autorelease();
|
||||
|
@ -589,7 +589,7 @@ bool __CCCallFuncO::initWithTarget(Ref* selectorTarget, SEL_CallFuncO selector,
|
|||
__CCCallFuncO * __CCCallFuncO::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new __CCCallFuncO();
|
||||
auto a = new (std::nothrow) __CCCallFuncO();
|
||||
|
||||
if( _selectorTarget)
|
||||
{
|
||||
|
|
|
@ -46,8 +46,8 @@ rect()
|
|||
filename = other.filename;
|
||||
isVertsOwner = true;
|
||||
rect = other.rect;
|
||||
triangles.verts = new V3F_C4B_T2F[other.triangles.vertCount];
|
||||
triangles.indices = new unsigned short[other.triangles.indexCount];
|
||||
triangles.verts = new (std::nothrow) V3F_C4B_T2F[other.triangles.vertCount];
|
||||
triangles.indices = new (std::nothrow) unsigned short[other.triangles.indexCount];
|
||||
triangles.vertCount = other.triangles.vertCount;
|
||||
triangles.indexCount = other.triangles.indexCount;
|
||||
memcpy(triangles.verts, other.triangles.verts, other.triangles.vertCount*sizeof(V3F_C4B_T2F));
|
||||
|
@ -62,8 +62,8 @@ PolygonInfo& PolygonInfo::operator= (const PolygonInfo& other)
|
|||
filename = other.filename;
|
||||
isVertsOwner = true;
|
||||
rect = other.rect;
|
||||
triangles.verts = new V3F_C4B_T2F[other.triangles.vertCount];
|
||||
triangles.indices = new unsigned short[other.triangles.indexCount];
|
||||
triangles.verts = new (std::nothrow) V3F_C4B_T2F[other.triangles.vertCount];
|
||||
triangles.indices = new (std::nothrow) unsigned short[other.triangles.indexCount];
|
||||
triangles.vertCount = other.triangles.vertCount;
|
||||
triangles.indexCount = other.triangles.indexCount;
|
||||
memcpy(triangles.verts, other.triangles.verts, other.triangles.vertCount*sizeof(V3F_C4B_T2F));
|
||||
|
@ -148,7 +148,7 @@ AutoPolygon::AutoPolygon(const std::string &filename)
|
|||
,_scaleFactor(0)
|
||||
{
|
||||
_filename = filename;
|
||||
_image = new Image();
|
||||
_image = new (std::nothrow) Image();
|
||||
_image->initWithImageFile(filename);
|
||||
CCASSERT(_image->getRenderFormat()==Texture2D::PixelFormat::RGBA8888, "unsupported format, currently only supports rgba8888");
|
||||
_data = _image->getData();
|
||||
|
@ -550,15 +550,15 @@ TrianglesCommand::Triangles AutoPolygon::triangulate(const std::vector<Vec2>& po
|
|||
std::vector<p2t::Point*> p2points;
|
||||
for(std::vector<Vec2>::const_iterator it = points.begin(); it<points.end(); it++)
|
||||
{
|
||||
p2t::Point * p = new p2t::Point(it->x, it->y);
|
||||
p2t::Point * p = new (std::nothrow) p2t::Point(it->x, it->y);
|
||||
p2points.push_back(p);
|
||||
}
|
||||
p2t::CDT cdt(p2points);
|
||||
cdt.Triangulate();
|
||||
std::vector<p2t::Triangle*> tris = cdt.GetTriangles();
|
||||
|
||||
V3F_C4B_T2F* verts= new V3F_C4B_T2F[points.size()];
|
||||
unsigned short* indices = new unsigned short[tris.size()*3];
|
||||
V3F_C4B_T2F* verts= new (std::nothrow) V3F_C4B_T2F[points.size()];
|
||||
unsigned short* indices = new (std::nothrow) unsigned short[tris.size()*3];
|
||||
unsigned short idx = 0;
|
||||
unsigned short vdx = 0;
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ NS_CC_BEGIN
|
|||
|
||||
ClippingRectangleNode* ClippingRectangleNode::create(const Rect& clippingRegion)
|
||||
{
|
||||
ClippingRectangleNode* node = new ClippingRectangleNode();
|
||||
ClippingRectangleNode* node = new (std::nothrow) ClippingRectangleNode();
|
||||
if (node && node->init()) {
|
||||
node->setClippingRegion(clippingRegion);
|
||||
node->autorelease();
|
||||
|
@ -22,7 +22,7 @@ ClippingRectangleNode* ClippingRectangleNode::create(const Rect& clippingRegion)
|
|||
|
||||
ClippingRectangleNode* ClippingRectangleNode::create()
|
||||
{
|
||||
ClippingRectangleNode* node = new ClippingRectangleNode();
|
||||
ClippingRectangleNode* node = new (std::nothrow) ClippingRectangleNode();
|
||||
if (node && node->init()) {
|
||||
node->autorelease();
|
||||
} else {
|
||||
|
|
|
@ -177,7 +177,8 @@ void TMXLayer::draw(Renderer *renderer, const Mat4& transform, uint32_t flags)
|
|||
if(iter.second->getCount() > 0)
|
||||
{
|
||||
auto& cmd = _renderCommands[index++];
|
||||
cmd.init(iter.first, _texture->getName(), getGLProgramState(), BlendFunc::ALPHA_NON_PREMULTIPLIED, iter.second, _modelViewTransform, flags);
|
||||
auto blendfunc = _texture->hasPremultipliedAlpha() ? BlendFunc::ALPHA_PREMULTIPLIED : BlendFunc::ALPHA_NON_PREMULTIPLIED;
|
||||
cmd.init(iter.first, _texture->getName(), getGLProgramState(), blendfunc, iter.second, _modelViewTransform, flags);
|
||||
renderer->addCommand(&cmd);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ FontAtlas::FontAtlas(Font &theFont)
|
|||
_currentPageDataSize *= 2;
|
||||
}
|
||||
|
||||
_currentPageData = new unsigned char[_currentPageDataSize];
|
||||
_currentPageData = new (std::nothrow) unsigned char[_currentPageDataSize];
|
||||
memset(_currentPageData, 0, _currentPageDataSize);
|
||||
|
||||
auto pixelFormat = outlineSize > 0 ? Texture2D::PixelFormat::AI88 : Texture2D::PixelFormat::A8;
|
||||
|
@ -110,7 +110,7 @@ FontAtlas::~FontAtlas()
|
|||
#endif
|
||||
|
||||
_font->release();
|
||||
relaseTextures();
|
||||
releaseTextures();
|
||||
|
||||
delete []_currentPageData;
|
||||
|
||||
|
@ -123,7 +123,7 @@ FontAtlas::~FontAtlas()
|
|||
#endif
|
||||
}
|
||||
|
||||
void FontAtlas::relaseTextures()
|
||||
void FontAtlas::releaseTextures()
|
||||
{
|
||||
for( auto &item: _atlasTextures)
|
||||
{
|
||||
|
@ -132,6 +132,11 @@ void FontAtlas::relaseTextures()
|
|||
_atlasTextures.clear();
|
||||
}
|
||||
|
||||
void FontAtlas::relaseTextures()
|
||||
{
|
||||
releaseTextures();
|
||||
}
|
||||
|
||||
void FontAtlas::purgeTexturesAtlas()
|
||||
{
|
||||
if (_fontFreeType && _atlasTextures.size() > 1)
|
||||
|
|
|
@ -109,7 +109,10 @@ public:
|
|||
void setAliasTexParameters();
|
||||
|
||||
protected:
|
||||
void relaseTextures();
|
||||
void releaseTextures();
|
||||
|
||||
/** @deprecated Use method releaseTextures() instead */
|
||||
CC_DEPRECATED_ATTRIBUTE void relaseTextures();
|
||||
|
||||
void findNewCharacters(const std::u16string& u16Text, std::unordered_map<unsigned short, unsigned short>& charCodeMap);
|
||||
|
||||
|
|
|
@ -290,7 +290,7 @@ std::set<unsigned int>* BMFontConfiguration::parseConfigFile(const std::string&
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
std::set<unsigned int> *validCharsString = new std::set<unsigned int>();
|
||||
std::set<unsigned int> *validCharsString = new (std::nothrow) std::set<unsigned int>();
|
||||
|
||||
auto contentsLen = data.getSize();
|
||||
char line[512];
|
||||
|
@ -364,7 +364,7 @@ std::set<unsigned int>* BMFontConfiguration::parseBinaryConfigFile(unsigned char
|
|||
{
|
||||
/* based on http://www.angelcode.com/products/bmfont/doc/file_format.html file format */
|
||||
|
||||
set<unsigned int> *validCharsString = new set<unsigned int>();
|
||||
set<unsigned int> *validCharsString = new (std::nothrow) set<unsigned int>();
|
||||
|
||||
unsigned long remains = size;
|
||||
|
||||
|
@ -687,7 +687,7 @@ int * FontFNT::getHorizontalKerningForTextUTF16(const std::u16string& text, int
|
|||
if (!outNumLetters)
|
||||
return 0;
|
||||
|
||||
int *sizes = new int[outNumLetters];
|
||||
int *sizes = new (std::nothrow) int[outNumLetters];
|
||||
if (!sizes)
|
||||
return 0;
|
||||
|
||||
|
@ -821,7 +821,7 @@ void FontFNT::reloadBMFontResource(const std::string& fntFilePath)
|
|||
if (ret)
|
||||
{
|
||||
s_configurations->insert(fntFilePath, ret);
|
||||
TextureCache::getInstance()->reloadTexture(ret->getAtlasName());
|
||||
Director::getInstance()->getTextureCache()->reloadTexture(ret->getAtlasName());
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -230,7 +230,7 @@ int * FontFreeType::getHorizontalKerningForTextUTF16(const std::u16string& text,
|
|||
if (!outNumLetters)
|
||||
return nullptr;
|
||||
|
||||
int *sizes = new int[outNumLetters];
|
||||
int *sizes = new (std::nothrow) int[outNumLetters];
|
||||
if (!sizes)
|
||||
return nullptr;
|
||||
memset(sizes,0,outNumLetters * sizeof(int));
|
||||
|
@ -309,7 +309,7 @@ unsigned char* FontFreeType::getGlyphBitmap(unsigned short theChar, long &outWid
|
|||
|
||||
if (_outlineSize > 0)
|
||||
{
|
||||
auto copyBitmap = new unsigned char[outWidth * outHeight];
|
||||
auto copyBitmap = new (std::nothrow) unsigned char[outWidth * outHeight];
|
||||
memcpy(copyBitmap,ret,outWidth * outHeight * sizeof(unsigned char));
|
||||
|
||||
FT_BBox bbox;
|
||||
|
@ -342,7 +342,7 @@ unsigned char* FontFreeType::getGlyphBitmap(unsigned short theChar, long &outWid
|
|||
outRect.origin.y = -blendImageMaxY + _outlineSize;
|
||||
|
||||
long index, index2;
|
||||
auto blendImage = new unsigned char[blendWidth * blendHeight * 2];
|
||||
auto blendImage = new (std::nothrow) unsigned char[blendWidth * blendHeight * 2];
|
||||
memset(blendImage, 0, blendWidth * blendHeight * 2);
|
||||
|
||||
auto px = outlineMinX - blendImageMinX;
|
||||
|
@ -415,7 +415,7 @@ unsigned char * FontFreeType::getGlyphBitmapWithOutline(unsigned short theChar,
|
|||
long rows = (bbox.yMax - bbox.yMin)>>6;
|
||||
|
||||
FT_Bitmap bmp;
|
||||
bmp.buffer = new unsigned char[width * rows];
|
||||
bmp.buffer = new (std::nothrow) unsigned char[width * rows];
|
||||
memset(bmp.buffer, 0, width * rows);
|
||||
bmp.width = (int)width;
|
||||
bmp.rows = (int)rows;
|
||||
|
|
|
@ -52,6 +52,7 @@ public:
|
|||
LabelLetter()
|
||||
{
|
||||
_textureAtlas = nullptr;
|
||||
_letterVisible = true;
|
||||
}
|
||||
|
||||
static LabelLetter* createWithTexture(Texture2D *texture, const Rect& rect, bool rotated = false)
|
||||
|
@ -59,7 +60,7 @@ public:
|
|||
auto letter = new (std::nothrow) LabelLetter();
|
||||
if (letter && letter->initWithTexture(texture, rect, rotated))
|
||||
{
|
||||
letter->setVisible(false);
|
||||
letter->Sprite::setVisible(false);
|
||||
letter->autorelease();
|
||||
return letter;
|
||||
}
|
||||
|
@ -130,13 +131,18 @@ public:
|
|||
return;
|
||||
}
|
||||
|
||||
Color4B color4(_displayedColor.r, _displayedColor.g, _displayedColor.b, _displayedOpacity);
|
||||
auto displayedOpacity = _displayedOpacity;
|
||||
if(!_letterVisible)
|
||||
{
|
||||
displayedOpacity = 0.0f;
|
||||
}
|
||||
Color4B color4(_displayedColor.r, _displayedColor.g, _displayedColor.b, displayedOpacity);
|
||||
// special opacity for premultiplied textures
|
||||
if (_opacityModifyRGB)
|
||||
{
|
||||
color4.r *= _displayedOpacity / 255.0f;
|
||||
color4.g *= _displayedOpacity / 255.0f;
|
||||
color4.b *= _displayedOpacity / 255.0f;
|
||||
color4.r *= displayedOpacity / 255.0f;
|
||||
color4.g *= displayedOpacity / 255.0f;
|
||||
color4.b *= displayedOpacity / 255.0f;
|
||||
}
|
||||
_quad.bl.colors = color4;
|
||||
_quad.br.colors = color4;
|
||||
|
@ -146,10 +152,19 @@ public:
|
|||
_textureAtlas->updateQuad(&_quad, _atlasIndex);
|
||||
}
|
||||
|
||||
void setVisible(bool visible) override
|
||||
{
|
||||
_letterVisible = visible;
|
||||
updateColor();
|
||||
}
|
||||
|
||||
//LabelLetter doesn't need to draw directly.
|
||||
void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
bool _letterVisible;
|
||||
};
|
||||
|
||||
Label* Label::create()
|
||||
|
|
|
@ -54,17 +54,14 @@ ProgressTimer::ProgressTimer()
|
|||
ProgressTimer* ProgressTimer::create(Sprite* sp)
|
||||
{
|
||||
ProgressTimer *progressTimer = new (std::nothrow) ProgressTimer();
|
||||
if (progressTimer->initWithSprite(sp))
|
||||
if (progressTimer && progressTimer->initWithSprite(sp))
|
||||
{
|
||||
progressTimer->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
delete progressTimer;
|
||||
progressTimer = nullptr;
|
||||
return progressTimer;
|
||||
}
|
||||
|
||||
return progressTimer;
|
||||
delete progressTimer;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool ProgressTimer::initWithSprite(Sprite* sp)
|
||||
|
|
|
@ -142,9 +142,11 @@ Sprite* Sprite::create()
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
bool Sprite::init(void)
|
||||
bool Sprite::init()
|
||||
{
|
||||
return initWithTexture(nullptr, Rect::ZERO );
|
||||
initWithTexture(nullptr, Rect::ZERO);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Sprite::initWithTexture(Texture2D *texture)
|
||||
|
@ -152,9 +154,11 @@ bool Sprite::initWithTexture(Texture2D *texture)
|
|||
CCASSERT(texture != nullptr, "Invalid texture for sprite");
|
||||
|
||||
Rect rect = Rect::ZERO;
|
||||
rect.size = texture->getContentSize();
|
||||
if (texture) {
|
||||
rect.size = texture->getContentSize();
|
||||
}
|
||||
|
||||
return initWithTexture(texture, rect);
|
||||
return initWithTexture(texture, rect, false);
|
||||
}
|
||||
|
||||
bool Sprite::initWithTexture(Texture2D *texture, const Rect& rect)
|
||||
|
@ -173,7 +177,7 @@ bool Sprite::initWithFile(const std::string& filename)
|
|||
_fileName = filename;
|
||||
_fileType = 0;
|
||||
|
||||
Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(filename);
|
||||
Texture2D *texture = _director->getTextureCache()->addImage(filename);
|
||||
if (texture)
|
||||
{
|
||||
Rect rect = Rect::ZERO;
|
||||
|
@ -189,12 +193,16 @@ bool Sprite::initWithFile(const std::string& filename)
|
|||
|
||||
bool Sprite::initWithFile(const std::string &filename, const Rect& rect)
|
||||
{
|
||||
CCASSERT(filename.size()>0, "Invalid filename");
|
||||
CCASSERT(!filename.empty(), "Invalid filename");
|
||||
if (filename.empty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
_fileName = filename;
|
||||
_fileType = 0;
|
||||
|
||||
Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(filename);
|
||||
Texture2D *texture = _director->getTextureCache()->addImage(filename);
|
||||
if (texture)
|
||||
{
|
||||
return initWithTexture(texture, rect);
|
||||
|
@ -208,7 +216,11 @@ bool Sprite::initWithFile(const std::string &filename, const Rect& rect)
|
|||
|
||||
bool Sprite::initWithSpriteFrameName(const std::string& spriteFrameName)
|
||||
{
|
||||
CCASSERT(spriteFrameName.size() > 0, "Invalid spriteFrameName");
|
||||
CCASSERT(!spriteFrameName.empty(), "Invalid spriteFrameName");
|
||||
if (spriteFrameName.empty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
_fileName = spriteFrameName;
|
||||
_fileType = 1;
|
||||
|
@ -220,6 +232,10 @@ bool Sprite::initWithSpriteFrameName(const std::string& spriteFrameName)
|
|||
bool Sprite::initWithSpriteFrame(SpriteFrame *spriteFrame)
|
||||
{
|
||||
CCASSERT(spriteFrame != nullptr, "spriteFrame can't be nullptr!");
|
||||
if (spriteFrame == nullptr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool bRet = initWithTexture(spriteFrame->getTexture(), spriteFrame->getRect());
|
||||
setSpriteFrame(spriteFrame);
|
||||
|
@ -229,21 +245,23 @@ bool Sprite::initWithSpriteFrame(SpriteFrame *spriteFrame)
|
|||
|
||||
bool Sprite::initWithPolygon(const cocos2d::PolygonInfo &info)
|
||||
{
|
||||
Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(info.filename);
|
||||
bool res = false;
|
||||
if(initWithTexture(texture))
|
||||
bool ret = false;
|
||||
|
||||
Texture2D *texture = _director->getTextureCache()->addImage(info.filename);
|
||||
if(texture && initWithTexture(texture))
|
||||
{
|
||||
_polyInfo = info;
|
||||
setContentSize(_polyInfo.rect.size/Director::getInstance()->getContentScaleFactor());
|
||||
res = true;
|
||||
setContentSize(_polyInfo.rect.size / _director->getContentScaleFactor());
|
||||
ret = true;
|
||||
}
|
||||
return res;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// designated initializer
|
||||
bool Sprite::initWithTexture(Texture2D *texture, const Rect& rect, bool rotated)
|
||||
{
|
||||
bool result;
|
||||
bool result = false;
|
||||
if (Node::init())
|
||||
{
|
||||
_batchNode = nullptr;
|
||||
|
@ -284,12 +302,10 @@ bool Sprite::initWithTexture(Texture2D *texture, const Rect& rect, bool rotated)
|
|||
setBatchNode(nullptr);
|
||||
result = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
|
||||
_recursiveDirty = true;
|
||||
setDirty(true);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -359,7 +375,7 @@ void Sprite::setTexture(Texture2D *texture)
|
|||
if (texture == nullptr)
|
||||
{
|
||||
// Gets the texture by key firstly.
|
||||
texture = Director::getInstance()->getTextureCache()->getTextureForKey(CC_2x2_WHITE_IMAGE_KEY);
|
||||
texture = _director->getTextureCache()->getTextureForKey(CC_2x2_WHITE_IMAGE_KEY);
|
||||
|
||||
// If texture wasn't in cache, create it from RAW data.
|
||||
if (texture == nullptr)
|
||||
|
@ -369,7 +385,7 @@ void Sprite::setTexture(Texture2D *texture)
|
|||
CC_UNUSED_PARAM(isOK);
|
||||
CCASSERT(isOK, "The 2x2 empty texture was created unsuccessfully.");
|
||||
|
||||
texture = Director::getInstance()->getTextureCache()->addImage(image, CC_2x2_WHITE_IMAGE_KEY);
|
||||
texture = _director->getTextureCache()->addImage(image, CC_2x2_WHITE_IMAGE_KEY);
|
||||
CC_SAFE_RELEASE(image);
|
||||
}
|
||||
}
|
||||
|
@ -451,14 +467,14 @@ void Sprite::setVertexRect(const Rect& rect)
|
|||
|
||||
void Sprite::setTextureCoords(Rect rect)
|
||||
{
|
||||
rect = CC_RECT_POINTS_TO_PIXELS(rect);
|
||||
|
||||
Texture2D *tex = _batchNode ? _textureAtlas->getTexture() : _texture;
|
||||
if (! tex)
|
||||
if (tex == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
rect = CC_RECT_POINTS_TO_PIXELS(rect);
|
||||
|
||||
float atlasWidth = (float)tex->getPixelsWide();
|
||||
float atlasHeight = (float)tex->getPixelsHigh();
|
||||
|
||||
|
@ -637,6 +653,11 @@ void Sprite::updateTransform(void)
|
|||
|
||||
void Sprite::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
|
||||
{
|
||||
if (_texture == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#if CC_USE_CULLING
|
||||
// Don't do calculate the culling if the transform was not updated
|
||||
auto visitingCamera = Camera::getVisitingCamera();
|
||||
|
@ -684,6 +705,10 @@ void Sprite::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
|
|||
void Sprite::addChild(Node *child, int zOrder, int tag)
|
||||
{
|
||||
CCASSERT(child != nullptr, "Argument must be non-nullptr");
|
||||
if (child == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_batchNode)
|
||||
{
|
||||
|
@ -705,6 +730,10 @@ void Sprite::addChild(Node *child, int zOrder, int tag)
|
|||
void Sprite::addChild(Node *child, int zOrder, const std::string &name)
|
||||
{
|
||||
CCASSERT(child != nullptr, "Argument must be non-nullptr");
|
||||
if (child == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_batchNode)
|
||||
{
|
||||
|
@ -1012,6 +1041,12 @@ bool Sprite::isOpacityModifyRGB(void) const
|
|||
|
||||
void Sprite::setSpriteFrame(const std::string &spriteFrameName)
|
||||
{
|
||||
CCASSERT(!spriteFrameName.empty(), "spriteFrameName must not be empty");
|
||||
if (spriteFrameName.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SpriteFrameCache *cache = SpriteFrameCache::getInstance();
|
||||
SpriteFrame *spriteFrame = cache->getSpriteFrameByName(spriteFrameName);
|
||||
|
||||
|
@ -1051,7 +1086,11 @@ void Sprite::setSpriteFrame(SpriteFrame *spriteFrame)
|
|||
|
||||
void Sprite::setDisplayFrameWithAnimationName(const std::string& animationName, ssize_t frameIndex)
|
||||
{
|
||||
CCASSERT(animationName.size()>0, "CCSprite#setDisplayFrameWithAnimationName. animationName must not be nullptr");
|
||||
CCASSERT(!animationName.empty(), "CCSprite#setDisplayFrameWithAnimationName. animationName must not be nullptr");
|
||||
if (animationName.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Animation *a = AnimationCache::getInstance()->getAnimation(animationName);
|
||||
|
||||
|
|
|
@ -45,10 +45,14 @@ NS_CC_BEGIN
|
|||
SpriteBatchNode* SpriteBatchNode::createWithTexture(Texture2D* tex, ssize_t capacity/* = DEFAULT_CAPACITY*/)
|
||||
{
|
||||
SpriteBatchNode *batchNode = new (std::nothrow) SpriteBatchNode();
|
||||
batchNode->initWithTexture(tex, capacity);
|
||||
batchNode->autorelease();
|
||||
if(batchNode && batchNode->initWithTexture(tex, capacity))
|
||||
{
|
||||
batchNode->autorelease();
|
||||
return batchNode;
|
||||
}
|
||||
|
||||
return batchNode;
|
||||
delete batchNode;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -58,10 +62,14 @@ SpriteBatchNode* SpriteBatchNode::createWithTexture(Texture2D* tex, ssize_t capa
|
|||
SpriteBatchNode* SpriteBatchNode::create(const std::string& fileImage, ssize_t capacity/* = DEFAULT_CAPACITY*/)
|
||||
{
|
||||
SpriteBatchNode *batchNode = new (std::nothrow) SpriteBatchNode();
|
||||
batchNode->initWithFile(fileImage, capacity);
|
||||
batchNode->autorelease();
|
||||
if(batchNode && batchNode->initWithFile(fileImage, capacity))
|
||||
{
|
||||
batchNode->autorelease();
|
||||
return batchNode;
|
||||
}
|
||||
|
||||
return batchNode;
|
||||
delete batchNode;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -69,6 +77,11 @@ SpriteBatchNode* SpriteBatchNode::create(const std::string& fileImage, ssize_t c
|
|||
*/
|
||||
bool SpriteBatchNode::initWithTexture(Texture2D *tex, ssize_t capacity/* = DEFAULT_CAPACITY*/)
|
||||
{
|
||||
if(tex == nullptr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
CCASSERT(capacity>=0, "Capacity must be >= 0");
|
||||
|
||||
_blendFunc = BlendFunc::ALPHA_PREMULTIPLIED;
|
||||
|
@ -78,7 +91,7 @@ bool SpriteBatchNode::initWithTexture(Texture2D *tex, ssize_t capacity/* = DEFAU
|
|||
}
|
||||
_textureAtlas = new (std::nothrow) TextureAtlas();
|
||||
|
||||
if (capacity == 0)
|
||||
if (capacity <= 0)
|
||||
{
|
||||
capacity = DEFAULT_CAPACITY;
|
||||
}
|
||||
|
@ -148,13 +161,12 @@ void SpriteBatchNode::visit(Renderer *renderer, const Mat4 &parentTransform, uin
|
|||
// IMPORTANT:
|
||||
// To ease the migration to v3.0, we still support the Mat4 stack,
|
||||
// but it is deprecated and your code should not rely on it
|
||||
Director* director = Director::getInstance();
|
||||
director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewTransform);
|
||||
_director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
_director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewTransform);
|
||||
|
||||
draw(renderer, _modelViewTransform, flags);
|
||||
|
||||
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
_director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
// FIX ME: Why need to set _orderOfArrival to 0??
|
||||
// Please refer to https://github.com/cocos2d/cocos2d-x/pull/6920
|
||||
// setOrderOfArrival(0);
|
||||
|
|
|
@ -113,7 +113,7 @@ void SpriteFrameCache::initializePolygonInfo(const Size &textureSize,
|
|||
|
||||
float scaleFactor = CC_CONTENT_SCALE_FACTOR();
|
||||
|
||||
V3F_C4B_T2F *vertexData = new V3F_C4B_T2F[vertexCount];
|
||||
V3F_C4B_T2F *vertexData = new (std::nothrow) V3F_C4B_T2F[vertexCount];
|
||||
for (size_t i = 0; i < vertexCount/2; i++)
|
||||
{
|
||||
vertexData[i].colors = Color4B::WHITE;
|
||||
|
@ -282,7 +282,7 @@ void SpriteFrameCache::addSpriteFramesWithDictionary(ValueMap& dictionary, Textu
|
|||
if(flag)
|
||||
{
|
||||
if (image == nullptr) {
|
||||
image = new Image();
|
||||
image = new (std::nothrow) Image();
|
||||
image->initWithImageFile(textureFileName);
|
||||
}
|
||||
parser.setSpriteFrameInfo(image, spriteFrame->getRectInPixels(), spriteFrame->isRotated());
|
||||
|
|
|
@ -1131,7 +1131,7 @@ bool Bundle3D::loadBinary(const std::string& path)
|
|||
bool Bundle3D::loadMeshDataJson_0_1(MeshDatas& meshdatas)
|
||||
{
|
||||
const rapidjson::Value& mesh_data_array = _jsonReader[MESH];
|
||||
MeshData* meshdata= new MeshData();
|
||||
MeshData* meshdata= new (std::nothrow) MeshData();
|
||||
const rapidjson::Value& mesh_data_val = mesh_data_array[(rapidjson::SizeType)0];
|
||||
|
||||
const rapidjson::Value& mesh_data_body_array = mesh_data_val[DEFAULTPART];
|
||||
|
@ -1179,7 +1179,7 @@ bool Bundle3D::loadMeshDataJson_0_1(MeshDatas& meshdatas)
|
|||
|
||||
bool Bundle3D::loadMeshDataJson_0_2(MeshDatas& meshdatas)
|
||||
{
|
||||
MeshData* meshdata= new MeshData();
|
||||
MeshData* meshdata= new (std::nothrow) MeshData();
|
||||
const rapidjson::Value& mesh_array = _jsonReader[MESH];
|
||||
const rapidjson::Value& mesh_array_0 = mesh_array[(rapidjson::SizeType)0];
|
||||
|
||||
|
|
|
@ -364,6 +364,13 @@ Sprite3D* Sprite3D::createSprite3DNode(NodeData* nodedata,ModelData* modeldata,c
|
|||
{
|
||||
sprite->setName(nodedata->id);
|
||||
auto mesh = Mesh::create(nodedata->id, getMeshIndexData(modeldata->subMeshId));
|
||||
|
||||
if (_skeleton && modeldata->bones.size())
|
||||
{
|
||||
auto skin = MeshSkin::create(_skeleton, modeldata->bones, modeldata->invBindPose);
|
||||
mesh->setSkin(skin);
|
||||
}
|
||||
|
||||
if (modeldata->matrialId == "" && materialdatas.materials.size())
|
||||
{
|
||||
const NTextureData* textureData = materialdatas.materials[0].getTextureData(NTextureData::Usage::Diffuse);
|
||||
|
@ -748,7 +755,7 @@ void Sprite3D::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
|
|||
{
|
||||
#if CC_USE_CULLING
|
||||
// camera clipping
|
||||
if(Camera::getVisitingCamera() && !Camera::getVisitingCamera()->isVisibleInFrustum(&this->getAABB()))
|
||||
if(_children.size() == 0 && Camera::getVisitingCamera() && !Camera::getVisitingCamera()->isVisibleInFrustum(&getAABB()))
|
||||
return;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -225,7 +225,7 @@ void Terrain::onDraw(const Mat4 &transform, uint32_t flags)
|
|||
|
||||
bool Terrain::initHeightMap(const std::string& heightMap)
|
||||
{
|
||||
_heightMapImage = new Image();
|
||||
_heightMapImage = new (std::nothrow) Image();
|
||||
_heightMapImage->initWithImageFile(heightMap);
|
||||
_data = _heightMapImage->getData();
|
||||
_imageWidth =_heightMapImage->getWidth();
|
||||
|
@ -244,7 +244,7 @@ bool Terrain::initHeightMap(const std::string& heightMap)
|
|||
{
|
||||
for(int n =0; n<chunk_amount_x;n++)
|
||||
{
|
||||
_chunkesArray[m][n] = new Chunk();
|
||||
_chunkesArray[m][n] = new (std::nothrow) Chunk();
|
||||
_chunkesArray[m][n]->_terrain = this;
|
||||
_chunkesArray[m][n]->_size = _chunkSize;
|
||||
_chunkesArray[m][n]->generate(_imageWidth,_imageHeight,m,n,_data);
|
||||
|
@ -262,7 +262,7 @@ bool Terrain::initHeightMap(const std::string& heightMap)
|
|||
if(m+1<chunk_amount_y) _chunkesArray[m][n]->_front = _chunkesArray[m+1][n];
|
||||
}
|
||||
}
|
||||
_quadRoot = new QuadTree(0,0,_imageWidth,_imageHeight,this);
|
||||
_quadRoot = new (std::nothrow) QuadTree(0,0,_imageWidth,_imageHeight,this);
|
||||
setLODDistance(_chunkSize.width,2*_chunkSize.width,3*_chunkSize.width);
|
||||
return true;
|
||||
}else
|
||||
|
@ -1487,13 +1487,13 @@ Terrain::QuadTree::QuadTree(int x, int y, int w, int h, Terrain * terrain)
|
|||
if(_width> terrain->_chunkSize.width &&_height >terrain->_chunkSize.height) //subdivision
|
||||
{
|
||||
_isTerminal = false;
|
||||
this->_tl = new QuadTree(x,y,_width/2,_height/2,terrain);
|
||||
this->_tl = new (std::nothrow) QuadTree(x,y,_width/2,_height/2,terrain);
|
||||
this->_tl->_parent = this;
|
||||
this->_tr = new QuadTree(x+_width/2,y,_width/2,_height/2,terrain);
|
||||
this->_tr = new (std::nothrow) QuadTree(x+_width/2,y,_width/2,_height/2,terrain);
|
||||
this->_tr->_parent = this;
|
||||
this->_bl = new QuadTree(x,y+_height/2,_width/2,_height/2,terrain);
|
||||
this->_bl = new (std::nothrow) QuadTree(x,y+_height/2,_width/2,_height/2,terrain);
|
||||
this->_bl->_parent = this;
|
||||
this->_br = new QuadTree(x+_width/2,y+_height/2,_width/2,_height/2,terrain);
|
||||
this->_br = new (std::nothrow) QuadTree(x+_width/2,y+_height/2,_width/2,_height/2,terrain);
|
||||
this->_br->_parent = this;
|
||||
|
||||
_localAABB.merge(_tl->_localAABB);
|
||||
|
|
|
@ -57,7 +57,7 @@ Configuration::Configuration()
|
|||
, _maxSpotLightInShader(1)
|
||||
, _animate3DQuality(Animate3DQuality::QUALITY_LOW)
|
||||
{
|
||||
_loadedEvent = new EventCustom(CONFIG_FILE_LOADED);
|
||||
_loadedEvent = new (std::nothrow) EventCustom(CONFIG_FILE_LOADED);
|
||||
}
|
||||
|
||||
bool Configuration::init()
|
||||
|
|
|
@ -126,7 +126,7 @@ bool Director::init(void)
|
|||
_frameRate = 0.0f;
|
||||
_FPSLabel = _drawnBatchesLabel = _drawnVerticesLabel = nullptr;
|
||||
_totalFrames = 0;
|
||||
_lastUpdate = new struct timeval;
|
||||
_lastUpdate = new (std::nothrow) struct timeval;
|
||||
_secondsPerFrame = 1.0f;
|
||||
|
||||
// paused ?
|
||||
|
|
|
@ -153,7 +153,7 @@ void EventDispatcher::EventListenerVector::push_back(EventListener* listener)
|
|||
{
|
||||
if (_sceneGraphListeners == nullptr)
|
||||
{
|
||||
_sceneGraphListeners = new std::vector<EventListener*>();
|
||||
_sceneGraphListeners = new (std::nothrow) std::vector<EventListener*>();
|
||||
_sceneGraphListeners->reserve(100);
|
||||
}
|
||||
|
||||
|
@ -412,7 +412,7 @@ void EventDispatcher::associateNodeAndEventListener(Node* node, EventListener* l
|
|||
}
|
||||
else
|
||||
{
|
||||
listeners = new std::vector<EventListener*>();
|
||||
listeners = new (std::nothrow) std::vector<EventListener*>();
|
||||
_nodeListenersMap.insert(std::make_pair(node, listeners));
|
||||
}
|
||||
|
||||
|
|
|
@ -383,7 +383,7 @@ void Scheduler::unschedule(const std::string &key, void *target)
|
|||
|
||||
void Scheduler::priorityIn(tListEntry **list, const ccSchedulerFunc& callback, void *target, int priority, bool paused)
|
||||
{
|
||||
tListEntry *listElement = new tListEntry();
|
||||
tListEntry *listElement = new (std::nothrow) tListEntry();
|
||||
|
||||
listElement->callback = callback;
|
||||
listElement->target = target;
|
||||
|
@ -440,7 +440,7 @@ void Scheduler::priorityIn(tListEntry **list, const ccSchedulerFunc& callback, v
|
|||
|
||||
void Scheduler::appendIn(_listEntry **list, const ccSchedulerFunc& callback, void *target, bool paused)
|
||||
{
|
||||
tListEntry *listElement = new tListEntry();
|
||||
tListEntry *listElement = new (std::nothrow) tListEntry();
|
||||
|
||||
listElement->callback = callback;
|
||||
listElement->target = target;
|
||||
|
|
|
@ -74,7 +74,7 @@ static tinyxml2::XMLElement* getXMLNodeForKey(const char* pKey, tinyxml2::XMLDoc
|
|||
|
||||
do
|
||||
{
|
||||
tinyxml2::XMLDocument* xmlDoc = new tinyxml2::XMLDocument();
|
||||
tinyxml2::XMLDocument* xmlDoc = new (std::nothrow) tinyxml2::XMLDocument();
|
||||
*doc = xmlDoc;
|
||||
ssize_t size;
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ static tinyxml2::XMLElement* getXMLNodeForKey(const char* pKey, tinyxml2::XMLDoc
|
|||
|
||||
do
|
||||
{
|
||||
tinyxml2::XMLDocument* xmlDoc = new tinyxml2::XMLDocument();
|
||||
tinyxml2::XMLDocument* xmlDoc = new (std::nothrow) tinyxml2::XMLDocument();
|
||||
*doc = xmlDoc;
|
||||
|
||||
std::string xmlBuffer = FileUtils::getInstance()->getStringFromFile(UserDefault::getInstance()->getXMLFilePath());
|
||||
|
|
|
@ -57,7 +57,7 @@ static tinyxml2::XMLElement* getXMLNodeForKey(const char* pKey, tinyxml2::XMLEle
|
|||
|
||||
do
|
||||
{
|
||||
tinyxml2::XMLDocument* xmlDoc = new tinyxml2::XMLDocument();
|
||||
tinyxml2::XMLDocument* xmlDoc = new (std::nothrow) tinyxml2::XMLDocument();
|
||||
*doc = xmlDoc;
|
||||
|
||||
std::string xmlBuffer = FileUtils::getInstance()->getStringFromFile(UserDefault::getInstance()->getXMLFilePath());
|
||||
|
@ -467,7 +467,7 @@ void UserDefault::initXMLFilePath()
|
|||
bool UserDefault::createXMLFile()
|
||||
{
|
||||
bool bRet = false;
|
||||
tinyxml2::XMLDocument *pDoc = new tinyxml2::XMLDocument();
|
||||
tinyxml2::XMLDocument *pDoc = new (std::nothrow) tinyxml2::XMLDocument();
|
||||
if (nullptr==pDoc)
|
||||
{
|
||||
return false;
|
||||
|
|
|
@ -74,7 +74,7 @@ Value::Value(bool v)
|
|||
Value::Value(const char* v)
|
||||
: _type(Type::STRING)
|
||||
{
|
||||
_field.strVal = new std::string();
|
||||
_field.strVal = new (std::nothrow) std::string();
|
||||
if (v)
|
||||
{
|
||||
*_field.strVal = v;
|
||||
|
@ -84,7 +84,7 @@ Value::Value(const char* v)
|
|||
Value::Value(const std::string& v)
|
||||
: _type(Type::STRING)
|
||||
{
|
||||
_field.strVal = new std::string();
|
||||
_field.strVal = new (std::nothrow) std::string();
|
||||
*_field.strVal = v;
|
||||
}
|
||||
|
||||
|
@ -813,7 +813,7 @@ void Value::reset(Type type)
|
|||
switch (type)
|
||||
{
|
||||
case Type::STRING:
|
||||
_field.strVal = new std::string();
|
||||
_field.strVal = new (std::nothrow) std::string();
|
||||
break;
|
||||
case Type::VECTOR:
|
||||
_field.vectorVal = new (std::nothrow) ValueVector();
|
||||
|
|
|
@ -518,7 +518,7 @@ public:
|
|||
|
||||
ZipFile *ZipFile::createWithBuffer(const void* buffer, uLong size)
|
||||
{
|
||||
ZipFile *zip = new ZipFile();
|
||||
ZipFile *zip = new (std::nothrow) ZipFile();
|
||||
if (zip && zip->initWithBuffer(buffer, size)) {
|
||||
return zip;
|
||||
} else {
|
||||
|
|
|
@ -293,7 +293,7 @@ unsigned short* cc_utf8_to_utf16(const char* str_old, int length/* = -1*/, int*
|
|||
|
||||
if (succeed)
|
||||
{
|
||||
ret = new unsigned short[outUtf16.length() + 1];
|
||||
ret = new (std::nothrow) unsigned short[outUtf16.length() + 1];
|
||||
ret[outUtf16.length()] = 0;
|
||||
memcpy(ret, outUtf16.data(), outUtf16.length() * sizeof(unsigned short));
|
||||
if (rUtf16Size)
|
||||
|
@ -328,7 +328,7 @@ char * cc_utf16_to_utf8 (const unsigned short *str,
|
|||
|
||||
if (succeed)
|
||||
{
|
||||
ret = new char[outUtf8.length() + 1];
|
||||
ret = new (std::nothrow) char[outUtf8.length() + 1];
|
||||
ret[outUtf8.length()] = '\0';
|
||||
memcpy(ret, outUtf8.data(), outUtf8.length());
|
||||
}
|
||||
|
|
|
@ -271,12 +271,12 @@ Sprite* createSpriteFromBase64(const char* base64String)
|
|||
unsigned char* decoded;
|
||||
int length = base64Decode((const unsigned char*) base64String, (unsigned int) strlen(base64String), &decoded);
|
||||
|
||||
Image *image = new Image();
|
||||
Image *image = new (std::nothrow) Image();
|
||||
bool imageResult = image->initWithImageData(decoded, length);
|
||||
CCASSERT(imageResult, "Failed to create image from base64!");
|
||||
free(decoded);
|
||||
|
||||
Texture2D *texture = new Texture2D();
|
||||
Texture2D *texture = new (std::nothrow) Texture2D();
|
||||
texture->initWithImage(image);
|
||||
texture->setAliasTexParameters();
|
||||
image->release();
|
||||
|
|
|
@ -44,7 +44,7 @@ __Array::__Array()
|
|||
|
||||
__Array* __Array::create()
|
||||
{
|
||||
__Array* array = new __Array();
|
||||
__Array* array = new (std::nothrow) __Array();
|
||||
|
||||
if (array && array->initWithCapacity(7))
|
||||
{
|
||||
|
@ -60,7 +60,7 @@ __Array* __Array::create()
|
|||
|
||||
__Array* __Array::createWithObject(Ref* object)
|
||||
{
|
||||
__Array* array = new __Array();
|
||||
__Array* array = new (std::nothrow) __Array();
|
||||
|
||||
if (array && array->initWithObject(object))
|
||||
{
|
||||
|
@ -109,7 +109,7 @@ __Array* __Array::createWithCapacity(int capacity)
|
|||
{
|
||||
CCASSERT(capacity>=0, "Invalid capacity");
|
||||
|
||||
__Array* array = new __Array();
|
||||
__Array* array = new (std::nothrow) __Array();
|
||||
|
||||
if (array && array->initWithCapacity(capacity))
|
||||
{
|
||||
|
@ -342,7 +342,7 @@ __Array::~Array()
|
|||
|
||||
__Array* __Array::clone() const
|
||||
{
|
||||
__Array* ret = new __Array();
|
||||
__Array* ret = new (std::nothrow) __Array();
|
||||
ret->autorelease();
|
||||
ret->initWithCapacity(this->data.size() > 0 ? this->data.size() : 1);
|
||||
|
||||
|
@ -387,7 +387,7 @@ __Array::__Array()
|
|||
|
||||
__Array* __Array::create()
|
||||
{
|
||||
__Array* array = new __Array();
|
||||
__Array* array = new (std::nothrow) __Array();
|
||||
|
||||
if (array && array->initWithCapacity(7))
|
||||
{
|
||||
|
@ -403,7 +403,7 @@ __Array* __Array::create()
|
|||
|
||||
__Array* __Array::createWithObject(Ref* object)
|
||||
{
|
||||
__Array* array = new __Array();
|
||||
__Array* array = new (std::nothrow) __Array();
|
||||
|
||||
if (array && array->initWithObject(object))
|
||||
{
|
||||
|
@ -452,7 +452,7 @@ __Array* __Array::createWithCapacity(ssize_t capacity)
|
|||
{
|
||||
CCASSERT(capacity>=0, "Invalid capacity");
|
||||
|
||||
__Array* array = new __Array();
|
||||
__Array* array = new (std::nothrow) __Array();
|
||||
|
||||
if (array && array->initWithCapacity(capacity))
|
||||
{
|
||||
|
@ -728,7 +728,7 @@ __Array::~__Array()
|
|||
|
||||
__Array* __Array::clone() const
|
||||
{
|
||||
__Array* ret = new __Array();
|
||||
__Array* ret = new (std::nothrow) __Array();
|
||||
ret->autorelease();
|
||||
ret->initWithCapacity(this->data->num > 0 ? this->data->num : 1);
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ public:
|
|||
|
||||
static __Bool* create(bool v)
|
||||
{
|
||||
__Bool* pRet = new __Bool(v);
|
||||
__Bool* pRet = new (std::nothrow) __Bool(v);
|
||||
if (pRet)
|
||||
{
|
||||
pRet->autorelease();
|
||||
|
|
|
@ -106,7 +106,7 @@ __Array* __Dictionary::allKeys()
|
|||
{
|
||||
HASH_ITER(hh, _elements, pElement, tmp)
|
||||
{
|
||||
__String* pOneKey = new __String(pElement->_strKey);
|
||||
__String* pOneKey = new (std::nothrow) __String(pElement->_strKey);
|
||||
array->addObject(pOneKey);
|
||||
CC_SAFE_RELEASE(pOneKey);
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ __Array* __Dictionary::allKeys()
|
|||
{
|
||||
HASH_ITER(hh, _elements, pElement, tmp)
|
||||
{
|
||||
__Integer* pOneKey = new __Integer(static_cast<int>(pElement->_intKey));
|
||||
__Integer* pOneKey = new (std::nothrow) __Integer(static_cast<int>(pElement->_intKey));
|
||||
array->addObject(pOneKey);
|
||||
CC_SAFE_RELEASE(pOneKey);
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ __Array* __Dictionary::allKeysForObject(Ref* object)
|
|||
{
|
||||
if (object == pElement->_object)
|
||||
{
|
||||
__String* pOneKey = new __String(pElement->_strKey);
|
||||
__String* pOneKey = new (std::nothrow) __String(pElement->_strKey);
|
||||
array->addObject(pOneKey);
|
||||
CC_SAFE_RELEASE(pOneKey);
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ __Array* __Dictionary::allKeysForObject(Ref* object)
|
|||
{
|
||||
if (object == pElement->_object)
|
||||
{
|
||||
__Integer* pOneKey = new __Integer(static_cast<int>(pElement->_intKey));
|
||||
__Integer* pOneKey = new (std::nothrow) __Integer(static_cast<int>(pElement->_intKey));
|
||||
array->addObject(pOneKey);
|
||||
CC_SAFE_RELEASE(pOneKey);
|
||||
}
|
||||
|
@ -366,7 +366,7 @@ Ref* __Dictionary::randomObject()
|
|||
|
||||
__Dictionary* __Dictionary::create()
|
||||
{
|
||||
__Dictionary* ret = new __Dictionary();
|
||||
__Dictionary* ret = new (std::nothrow) __Dictionary();
|
||||
if (ret && ret->init() )
|
||||
{
|
||||
ret->autorelease();
|
||||
|
@ -388,7 +388,7 @@ static __Array* visitArray(const ValueVector& array);
|
|||
|
||||
static __Dictionary* visitDict(const ValueMap& dict)
|
||||
{
|
||||
__Dictionary* ret = new __Dictionary();
|
||||
__Dictionary* ret = new (std::nothrow) __Dictionary();
|
||||
ret->init();
|
||||
|
||||
for (auto iter = dict.begin(); iter != dict.end(); ++iter)
|
||||
|
@ -409,7 +409,7 @@ static __Dictionary* visitDict(const ValueMap& dict)
|
|||
}
|
||||
else
|
||||
{
|
||||
auto str = new __String(iter->second.asString());
|
||||
auto str = new (std::nothrow) __String(iter->second.asString());
|
||||
ret->setObject(str, iter->first);
|
||||
str->release();
|
||||
}
|
||||
|
@ -419,7 +419,7 @@ static __Dictionary* visitDict(const ValueMap& dict)
|
|||
|
||||
static __Array* visitArray(const ValueVector& array)
|
||||
{
|
||||
__Array* ret = new __Array();
|
||||
__Array* ret = new (std::nothrow) __Array();
|
||||
ret->init();
|
||||
|
||||
for(const auto &value : array) {
|
||||
|
@ -439,7 +439,7 @@ static __Array* visitArray(const ValueVector& array)
|
|||
}
|
||||
else
|
||||
{
|
||||
auto str = new __String(value.asString());
|
||||
auto str = new (std::nothrow) __String(value.asString());
|
||||
ret->addObject(str);
|
||||
str->release();
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
|
||||
static __Double* create(double v)
|
||||
{
|
||||
__Double* pRet = new __Double(v);
|
||||
__Double* pRet = new (std::nothrow) __Double(v);
|
||||
if (pRet)
|
||||
{
|
||||
pRet->autorelease();
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
|
||||
static __Float* create(float v)
|
||||
{
|
||||
__Float* pRet = new __Float(v);
|
||||
__Float* pRet = new (std::nothrow) __Float(v);
|
||||
if (pRet)
|
||||
{
|
||||
pRet->autorelease();
|
||||
|
|
|
@ -43,7 +43,7 @@ class CC_DLL __Integer : public Ref, public Clonable
|
|||
public:
|
||||
static __Integer* create(int v)
|
||||
{
|
||||
__Integer* pRet = new __Integer(v);
|
||||
__Integer* pRet = new (std::nothrow) __Integer(v);
|
||||
pRet->autorelease();
|
||||
return pRet;
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ __NotificationCenter *__NotificationCenter::getInstance()
|
|||
{
|
||||
if (!s_sharedNotifCenter)
|
||||
{
|
||||
s_sharedNotifCenter = new __NotificationCenter;
|
||||
s_sharedNotifCenter = new (std::nothrow) __NotificationCenter;
|
||||
}
|
||||
return s_sharedNotifCenter;
|
||||
}
|
||||
|
|
|
@ -31,12 +31,12 @@ NS_CC_BEGIN
|
|||
|
||||
__Set::__Set(void)
|
||||
{
|
||||
_set = new set<Ref *>;
|
||||
_set = new (std::nothrow) set<Ref *>;
|
||||
}
|
||||
|
||||
__Set::__Set(const __Set &other)
|
||||
{
|
||||
_set = new set<Ref *>(*other._set);
|
||||
_set = new (std::nothrow) set<Ref *>(*other._set);
|
||||
|
||||
// call retain of members
|
||||
__SetIterator iter;
|
||||
|
@ -64,7 +64,7 @@ void __Set::acceptVisitor(DataVisitor &visitor)
|
|||
|
||||
__Set * __Set::create()
|
||||
{
|
||||
__Set * pRet = new __Set();
|
||||
__Set * pRet = new (std::nothrow) __Set();
|
||||
|
||||
if (pRet != nullptr)
|
||||
{
|
||||
|
@ -76,7 +76,7 @@ __Set * __Set::create()
|
|||
|
||||
__Set* __Set::copy(void)
|
||||
{
|
||||
__Set *p__Set = new __Set(*this);
|
||||
__Set *p__Set = new (std::nothrow) __Set(*this);
|
||||
|
||||
return p__Set;
|
||||
}
|
||||
|
|
|
@ -220,7 +220,7 @@ bool __String::isEqual(const Ref* pObject)
|
|||
|
||||
__String* __String::create(const std::string& str)
|
||||
{
|
||||
__String* ret = new __String(str);
|
||||
__String* ret = new (std::nothrow) __String(str);
|
||||
ret->autorelease();
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -468,7 +468,7 @@ float * NodeLoader::parsePropTypeFloatXY(Node * pNode, Node * pParent, CCBReader
|
|||
float x = ccbReader->readFloat();
|
||||
float y = ccbReader->readFloat();
|
||||
|
||||
float * floatXY = new float[2];
|
||||
float * floatXY = new (std::nothrow) float[2];
|
||||
floatXY[0] = x;
|
||||
floatXY[1] = y;
|
||||
|
||||
|
@ -499,7 +499,7 @@ float * NodeLoader::parsePropTypeScaleLock(Node * pNode, Node * pParent, CCBRead
|
|||
y *= ccbReader->getResolutionScale();
|
||||
}
|
||||
|
||||
float * scaleLock = new float[2];
|
||||
float * scaleLock = new (std::nothrow) float[2];
|
||||
scaleLock[0] = x;
|
||||
scaleLock[1] = y;
|
||||
|
||||
|
@ -549,7 +549,7 @@ float * NodeLoader::parsePropTypeFloatVar(Node * pNode, Node * pParent, CCBReade
|
|||
float f = ccbReader->readFloat();
|
||||
float fVar = ccbReader->readFloat();
|
||||
|
||||
float * arr = new float[2];
|
||||
float * arr = new (std::nothrow) float[2];
|
||||
arr[0] = f;
|
||||
arr[1] = fVar;
|
||||
|
||||
|
@ -705,7 +705,7 @@ bool * NodeLoader::parsePropTypeFlip(Node * pNode, Node * pParent, CCBReader * c
|
|||
bool flipX = ccbReader->readBool();
|
||||
bool flipY = ccbReader->readBool();
|
||||
|
||||
bool * arr = new bool[2];
|
||||
bool * arr = new (std::nothrow) bool[2];
|
||||
arr[0] = flipX;
|
||||
arr[1] = flipY;
|
||||
|
||||
|
|
|
@ -171,7 +171,7 @@ CSLoader* CSLoader::getInstance()
|
|||
{
|
||||
if (! _sharedCSLoader)
|
||||
{
|
||||
_sharedCSLoader = new CSLoader();
|
||||
_sharedCSLoader = new (std::nothrow) CSLoader();
|
||||
_sharedCSLoader->init();
|
||||
}
|
||||
|
||||
|
@ -742,7 +742,7 @@ Node* CSLoader::loadWidget(const rapidjson::Value& json)
|
|||
|
||||
|
||||
|
||||
WidgetPropertiesReader0300* widgetPropertiesReader = new WidgetPropertiesReader0300();
|
||||
WidgetPropertiesReader0300* widgetPropertiesReader = new (std::nothrow) WidgetPropertiesReader0300();
|
||||
Widget* widget = nullptr;
|
||||
|
||||
if (isWidget(classname))
|
||||
|
|
|
@ -421,7 +421,7 @@ void ColliderDetector::setBody(b2Body *pBody)
|
|||
|
||||
ContourData *contourData = colliderBody->getContourData();
|
||||
|
||||
b2Vec2 *b2bv = new b2Vec2[contourData->vertexList.size()];
|
||||
b2Vec2 *b2bv = new (std::nothrow) b2Vec2[contourData->vertexList.size()];
|
||||
|
||||
int i = 0;
|
||||
for(auto& v : contourData->vertexList)
|
||||
|
@ -470,7 +470,7 @@ void ColliderDetector::setBody(cpBody *pBody)
|
|||
|
||||
ssize_t num = contourData->vertexList.size();
|
||||
auto vs = contourData->vertexList;
|
||||
cpVect *verts = new cpVect[num];
|
||||
cpVect *verts = new (std::nothrow) cpVect[num];
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
verts[num - 1 - i].x = vs.at(i).x;
|
||||
|
|
|
@ -373,7 +373,7 @@ void DataReaderHelper::addDataFromFileAsync(const std::string& imagePath, const
|
|||
if (_asyncStructQueue == nullptr)
|
||||
{
|
||||
_asyncStructQueue = new std::queue<AsyncStruct *>();
|
||||
_dataQueue = new std::queue<DataInfo *>();
|
||||
_dataQueue = new (std::nothrow) std::queue<DataInfo *>();
|
||||
|
||||
// create a new thread to load images
|
||||
_loadingThread = new std::thread(&DataReaderHelper::loadData, this);
|
||||
|
@ -1644,7 +1644,7 @@ FrameData *DataReaderHelper::decodeFrame(const rapidjson::Value& json, DataInfo
|
|||
int length = DICTOOL->getArrayCount_json(json, A_EASING_PARAM);
|
||||
if (length != 0)
|
||||
{
|
||||
frameData->easingParams = new float[length];
|
||||
frameData->easingParams = new (std::nothrow) float[length];
|
||||
frameData->easingParamNumber = length;
|
||||
|
||||
for (int i = 0; i < length; i++)
|
||||
|
@ -2384,7 +2384,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
|
|||
int count = pFrameDataArray[i].GetChildNum();
|
||||
if (count != 0 )
|
||||
{
|
||||
frameData->easingParams = new float[count];
|
||||
frameData->easingParams = new (std::nothrow) float[count];
|
||||
stExpCocoNode *pFrameData = pFrameDataArray[i].GetChildArray(cocoLoader);
|
||||
for (int ii = 0; ii < count; ++ii)
|
||||
{
|
||||
|
|
|
@ -283,7 +283,7 @@ void FrameData::copy(const BaseData *baseData)
|
|||
CC_SAFE_DELETE(easingParams);
|
||||
if (easingParamNumber != 0)
|
||||
{
|
||||
easingParams = new float[easingParamNumber];
|
||||
easingParams = new (std::nothrow) float[easingParamNumber];
|
||||
for (int i = 0; i<easingParamNumber; i++)
|
||||
{
|
||||
easingParams[i] = frameData->easingParams[i];
|
||||
|
|
|
@ -39,7 +39,7 @@ THE SOFTWARE.
|
|||
#define CC_CREATE_NO_PARAM_NO_INIT(varType)\
|
||||
public: \
|
||||
static inline varType *create(void){ \
|
||||
varType *var = new varType();\
|
||||
varType *var = new (std::nothrow) varType();\
|
||||
if (var)\
|
||||
{\
|
||||
var->autorelease();\
|
||||
|
@ -52,7 +52,7 @@ public: \
|
|||
#define CC_CREATE_NO_PARAM(varType)\
|
||||
public: \
|
||||
static inline varType *create(void){ \
|
||||
varType *var = new varType();\
|
||||
varType *var = new (std::nothrow) varType();\
|
||||
if (var && var->init())\
|
||||
{\
|
||||
var->autorelease();\
|
||||
|
|
|
@ -177,7 +177,7 @@ bool CocoLoader::ReadCocoBinBuff(char* pBinBuff)
|
|||
pTempBuff += sizeof(stCocoFileHeader);
|
||||
char* pStartAddr = m_pMemoryBuff = pTempBuff;
|
||||
|
||||
char* pDestBuff = new char[m_pFileHeader->m_nDataSize];
|
||||
char* pDestBuff = new (std::nothrow) char[m_pFileHeader->m_nDataSize];
|
||||
if (m_pFileHeader->m_nCompressSize > 0)
|
||||
{
|
||||
uLongf dwSrcSize = m_pFileHeader->m_nCompressSize;
|
||||
|
|
|
@ -119,7 +119,7 @@ FlatBuffersSerialize* FlatBuffersSerialize::getInstance()
|
|||
{
|
||||
if (!_instanceFlatBuffersSerialize)
|
||||
{
|
||||
_instanceFlatBuffersSerialize = new FlatBuffersSerialize();
|
||||
_instanceFlatBuffersSerialize = new (std::nothrow) FlatBuffersSerialize();
|
||||
}
|
||||
|
||||
return _instanceFlatBuffersSerialize;
|
||||
|
@ -161,7 +161,7 @@ std::string FlatBuffersSerialize::serializeFlatBuffersWithXMLFile(const std::str
|
|||
std::string content = FileUtils::getInstance()->getStringFromFile(inFullpath);
|
||||
|
||||
// xml parse
|
||||
tinyxml2::XMLDocument* document = new tinyxml2::XMLDocument();
|
||||
tinyxml2::XMLDocument* document = new (std::nothrow) tinyxml2::XMLDocument();
|
||||
document->Parse(content.c_str());
|
||||
|
||||
const tinyxml2::XMLElement* rootElement = document->RootElement();// Root
|
||||
|
@ -238,7 +238,7 @@ std::string FlatBuffersSerialize::serializeFlatBuffersWithXMLFile(const std::str
|
|||
|
||||
if (serializeEnabled)
|
||||
{
|
||||
_builder = new FlatBufferBuilder();
|
||||
_builder = new (std::nothrow) FlatBufferBuilder();
|
||||
|
||||
Offset<NodeTree> nodeTree;
|
||||
Offset<NodeAction> aciton;
|
||||
|
@ -1292,7 +1292,7 @@ FlatBufferBuilder* FlatBuffersSerialize::createFlatBuffersWithXMLFileForSimulato
|
|||
std::string content = FileUtils::getInstance()->getStringFromFile(inFullpath);
|
||||
|
||||
// xml parse
|
||||
tinyxml2::XMLDocument* document = new tinyxml2::XMLDocument();
|
||||
tinyxml2::XMLDocument* document = new (std::nothrow) tinyxml2::XMLDocument();
|
||||
document->Parse(content.c_str());
|
||||
|
||||
const tinyxml2::XMLElement* rootElement = document->RootElement();// Root
|
||||
|
@ -1345,7 +1345,7 @@ FlatBufferBuilder* FlatBuffersSerialize::createFlatBuffersWithXMLFileForSimulato
|
|||
|
||||
if (serializeEnabled)
|
||||
{
|
||||
_builder = new FlatBufferBuilder();
|
||||
_builder = new (std::nothrow) FlatBufferBuilder();
|
||||
|
||||
Offset<NodeTree> nodeTree;
|
||||
Offset<NodeAction> aciton;
|
||||
|
|
|
@ -29,10 +29,10 @@ using namespace cocostudio;
|
|||
|
||||
void sendEvent(unsigned int event)
|
||||
{
|
||||
char* buf = new char[10];
|
||||
char buf[10];
|
||||
sprintf(buf, "%d", event);
|
||||
std::string custom_event_name(buf);
|
||||
CC_SAFE_DELETE_ARRAY(buf);
|
||||
|
||||
EventCustom eventCustom(custom_event_name);
|
||||
TriggerMng::getInstance()->dispatchEvent(&eventCustom);
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ THE SOFTWARE.
|
|||
#define IMPLEMENT_CLASS_INFO(className) \
|
||||
cocos2d::Ref* className::createInstance(void) \
|
||||
{ \
|
||||
auto ret = new className; \
|
||||
auto ret = new (std::nothrow) className; \
|
||||
ret->autorelease(); \
|
||||
return ret; \
|
||||
} \
|
||||
|
|
|
@ -491,7 +491,7 @@ void TriggerMng::addEventListenerWithFixedPriority(cocos2d::EventListener* liste
|
|||
ArmatureMovementDispatcher::ArmatureMovementDispatcher(void)
|
||||
: _mapEventAnimation(nullptr)
|
||||
{
|
||||
_mapEventAnimation = new std::unordered_map<Ref*, SEL_MovementEventCallFunc> ;
|
||||
_mapEventAnimation = new (std::nothrow) std::unordered_map<Ref*, SEL_MovementEventCallFunc> ;
|
||||
}
|
||||
|
||||
ArmatureMovementDispatcher::~ArmatureMovementDispatcher(void)
|
||||
|
|
|
@ -224,10 +224,9 @@ void TriggerObj::serialize(const rapidjson::Value &val)
|
|||
continue;
|
||||
}
|
||||
|
||||
char* buf = new char[10];
|
||||
char buf[10];
|
||||
sprintf(buf, "%d", event);
|
||||
std::string custom_event_name(buf);
|
||||
CC_SAFE_DELETE_ARRAY(buf);
|
||||
|
||||
EventListenerCustom* listener = EventListenerCustom::create(custom_event_name, [=](EventCustom* evt){
|
||||
if (detect())
|
||||
|
@ -316,10 +315,9 @@ void TriggerObj::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stEx
|
|||
{
|
||||
continue;
|
||||
}
|
||||
char* buf = new char[10];
|
||||
char buf[10];
|
||||
sprintf(buf, "%d", event);
|
||||
std::string custom_event_name(buf);
|
||||
CC_SAFE_DELETE_ARRAY(buf);
|
||||
|
||||
EventListenerCustom* listener = EventListenerCustom::create(custom_event_name, [=](EventCustom* evt){
|
||||
if (detect())
|
||||
|
|
|
@ -55,7 +55,7 @@ namespace cocostudio
|
|||
{
|
||||
if (!_instanceTMXTiledMapReader)
|
||||
{
|
||||
_instanceTMXTiledMapReader = new GameMapReader();
|
||||
_instanceTMXTiledMapReader = new (std::nothrow) GameMapReader();
|
||||
}
|
||||
|
||||
return _instanceTMXTiledMapReader;
|
||||
|
|
|
@ -57,7 +57,7 @@ namespace cocostudio
|
|||
{
|
||||
if (!_instanceNode3DReader)
|
||||
{
|
||||
_instanceNode3DReader = new GameNode3DReader();
|
||||
_instanceNode3DReader = new (std::nothrow) GameNode3DReader();
|
||||
}
|
||||
|
||||
return _instanceNode3DReader;
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace cocostudio
|
|||
{
|
||||
if (!_instanceLight3DReader)
|
||||
{
|
||||
_instanceLight3DReader = new Light3DReader();
|
||||
_instanceLight3DReader = new (std::nothrow) Light3DReader();
|
||||
}
|
||||
|
||||
return _instanceLight3DReader;
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace cocostudio
|
|||
{
|
||||
if (!_instanceNode3DReader)
|
||||
{
|
||||
_instanceNode3DReader = new Node3DReader();
|
||||
_instanceNode3DReader = new (std::nothrow) Node3DReader();
|
||||
}
|
||||
|
||||
return _instanceNode3DReader;
|
||||
|
|
|
@ -73,7 +73,7 @@ namespace cocostudio
|
|||
{
|
||||
if (!_instanceNodeReader)
|
||||
{
|
||||
_instanceNodeReader = new NodeReader();
|
||||
_instanceNodeReader = new (std::nothrow) NodeReader();
|
||||
}
|
||||
|
||||
return _instanceNodeReader;
|
||||
|
|
|
@ -57,7 +57,7 @@ namespace cocostudio
|
|||
{
|
||||
if (!_instanceParticle3DReader)
|
||||
{
|
||||
_instanceParticle3DReader = new Particle3DReader();
|
||||
_instanceParticle3DReader = new (std::nothrow) Particle3DReader();
|
||||
}
|
||||
|
||||
return _instanceParticle3DReader;
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace cocostudio
|
|||
{
|
||||
if (!_instanceParticleReader)
|
||||
{
|
||||
_instanceParticleReader = new ParticleReader();
|
||||
_instanceParticleReader = new (std::nothrow) ParticleReader();
|
||||
}
|
||||
|
||||
return _instanceParticleReader;
|
||||
|
|
|
@ -51,7 +51,7 @@ namespace cocostudio
|
|||
{
|
||||
if (!_instanceProjectNodeReader)
|
||||
{
|
||||
_instanceProjectNodeReader = new ProjectNodeReader();
|
||||
_instanceProjectNodeReader = new (std::nothrow) ProjectNodeReader();
|
||||
}
|
||||
|
||||
return _instanceProjectNodeReader;
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace cocostudio
|
|||
{
|
||||
if (!_instanceSingleNodeReader)
|
||||
{
|
||||
_instanceSingleNodeReader = new SingleNodeReader();
|
||||
_instanceSingleNodeReader = new (std::nothrow) SingleNodeReader();
|
||||
}
|
||||
|
||||
return _instanceSingleNodeReader;
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace cocostudio
|
|||
{
|
||||
if (!_instanceSprite3DReader)
|
||||
{
|
||||
_instanceSprite3DReader = new Sprite3DReader();
|
||||
_instanceSprite3DReader = new (std::nothrow) Sprite3DReader();
|
||||
}
|
||||
|
||||
return _instanceSprite3DReader;
|
||||
|
|
|
@ -54,7 +54,7 @@ namespace cocostudio
|
|||
{
|
||||
if (!_instanceSpriteReader)
|
||||
{
|
||||
_instanceSpriteReader = new SpriteReader();
|
||||
_instanceSpriteReader = new (std::nothrow) SpriteReader();
|
||||
}
|
||||
|
||||
return _instanceSpriteReader;
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace cocostudio
|
|||
{
|
||||
if (!_instanceUserCameraReader)
|
||||
{
|
||||
_instanceUserCameraReader = new UserCameraReader();
|
||||
_instanceUserCameraReader = new (std::nothrow) UserCameraReader();
|
||||
}
|
||||
|
||||
return _instanceUserCameraReader;
|
||||
|
|
|
@ -183,9 +183,9 @@ bool NavMesh::loadNavMeshFile()
|
|||
return false;
|
||||
}
|
||||
|
||||
_allocator = new LinearAllocator(32000);
|
||||
_compressor = new FastLZCompressor;
|
||||
_meshProcess = new MeshProcess(_geomData);
|
||||
_allocator = new (std::nothrow) LinearAllocator(32000);
|
||||
_compressor = new (std::nothrow) FastLZCompressor;
|
||||
_meshProcess = new (std::nothrow) MeshProcess(_geomData);
|
||||
status = _tileCache->init(&header.cacheParams, _allocator, _compressor, _meshProcess);
|
||||
|
||||
if (dtStatusFailed(status))
|
||||
|
@ -233,7 +233,7 @@ bool NavMesh::loadGeomFile()
|
|||
auto data = FileUtils::getInstance()->getDataFromFile(_geomFilePath);
|
||||
if (data.isNull()) return false;
|
||||
buf = data.getBytes();
|
||||
_geomData = new GeomData;
|
||||
_geomData = new (std::nothrow) GeomData;
|
||||
_geomData->offMeshConCount = 0;
|
||||
|
||||
unsigned char* src = buf;
|
||||
|
|
|
@ -93,7 +93,7 @@ void NavMeshDebugDraw::depthMask(bool state)
|
|||
void NavMeshDebugDraw::begin(duDebugDrawPrimitives prim, float size /*= 1.0f*/)
|
||||
{
|
||||
if (_currentPrimitive) return;
|
||||
_currentPrimitive = new Primitive;
|
||||
_currentPrimitive = new (std::nothrow) Primitive;
|
||||
_currentPrimitive->type = getPrimitiveType(prim);
|
||||
_currentPrimitive->depthMask = _currentDepthMask;
|
||||
_currentPrimitive->start = _vertices.size();
|
||||
|
|
|
@ -104,7 +104,7 @@ namespace cocos2d { namespace network {
|
|||
}
|
||||
IDownloadTask *DownloaderApple::createCoTask(std::shared_ptr<const DownloadTask>& task)
|
||||
{
|
||||
DownloadTaskApple* coTask = new DownloadTaskApple();
|
||||
DownloadTaskApple* coTask = new (std::nothrow) DownloadTaskApple();
|
||||
DeclareDownloaderImplVar;
|
||||
if (task->storagePath.length())
|
||||
{
|
||||
|
|
|
@ -740,7 +740,7 @@ namespace cocos2d { namespace network {
|
|||
|
||||
IDownloadTask *DownloaderCURL::createCoTask(std::shared_ptr<const DownloadTask>& task)
|
||||
{
|
||||
DownloadTaskCURL *coTask = new DownloadTaskCURL;
|
||||
DownloadTaskCURL *coTask = new (std::nothrow) DownloadTaskCURL;
|
||||
coTask->init(task->storagePath, _impl->hints.tempFileNameSuffix);
|
||||
|
||||
DLLOG(" DownloaderCURL: createTask: Id(%d)", coTask->serialId);
|
||||
|
|
|
@ -130,7 +130,7 @@ namespace cocos2d { namespace network {
|
|||
|
||||
std::shared_ptr<const DownloadTask> Downloader::createDownloadDataTask(const std::string& srcUrl, const std::string& identifier/* = ""*/)
|
||||
{
|
||||
DownloadTask *task_ = new DownloadTask();
|
||||
DownloadTask *task_ = new (std::nothrow) DownloadTask();
|
||||
std::shared_ptr<const DownloadTask> task(task_);
|
||||
do
|
||||
{
|
||||
|
@ -155,7 +155,7 @@ namespace cocos2d { namespace network {
|
|||
const std::string& storagePath,
|
||||
const std::string& identifier/* = ""*/)
|
||||
{
|
||||
DownloadTask *task_ = new DownloadTask();
|
||||
DownloadTask *task_ = new (std::nothrow) DownloadTask();
|
||||
std::shared_ptr<const DownloadTask> task(task_);
|
||||
do
|
||||
{
|
||||
|
|
|
@ -78,7 +78,7 @@ namespace network {
|
|||
|
||||
static void processHttpResponse(HttpResponse* response, std::string& errorStr);
|
||||
|
||||
static HttpRequest *s_requestSentinel = new HttpRequest;
|
||||
static HttpRequest *s_requestSentinel = new (std::nothrow) HttpRequest;
|
||||
|
||||
// Worker thread
|
||||
void HttpClient::networkThread()
|
||||
|
|
|
@ -308,10 +308,10 @@ SocketIOPacket * SocketIOPacket::createPacketWithType(std::string type, SocketIO
|
|||
switch (version)
|
||||
{
|
||||
case SocketIOPacket::SocketIOVersion::V09x:
|
||||
ret = new SocketIOPacket;
|
||||
ret = new (std::nothrow) SocketIOPacket;
|
||||
break;
|
||||
case SocketIOPacket::SocketIOVersion::V10x:
|
||||
ret = new SocketIOPacketV10x;
|
||||
ret = new (std::nothrow) SocketIOPacketV10x;
|
||||
break;
|
||||
}
|
||||
ret->initWithType(type);
|
||||
|
@ -325,10 +325,10 @@ SocketIOPacket * SocketIOPacket::createPacketWithTypeIndex(int type, SocketIOPac
|
|||
switch (version)
|
||||
{
|
||||
case SocketIOPacket::SocketIOVersion::V09x:
|
||||
ret = new SocketIOPacket;
|
||||
ret = new (std::nothrow) SocketIOPacket;
|
||||
break;
|
||||
case SocketIOPacket::SocketIOVersion::V10x:
|
||||
return new SocketIOPacketV10x;
|
||||
return new (std::nothrow) SocketIOPacketV10x;
|
||||
break;
|
||||
}
|
||||
ret->initWithTypeIndex(type);
|
||||
|
|
|
@ -120,8 +120,8 @@ WsThreadHelper::WsThreadHelper()
|
|||
, _ws(nullptr)
|
||||
, _needQuit(false)
|
||||
{
|
||||
_UIWsMessageQueue = new std::list<WsMessage*>();
|
||||
_subThreadWsMessageQueue = new std::list<WsMessage*>();
|
||||
_UIWsMessageQueue = new (std::nothrow) std::list<WsMessage*>();
|
||||
_subThreadWsMessageQueue = new (std::nothrow) std::list<WsMessage*>();
|
||||
|
||||
Director::getInstance()->getScheduler()->scheduleUpdate(this, 0, false);
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ bool WsThreadHelper::createThread(const WebSocket& ws)
|
|||
_ws = const_cast<WebSocket*>(&ws);
|
||||
|
||||
// Creates websocket thread
|
||||
_subThreadInstance = new std::thread(&WsThreadHelper::wsThreadEntryFunc, this);
|
||||
_subThreadInstance = new (std::nothrow) std::thread(&WsThreadHelper::wsThreadEntryFunc, this);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -309,7 +309,7 @@ bool WebSocket::init(const Delegate& delegate,
|
|||
protocolCount = 1;
|
||||
}
|
||||
|
||||
_wsProtocols = new libwebsocket_protocols[protocolCount+1];
|
||||
_wsProtocols = new (std::nothrow) libwebsocket_protocols[protocolCount+1];
|
||||
memset(_wsProtocols, 0, sizeof(libwebsocket_protocols)*(protocolCount+1));
|
||||
|
||||
if (protocols && protocols->size() > 0)
|
||||
|
@ -317,7 +317,7 @@ bool WebSocket::init(const Delegate& delegate,
|
|||
int i = 0;
|
||||
for (std::vector<std::string>::const_iterator iter = protocols->begin(); iter != protocols->end(); ++iter, ++i)
|
||||
{
|
||||
char* name = new char[(*iter).length()+1];
|
||||
char* name = new (std::nothrow) char[(*iter).length()+1];
|
||||
strcpy(name, (*iter).c_str());
|
||||
_wsProtocols[i].name = name;
|
||||
_wsProtocols[i].callback = WebSocketCallbackWrapper::onSocketCallback;
|
||||
|
@ -325,7 +325,7 @@ bool WebSocket::init(const Delegate& delegate,
|
|||
}
|
||||
else
|
||||
{
|
||||
char* name = new char[20];
|
||||
char* name = new (std::nothrow) char[20];
|
||||
strcpy(name, "default-protocol");
|
||||
_wsProtocols[0].name = name;
|
||||
_wsProtocols[0].callback = WebSocketCallbackWrapper::onSocketCallback;
|
||||
|
@ -346,7 +346,7 @@ void WebSocket::send(const std::string& message)
|
|||
WsMessage* msg = new (std::nothrow) WsMessage();
|
||||
msg->what = WS_MSG_TO_SUBTRHEAD_SENDING_STRING;
|
||||
Data* data = new (std::nothrow) Data();
|
||||
data->bytes = new char[message.length()+1];
|
||||
data->bytes = new (std::nothrow) char[message.length()+1];
|
||||
strcpy(data->bytes, message.c_str());
|
||||
data->len = static_cast<ssize_t>(message.length());
|
||||
msg->obj = data;
|
||||
|
@ -364,7 +364,7 @@ void WebSocket::send(const unsigned char* binaryMsg, unsigned int len)
|
|||
WsMessage* msg = new (std::nothrow) WsMessage();
|
||||
msg->what = WS_MSG_TO_SUBTRHEAD_SENDING_BINARY;
|
||||
Data* data = new (std::nothrow) Data();
|
||||
data->bytes = new char[len];
|
||||
data->bytes = new (std::nothrow) char[len];
|
||||
memcpy((void*)data->bytes, (void*)binaryMsg, len);
|
||||
data->len = len;
|
||||
msg->obj = data;
|
||||
|
@ -546,7 +546,7 @@ int WebSocket::onSocketCallback(struct libwebsocket_context *ctx,
|
|||
//fixme: the log is not thread safe
|
||||
// CCLOG("[websocket:send] total: %d, sent: %d, remaining: %d, buffer size: %d", static_cast<int>(data->len), static_cast<int>(data->issued), static_cast<int>(remaining), static_cast<int>(n));
|
||||
|
||||
unsigned char* buf = new unsigned char[LWS_SEND_BUFFER_PRE_PADDING + n + LWS_SEND_BUFFER_POST_PADDING];
|
||||
unsigned char* buf = new (std::nothrow) unsigned char[LWS_SEND_BUFFER_PRE_PADDING + n + LWS_SEND_BUFFER_POST_PADDING];
|
||||
|
||||
memcpy((char*)&buf[LWS_SEND_BUFFER_PRE_PADDING], data->bytes + data->issued, n);
|
||||
|
||||
|
@ -630,13 +630,13 @@ int WebSocket::onSocketCallback(struct libwebsocket_context *ctx,
|
|||
// Accumulate the data (increasing the buffer as we go)
|
||||
if (_currentDataLen == 0)
|
||||
{
|
||||
_currentData = new char[len];
|
||||
_currentData = new (std::nothrow) char[len];
|
||||
memcpy (_currentData, in, len);
|
||||
_currentDataLen = len;
|
||||
}
|
||||
else
|
||||
{
|
||||
char *new_data = new char [_currentDataLen + len];
|
||||
char *new_data = new (std::nothrow) char [_currentDataLen + len];
|
||||
memcpy (new_data, _currentData, _currentDataLen);
|
||||
memcpy (new_data + _currentDataLen, in, len);
|
||||
CC_SAFE_DELETE_ARRAY(_currentData);
|
||||
|
@ -663,12 +663,12 @@ int WebSocket::onSocketCallback(struct libwebsocket_context *ctx,
|
|||
if (lws_frame_is_binary(wsi))
|
||||
{
|
||||
|
||||
bytes = new char[_currentDataLen];
|
||||
bytes = new (std::nothrow) char[_currentDataLen];
|
||||
data->isBinary = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
bytes = new char[_currentDataLen+1];
|
||||
bytes = new (std::nothrow) char[_currentDataLen+1];
|
||||
bytes[_currentDataLen] = '\0';
|
||||
data->isBinary = false;
|
||||
}
|
||||
|
|
|
@ -271,7 +271,7 @@ void PhysicsShape::setSensor(bool sensor)
|
|||
|
||||
void PhysicsShape::recenterPoints(Vec2* points, int count, const Vec2& center)
|
||||
{
|
||||
cpVect* cpvs = new cpVect[count];
|
||||
cpVect* cpvs = new (std::nothrow) cpVect[count];
|
||||
cpRecenterPoly(count, PhysicsHelper::points2cpvs(points, cpvs, count));
|
||||
PhysicsHelper::cpvs2points(cpvs, points, count);
|
||||
delete[] cpvs;
|
||||
|
@ -287,7 +287,7 @@ void PhysicsShape::recenterPoints(Vec2* points, int count, const Vec2& center)
|
|||
|
||||
Vec2 PhysicsShape::getPolyonCenter(const Vec2* points, int count)
|
||||
{
|
||||
cpVect* cpvs = new cpVect[count];
|
||||
cpVect* cpvs = new (std::nothrow) cpVect[count];
|
||||
cpVect center = cpCentroidForPoly(count, PhysicsHelper::points2cpvs(points, cpvs, count));
|
||||
delete[] cpvs;
|
||||
|
||||
|
@ -550,7 +550,7 @@ bool PhysicsShapePolygon::init(const Vec2* points, int count, const PhysicsMater
|
|||
{
|
||||
_type = Type::POLYGEN;
|
||||
|
||||
auto vecs = new cpVect[count];
|
||||
auto vecs = new (std::nothrow) cpVect[count];
|
||||
PhysicsHelper::points2cpvs(points, vecs, count);
|
||||
auto shape = cpPolyShapeNew(s_sharedBody, count, vecs, PhysicsHelper::point2cpv(offset));
|
||||
CC_SAFE_DELETE_ARRAY(vecs);
|
||||
|
@ -573,7 +573,7 @@ bool PhysicsShapePolygon::init(const Vec2* points, int count, const PhysicsMater
|
|||
|
||||
float PhysicsShapePolygon::calculateArea(const Vec2* points, int count)
|
||||
{
|
||||
cpVect* vecs = new cpVect[count];
|
||||
cpVect* vecs = new (std::nothrow) cpVect[count];
|
||||
PhysicsHelper::points2cpvs(points, vecs, count);
|
||||
float area = PhysicsHelper::cpfloat2float(cpAreaForPoly(count, vecs));
|
||||
CC_SAFE_DELETE_ARRAY(vecs);
|
||||
|
@ -583,7 +583,7 @@ float PhysicsShapePolygon::calculateArea(const Vec2* points, int count)
|
|||
|
||||
float PhysicsShapePolygon::calculateMoment(float mass, const Vec2* points, int count, const Vec2& offset)
|
||||
{
|
||||
cpVect* vecs = new cpVect[count];
|
||||
cpVect* vecs = new (std::nothrow) cpVect[count];
|
||||
PhysicsHelper::points2cpvs(points, vecs, count);
|
||||
float moment = mass == PHYSICS_INFINITY ? PHYSICS_INFINITY
|
||||
: PhysicsHelper::cpfloat2float(cpMomentForPoly(mass, count, vecs, PhysicsHelper::point2cpv(offset)));
|
||||
|
@ -735,7 +735,7 @@ bool PhysicsShapeEdgePolygon::init(const Vec2* points, int count, const PhysicsM
|
|||
{
|
||||
_type = Type::EDGEPOLYGEN;
|
||||
|
||||
vec = new cpVect[count];
|
||||
vec = new (std::nothrow) cpVect[count];
|
||||
PhysicsHelper::points2cpvs(points, vec, count);
|
||||
|
||||
int i = 0;
|
||||
|
@ -767,7 +767,7 @@ bool PhysicsShapeEdgePolygon::init(const Vec2* points, int count, const PhysicsM
|
|||
Vec2 PhysicsShapeEdgePolygon::getCenter()
|
||||
{
|
||||
int count = (int)_cpShapes.size();
|
||||
cpVect* points = new cpVect[count];
|
||||
cpVect* points = new (std::nothrow) cpVect[count];
|
||||
int i = 0;
|
||||
for(auto shape : _cpShapes)
|
||||
{
|
||||
|
@ -834,7 +834,7 @@ bool PhysicsShapeEdgeChain::init(const Vec2* points, int count, const PhysicsMat
|
|||
{
|
||||
_type = Type::EDGECHAIN;
|
||||
|
||||
vec = new cpVect[count];
|
||||
vec = new (std::nothrow) cpVect[count];
|
||||
PhysicsHelper::points2cpvs(points, vec, count);
|
||||
|
||||
int i = 0;
|
||||
|
@ -865,7 +865,7 @@ bool PhysicsShapeEdgeChain::init(const Vec2* points, int count, const PhysicsMat
|
|||
Vec2 PhysicsShapeEdgeChain::getCenter()
|
||||
{
|
||||
int count = (int)_cpShapes.size() + 1;
|
||||
cpVect* points = new cpVect[count];
|
||||
cpVect* points = new (std::nothrow) cpVect[count];
|
||||
int i = 0;
|
||||
for(auto shape : _cpShapes)
|
||||
{
|
||||
|
|
|
@ -32,7 +32,7 @@ NS_CC_BEGIN
|
|||
|
||||
PhysicsSprite3D* PhysicsSprite3D::create(const std::string &modelPath, Physics3DRigidBodyDes* rigidDes, const cocos2d::Vec3& translateInPhysics, const cocos2d::Quaternion& rotInPhsyics)
|
||||
{
|
||||
auto ret = new PhysicsSprite3D();
|
||||
auto ret = new (std::nothrow) PhysicsSprite3D();
|
||||
if (ret && ret->initWithFile(modelPath))
|
||||
{
|
||||
auto obj = Physics3DRigidBody::create(rigidDes);
|
||||
|
|
|
@ -869,7 +869,7 @@ bool Image::encodeWithWIC(const std::string& filePath, bool isToRGB, GUID contai
|
|||
{
|
||||
bpp = 3;
|
||||
saveLen = _width * _height * bpp;
|
||||
pSaveData = new unsigned char[saveLen];
|
||||
pSaveData = new (std::nothrow) unsigned char[saveLen];
|
||||
int indL = 0, indR = 0;
|
||||
|
||||
while (indL < saveLen && indR < _dataLen)
|
||||
|
@ -881,7 +881,7 @@ bool Image::encodeWithWIC(const std::string& filePath, bool isToRGB, GUID contai
|
|||
}
|
||||
else
|
||||
{
|
||||
pSaveData = new unsigned char[saveLen];
|
||||
pSaveData = new (std::nothrow) unsigned char[saveLen];
|
||||
memcpy(pSaveData, _data, saveLen);
|
||||
}
|
||||
|
||||
|
@ -1456,7 +1456,7 @@ bool Image::initWithPVRv2Data(const unsigned char * data, ssize_t dataLen)
|
|||
CCLOG("cocos2d: Hardware PVR decoder not present. Using software decoder");
|
||||
_unpack = true;
|
||||
_mipmaps[_numberOfMipmaps].len = width*height*4;
|
||||
_mipmaps[_numberOfMipmaps].address = new unsigned char[width*height*4];
|
||||
_mipmaps[_numberOfMipmaps].address = new (std::nothrow) unsigned char[width*height*4];
|
||||
PVRTDecompressPVRTC(_data+dataOffset,width,height,_mipmaps[_numberOfMipmaps].address, true);
|
||||
bpp = 2;
|
||||
}
|
||||
|
@ -1470,7 +1470,7 @@ bool Image::initWithPVRv2Data(const unsigned char * data, ssize_t dataLen)
|
|||
CCLOG("cocos2d: Hardware PVR decoder not present. Using software decoder");
|
||||
_unpack = true;
|
||||
_mipmaps[_numberOfMipmaps].len = width*height*4;
|
||||
_mipmaps[_numberOfMipmaps].address = new unsigned char[width*height*4];
|
||||
_mipmaps[_numberOfMipmaps].address = new (std::nothrow) unsigned char[width*height*4];
|
||||
PVRTDecompressPVRTC(_data+dataOffset,width,height,_mipmaps[_numberOfMipmaps].address, false);
|
||||
bpp = 4;
|
||||
}
|
||||
|
@ -1612,7 +1612,7 @@ bool Image::initWithPVRv3Data(const unsigned char * data, ssize_t dataLen)
|
|||
CCLOG("cocos2d: Hardware PVR decoder not present. Using software decoder");
|
||||
_unpack = true;
|
||||
_mipmaps[i].len = width*height*4;
|
||||
_mipmaps[i].address = new unsigned char[width*height*4];
|
||||
_mipmaps[i].address = new (std::nothrow) unsigned char[width*height*4];
|
||||
PVRTDecompressPVRTC(_data+dataOffset,width,height,_mipmaps[i].address, true);
|
||||
bpp = 2;
|
||||
}
|
||||
|
@ -1627,7 +1627,7 @@ bool Image::initWithPVRv3Data(const unsigned char * data, ssize_t dataLen)
|
|||
CCLOG("cocos2d: Hardware PVR decoder not present. Using software decoder");
|
||||
_unpack = true;
|
||||
_mipmaps[i].len = width*height*4;
|
||||
_mipmaps[i].address = new unsigned char[width*height*4];
|
||||
_mipmaps[i].address = new (std::nothrow) unsigned char[width*height*4];
|
||||
PVRTDecompressPVRTC(_data+dataOffset,width,height,_mipmaps[i].address, false);
|
||||
bpp = 4;
|
||||
}
|
||||
|
@ -1643,7 +1643,7 @@ bool Image::initWithPVRv3Data(const unsigned char * data, ssize_t dataLen)
|
|||
unsigned int stride = width * bytePerPixel;
|
||||
_unpack = true;
|
||||
_mipmaps[i].len = width*height*bytePerPixel;
|
||||
_mipmaps[i].address = new unsigned char[width*height*bytePerPixel];
|
||||
_mipmaps[i].address = new (std::nothrow) unsigned char[width*height*bytePerPixel];
|
||||
if (etc1_decode_image(static_cast<const unsigned char*>(_data+dataOffset), static_cast<etc1_byte*>(_mipmaps[i].address), width, height, bytePerPixel, stride) != 0)
|
||||
{
|
||||
return false;
|
||||
|
|
|
@ -72,7 +72,7 @@ static CCAccelerometerDispatcher* s_pAccelerometerDispatcher;
|
|||
- (id) init
|
||||
{
|
||||
if( (self = [super init]) ) {
|
||||
_acceleration = new cocos2d::Acceleration();
|
||||
_acceleration = new (std::nothrow) cocos2d::Acceleration();
|
||||
_motionManager = [[CMMotionManager alloc] init];
|
||||
_motionManager.accelerometerUpdateInterval = SENSOR_DELAY_GAME;
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ bool cocos2d::Image::saveToFile(const std::string& filename, bool isToRGB)
|
|||
// or want to save as jpg, remove the alpha channel.
|
||||
if (hasAlpha() && bitsPerPixel == 24)
|
||||
{
|
||||
pixels = new unsigned char[myDataLength];
|
||||
pixels = new (std::nothrow) unsigned char[myDataLength];
|
||||
|
||||
for (int i = 0; i < _height; ++i)
|
||||
{
|
||||
|
|
|
@ -237,43 +237,43 @@ void GLProgramCache::loadDefaultGLPrograms()
|
|||
loadDefaultGLProgram(p, kShaderType_3DSkinPositionTex);
|
||||
_programs.insert(std::make_pair(GLProgram::SHADER_3D_SKINPOSITION_TEXTURE, p));
|
||||
|
||||
p = new GLProgram();
|
||||
p = new (std::nothrow) GLProgram();
|
||||
loadDefaultGLProgram(p, kShaderType_3DPositionNormal);
|
||||
_programs.insert( std::make_pair(GLProgram::SHADER_3D_POSITION_NORMAL, p) );
|
||||
|
||||
p = new GLProgram();
|
||||
p = new (std::nothrow) GLProgram();
|
||||
loadDefaultGLProgram(p, kShaderType_3DPositionNormalTex);
|
||||
_programs.insert( std::make_pair(GLProgram::SHADER_3D_POSITION_NORMAL_TEXTURE, p) );
|
||||
|
||||
p = new GLProgram();
|
||||
p = new (std::nothrow) GLProgram();
|
||||
loadDefaultGLProgram(p, kShaderType_3DSkinPositionNormalTex);
|
||||
_programs.insert(std::make_pair(GLProgram::SHADER_3D_SKINPOSITION_NORMAL_TEXTURE, p));
|
||||
|
||||
p = new GLProgram();
|
||||
p = new (std::nothrow) GLProgram();
|
||||
loadDefaultGLProgram(p, kShaderType_3DPositionBumpedNormalTex);
|
||||
_programs.insert(std::make_pair(GLProgram::SHADER_3D_POSITION_BUMPEDNORMAL_TEXTURE, p));
|
||||
|
||||
p = new GLProgram();
|
||||
p = new (std::nothrow) GLProgram();
|
||||
loadDefaultGLProgram(p, kShaderType_3DSkinPositionBumpedNormalTex);
|
||||
_programs.insert(std::make_pair(GLProgram::SHADER_3D_SKINPOSITION_BUMPEDNORMAL_TEXTURE, p));
|
||||
|
||||
p = new GLProgram();
|
||||
p = new (std::nothrow) GLProgram();
|
||||
loadDefaultGLProgram(p, kShaderType_3DParticleColor);
|
||||
_programs.insert(std::make_pair(GLProgram::SHADER_3D_PARTICLE_COLOR, p));
|
||||
|
||||
p = new GLProgram();
|
||||
p = new (std::nothrow) GLProgram();
|
||||
loadDefaultGLProgram(p, kShaderType_3DParticleTex);
|
||||
_programs.insert(std::make_pair(GLProgram::SHADER_3D_PARTICLE_TEXTURE, p));
|
||||
|
||||
p = new GLProgram();
|
||||
p = new (std::nothrow) GLProgram();
|
||||
loadDefaultGLProgram(p, kShaderType_3DSkyBox);
|
||||
_programs.insert(std::make_pair(GLProgram::SHADER_3D_SKYBOX, p));
|
||||
|
||||
p = new GLProgram();
|
||||
p = new (std::nothrow) GLProgram();
|
||||
loadDefaultGLProgram(p, kShaderType_3DTerrain);
|
||||
_programs.insert(std::make_pair(GLProgram::SHADER_3D_TERRAIN, p));
|
||||
|
||||
p = new GLProgram();
|
||||
p = new (std::nothrow) GLProgram();
|
||||
loadDefaultGLProgram(p, kShaderType_CameraClear);
|
||||
_programs.insert(std::make_pair(GLProgram::SHADER_CAMERA_CLEAR, p));
|
||||
}
|
||||
|
|
|
@ -155,7 +155,7 @@ void UniformValue::setCallback(const std::function<void(GLProgram*, Uniform*)> &
|
|||
if (_type == Type::CALLBACK_FN)
|
||||
delete _value.callback;
|
||||
|
||||
_value.callback = new std::function<void(GLProgram*, Uniform*)>();
|
||||
_value.callback = new (std::nothrow) std::function<void(GLProgram*, Uniform*)>();
|
||||
*_value.callback = callback;
|
||||
|
||||
_type = Type::CALLBACK_FN;
|
||||
|
@ -290,7 +290,7 @@ void VertexAttribValue::apply()
|
|||
|
||||
void VertexAttribValue::setCallback(const std::function<void(VertexAttrib*)> &callback)
|
||||
{
|
||||
_value.callback = new std::function<void(VertexAttrib*)>();
|
||||
_value.callback = new (std::nothrow) std::function<void(VertexAttrib*)>();
|
||||
*_value.callback = callback;
|
||||
_useCallback = true;
|
||||
_enabled = true;
|
||||
|
|
|
@ -1392,7 +1392,7 @@ void Texture2D::addSpriteFrameCapInset(SpriteFrame* spritframe, const Rect& capI
|
|||
{
|
||||
if(nullptr == _ninePatchInfo)
|
||||
{
|
||||
_ninePatchInfo = new NinePatchInfo;
|
||||
_ninePatchInfo = new (std::nothrow) NinePatchInfo;
|
||||
}
|
||||
if(nullptr == spritframe)
|
||||
{
|
||||
|
|
|
@ -154,7 +154,7 @@ void TextureCache::addImageAsync(const std::string &path, const std::function<vo
|
|||
if (_loadingThread == nullptr)
|
||||
{
|
||||
// create a new thread to load images
|
||||
_loadingThread = new std::thread(&TextureCache::loadImage, this);
|
||||
_loadingThread = new (std::nothrow) std::thread(&TextureCache::loadImage, this);
|
||||
_needQuit = false;
|
||||
}
|
||||
|
||||
|
@ -617,7 +617,7 @@ void TextureCache::renameTextureWithKey(const std::string srcName, const std::st
|
|||
std::string fullpath = FileUtils::getInstance()->fullPathForFilename(dstName);
|
||||
Texture2D* tex = it->second;
|
||||
|
||||
Image* image = new Image();
|
||||
Image* image = new (std::nothrow) Image();
|
||||
if (image)
|
||||
{
|
||||
bool ret = image->initWithImageFile(dstName);
|
||||
|
|
|
@ -68,7 +68,7 @@ unsigned char* getImageData(Image* img, Texture2D::PixelFormat& ePixFmt)
|
|||
{
|
||||
// Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRRGGGGGGBBBBB"
|
||||
inPixel32 = (unsigned int*)img->getData();
|
||||
pTmpData = new unsigned char[nWidth * nHeight * 2];
|
||||
pTmpData = new (std::nothrow) unsigned char[nWidth * nHeight * 2];
|
||||
outPixel16 = (unsigned short*)pTmpData;
|
||||
|
||||
for (unsigned int i = 0; i < uLen; ++i, ++inPixel32)
|
||||
|
@ -82,7 +82,7 @@ unsigned char* getImageData(Image* img, Texture2D::PixelFormat& ePixFmt)
|
|||
else
|
||||
{
|
||||
// Convert "RRRRRRRRGGGGGGGGBBBBBBBB" to "RRRRRGGGGGGBBBBB"
|
||||
pTmpData = new unsigned char[nWidth * nHeight * 2];
|
||||
pTmpData = new (std::nothrow) unsigned char[nWidth * nHeight * 2];
|
||||
outPixel16 = (unsigned short*)pTmpData;
|
||||
inPixel8 = (unsigned char*)img->getData();
|
||||
|
||||
|
@ -105,7 +105,7 @@ unsigned char* getImageData(Image* img, Texture2D::PixelFormat& ePixFmt)
|
|||
// Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRRRRRGGGGGGGGBBBBBBBB"
|
||||
inPixel32 = (unsigned int*)img->getData();
|
||||
|
||||
pTmpData = new unsigned char[nWidth * nHeight * 3];
|
||||
pTmpData = new (std::nothrow) unsigned char[nWidth * nHeight * 3];
|
||||
unsigned char* outPixel8 = pTmpData;
|
||||
|
||||
for (unsigned int i = 0; i < uLen; ++i, ++inPixel32)
|
||||
|
|
|
@ -79,7 +79,7 @@ static bool js_cocos2dx_Sprite3D_createAsync(JSContext *cx, uint32_t argc, jsval
|
|||
};
|
||||
callback = lambda;
|
||||
|
||||
JSB_HeapValueWrapper* data = new JSB_HeapValueWrapper(cx, args.get(argc == 4 ? 3 : 4));
|
||||
JSB_HeapValueWrapper* data = new (std::nothrow) JSB_HeapValueWrapper(cx, args.get(argc == 4 ? 3 : 4));
|
||||
|
||||
if(argc == 4)
|
||||
cocos2d::Sprite3D::createAsync(modelPath, callback, data);
|
||||
|
|
|
@ -454,7 +454,7 @@ ScriptingCore* ScriptingCore::getInstance()
|
|||
{
|
||||
static ScriptingCore* instance = nullptr;
|
||||
if (instance == nullptr)
|
||||
instance = new ScriptingCore();
|
||||
instance = new (std::nothrow) ScriptingCore();
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
@ -475,7 +475,7 @@ ScriptingCore::ScriptingCore()
|
|||
void ScriptingCore::initRegister()
|
||||
{
|
||||
this->addRegisterCallback(registerDefaultClasses);
|
||||
this->_runLoop = new SimpleRunLoop();
|
||||
this->_runLoop = new (std::nothrow) SimpleRunLoop();
|
||||
}
|
||||
|
||||
void ScriptingCore::string_report(JS::HandleValue val) {
|
||||
|
|
|
@ -38,7 +38,7 @@ void static freeSpaceChildren(cpSpace *space);
|
|||
template<class T>
|
||||
static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) {
|
||||
TypeTest<T> t;
|
||||
T* cobj = new T();
|
||||
T* cobj = new (std::nothrow) T();
|
||||
cobj->autorelease();
|
||||
js_type_class_t *p;
|
||||
std::string typeName = t.s_name();
|
||||
|
@ -483,7 +483,7 @@ bool JSPROXY_CCPhysicsSprite_spriteWithSpriteFrameName__static(JSContext *cx, ui
|
|||
bool JSPROXY_CCPhysicsSprite_constructor(JSContext *cx, uint32_t argc, jsval *vp) {
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
bool ok = true;
|
||||
PhysicsSprite* cobj = new PhysicsSprite();
|
||||
PhysicsSprite* cobj = new (std::nothrow) PhysicsSprite();
|
||||
cocos2d::Ref *_ccobj = dynamic_cast<cocos2d::Ref *>(cobj);
|
||||
if (_ccobj) {
|
||||
_ccobj->autorelease();
|
||||
|
@ -511,7 +511,7 @@ static bool JSPROXY_CCPhysicsSprite_ctor(JSContext *cx, uint32_t argc, jsval *vp
|
|||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
|
||||
PhysicsSprite *nobj = new PhysicsSprite();
|
||||
PhysicsSprite *nobj = new (std::nothrow) PhysicsSprite();
|
||||
if (nobj) {
|
||||
nobj->autorelease();
|
||||
}
|
||||
|
@ -951,7 +951,7 @@ void JSB_cpSpace_finalize(JSFreeOp *fop, JSObject *jsthis)
|
|||
static
|
||||
bool __jsb_cpSpace_addCollisionHandler(JSContext *cx, jsval *vp, jsval *argvp, JS::HandleObject jsspace, cpSpace *space, unsigned int is_oo)
|
||||
{
|
||||
struct collision_handler *handler = new collision_handler();
|
||||
struct collision_handler *handler = new (std::nothrow) collision_handler();
|
||||
handler->typeA = 0;
|
||||
handler->typeB = 0;
|
||||
|
||||
|
@ -1048,7 +1048,7 @@ bool JSB_cpSpace_setDefaultCollisionHandler(JSContext *cx, uint32_t argc, jsval
|
|||
struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis);
|
||||
cpSpace* space = (cpSpace*) proxy->handle;
|
||||
|
||||
collision_handler *handler = new collision_handler();
|
||||
collision_handler *handler = new (std::nothrow) collision_handler();
|
||||
JSB_PRECONDITION(handler, "Error allocating memory");
|
||||
|
||||
handler->typeA = 0;
|
||||
|
@ -1367,7 +1367,7 @@ bool JSB_cpSpace_segmentQueryFirst(JSContext *cx, uint32_t argc, jsval *vp){
|
|||
ok &= jsval_to_uint( cx, args.get(3), (unsigned int*)&group );
|
||||
JSB_PRECONDITION2(ok, cx, false, "Error processing arguments");
|
||||
|
||||
cpSegmentQueryInfo *out = new cpSegmentQueryInfo();
|
||||
cpSegmentQueryInfo *out = new (std::nothrow) cpSegmentQueryInfo();
|
||||
cpShape* target = cpSpaceSegmentQueryFirst(space, start, end, layers, group, out);
|
||||
|
||||
if(target)
|
||||
|
@ -1405,7 +1405,7 @@ bool JSB_cpSpace_nearestPointQueryNearest(JSContext *cx, uint32_t argc, jsval *v
|
|||
ok &= jsval_to_uint( cx, args.get(3), (unsigned int*)&group );
|
||||
JSB_PRECONDITION2(ok, cx, false, "Error processing arguments");
|
||||
|
||||
cpNearestPointQueryInfo* info = new cpNearestPointQueryInfo();
|
||||
cpNearestPointQueryInfo* info = new (std::nothrow) cpNearestPointQueryInfo();
|
||||
cpShape* target = cpSpaceNearestPointQueryNearest(space, point, maxDistance, layers, group, info);
|
||||
|
||||
if(target)
|
||||
|
|
|
@ -537,7 +537,7 @@ bool js_cocos2dx_JSTouchDelegate_registerStandardDelegate(JSContext *cx, uint32_
|
|||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
|
||||
JSTouchDelegate *touch = new JSTouchDelegate();
|
||||
JSTouchDelegate *touch = new (std::nothrow) JSTouchDelegate();
|
||||
|
||||
int priority = 1;
|
||||
if (argc == 2)
|
||||
|
@ -562,7 +562,7 @@ bool js_cocos2dx_JSTouchDelegate_registerTargetedDelegate(JSContext *cx, uint32_
|
|||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
|
||||
JSTouchDelegate *touch = new JSTouchDelegate();
|
||||
JSTouchDelegate *touch = new (std::nothrow) JSTouchDelegate();
|
||||
touch->registerTargetedDelegate(args.get(0).toInt32(), args.get(1).toBoolean());
|
||||
|
||||
JS::RootedObject jsobj(cx, args.get(2).toObjectOrNull());
|
||||
|
@ -807,7 +807,7 @@ void JSScheduleWrapper::setTargetForSchedule(JS::HandleValue sched, JSScheduleWr
|
|||
JSObject* jsfunc = sched.toObjectOrNull();
|
||||
auto targetArray = getTargetForSchedule(sched);
|
||||
if (NULL == targetArray) {
|
||||
targetArray = new __Array();
|
||||
targetArray = new (std::nothrow) __Array();
|
||||
targetArray->init();
|
||||
schedFunc_proxy_t *p = (schedFunc_proxy_t *)malloc(sizeof(schedFunc_proxy_t));
|
||||
assert(p);
|
||||
|
@ -834,7 +834,7 @@ void JSScheduleWrapper::setTargetForJSObject(JS::HandleObject jsTargetObj, JSSch
|
|||
{
|
||||
auto targetArray = getTargetForJSObject(jsTargetObj);
|
||||
if (NULL == targetArray) {
|
||||
targetArray = new __Array();
|
||||
targetArray = new (std::nothrow) __Array();
|
||||
targetArray->init();
|
||||
schedTarget_proxy_t *p = (schedTarget_proxy_t *)malloc(sizeof(schedTarget_proxy_t));
|
||||
assert(p);
|
||||
|
@ -1255,7 +1255,7 @@ bool js_CCNode_scheduleOnce(JSContext *cx, uint32_t argc, jsval *vp)
|
|||
|
||||
if (!bFound)
|
||||
{
|
||||
tmpCobj = new JSScheduleWrapper();
|
||||
tmpCobj = new (std::nothrow) JSScheduleWrapper();
|
||||
tmpCobj->autorelease();
|
||||
tmpCobj->setJSCallbackThis(thisValue);
|
||||
tmpCobj->setJSCallbackFunc(args.get(0));
|
||||
|
@ -1351,7 +1351,7 @@ bool js_CCNode_schedule(JSContext *cx, uint32_t argc, jsval *vp)
|
|||
|
||||
if (!bFound)
|
||||
{
|
||||
tmpCobj = new JSScheduleWrapper();
|
||||
tmpCobj = new (std::nothrow) JSScheduleWrapper();
|
||||
tmpCobj->autorelease();
|
||||
tmpCobj->setJSCallbackThis(thisValue);
|
||||
tmpCobj->setJSCallbackFunc(args.get(0));
|
||||
|
@ -1425,7 +1425,7 @@ bool js_cocos2dx_CCNode_scheduleUpdateWithPriority(JSContext *cx, uint32_t argc,
|
|||
|
||||
if (!bFound)
|
||||
{
|
||||
tmpCobj = new JSScheduleWrapper();
|
||||
tmpCobj = new (std::nothrow) JSScheduleWrapper();
|
||||
tmpCobj->autorelease();
|
||||
tmpCobj->setJSCallbackThis(thisValue);
|
||||
tmpCobj->setJSCallbackFunc(jsUpdateFunc);
|
||||
|
@ -1526,7 +1526,7 @@ bool js_cocos2dx_CCNode_scheduleUpdate(JSContext *cx, uint32_t argc, jsval *vp)
|
|||
|
||||
if (!bFound)
|
||||
{
|
||||
tmpCobj = new JSScheduleWrapper();
|
||||
tmpCobj = new (std::nothrow) JSScheduleWrapper();
|
||||
tmpCobj->autorelease();
|
||||
tmpCobj->setJSCallbackThis(thisValue);
|
||||
tmpCobj->setJSCallbackFunc(jsUpdateFunc);
|
||||
|
@ -1641,7 +1641,7 @@ bool js_CCScheduler_scheduleUpdateForTarget(JSContext *cx, uint32_t argc, jsval
|
|||
|
||||
if (!bFound)
|
||||
{
|
||||
tmpCObj = new JSScheduleWrapper();
|
||||
tmpCObj = new (std::nothrow) JSScheduleWrapper();
|
||||
tmpCObj->autorelease();
|
||||
tmpCObj->setJSCallbackThis(args.get(0));
|
||||
tmpCObj->setJSCallbackFunc(jsUpdateFunc);
|
||||
|
@ -1767,7 +1767,7 @@ bool js_CCScheduler_scheduleCallbackForTarget(JSContext *cx, uint32_t argc, jsva
|
|||
|
||||
if (!bFound)
|
||||
{
|
||||
tmpCObj = new JSScheduleWrapper();
|
||||
tmpCObj = new (std::nothrow) JSScheduleWrapper();
|
||||
tmpCObj->autorelease();
|
||||
tmpCObj->setJSCallbackThis(args.get(0));
|
||||
tmpCObj->setJSCallbackFunc(args.get(1));
|
||||
|
@ -5643,7 +5643,7 @@ bool js_cocos2dx_AutoPolygon_generatePolygon(JSContext *cx, uint32_t argc, jsval
|
|||
std::string arg0;
|
||||
ok &= jsval_to_std_string(cx, args.get(0), &arg0);
|
||||
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_AutoPolygon_generatePolygon : Error processing arguments");
|
||||
cocos2d::PolygonInfo* ret = new cocos2d::PolygonInfo(cocos2d::AutoPolygon::generatePolygon(arg0));
|
||||
cocos2d::PolygonInfo* ret = new (std::nothrow) cocos2d::PolygonInfo(cocos2d::AutoPolygon::generatePolygon(arg0));
|
||||
jsval jsret = JSVAL_NULL;
|
||||
if (ret) {
|
||||
jsret = OBJECT_TO_JSVAL(js_get_or_create_jsobject<cocos2d::PolygonInfo>(cx, ret));
|
||||
|
@ -5657,7 +5657,7 @@ bool js_cocos2dx_AutoPolygon_generatePolygon(JSContext *cx, uint32_t argc, jsval
|
|||
ok &= jsval_to_std_string(cx, args.get(0), &arg0);
|
||||
ok &= jsval_to_ccrect(cx, args.get(1), &arg1);
|
||||
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_AutoPolygon_generatePolygon : Error processing arguments");
|
||||
cocos2d::PolygonInfo* ret = new cocos2d::PolygonInfo(cocos2d::AutoPolygon::generatePolygon(arg0, arg1));
|
||||
cocos2d::PolygonInfo* ret = new (std::nothrow) cocos2d::PolygonInfo(cocos2d::AutoPolygon::generatePolygon(arg0, arg1));
|
||||
jsval jsret = JSVAL_NULL;
|
||||
if (ret) {
|
||||
jsret = OBJECT_TO_JSVAL(js_get_or_create_jsobject<cocos2d::PolygonInfo>(cx, ret));
|
||||
|
@ -5673,7 +5673,7 @@ bool js_cocos2dx_AutoPolygon_generatePolygon(JSContext *cx, uint32_t argc, jsval
|
|||
ok &= jsval_to_ccrect(cx, args.get(1), &arg1);
|
||||
ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2);
|
||||
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_AutoPolygon_generatePolygon : Error processing arguments");
|
||||
cocos2d::PolygonInfo* ret = new cocos2d::PolygonInfo(cocos2d::AutoPolygon::generatePolygon(arg0, arg1, arg2));
|
||||
cocos2d::PolygonInfo* ret = new (std::nothrow) cocos2d::PolygonInfo(cocos2d::AutoPolygon::generatePolygon(arg0, arg1, arg2));
|
||||
jsval jsret = JSVAL_NULL;
|
||||
if (ret) {
|
||||
jsret = OBJECT_TO_JSVAL(js_get_or_create_jsobject<cocos2d::PolygonInfo>(cx, ret));
|
||||
|
@ -5691,7 +5691,7 @@ bool js_cocos2dx_AutoPolygon_generatePolygon(JSContext *cx, uint32_t argc, jsval
|
|||
ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2);
|
||||
ok &= JS::ToNumber( cx, args.get(3), &arg3) && !isnan(arg3);
|
||||
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_AutoPolygon_generatePolygon : Error processing arguments");
|
||||
cocos2d::PolygonInfo* ret = new cocos2d::PolygonInfo(cocos2d::AutoPolygon::generatePolygon(arg0, arg1, arg2, arg3));
|
||||
cocos2d::PolygonInfo* ret = new (std::nothrow) cocos2d::PolygonInfo(cocos2d::AutoPolygon::generatePolygon(arg0, arg1, arg2, arg3));
|
||||
jsval jsret = JSVAL_NULL;
|
||||
if (ret) {
|
||||
jsret = OBJECT_TO_JSVAL(js_get_or_create_jsobject<cocos2d::PolygonInfo>(cx, ret));
|
||||
|
|
|
@ -270,7 +270,7 @@ public:
|
|||
static __JSPlistDelegator* getInstance() {
|
||||
static __JSPlistDelegator* pInstance = NULL;
|
||||
if (pInstance == NULL) {
|
||||
pInstance = new __JSPlistDelegator();
|
||||
pInstance = new (std::nothrow) __JSPlistDelegator();
|
||||
}
|
||||
return pInstance;
|
||||
};
|
||||
|
|
|
@ -64,7 +64,7 @@ void CCBScriptCallbackProxy::onNodeLoaded(Node * pNode,
|
|||
NodeLoader * pNodeLoader) {}
|
||||
|
||||
CCBSelectorResolver * CCBScriptCallbackProxy::createNew() {
|
||||
CCBScriptCallbackProxy * ret = new CCBScriptCallbackProxy();
|
||||
CCBScriptCallbackProxy * ret = new (std::nothrow) CCBScriptCallbackProxy();
|
||||
ret->setJSOwner(this->owner);
|
||||
return dynamic_cast<CCBSelectorResolver *>(ret);
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ bool js_cocos2dx_CCBAnimationManager_animationCompleteCallback(JSContext *cx, ui
|
|||
js_proxy_t *p = jsb_get_js_proxy(obj);
|
||||
cocosbuilder::CCBAnimationManager *node = (cocosbuilder::CCBAnimationManager *)(p ? p->ptr : NULL);
|
||||
|
||||
JSCCBAnimationWrapper *tmpCobj = new JSCCBAnimationWrapper();
|
||||
JSCCBAnimationWrapper *tmpCobj = new (std::nothrow) JSCCBAnimationWrapper();
|
||||
tmpCobj->autorelease();
|
||||
|
||||
tmpCobj->setJSCallbackThis(args.get(0));
|
||||
|
@ -289,7 +289,7 @@ bool js_CocosBuilder_create(JSContext *cx, uint32_t argc, jsval *vp)
|
|||
|
||||
ccNodeLoaderLibrary->registerNodeLoader("", JSLayerLoader::loader());
|
||||
|
||||
CCBReader * ret = new CCBReader(ccNodeLoaderLibrary);
|
||||
CCBReader * ret = new (std::nothrow) CCBReader(ccNodeLoaderLibrary);
|
||||
ret->autorelease();
|
||||
|
||||
jsval jsret;
|
||||
|
|
|
@ -115,7 +115,7 @@ static bool js_cocos2dx_ArmatureAnimation_setMovementEventCallFunc(JSContext *cx
|
|||
return true;
|
||||
}
|
||||
else if (argc == 1 || argc == 2) {
|
||||
JSArmatureWrapper *tmpObj = new JSArmatureWrapper();
|
||||
JSArmatureWrapper *tmpObj = new (std::nothrow) JSArmatureWrapper();
|
||||
tmpObj->autorelease();
|
||||
|
||||
cocos2d::__Dictionary* dict = static_cast<cocos2d::__Dictionary*>(cobj->getUserObject());
|
||||
|
@ -161,7 +161,7 @@ static bool js_cocos2dx_ArmatureAnimation_setFrameEventCallFunc(JSContext *cx, u
|
|||
return true;
|
||||
}
|
||||
else if (argc == 1 || argc == 2) {
|
||||
JSArmatureWrapper *tmpObj = new JSArmatureWrapper();
|
||||
JSArmatureWrapper *tmpObj = new (std::nothrow) JSArmatureWrapper();
|
||||
tmpObj->autorelease();
|
||||
|
||||
cocos2d::__Dictionary* dict = static_cast<cocos2d::__Dictionary*>(cobj->getUserObject());
|
||||
|
@ -202,7 +202,7 @@ static bool jsb_Animation_addArmatureFileInfoAsyncCallFunc(JSContext *cx, uint32
|
|||
JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object");
|
||||
|
||||
if (argc == 3) {
|
||||
JSArmatureWrapper *tmpObj = new JSArmatureWrapper();
|
||||
JSArmatureWrapper *tmpObj = new (std::nothrow) JSArmatureWrapper();
|
||||
tmpObj->autorelease();
|
||||
|
||||
tmpObj->setJSCallbackFunc(args.get(1));
|
||||
|
@ -217,7 +217,7 @@ static bool jsb_Animation_addArmatureFileInfoAsyncCallFunc(JSContext *cx, uint32
|
|||
}
|
||||
|
||||
if(argc == 5){
|
||||
JSArmatureWrapper *tmpObj = new JSArmatureWrapper();
|
||||
JSArmatureWrapper *tmpObj = new (std::nothrow) JSArmatureWrapper();
|
||||
tmpObj->autorelease();
|
||||
|
||||
tmpObj->setJSCallbackFunc(args.get(3));
|
||||
|
|
|
@ -73,7 +73,7 @@ ComponentJS::ComponentJS(const std::string& scriptFileName)
|
|||
CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
|
||||
typeClass = typeMapIter->second;
|
||||
|
||||
mozilla::Maybe<JS::PersistentRootedObject> *jsObj = new mozilla::Maybe<JS::PersistentRootedObject>();
|
||||
mozilla::Maybe<JS::PersistentRootedObject> *jsObj = new (std::nothrow) mozilla::Maybe<JS::PersistentRootedObject>();
|
||||
|
||||
JS::RootedObject proto(cx, protoValue.toObjectOrNull());
|
||||
JS::RootedObject parent(cx, typeClass->proto.ref());
|
||||
|
|
|
@ -86,7 +86,7 @@ static bool js_cocos2dx_CCScrollView_setDelegate(JSContext *cx, uint32_t argc, j
|
|||
{
|
||||
// save the delegate
|
||||
JS::RootedObject jsDelegate(cx, args.get(0).toObjectOrNull());
|
||||
JSB_ScrollViewDelegate* nativeDelegate = new JSB_ScrollViewDelegate();
|
||||
JSB_ScrollViewDelegate* nativeDelegate = new (std::nothrow) JSB_ScrollViewDelegate();
|
||||
nativeDelegate->setJSDelegate(jsDelegate);
|
||||
|
||||
cobj->setUserObject(nativeDelegate);
|
||||
|
@ -196,13 +196,13 @@ static bool js_cocos2dx_CCTableView_setDelegate(JSContext *cx, uint32_t argc, js
|
|||
{
|
||||
// save the delegate
|
||||
JS::RootedObject jsDelegate(cx, args.get(0).toObjectOrNull());
|
||||
JSB_TableViewDelegate* nativeDelegate = new JSB_TableViewDelegate();
|
||||
JSB_TableViewDelegate* nativeDelegate = new (std::nothrow) JSB_TableViewDelegate();
|
||||
nativeDelegate->setJSDelegate(jsDelegate);
|
||||
|
||||
__Dictionary* userDict = static_cast<__Dictionary*>(cobj->getUserObject());
|
||||
if (NULL == userDict)
|
||||
{
|
||||
userDict = new __Dictionary();
|
||||
userDict = new (std::nothrow) __Dictionary();
|
||||
cobj->setUserObject(userDict);
|
||||
userDict->release();
|
||||
}
|
||||
|
@ -376,14 +376,14 @@ static bool js_cocos2dx_CCTableView_setDataSource(JSContext *cx, uint32_t argc,
|
|||
JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object");
|
||||
if (argc == 1)
|
||||
{
|
||||
JSB_TableViewDataSource* pNativeSource = new JSB_TableViewDataSource();
|
||||
JSB_TableViewDataSource* pNativeSource = new (std::nothrow) JSB_TableViewDataSource();
|
||||
JS::RootedObject jsdata(cx, args.get(0).toObjectOrNull());
|
||||
pNativeSource->setTableViewDataSource(jsdata);
|
||||
|
||||
__Dictionary* userDict = static_cast<__Dictionary*>(cobj->getUserObject());
|
||||
if (NULL == userDict)
|
||||
{
|
||||
userDict = new __Dictionary();
|
||||
userDict = new (std::nothrow) __Dictionary();
|
||||
cobj->setUserObject(userDict);
|
||||
userDict->release();
|
||||
}
|
||||
|
@ -409,14 +409,14 @@ static bool js_cocos2dx_CCTableView_create(JSContext *cx, uint32_t argc, jsval *
|
|||
if (argc == 3 || argc == 2)
|
||||
{
|
||||
|
||||
JSB_TableViewDataSource* pNativeSource = new JSB_TableViewDataSource();
|
||||
JSB_TableViewDataSource* pNativeSource = new (std::nothrow) JSB_TableViewDataSource();
|
||||
JS::RootedObject jsdata(cx, args.get(0).toObjectOrNull());
|
||||
pNativeSource->setTableViewDataSource(jsdata);
|
||||
|
||||
cocos2d::Size arg1;
|
||||
ok &= jsval_to_ccsize(cx, args.get(1), &arg1);
|
||||
cocos2d::extension::TableView* ret = NULL;
|
||||
ret = new TableView();
|
||||
ret = new (std::nothrow) TableView();
|
||||
ret->autorelease();
|
||||
|
||||
ret->setDataSource(pNativeSource);
|
||||
|
@ -454,7 +454,7 @@ static bool js_cocos2dx_CCTableView_create(JSContext *cx, uint32_t argc, jsval *
|
|||
}
|
||||
ret->reloadData();
|
||||
|
||||
__Dictionary* userDict = new __Dictionary();
|
||||
__Dictionary* userDict = new (std::nothrow) __Dictionary();
|
||||
userDict->setObject(pNativeSource, KEY_TABLEVIEW_DATA_SOURCE);
|
||||
ret->setUserObject(userDict);
|
||||
userDict->release();
|
||||
|
@ -480,7 +480,7 @@ static bool js_cocos2dx_CCTableView_init(JSContext *cx, uint32_t argc, jsval *vp
|
|||
if (argc == 3 || argc == 2)
|
||||
{
|
||||
|
||||
JSB_TableViewDataSource* pNativeSource = new JSB_TableViewDataSource();
|
||||
JSB_TableViewDataSource* pNativeSource = new (std::nothrow) JSB_TableViewDataSource();
|
||||
JS::RootedObject jsdata(cx, args.get(0).toObjectOrNull());
|
||||
pNativeSource->setTableViewDataSource(jsdata);
|
||||
cobj->setDataSource(pNativeSource);
|
||||
|
@ -507,7 +507,7 @@ static bool js_cocos2dx_CCTableView_init(JSContext *cx, uint32_t argc, jsval *vp
|
|||
}
|
||||
cobj->reloadData();
|
||||
|
||||
__Dictionary* userDict = new __Dictionary();
|
||||
__Dictionary* userDict = new (std::nothrow) __Dictionary();
|
||||
userDict->setObject(pNativeSource, KEY_TABLEVIEW_DATA_SOURCE);
|
||||
cobj->setUserObject(userDict);
|
||||
userDict->release();
|
||||
|
@ -583,7 +583,7 @@ public:
|
|||
CC_SAFE_DELETE(_callback);
|
||||
}
|
||||
JSContext* cx = ScriptingCore::getInstance()->getGlobalContext();
|
||||
_callback = new JSFunctionWrapper(cx, jsTarget, jsFunc);
|
||||
_callback = new (std::nothrow) JSFunctionWrapper(cx, jsTarget, jsFunc);
|
||||
_jsFunc.ref() = jsFunc.toObjectOrNull();
|
||||
}
|
||||
|
||||
|
@ -631,7 +631,7 @@ static bool js_cocos2dx_CCControl_addTargetWithActionForControlEvents(JSContext
|
|||
}
|
||||
|
||||
// save the delegate
|
||||
JSB_ControlButtonTarget* nativeDelegate = new JSB_ControlButtonTarget();
|
||||
JSB_ControlButtonTarget* nativeDelegate = new (std::nothrow) JSB_ControlButtonTarget();
|
||||
|
||||
JS::RootedObject jscb(cx, jsDelegate);
|
||||
nativeDelegate->setJSCallback(args.get(1), jscb);
|
||||
|
@ -640,7 +640,7 @@ static bool js_cocos2dx_CCControl_addTargetWithActionForControlEvents(JSContext
|
|||
__Array* nativeDelegateArray = static_cast<__Array*>(cobj->getUserObject());
|
||||
if (nullptr == nativeDelegateArray)
|
||||
{
|
||||
nativeDelegateArray = new __Array();
|
||||
nativeDelegateArray = new (std::nothrow) __Array();
|
||||
nativeDelegateArray->init();
|
||||
cobj->setUserObject(nativeDelegateArray); // The reference of nativeDelegateArray is added to 2
|
||||
nativeDelegateArray->release(); // Release nativeDelegateArray to make the reference to 1
|
||||
|
|
|
@ -70,7 +70,7 @@ bool js_cocos2dx_GLNode_constructor(JSContext *cx, uint32_t argc, jsval *vp)
|
|||
{
|
||||
|
||||
if (argc == 0) {
|
||||
cocos2d::GLNode* cobj = new cocos2d::GLNode();
|
||||
cocos2d::GLNode* cobj = new (std::nothrow) cocos2d::GLNode();
|
||||
cocos2d::Ref *_ccobj = dynamic_cast<cocos2d::Ref *>(cobj);
|
||||
if (_ccobj) {
|
||||
_ccobj->autorelease();
|
||||
|
@ -108,7 +108,7 @@ static bool js_cocos2dx_GLNode_ctor(JSContext *cx, uint32_t argc, jsval *vp)
|
|||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
|
||||
cocos2d::GLNode *nobj = new cocos2d::GLNode();
|
||||
cocos2d::GLNode *nobj = new (std::nothrow) cocos2d::GLNode();
|
||||
js_proxy_t* p = jsb_new_proxy(nobj, obj);
|
||||
nobj->autorelease();
|
||||
JS::AddNamedObjectRoot(cx, &p->obj, "GLNode");
|
||||
|
@ -119,7 +119,7 @@ static bool js_cocos2dx_GLNode_ctor(JSContext *cx, uint32_t argc, jsval *vp)
|
|||
bool js_cocos2dx_GLNode_create(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
cocos2d::GLNode* ret = new cocos2d::GLNode();
|
||||
cocos2d::GLNode* ret = new (std::nothrow) cocos2d::GLNode();
|
||||
jsval jsret;
|
||||
do {
|
||||
if (ret) {
|
||||
|
|
|
@ -937,7 +937,7 @@ bool jsval_to_ccarray_of_CCPoint(JSContext* cx, JS::HandleValue v, Point **point
|
|||
uint32_t len;
|
||||
JS_GetArrayLength(cx, jsobj, &len);
|
||||
|
||||
Point *array = new Point[len];
|
||||
Point *array = new (std::nothrow) Point[len];
|
||||
|
||||
for( uint32_t i=0; i< len;i++ ) {
|
||||
JS::RootedValue valarg(cx);
|
||||
|
|
|
@ -194,7 +194,7 @@ bool JSB_glGetProgramInfoLog(JSContext *cx, uint32_t argc, jsval *vp)
|
|||
|
||||
GLsizei length;
|
||||
glGetProgramiv(arg0, GL_INFO_LOG_LENGTH, &length);
|
||||
GLchar* src = new GLchar[length];
|
||||
GLchar* src = new (std::nothrow) GLchar[length];
|
||||
glGetProgramInfoLog(arg0, length, NULL, src);
|
||||
|
||||
args.rval().set(charptr_to_jsval(cx, src));
|
||||
|
@ -215,7 +215,7 @@ bool JSB_glGetShaderInfoLog(JSContext *cx, uint32_t argc, jsval *vp)
|
|||
|
||||
GLsizei length;
|
||||
glGetShaderiv(arg0, GL_INFO_LOG_LENGTH, &length);
|
||||
GLchar* src = new GLchar[length];
|
||||
GLchar* src = new (std::nothrow) GLchar[length];
|
||||
glGetShaderInfoLog(arg0, length, NULL, src);
|
||||
|
||||
args.rval().set(charptr_to_jsval(cx, src));
|
||||
|
@ -236,7 +236,7 @@ bool JSB_glGetShaderSource(JSContext *cx, uint32_t argc, jsval *vp)
|
|||
|
||||
GLsizei length;
|
||||
glGetShaderiv(arg0, GL_SHADER_SOURCE_LENGTH, &length);
|
||||
GLchar* src = new GLchar[length];
|
||||
GLchar* src = new (std::nothrow) GLchar[length];
|
||||
glGetShaderSource(arg0, length, NULL, src);
|
||||
|
||||
args.rval().set(charptr_to_jsval(cx, src));
|
||||
|
@ -262,7 +262,7 @@ bool JSB_glGetActiveAttrib(JSContext *cx, uint32_t argc, jsval *vp)
|
|||
|
||||
GLsizei length;
|
||||
glGetProgramiv(arg0, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &length);
|
||||
GLchar* buffer = new GLchar[length];
|
||||
GLchar* buffer = new (std::nothrow) GLchar[length];
|
||||
GLint size = -1;
|
||||
GLenum type = -1;
|
||||
|
||||
|
@ -306,7 +306,7 @@ bool JSB_glGetActiveUniform(JSContext *cx, uint32_t argc, jsval *vp)
|
|||
|
||||
GLsizei length;
|
||||
glGetProgramiv(arg0, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &length);
|
||||
GLchar* buffer = new GLchar[length];
|
||||
GLchar* buffer = new (std::nothrow) GLchar[length];
|
||||
GLint size = -1;
|
||||
GLenum type = -1;
|
||||
|
||||
|
@ -344,7 +344,7 @@ bool JSB_glGetAttachedShaders(JSContext *cx, uint32_t argc, jsval *vp)
|
|||
|
||||
GLsizei length;
|
||||
glGetProgramiv(arg0, GL_ATTACHED_SHADERS, &length);
|
||||
GLuint* buffer = new GLuint[length];
|
||||
GLuint* buffer = new (std::nothrow) GLuint[length];
|
||||
memset(buffer, 0, length * sizeof(GLuint));
|
||||
//Fix bug 2448, it seems that glGetAttachedShaders will crash if we send NULL to the third parameter (eg Windows), same as in lua binding
|
||||
GLsizei realShaderCount = 0;
|
||||
|
@ -376,7 +376,7 @@ bool JSB_glGetSupportedExtensions(JSContext *cx, uint32_t argc, jsval *vp)
|
|||
|
||||
// copy, to be able to add '\0'
|
||||
size_t len = strlen((char*)extensions);
|
||||
GLubyte* copy = new GLubyte[len+1];
|
||||
GLubyte* copy = new (std::nothrow) GLubyte[len+1];
|
||||
strncpy((char*)copy, (const char*)extensions, len );
|
||||
|
||||
int start_extension=0;
|
||||
|
@ -438,7 +438,7 @@ bool JSB_glGetUniformfv(JSContext *cx, uint32_t argc, jsval *vp)
|
|||
|
||||
GLsizei length;
|
||||
glGetProgramiv(arg0, GL_ACTIVE_UNIFORM_MAX_LENGTH, &length);
|
||||
GLchar* namebuffer = new GLchar[length+1];
|
||||
GLchar* namebuffer = new (std::nothrow) GLchar[length+1];
|
||||
GLint size = -1;
|
||||
GLenum type = -1;
|
||||
|
||||
|
@ -520,7 +520,7 @@ bool JSB_glGetUniformfv(JSContext *cx, uint32_t argc, jsval *vp)
|
|||
// FIXME: glew on windows will cause array overflow after invoking glGetUniformfv.
|
||||
// It seems that glGetUniformfv re-assign the memeroy with a wrong size which is 4x than we pass in.
|
||||
// For temporary solution, we allocate 4x array.
|
||||
GLfloat* param = new GLfloat[usize*4];
|
||||
GLfloat* param = new (std::nothrow) GLfloat[usize*4];
|
||||
glGetUniformfv(arg0, arg1, param);
|
||||
|
||||
typedArray = JS_NewFloat32Array(cx, usize);
|
||||
|
@ -531,7 +531,7 @@ bool JSB_glGetUniformfv(JSContext *cx, uint32_t argc, jsval *vp)
|
|||
// FIXME: glew on windows will cause array overflow after invoking glGetUniformfv.
|
||||
// It seems that glGetUniformfv re-assign the memeroy with a wrong size which is 4x than we pass in.
|
||||
// For temporary solution, we allocate 4x array.
|
||||
GLint* param = new GLint[usize*4];
|
||||
GLint* param = new (std::nothrow) GLint[usize*4];
|
||||
glGetUniformiv(arg0, arg1, param);
|
||||
|
||||
typedArray = JS_NewInt32Array(cx, usize);
|
||||
|
|
|
@ -44,7 +44,7 @@ void MinXmlHttpRequest::_gotHeader(string header)
|
|||
{
|
||||
// Get Header and Set StatusText
|
||||
// Split String into Tokens
|
||||
char * cstr = new char [header.length()+1];
|
||||
char * cstr = new (std::nothrow) char [header.length()+1];
|
||||
|
||||
// check for colon.
|
||||
size_t found_header_field = header.find_first_of(":");
|
||||
|
@ -335,7 +335,7 @@ JS_BINDED_CLASS_GLUE_IMPL(MinXmlHttpRequest);
|
|||
JS_BINDED_CONSTRUCTOR_IMPL(MinXmlHttpRequest)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
MinXmlHttpRequest* req = new MinXmlHttpRequest();
|
||||
MinXmlHttpRequest* req = new (std::nothrow) MinXmlHttpRequest();
|
||||
req->autorelease();
|
||||
|
||||
js_proxy_t *p;
|
||||
|
|
|
@ -153,7 +153,7 @@ bool js_cocos2dx_SocketIO_connect(JSContext* cx, uint32_t argc, jsval* vp)
|
|||
JSB_PRECONDITION2( ok, cx, false, "Error processing arguments");
|
||||
} while (0);
|
||||
|
||||
JSB_SocketIODelegate* siodelegate = new JSB_SocketIODelegate();
|
||||
JSB_SocketIODelegate* siodelegate = new (std::nothrow) JSB_SocketIODelegate();
|
||||
|
||||
CCLOG("Calling native SocketIO.connect method");
|
||||
SIOClient* ret = SocketIO::connect(url, *siodelegate);
|
||||
|
|
|
@ -268,8 +268,8 @@ bool js_cocos2dx_extension_WebSocket_constructor(JSContext *cx, uint32_t argc, j
|
|||
JS::RootedObject obj(cx, JS_NewObject(cx, js_cocos2dx_websocket_class, proto, JS::NullPtr()));
|
||||
//JS::RootedObject obj(cx, JS_NewObjectForConstructor(cx, js_cocos2dx_websocket_class, args));
|
||||
|
||||
WebSocket* cobj = new WebSocket();
|
||||
JSB_WebSocketDelegate* delegate = new JSB_WebSocketDelegate();
|
||||
WebSocket* cobj = new (std::nothrow) WebSocket();
|
||||
JSB_WebSocketDelegate* delegate = new (std::nothrow) JSB_WebSocketDelegate();
|
||||
delegate->setJSDelegate(obj);
|
||||
|
||||
if (argc == 2)
|
||||
|
|
|
@ -206,7 +206,7 @@ void JavaScriptObjCBridge::CallInfo::pushValue(void *val){
|
|||
else if ([oval isKindOfClass:[NSString class]])
|
||||
{
|
||||
const char *content = [oval cStringUsingEncoding:NSUTF8StringEncoding];
|
||||
m_ret.stringValue = new string(content);
|
||||
m_ret.stringValue = new (std::nothrow) string(content);
|
||||
m_returnType = TypeString;
|
||||
}
|
||||
else if ([oval isKindOfClass:[NSDictionary class]])
|
||||
|
@ -232,7 +232,7 @@ JS_BINDED_CLASS_GLUE_IMPL(JavaScriptObjCBridge);
|
|||
*/
|
||||
JS_BINDED_CONSTRUCTOR_IMPL(JavaScriptObjCBridge)
|
||||
{
|
||||
JavaScriptObjCBridge* jsj = new JavaScriptObjCBridge();
|
||||
JavaScriptObjCBridge* jsj = new (std::nothrow) JavaScriptObjCBridge();
|
||||
|
||||
js_proxy_t *p;
|
||||
jsval out;
|
||||
|
|
|
@ -184,7 +184,7 @@ static bool js_cocos2dx_CCEditBox_setDelegate(JSContext *cx, uint32_t argc, jsva
|
|||
if (argc == 1)
|
||||
{
|
||||
// save the delegate
|
||||
JSB_EditBoxDelegate* nativeDelegate = new JSB_EditBoxDelegate();
|
||||
JSB_EditBoxDelegate* nativeDelegate = new (std::nothrow) JSB_EditBoxDelegate();
|
||||
nativeDelegate->setJSDelegate(args.get(0));
|
||||
|
||||
cobj->setUserObject(nativeDelegate);
|
||||
|
|
|
@ -977,7 +977,7 @@ int lua_cocos2dx_3d_AABB_constructor(lua_State* L)
|
|||
ok &= luaval_to_vec3(L, 3, &arg1, "cc.AABB:AABB");
|
||||
|
||||
if (!ok) { break; }
|
||||
cobj = new cocos2d::AABB(arg0, arg1);
|
||||
cobj = new (std::nothrow) cocos2d::AABB(arg0, arg1);
|
||||
tolua_pushusertype(L,(void*)cobj,"cc.AABB");
|
||||
tolua_register_gc(L,lua_gettop(L));
|
||||
return 1;
|
||||
|
@ -986,7 +986,7 @@ int lua_cocos2dx_3d_AABB_constructor(lua_State* L)
|
|||
ok = true;
|
||||
do{
|
||||
if (argc == 0) {
|
||||
cobj = new cocos2d::AABB();
|
||||
cobj = new (std::nothrow) cocos2d::AABB();
|
||||
tolua_pushusertype(L,(void*)cobj,"cc.AABB");
|
||||
tolua_register_gc(L,lua_gettop(L));
|
||||
return 1;
|
||||
|
@ -1381,7 +1381,7 @@ int lua_cocos2dx_3d_OBB_constructor(lua_State* L)
|
|||
ok &= luaval_to_object<cocos2d::AABB>(L, 2, "cc.AABB",&arg0, "cc.OBB:OBB");
|
||||
|
||||
if (!ok) { break; }
|
||||
cobj = new cocos2d::OBB(*arg0);
|
||||
cobj = new (std::nothrow) cocos2d::OBB(*arg0);
|
||||
tolua_pushusertype(L,(void*)cobj,"cc.OBB");
|
||||
tolua_register_gc(L,lua_gettop(L));
|
||||
return 1;
|
||||
|
@ -1390,7 +1390,7 @@ int lua_cocos2dx_3d_OBB_constructor(lua_State* L)
|
|||
ok = true;
|
||||
do{
|
||||
if (argc == 0) {
|
||||
cobj = new cocos2d::OBB();
|
||||
cobj = new (std::nothrow) cocos2d::OBB();
|
||||
tolua_pushusertype(L,(void*)cobj,"cc.OBB");
|
||||
tolua_register_gc(L,lua_gettop(L));
|
||||
return 1;
|
||||
|
@ -1407,7 +1407,7 @@ int lua_cocos2dx_3d_OBB_constructor(lua_State* L)
|
|||
ok &= luaval_to_int32(L, 3,(int *)&arg1, "cc.OBB:OBB");
|
||||
|
||||
if (!ok) { break; }
|
||||
cobj = new cocos2d::OBB(arg0, arg1);
|
||||
cobj = new (std::nothrow) cocos2d::OBB(arg0, arg1);
|
||||
tolua_pushusertype(L,(void*)cobj,"cc.OBB");
|
||||
tolua_register_gc(L,lua_gettop(L));
|
||||
return 1;
|
||||
|
@ -1839,7 +1839,7 @@ int lua_cocos2dx_3d_OBB_getCorners(lua_State* L)
|
|||
return 0;
|
||||
}
|
||||
|
||||
arg0 = new cocos2d::Vec3[len];
|
||||
arg0 = new (std::nothrow) cocos2d::Vec3[len];
|
||||
|
||||
if (nullptr == arg0)
|
||||
{
|
||||
|
@ -2075,7 +2075,7 @@ int lua_cocos2dx_3d_Ray_constructor(lua_State* L)
|
|||
ok &= luaval_to_vec3(L, 3, &arg1, "cc.Ray:Ray");
|
||||
|
||||
if (!ok) { break; }
|
||||
cobj = new cocos2d::Ray(arg0, arg1);
|
||||
cobj = new (std::nothrow) cocos2d::Ray(arg0, arg1);
|
||||
tolua_pushusertype(L,(void*)cobj,"cc.Ray");
|
||||
tolua_register_gc(L,lua_gettop(L));
|
||||
return 1;
|
||||
|
@ -2084,7 +2084,7 @@ int lua_cocos2dx_3d_Ray_constructor(lua_State* L)
|
|||
ok = true;
|
||||
do{
|
||||
if (argc == 0) {
|
||||
cobj = new cocos2d::Ray();
|
||||
cobj = new (std::nothrow) cocos2d::Ray();
|
||||
tolua_pushusertype(L,(void*)cobj,"cc.Ray");
|
||||
tolua_register_gc(L,lua_gettop(L));
|
||||
return 1;
|
||||
|
|
|
@ -557,7 +557,7 @@ static int tolua_Cocos2d_glBufferData00(lua_State* tolua_S)
|
|||
{
|
||||
unsigned int target = (unsigned int)tolua_tonumber(tolua_S,1,0);
|
||||
long length = (long)tolua_tonumber(tolua_S,2,0);
|
||||
float* floatArray = new float[length];
|
||||
float* floatArray = new (std::nothrow) float[length];
|
||||
if (NULL == floatArray)
|
||||
{
|
||||
return 0;
|
||||
|
@ -600,7 +600,7 @@ static int tolua_Cocos2d_glBufferSubData00(lua_State* tolua_S)
|
|||
unsigned int target = (unsigned int)tolua_tonumber(tolua_S,1,0);
|
||||
long offset = (long)tolua_tonumber(tolua_S,2,0);
|
||||
long length = (long)tolua_tonumber(tolua_S,3,0);
|
||||
float* floatArray = new float[length];
|
||||
float* floatArray = new (std::nothrow) float[length];
|
||||
if (NULL == floatArray)
|
||||
{
|
||||
return 0;
|
||||
|
@ -850,7 +850,7 @@ static int tolua_Cocos2d_glCompressedTexImage2D00(lua_State* tolua_S)
|
|||
int imageSize = (int)tolua_tonumber(tolua_S, 7, 0);
|
||||
|
||||
long length = (long)tolua_tonumber(tolua_S,8,0);
|
||||
float* floatArray = new float[length];
|
||||
float* floatArray = new (std::nothrow) float[length];
|
||||
if (NULL == floatArray)
|
||||
{
|
||||
return 0;
|
||||
|
@ -905,7 +905,7 @@ static int tolua_Cocos2d_glCompressedTexSubImage2D00(lua_State* tolua_S)
|
|||
int imageSize = (int)tolua_tonumber(tolua_S, 8, 0);
|
||||
|
||||
long length = (long)tolua_tonumber(tolua_S,9,0);
|
||||
float* floatArray = new float[length];
|
||||
float* floatArray = new (std::nothrow) float[length];
|
||||
if (NULL == floatArray)
|
||||
{
|
||||
return 0;
|
||||
|
@ -1459,7 +1459,7 @@ static int tolua_Cocos2d_glDrawElements00(lua_State* tolua_S)
|
|||
{
|
||||
if (arg3 > 0)
|
||||
{
|
||||
unsigned char* unit8Array = new unsigned char[arg3];
|
||||
unsigned char* unit8Array = new (std::nothrow) unsigned char[arg3];
|
||||
if (NULL == unit8Array)
|
||||
{
|
||||
return 0;
|
||||
|
@ -1481,7 +1481,7 @@ static int tolua_Cocos2d_glDrawElements00(lua_State* tolua_S)
|
|||
{
|
||||
if (arg3 > 0)
|
||||
{
|
||||
unsigned short* shortArray = new unsigned short[arg3];
|
||||
unsigned short* shortArray = new (std::nothrow) unsigned short[arg3];
|
||||
if (NULL == shortArray)
|
||||
{
|
||||
return 0;
|
||||
|
@ -1504,8 +1504,8 @@ static int tolua_Cocos2d_glDrawElements00(lua_State* tolua_S)
|
|||
{
|
||||
if (arg3 > 0)
|
||||
{
|
||||
unsigned int* intArray = new unsigned int[arg3];
|
||||
if (NULL == intArray)
|
||||
unsigned int* intArray = new (std::nothrow) unsigned int[arg3];
|
||||
if (nullptr == intArray)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -2723,7 +2723,7 @@ static int tolua_Cocos2d_glReadPixels00(lua_State* tolua_S)
|
|||
unsigned int arg5 = (unsigned int)tolua_tonumber(tolua_S, 6, 0);
|
||||
|
||||
long length = (long)tolua_tonumber(tolua_S,7,0);
|
||||
unsigned char* unit8Array = new unsigned char[length];
|
||||
unsigned char* unit8Array = new (std::nothrow) unsigned char[length];
|
||||
if (NULL == unit8Array)
|
||||
{
|
||||
return 0;
|
||||
|
@ -3110,7 +3110,7 @@ static int tolua_Cocos2d_glTexImage2D00(lua_State* tolua_S)
|
|||
unsigned int arg7 = (unsigned int)tolua_tonumber(tolua_S, 8, 0);
|
||||
unsigned int arg8 = (unsigned int)tolua_tonumber(tolua_S, 9, 0);
|
||||
|
||||
unsigned char* unit8Array = new unsigned char[arg8];
|
||||
unsigned char* unit8Array = new (std::nothrow) unsigned char[arg8];
|
||||
if (NULL == unit8Array)
|
||||
{
|
||||
return 0;
|
||||
|
@ -3236,7 +3236,7 @@ static int tolua_Cocos2d_glTexSubImage2D00(lua_State* tolua_S)
|
|||
unsigned int arg7 = (unsigned int)tolua_tonumber(tolua_S, 8, 0);
|
||||
unsigned int arg8 = (unsigned int)tolua_tonumber(tolua_S, 9, 0);
|
||||
|
||||
unsigned char* unit8Array = new unsigned char[arg8];
|
||||
unsigned char* unit8Array = new (std::nothrow) unsigned char[arg8];
|
||||
if (NULL == unit8Array)
|
||||
{
|
||||
return 0;
|
||||
|
@ -3316,7 +3316,7 @@ static int tolua_Cocos2d_glUniform1fv00(lua_State* tolua_S)
|
|||
int arg0 = (int)tolua_tonumber(tolua_S, 1, 0);
|
||||
int arg1 = (int)tolua_tonumber(tolua_S, 2, 0);
|
||||
int arg2 = (int)tolua_tonumber(tolua_S, 3, 0);
|
||||
float* floatArray = new float[arg2];
|
||||
float* floatArray = new (std::nothrow) float[arg2];
|
||||
if (NULL == floatArray)
|
||||
{
|
||||
return 0;
|
||||
|
@ -3385,7 +3385,7 @@ static int tolua_Cocos2d_glUniform1iv00(lua_State* tolua_S)
|
|||
int arg0 = (int)tolua_tonumber(tolua_S, 1, 0);
|
||||
int arg1 = (int)tolua_tonumber(tolua_S, 2, 0);
|
||||
int arg2 = (int)tolua_tonumber(tolua_S, 3, 0);
|
||||
int* intArray = new int[arg2];
|
||||
int* intArray = new (std::nothrow) int[arg2];
|
||||
if (NULL == intArray)
|
||||
{
|
||||
return 0;
|
||||
|
@ -3456,7 +3456,7 @@ static int tolua_Cocos2d_glUniform2fv00(lua_State* tolua_S)
|
|||
int arg0 = (int)tolua_tonumber(tolua_S, 1, 0);
|
||||
int arg1 = (int)tolua_tonumber(tolua_S, 2, 0);
|
||||
int arg2 = (int)tolua_tonumber(tolua_S, 3, 0);
|
||||
float* floatArray = new float[arg2];
|
||||
float* floatArray = new (std::nothrow) float[arg2];
|
||||
if (NULL == floatArray)
|
||||
{
|
||||
return 0;
|
||||
|
@ -3527,7 +3527,7 @@ static int tolua_Cocos2d_glUniform2iv00(lua_State* tolua_S)
|
|||
int arg0 = (int)tolua_tonumber(tolua_S, 1, 0);
|
||||
int arg1 = (int)tolua_tonumber(tolua_S, 2, 0);
|
||||
int arg2 = (int)tolua_tonumber(tolua_S, 3, 0);
|
||||
int* intArray = new int[arg2];
|
||||
int* intArray = new (std::nothrow) int[arg2];
|
||||
if (NULL == intArray)
|
||||
{
|
||||
return 0;
|
||||
|
@ -3600,7 +3600,7 @@ static int tolua_Cocos2d_glUniform3fv00(lua_State* tolua_S)
|
|||
int arg0 = (int)tolua_tonumber(tolua_S, 1, 0);
|
||||
int arg1 = (int)tolua_tonumber(tolua_S, 2, 0);
|
||||
int arg2 = (int)tolua_tonumber(tolua_S, 3, 0);
|
||||
float* floatArray = new float[arg2];
|
||||
float* floatArray = new (std::nothrow) float[arg2];
|
||||
if (NULL == floatArray)
|
||||
{
|
||||
return 0;
|
||||
|
@ -3673,7 +3673,7 @@ static int tolua_Cocos2d_glUniform3iv00(lua_State* tolua_S)
|
|||
int arg0 = (int)tolua_tonumber(tolua_S, 1, 0);
|
||||
int arg1 = (int)tolua_tonumber(tolua_S, 2, 0);
|
||||
int arg2 = (int)tolua_tonumber(tolua_S, 3, 0);
|
||||
int* intArray = new int[arg2];
|
||||
int* intArray = new (std::nothrow) int[arg2];
|
||||
if (NULL == intArray)
|
||||
{
|
||||
return 0;
|
||||
|
@ -3748,7 +3748,7 @@ static int tolua_Cocos2d_glUniform4fv00(lua_State* tolua_S)
|
|||
int arg0 = (int)tolua_tonumber(tolua_S, 1, 0);
|
||||
int arg1 = (int)tolua_tonumber(tolua_S, 2, 0);
|
||||
int arg2 = (int)tolua_tonumber(tolua_S, 3, 0);
|
||||
float* floatArray = new float[arg2];
|
||||
float* floatArray = new (std::nothrow) float[arg2];
|
||||
if (NULL == floatArray)
|
||||
{
|
||||
return 0;
|
||||
|
@ -3823,7 +3823,7 @@ static int tolua_Cocos2d_glUniform4iv00(lua_State* tolua_S)
|
|||
int arg0 = (int)tolua_tonumber(tolua_S, 1, 0);
|
||||
int arg1 = (int)tolua_tonumber(tolua_S, 2, 0);
|
||||
int arg2 = (int)tolua_tonumber(tolua_S, 3, 0);
|
||||
int* intArray = new int[arg2];
|
||||
int* intArray = new (std::nothrow) int[arg2];
|
||||
if (NULL == intArray)
|
||||
{
|
||||
return 0;
|
||||
|
@ -3864,7 +3864,7 @@ static int tolua_Cocos2d_glUniformMatrix2fv00(lua_State* tolua_S)
|
|||
int arg0 = (int)tolua_tonumber(tolua_S, 1, 0);
|
||||
unsigned short arg1 = (unsigned short)tolua_tonumber(tolua_S, 2, 0);
|
||||
int arg2 = (int)tolua_tonumber(tolua_S, 3, 0);
|
||||
float* floatArray = new float[arg2];
|
||||
float* floatArray = new (std::nothrow) float[arg2];
|
||||
if (NULL == floatArray)
|
||||
{
|
||||
return 0;
|
||||
|
@ -3905,7 +3905,7 @@ static int tolua_Cocos2d_glUniformMatrix3fv00(lua_State* tolua_S)
|
|||
int arg0 = (int)tolua_tonumber(tolua_S, 1, 0);
|
||||
unsigned short arg1 = (unsigned short)tolua_tonumber(tolua_S, 2, 0);
|
||||
int arg2 = (int)tolua_tonumber(tolua_S, 3, 0);
|
||||
float* floatArray = new float[arg2];
|
||||
float* floatArray = new (std::nothrow) float[arg2];
|
||||
if (NULL == floatArray)
|
||||
{
|
||||
return 0;
|
||||
|
@ -3948,7 +3948,7 @@ static int tolua_Cocos2d_glUniformMatrix4fv00(lua_State* tolua_S)
|
|||
int arg0 = (int)tolua_tonumber(tolua_S, 1, 0);
|
||||
bool arg1 = (bool)tolua_toboolean(tolua_S, 2, 0);
|
||||
int arg2 = (int)tolua_tonumber(tolua_S, 3, 0);
|
||||
float* floatArray = new float[arg2];
|
||||
float* floatArray = new (std::nothrow) float[arg2];
|
||||
if (NULL == floatArray)
|
||||
{
|
||||
return 0;
|
||||
|
@ -4069,7 +4069,7 @@ static int tolua_Cocos2d_glVertexAttrib1fv00(lua_State* tolua_S)
|
|||
{
|
||||
int arg0 = (int)tolua_tonumber(tolua_S, 1, 0);
|
||||
int arg1 = (int)tolua_tonumber(tolua_S, 2, 0);
|
||||
float* floatArray = new float[arg1];
|
||||
float* floatArray = new (std::nothrow) float[arg1];
|
||||
if (NULL == floatArray)
|
||||
{
|
||||
return 0;
|
||||
|
@ -4141,7 +4141,7 @@ static int tolua_Cocos2d_glVertexAttrib2fv00(lua_State* tolua_S)
|
|||
{
|
||||
int arg0 = (int)tolua_tonumber(tolua_S, 1, 0);
|
||||
int arg1 = (int)tolua_tonumber(tolua_S, 2, 0);
|
||||
float* floatArray = new float[arg1];
|
||||
float* floatArray = new (std::nothrow) float[arg1];
|
||||
if (NULL == floatArray)
|
||||
{
|
||||
return 0;
|
||||
|
@ -4215,7 +4215,7 @@ static int tolua_Cocos2d_glVertexAttrib3fv00(lua_State* tolua_S)
|
|||
{
|
||||
int arg0 = (int)tolua_tonumber(tolua_S, 1, 0);
|
||||
int arg1 = (int)tolua_tonumber(tolua_S, 2, 0);
|
||||
float* floatArray = new float[arg1];
|
||||
float* floatArray = new (std::nothrow) float[arg1];
|
||||
if (NULL == floatArray)
|
||||
{
|
||||
return 0;
|
||||
|
@ -4291,7 +4291,7 @@ static int tolua_Cocos2d_glVertexAttrib4fv00(lua_State* tolua_S)
|
|||
{
|
||||
int arg0 = (int)tolua_tonumber(tolua_S, 1, 0);
|
||||
int arg1 = (int)tolua_tonumber(tolua_S, 2, 0);
|
||||
float* floatArray = new float[arg1];
|
||||
float* floatArray = new (std::nothrow) float[arg1];
|
||||
if (NULL == floatArray)
|
||||
{
|
||||
return 0;
|
||||
|
@ -4459,7 +4459,7 @@ CC_DEPRECATED_ATTRIBUTE static int tolua_cocos2d_DrawPrimitives_drawPoints00(lua
|
|||
|
||||
if (numberOfPoints > 0)
|
||||
{
|
||||
cocos2d::Vec2* points = new cocos2d::Vec2[numberOfPoints];
|
||||
cocos2d::Vec2* points = new (std::nothrow) cocos2d::Vec2[numberOfPoints];
|
||||
if (NULL == points)
|
||||
return 0;
|
||||
|
||||
|
@ -4621,7 +4621,7 @@ CC_DEPRECATED_ATTRIBUTE static int tolua_cocos2d_DrawPrimitives_drawPoly00(lua_S
|
|||
|
||||
if (numOfVertices > 0)
|
||||
{
|
||||
cocos2d::Vec2* points = new cocos2d::Vec2[numOfVertices];
|
||||
cocos2d::Vec2* points = new (std::nothrow) cocos2d::Vec2[numOfVertices];
|
||||
if (NULL == points)
|
||||
return 0;
|
||||
|
||||
|
@ -4675,7 +4675,7 @@ CC_DEPRECATED_ATTRIBUTE static int tolua_cocos2d_DrawPrimitives_drawSolidPoly00(
|
|||
unsigned int numberOfPoints = ((unsigned int) tolua_tonumber(tolua_S,2,0));
|
||||
if (numberOfPoints > 0)
|
||||
{
|
||||
cocos2d::Vec2* points = new cocos2d::Vec2[numberOfPoints];
|
||||
cocos2d::Vec2* points = new (std::nothrow) cocos2d::Vec2[numberOfPoints];
|
||||
if (NULL == points)
|
||||
return 0;
|
||||
|
||||
|
|
|
@ -2767,7 +2767,7 @@ static int lua_cocos2dx_LabelBMFont_constructor(lua_State* tolua_S)
|
|||
{
|
||||
if(!ok)
|
||||
return 0;
|
||||
cobj = new cocos2d::LabelBMFont();
|
||||
cobj = new (std::nothrow) cocos2d::LabelBMFont();
|
||||
cobj->autorelease();
|
||||
int ID = (int)cobj->_ID ;
|
||||
int* luaID = &cobj->_luaID ;
|
||||
|
@ -4287,7 +4287,7 @@ static int lua_cocos2dx_LabelTTF_constructor(lua_State* tolua_S)
|
|||
{
|
||||
if(!ok)
|
||||
return 0;
|
||||
cobj = new cocos2d::LabelTTF();
|
||||
cobj = new (std::nothrow) cocos2d::LabelTTF();
|
||||
cobj->autorelease();
|
||||
int ID = (int)cobj->_ID ;
|
||||
int* luaID = &cobj->_luaID ;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue