From 89a51433b80cc17f0cd004521df83398dd2ae10f Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 22 Nov 2012 10:24:26 +0800 Subject: [PATCH] issue #1564: Make TestJavascript works on windows. --- extensions/physics_nodes/CCPhysicsSprite.h | 4 ++-- .../TestJavascript/proj.win32/TestJavascript.vcxproj | 6 ++---- .../proj.win32/TestJavascript.vcxproj.filters | 6 ------ scripting/javascript/bindings/ScriptingCore.cpp | 12 ++++++++---- .../bindings/js_bindings_chipmunk_manual.cpp | 8 ++++---- 5 files changed, 16 insertions(+), 20 deletions(-) diff --git a/extensions/physics_nodes/CCPhysicsSprite.h b/extensions/physics_nodes/CCPhysicsSprite.h index 7c78f6b6b7..29567d857a 100644 --- a/extensions/physics_nodes/CCPhysicsSprite.h +++ b/extensions/physics_nodes/CCPhysicsSprite.h @@ -59,6 +59,8 @@ protected: float m_fPTMRatio; #endif // CC_ENABLE_CHIPMUNK_INTEGRATION public: + CCPhysicsSprite(); + static CCPhysicsSprite* create(); /** Creates an sprite with a texture. The rect used will be the size of the texture. @@ -127,8 +129,6 @@ public: #endif // CC_ENABLE_BOX2D_INTEGRATION -protected: - CCPhysicsSprite(); }; NS_CC_EXT_END diff --git a/samples/TestJavascript/proj.win32/TestJavascript.vcxproj b/samples/TestJavascript/proj.win32/TestJavascript.vcxproj index d25113bdde..6e8f48545a 100644 --- a/samples/TestJavascript/proj.win32/TestJavascript.vcxproj +++ b/samples/TestJavascript/proj.win32/TestJavascript.vcxproj @@ -64,7 +64,7 @@ Disabled $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\scripting\javascript\spidermonkey-win32\include;$(ProjectDir)..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\extensions;$(ProjectDir)..\..\..\scripting\javascript\bindings;$(ProjectDir)..\..\..\cocos2dx;$(ProjectDir)..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\CocosDenshion\include;%(AdditionalIncludeDirectories) - WIN32;_WINDOWS;STRICT;_DEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + WIN32;_WINDOWS;STRICT;_DEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_DEBUG=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebugDLL @@ -119,7 +119,7 @@ xcopy "$(ProjectDir)..\cocos2d-js-tests\src" "$(OutDir)\TestJavascriptRes\src\" $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\scripting\javascript\spidermonkey-win32\include;$(ProjectDir)..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\extensions;$(ProjectDir)..\..\..\scripting\javascript\bindings;$(ProjectDir)..\..\..\cocos2dx;$(ProjectDir)..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\CocosDenshion\include;%(AdditionalIncludeDirectories) - WIN32;_WINDOWS;STRICT;NDEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + WIN32;_WINDOWS;STRICT;NDEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreadedDLL @@ -158,7 +158,6 @@ xcopy "$(ProjectDir)..\cocos2d-js-tests\src" "$(OutDir)\TestJavascriptRes\src\" - @@ -174,7 +173,6 @@ xcopy "$(ProjectDir)..\cocos2d-js-tests\src" "$(OutDir)\TestJavascriptRes\src\" - diff --git a/samples/TestJavascript/proj.win32/TestJavascript.vcxproj.filters b/samples/TestJavascript/proj.win32/TestJavascript.vcxproj.filters index 363a9dc450..af3ce62424 100644 --- a/samples/TestJavascript/proj.win32/TestJavascript.vcxproj.filters +++ b/samples/TestJavascript/proj.win32/TestJavascript.vcxproj.filters @@ -28,9 +28,6 @@ bindings\generated - - bindings - bindings @@ -75,9 +72,6 @@ bindings\generated - - bindings - bindings diff --git a/scripting/javascript/bindings/ScriptingCore.cpp b/scripting/javascript/bindings/ScriptingCore.cpp index 1655dba19f..e97fd8d030 100644 --- a/scripting/javascript/bindings/ScriptingCore.cpp +++ b/scripting/javascript/bindings/ScriptingCore.cpp @@ -756,15 +756,19 @@ bool ScriptingCore::executeFunctionWithObjectData(CCNode *self, const char *name js_proxy_t * p; JS_GET_PROXY(p, self); - if (!p) return 0; + if (!p) return false; jsval retval; jsval dataVal = OBJECT_TO_JSVAL(obj); executeJSFunctionWithName(this->cx_, p->obj, name, dataVal, retval); - if(JSVAL_IS_NULL(retval)) return false; - else if(JSVAL_IS_BOOLEAN(retval)) return JSVAL_TO_BOOLEAN(retval); - + if(JSVAL_IS_NULL(retval)) { + return false; + } + else if(JSVAL_IS_BOOLEAN(retval)) { + return JSVAL_TO_BOOLEAN(retval); + } + return false; } int ScriptingCore::executeFunctionWithOwner(jsval owner, const char *name, jsval data) { diff --git a/scripting/javascript/bindings/js_bindings_chipmunk_manual.cpp b/scripting/javascript/bindings/js_bindings_chipmunk_manual.cpp index 225f3c5534..5928e62245 100644 --- a/scripting/javascript/bindings/js_bindings_chipmunk_manual.cpp +++ b/scripting/javascript/bindings/js_bindings_chipmunk_manual.cpp @@ -22,7 +22,7 @@ * THE SOFTWARE. */ - +#include "cocos-ext.h" #include "js_bindings_config.h" #ifdef JSB_INCLUDE_CHIPMUNK @@ -32,8 +32,8 @@ #include "js_bindings_chipmunk_manual.h" #include "js_manual_conversions.h" #include "uthash.h" -#include "CCPhysicsSprite.h" +USING_NS_CC_EXT; // Function declarations void static freeSpaceChildren(cpSpace *space); @@ -65,7 +65,7 @@ JSBool JSPROXY_CCPhysicsSprite_body(JSContext *cx, uint32_t argc, jsval *vp) { TEST_NATIVE_OBJECT(cx, real) cpBody* ret_val; - ret_val = real->_body; + ret_val = real->getBody(); jsval ret_jsval = opaque_to_jsval(cx, ret_val); JS_SET_RVAL(cx, vp, ret_jsval); @@ -83,7 +83,7 @@ JSBool JSPROXY_CCPhysicsSprite_ignoreBodyRotation(JSContext *cx, uint32_t argc, bool ret_val; - ret_val = real->_ignoreBodyRotation; + ret_val = real->isIgnoreBodyRotation(); JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret_val)); return JS_TRUE; }