Merge pull request #2172 from dumganhar/master

Updating VS2012 solution, CystalCraze project depends on libJSBinding and libExtensions.
This commit is contained in:
James Chen 2013-03-15 07:25:17 -07:00
commit 2fbd09fe27
2 changed files with 42 additions and 37 deletions

View File

@ -87,6 +87,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libJSBinding", "scripting\j
EndProjectSection EndProjectSection
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CrystalCraze", "samples\Javascript\CrystalCraze\proj.win32\CrystalCraze.vcxproj", "{9A17D9A4-4B11-4E32-94F6-895FF4909EC5}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CrystalCraze", "samples\Javascript\CrystalCraze\proj.win32\CrystalCraze.vcxproj", "{9A17D9A4-4B11-4E32-94F6-895FF4909EC5}"
ProjectSection(ProjectDependencies) = postProject
{21B2C324-891F-48EA-AD1A-5AE13DE12E28} = {21B2C324-891F-48EA-AD1A-5AE13DE12E28}
{39379840-825A-45A0-B363-C09FFEF864BD} = {39379840-825A-45A0-B363-C09FFEF864BD}
EndProjectSection
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AssetsManagerTest", "samples\Cpp\AssetsManagerTest\proj.win32\AssetsManagerTest.vcxproj", "{6D37505F-A890-441D-BD3F-A61E2C0469CE}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AssetsManagerTest", "samples\Cpp\AssetsManagerTest\proj.win32\AssetsManagerTest.vcxproj", "{6D37505F-A890-441D-BD3F-A61E2C0469CE}"
EndProject EndProject

View File

@ -1282,45 +1282,46 @@ JSBool jsval_to_ccarray(JSContext* cx, jsval v, CCArray** ret) {
jsval ccarray_to_jsval(JSContext* cx, CCArray *arr) jsval ccarray_to_jsval(JSContext* cx, CCArray *arr)
{ {
JSObject *jsretArr = JS_NewArrayObject(cx, 0, NULL); JSObject *jsretArr = JS_NewArrayObject(cx, 0, NULL);
if (arr && arr->count() > 0) {
for(unsigned int i = 0; i < arr->count(); ++i) {
jsval arrElement;
CCObject *obj = arr->objectAtIndex(i);
for(unsigned int i = 0; i < arr->count(); ++i) { //First, check whether object is associated with js object.
jsval arrElement; js_proxy_t* jsproxy = js_get_or_create_proxy<cocos2d::CCObject>(cx, obj);
CCObject *obj = arr->objectAtIndex(i); if (jsproxy) {
arrElement = OBJECT_TO_JSVAL(jsproxy->obj);
//First, check whether object is associated with js object. }
js_proxy_t* jsproxy = js_get_or_create_proxy<cocos2d::CCObject>(cx, obj); else {
if (jsproxy) { CCString* strVal = NULL;
arrElement = OBJECT_TO_JSVAL(jsproxy->obj); CCDictionary* dictVal = NULL;
} CCArray* arrVal = NULL;
else { CCDouble* doubleVal = NULL;
CCString* strVal = NULL; CCBool* boolVal = NULL;
CCDictionary* dictVal = NULL; CCFloat* floatVal = NULL;
CCArray* arrVal = NULL; CCInteger* intVal = NULL;
CCDouble* doubleVal = NULL;
CCBool* boolVal = NULL; if((strVal = dynamic_cast<cocos2d::CCString *>(obj))) {
CCFloat* floatVal = NULL; arrElement = c_string_to_jsval(cx, strVal->getCString());
CCInteger* intVal = NULL; } else if ((dictVal = dynamic_cast<cocos2d::CCDictionary*>(obj))) {
arrElement = ccdictionary_to_jsval(cx, dictVal);
if((strVal = dynamic_cast<cocos2d::CCString *>(obj))) { } else if ((arrVal = dynamic_cast<cocos2d::CCArray*>(obj))) {
arrElement = c_string_to_jsval(cx, strVal->getCString()); arrElement = ccarray_to_jsval(cx, arrVal);
} else if ((dictVal = dynamic_cast<cocos2d::CCDictionary*>(obj))) { } else if ((doubleVal = dynamic_cast<CCDouble*>(obj))) {
arrElement = ccdictionary_to_jsval(cx, dictVal); arrElement = DOUBLE_TO_JSVAL(doubleVal->getValue());
} else if ((arrVal = dynamic_cast<cocos2d::CCArray*>(obj))) { } else if ((floatVal = dynamic_cast<CCFloat*>(obj))) {
arrElement = ccarray_to_jsval(cx, arrVal); arrElement = DOUBLE_TO_JSVAL(floatVal->getValue());
} else if ((doubleVal = dynamic_cast<CCDouble*>(obj))) { } else if ((intVal = dynamic_cast<CCInteger*>(obj))) {
arrElement = DOUBLE_TO_JSVAL(doubleVal->getValue()); arrElement = INT_TO_JSVAL(intVal->getValue());
} else if ((floatVal = dynamic_cast<CCFloat*>(obj))) { } else if ((boolVal = dynamic_cast<CCBool*>(obj))) {
arrElement = DOUBLE_TO_JSVAL(floatVal->getValue()); arrElement = BOOLEAN_TO_JSVAL(boolVal->getValue() ? JS_TRUE : JS_FALSE);
} else if ((intVal = dynamic_cast<CCInteger*>(obj))) { } else {
arrElement = INT_TO_JSVAL(intVal->getValue()); CCAssert(false, "the type isn't suppored.");
} else if ((boolVal = dynamic_cast<CCBool*>(obj))) { }
arrElement = BOOLEAN_TO_JSVAL(boolVal->getValue() ? JS_TRUE : JS_FALSE); }
} else { if(!JS_SetElement(cx, jsretArr, i, &arrElement)) {
CCAssert(false, "the type isn't suppored."); break;
} }
}
if(!JS_SetElement(cx, jsretArr, i, &arrElement)) {
break;
} }
} }
return OBJECT_TO_JSVAL(jsretArr); return OBJECT_TO_JSVAL(jsretArr);