diff --git a/cocos2d-win32.vc2012.sln b/cocos2d-win32.vc2012.sln index 19d877c6d2..f6e8863c1d 100644 --- a/cocos2d-win32.vc2012.sln +++ b/cocos2d-win32.vc2012.sln @@ -87,6 +87,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libJSBinding", "scripting\j EndProjectSection EndProject 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 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AssetsManagerTest", "samples\Cpp\AssetsManagerTest\proj.win32\AssetsManagerTest.vcxproj", "{6D37505F-A890-441D-BD3F-A61E2C0469CE}" EndProject diff --git a/scripting/javascript/bindings/ScriptingCore.cpp b/scripting/javascript/bindings/ScriptingCore.cpp index e1336f0c43..ce8b1b92dd 100644 --- a/scripting/javascript/bindings/ScriptingCore.cpp +++ b/scripting/javascript/bindings/ScriptingCore.cpp @@ -1282,45 +1282,46 @@ JSBool jsval_to_ccarray(JSContext* cx, jsval v, CCArray** ret) { jsval ccarray_to_jsval(JSContext* cx, CCArray *arr) { 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) { - jsval arrElement; - CCObject *obj = arr->objectAtIndex(i); - - //First, check whether object is associated with js object. - js_proxy_t* jsproxy = js_get_or_create_proxy(cx, obj); - if (jsproxy) { - arrElement = OBJECT_TO_JSVAL(jsproxy->obj); - } - else { - CCString* strVal = NULL; - CCDictionary* dictVal = NULL; - CCArray* arrVal = NULL; - CCDouble* doubleVal = NULL; - CCBool* boolVal = NULL; - CCFloat* floatVal = NULL; - CCInteger* intVal = NULL; - - if((strVal = dynamic_cast(obj))) { - arrElement = c_string_to_jsval(cx, strVal->getCString()); - } else if ((dictVal = dynamic_cast(obj))) { - arrElement = ccdictionary_to_jsval(cx, dictVal); - } else if ((arrVal = dynamic_cast(obj))) { - arrElement = ccarray_to_jsval(cx, arrVal); - } else if ((doubleVal = dynamic_cast(obj))) { - arrElement = DOUBLE_TO_JSVAL(doubleVal->getValue()); - } else if ((floatVal = dynamic_cast(obj))) { - arrElement = DOUBLE_TO_JSVAL(floatVal->getValue()); - } else if ((intVal = dynamic_cast(obj))) { - arrElement = INT_TO_JSVAL(intVal->getValue()); - } else if ((boolVal = dynamic_cast(obj))) { - arrElement = BOOLEAN_TO_JSVAL(boolVal->getValue() ? JS_TRUE : JS_FALSE); - } else { - CCAssert(false, "the type isn't suppored."); + //First, check whether object is associated with js object. + js_proxy_t* jsproxy = js_get_or_create_proxy(cx, obj); + if (jsproxy) { + arrElement = OBJECT_TO_JSVAL(jsproxy->obj); + } + else { + CCString* strVal = NULL; + CCDictionary* dictVal = NULL; + CCArray* arrVal = NULL; + CCDouble* doubleVal = NULL; + CCBool* boolVal = NULL; + CCFloat* floatVal = NULL; + CCInteger* intVal = NULL; + + if((strVal = dynamic_cast(obj))) { + arrElement = c_string_to_jsval(cx, strVal->getCString()); + } else if ((dictVal = dynamic_cast(obj))) { + arrElement = ccdictionary_to_jsval(cx, dictVal); + } else if ((arrVal = dynamic_cast(obj))) { + arrElement = ccarray_to_jsval(cx, arrVal); + } else if ((doubleVal = dynamic_cast(obj))) { + arrElement = DOUBLE_TO_JSVAL(doubleVal->getValue()); + } else if ((floatVal = dynamic_cast(obj))) { + arrElement = DOUBLE_TO_JSVAL(floatVal->getValue()); + } else if ((intVal = dynamic_cast(obj))) { + arrElement = INT_TO_JSVAL(intVal->getValue()); + } else if ((boolVal = dynamic_cast(obj))) { + arrElement = BOOLEAN_TO_JSVAL(boolVal->getValue() ? JS_TRUE : JS_FALSE); + } else { + CCAssert(false, "the type isn't suppored."); + } + } + if(!JS_SetElement(cx, jsretArr, i, &arrElement)) { + break; } - } - if(!JS_SetElement(cx, jsretArr, i, &arrElement)) { - break; } } return OBJECT_TO_JSVAL(jsretArr);