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__ #define __CCSTRING_H__
#include <string> #include <string>
#include <functional>
#include "CCObject.h" #include "CCObject.h"
NS_CC_BEGIN NS_CC_BEGIN

View File

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

View File

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

View File

@ -6,7 +6,11 @@
#include "extensions/CCBReader/CCBSelectorResolver.h" #include "extensions/CCBReader/CCBSelectorResolver.h"
#include "extensions/CCBReader/CCBMemberVariableAssigner.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: public:
CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(ButtonTestLayer, node); CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(ButtonTestLayer, node);

View File

@ -17,7 +17,12 @@
* This thread describes the problem: * This thread describes the problem:
* http://www.cocoabuilder.com/archive/xcode/265549-crash-in-virtual-method-call.html * 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: public:
CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(HelloCocosBuilderLayer, node); CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(HelloCocosBuilderLayer, node);

View File

@ -6,7 +6,11 @@
#include "extensions/CCBReader/CCBSelectorResolver.h" #include "extensions/CCBReader/CCBSelectorResolver.h"
#include "extensions/CCBReader/CCBMemberVariableAssigner.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: public:
CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(MenuTestLayer, node); CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(MenuTestLayer, node);

View File

@ -5,7 +5,10 @@
#include "extensions/CCBReader/CCNodeLoader.h" #include "extensions/CCBReader/CCNodeLoader.h"
#include "extensions/CCBReader/CCBSelectorResolver.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: public:
CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(TestHeaderLayer, node); CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(TestHeaderLayer, node);