CCBIReader fixes + building and running flawless on iOS and Android.

Made it works on win32.
This commit is contained in:
James Chen 2012-06-16 12:48:20 +08:00
parent ab3dd66167
commit 73c9707d5d
7 changed files with 121 additions and 53 deletions

View File

@ -25,6 +25,7 @@ THE SOFTWARE.
#define __CCSTRING_H__
#include <string>
#include <functional>
#include "CCObject.h"
NS_CC_BEGIN

View File

@ -51,7 +51,7 @@ CCBReader::CCBReader(CCBReader * pCCBReader) {
}
CCBReader::~CCBReader() {
CC_SAFE_DELETE(this->mBytes);
CC_SAFE_DELETE_ARRAY(this->mBytes);
this->mCCNodeLoaderLibrary->release();
@ -104,8 +104,6 @@ CCNode * CCBReader::readNodeGraphFromFile(CCString * pCCBRootPath, CCString * pC
const char * path = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(ccbFullFilePath->getCString());
CC_SAFE_FREE(ccbFullFilePath);
unsigned long size = 0;
this->mBytes = CCFileUtils::sharedFileUtils()->getFileData(path, "rb", &size);
@ -390,15 +388,16 @@ CCString * CCBReader::toLowerCase(CCString * pString) {
}
CCString * CCBReader::concat(CCString * pStringA, CCString * pStringB) {
int concatenatedLength = pStringA->length() + pStringB->length() + 1;
char concatenated[concatenatedLength];
int concatenatedLength = pStringA->length() + pStringB->length();
char* concatenated = (char*) malloc(concatenatedLength+1);
CCString* pRet = NULL;
strcpy(concatenated, pStringA->getCString());
strcat(concatenated, pStringB->getCString());
concatenated[concatenatedLength] = '\0';
return CCString::stringWithCString(concatenated);
pRet = CCString::stringWithCString(concatenated);
CC_SAFE_FREE(concatenated);
return pRet;
}
bool CCBReader::endsWith(CCString * pString, CCString * pEnding) {

View File

@ -893,22 +893,6 @@
<Filter
Name="CocosBuilderTest"
>
<File
RelativePath="..\tests\ExtensionsTest\CocosBuilderTest\ButtonTestLayer.cpp"
>
</File>
<File
RelativePath="..\tests\ExtensionsTest\CocosBuilderTest\ButtonTestLayer.h"
>
</File>
<File
RelativePath="..\tests\ExtensionsTest\CocosBuilderTest\ButtonTestLayerLoader.cpp"
>
</File>
<File
RelativePath="..\tests\ExtensionsTest\CocosBuilderTest\ButtonTestLayerLoader.h"
>
</File>
<File
RelativePath="..\tests\ExtensionsTest\CocosBuilderTest\CocosBuilderTest.cpp"
>
@ -917,38 +901,106 @@
RelativePath="..\tests\ExtensionsTest\CocosBuilderTest\CocosBuilderTest.h"
>
</File>
<File
RelativePath="..\tests\ExtensionsTest\CocosBuilderTest\HelloCocosBuilderLayer.cpp"
<Filter
Name="ButtonTest"
>
</File>
<File
RelativePath="..\tests\ExtensionsTest\CocosBuilderTest\HelloCocosBuilderLayer.h"
<File
RelativePath="..\tests\ExtensionsTest\CocosBuilderTest\ButtonTest\ButtonTestLayer.cpp"
>
</File>
<File
RelativePath="..\tests\ExtensionsTest\CocosBuilderTest\ButtonTest\ButtonTestLayer.h"
>
</File>
<File
RelativePath="..\tests\ExtensionsTest\CocosBuilderTest\ButtonTest\ButtonTestLayerLoader.h"
>
</File>
</Filter>
<Filter
Name="HelloCocosBuilder"
>
</File>
<File
RelativePath="..\tests\ExtensionsTest\CocosBuilderTest\HelloCocosBuilderLayerLoader.cpp"
<File
RelativePath="..\tests\ExtensionsTest\CocosBuilderTest\HelloCocosBuilder\HelloCocosBuilderLayer.cpp"
>
</File>
<File
RelativePath="..\tests\ExtensionsTest\CocosBuilderTest\HelloCocosBuilder\HelloCocosBuilderLayer.h"
>
</File>
<File
RelativePath="..\tests\ExtensionsTest\CocosBuilderTest\HelloCocosBuilder\HelloCocosBuilderLayerLoader.h"
>
</File>
</Filter>
<Filter
Name="LabelTest"
>
</File>
<File
RelativePath="..\tests\ExtensionsTest\CocosBuilderTest\HelloCocosBuilderLayerLoader.h"
<File
RelativePath="..\tests\ExtensionsTest\CocosBuilderTest\LabelTest\LabelTestLayer.h"
>
</File>
<File
RelativePath="..\tests\ExtensionsTest\CocosBuilderTest\LabelTest\LabelTestLayerLoader.h"
>
</File>
</Filter>
<Filter
Name="MenuTest"
>
</File>
<File
RelativePath="..\tests\ExtensionsTest\CocosBuilderTest\TestHeaderLayer.cpp"
<File
RelativePath="..\tests\ExtensionsTest\CocosBuilderTest\MenuTest\MenuTestLayer.cpp"
>
</File>
<File
RelativePath="..\tests\ExtensionsTest\CocosBuilderTest\MenuTest\MenuTestLayer.h"
>
</File>
<File
RelativePath="..\tests\ExtensionsTest\CocosBuilderTest\MenuTest\MenuTestLayerLoader.h"
>
</File>
</Filter>
<Filter
Name="ParticleSystemTest"
>
</File>
<File
RelativePath="..\tests\ExtensionsTest\CocosBuilderTest\TestHeaderLayer.h"
<File
RelativePath="..\tests\ExtensionsTest\CocosBuilderTest\ParticleSystemTest\ParticleSystemTestLayer.h"
>
</File>
<File
RelativePath="..\tests\ExtensionsTest\CocosBuilderTest\ParticleSystemTest\ParticleSystemTestLayerLoader.h"
>
</File>
</Filter>
<Filter
Name="SpriteTest"
>
</File>
<File
RelativePath="..\tests\ExtensionsTest\CocosBuilderTest\TestHeaderLayerLoader.cpp"
<File
RelativePath="..\tests\ExtensionsTest\CocosBuilderTest\SpriteTest\SpriteTestLayer.h"
>
</File>
<File
RelativePath="..\tests\ExtensionsTest\CocosBuilderTest\SpriteTest\SpriteTestLayerLoader.h"
>
</File>
</Filter>
<Filter
Name="TestHeader"
>
</File>
<File
RelativePath="..\tests\ExtensionsTest\CocosBuilderTest\TestHeaderLayerLoader.h"
>
</File>
<File
RelativePath="..\tests\ExtensionsTest\CocosBuilderTest\TestHeader\TestHeaderLayer.cpp"
>
</File>
<File
RelativePath="..\tests\ExtensionsTest\CocosBuilderTest\TestHeader\TestHeaderLayer.h"
>
</File>
<File
RelativePath="..\tests\ExtensionsTest\CocosBuilderTest\TestHeader\TestHeaderLayerLoader.h"
>
</File>
</Filter>
</Filter>
</Filter>
<Filter

View File

@ -6,7 +6,11 @@
#include "extensions/CCBReader/CCBSelectorResolver.h"
#include "extensions/CCBReader/CCBMemberVariableAssigner.h"
class ButtonTestLayer : public cocos2d::extension::CCBSelectorResolver, public cocos2d::extension::CCBMemberVariableAssigner, public cocos2d::CCLayer {
class ButtonTestLayer
: public cocos2d::CCLayer
, public cocos2d::extension::CCBMemberVariableAssigner
, public cocos2d::extension::CCBSelectorResolver
{
public:
CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(ButtonTestLayer, node);

View File

@ -17,7 +17,12 @@
* This thread describes the problem:
* http://www.cocoabuilder.com/archive/xcode/265549-crash-in-virtual-method-call.html
*/
class HelloCocosBuilderLayer : public cocos2d::extension::CCBSelectorResolver, public cocos2d::extension::CCBMemberVariableAssigner, public cocos2d::extension::CCNodeLoaderListener, public cocos2d::CCLayer {
class HelloCocosBuilderLayer
: public cocos2d::CCLayer
, public cocos2d::extension::CCBSelectorResolver
, public cocos2d::extension::CCBMemberVariableAssigner
, public cocos2d::extension::CCNodeLoaderListener
{
public:
CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(HelloCocosBuilderLayer, node);

View File

@ -6,7 +6,11 @@
#include "extensions/CCBReader/CCBSelectorResolver.h"
#include "extensions/CCBReader/CCBMemberVariableAssigner.h"
class MenuTestLayer : public cocos2d::extension::CCBSelectorResolver, public cocos2d::extension::CCBMemberVariableAssigner, public cocos2d::CCLayer {
class MenuTestLayer
: public cocos2d::CCLayer
, public cocos2d::extension::CCBSelectorResolver
, public cocos2d::extension::CCBMemberVariableAssigner
{
public:
CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(MenuTestLayer, node);

View File

@ -5,7 +5,10 @@
#include "extensions/CCBReader/CCNodeLoader.h"
#include "extensions/CCBReader/CCBSelectorResolver.h"
class TestHeaderLayer : public cocos2d::extension::CCBSelectorResolver, public cocos2d::CCLayer {
class TestHeaderLayer
: public cocos2d::CCLayer
, public cocos2d::extension::CCBSelectorResolver
{
public:
CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(TestHeaderLayer, node);