issue #1564: Make TestJavascript works on windows.

This commit is contained in:
James Chen 2012-11-22 10:24:26 +08:00
parent 73b409f116
commit 89a51433b8
5 changed files with 16 additions and 20 deletions

View File

@ -59,6 +59,8 @@ protected:
float m_fPTMRatio; float m_fPTMRatio;
#endif // CC_ENABLE_CHIPMUNK_INTEGRATION #endif // CC_ENABLE_CHIPMUNK_INTEGRATION
public: public:
CCPhysicsSprite();
static CCPhysicsSprite* create(); static CCPhysicsSprite* create();
/** Creates an sprite with a texture. /** Creates an sprite with a texture.
The rect used will be the size of the texture. The rect used will be the size of the texture.
@ -127,8 +129,6 @@ public:
#endif // CC_ENABLE_BOX2D_INTEGRATION #endif // CC_ENABLE_BOX2D_INTEGRATION
protected:
CCPhysicsSprite();
}; };
NS_CC_EXT_END NS_CC_EXT_END

View File

@ -64,7 +64,7 @@
<ClCompile> <ClCompile>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>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)</PreprocessorDefinitions> <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)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild> <MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
@ -119,7 +119,7 @@ xcopy "$(ProjectDir)..\cocos2d-js-tests\src" "$(OutDir)\TestJavascriptRes\src\"
</Midl> </Midl>
<ClCompile> <ClCompile>
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_WINDOWS;STRICT;NDEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <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)</PreprocessorDefinitions>
<ExceptionHandling> <ExceptionHandling>
</ExceptionHandling> </ExceptionHandling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
@ -158,7 +158,6 @@ xcopy "$(ProjectDir)..\cocos2d-js-tests\src" "$(OutDir)\TestJavascriptRes\src\"
</PreBuildEvent> </PreBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\..\scripting\javascript\bindings\CCPhysicsSprite.cpp" />
<ClCompile Include="..\..\..\scripting\javascript\bindings\cocos2d_specifics.cpp" /> <ClCompile Include="..\..\..\scripting\javascript\bindings\cocos2d_specifics.cpp" />
<ClCompile Include="..\..\..\scripting\javascript\bindings\cocosjs_manual_conversions.cpp" /> <ClCompile Include="..\..\..\scripting\javascript\bindings\cocosjs_manual_conversions.cpp" />
<ClCompile Include="..\..\..\scripting\javascript\bindings\generated\cocos2dx.cpp" /> <ClCompile Include="..\..\..\scripting\javascript\bindings\generated\cocos2dx.cpp" />
@ -174,7 +173,6 @@ xcopy "$(ProjectDir)..\cocos2d-js-tests\src" "$(OutDir)\TestJavascriptRes\src\"
<ClCompile Include="..\Classes\AppDelegate.cpp" /> <ClCompile Include="..\Classes\AppDelegate.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\..\..\scripting\javascript\bindings\CCPhysicsSprite.h" />
<ClInclude Include="..\..\..\scripting\javascript\bindings\cocos2d_specifics.hpp" /> <ClInclude Include="..\..\..\scripting\javascript\bindings\cocos2d_specifics.hpp" />
<ClInclude Include="..\..\..\scripting\javascript\bindings\cocosjs_manual_conversions.h" /> <ClInclude Include="..\..\..\scripting\javascript\bindings\cocosjs_manual_conversions.h" />
<ClInclude Include="..\..\..\scripting\javascript\bindings\generated\cocos2dx.hpp" /> <ClInclude Include="..\..\..\scripting\javascript\bindings\generated\cocos2dx.hpp" />

View File

@ -28,9 +28,6 @@
<ClCompile Include="..\..\..\scripting\javascript\bindings\generated\cocos2dx.cpp"> <ClCompile Include="..\..\..\scripting\javascript\bindings\generated\cocos2dx.cpp">
<Filter>bindings\generated</Filter> <Filter>bindings\generated</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\scripting\javascript\bindings\CCPhysicsSprite.cpp">
<Filter>bindings</Filter>
</ClCompile>
<ClCompile Include="..\..\..\scripting\javascript\bindings\cocos2d_specifics.cpp"> <ClCompile Include="..\..\..\scripting\javascript\bindings\cocos2d_specifics.cpp">
<Filter>bindings</Filter> <Filter>bindings</Filter>
</ClCompile> </ClCompile>
@ -75,9 +72,6 @@
<ClInclude Include="..\..\..\scripting\javascript\bindings\generated\cocos2dx.hpp"> <ClInclude Include="..\..\..\scripting\javascript\bindings\generated\cocos2dx.hpp">
<Filter>bindings\generated</Filter> <Filter>bindings\generated</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\scripting\javascript\bindings\CCPhysicsSprite.h">
<Filter>bindings</Filter>
</ClInclude>
<ClInclude Include="..\..\..\scripting\javascript\bindings\cocos2d_specifics.hpp"> <ClInclude Include="..\..\..\scripting\javascript\bindings\cocos2d_specifics.hpp">
<Filter>bindings</Filter> <Filter>bindings</Filter>
</ClInclude> </ClInclude>

View File

@ -756,15 +756,19 @@ bool ScriptingCore::executeFunctionWithObjectData(CCNode *self, const char *name
js_proxy_t * p; js_proxy_t * p;
JS_GET_PROXY(p, self); JS_GET_PROXY(p, self);
if (!p) return 0; if (!p) return false;
jsval retval; jsval retval;
jsval dataVal = OBJECT_TO_JSVAL(obj); jsval dataVal = OBJECT_TO_JSVAL(obj);
executeJSFunctionWithName(this->cx_, p->obj, name, dataVal, retval); executeJSFunctionWithName(this->cx_, p->obj, name, dataVal, retval);
if(JSVAL_IS_NULL(retval)) return false; if(JSVAL_IS_NULL(retval)) {
else if(JSVAL_IS_BOOLEAN(retval)) return JSVAL_TO_BOOLEAN(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) { int ScriptingCore::executeFunctionWithOwner(jsval owner, const char *name, jsval data) {

View File

@ -22,7 +22,7 @@
* THE SOFTWARE. * THE SOFTWARE.
*/ */
#include "cocos-ext.h"
#include "js_bindings_config.h" #include "js_bindings_config.h"
#ifdef JSB_INCLUDE_CHIPMUNK #ifdef JSB_INCLUDE_CHIPMUNK
@ -32,8 +32,8 @@
#include "js_bindings_chipmunk_manual.h" #include "js_bindings_chipmunk_manual.h"
#include "js_manual_conversions.h" #include "js_manual_conversions.h"
#include "uthash.h" #include "uthash.h"
#include "CCPhysicsSprite.h"
USING_NS_CC_EXT;
// Function declarations // Function declarations
void static freeSpaceChildren(cpSpace *space); 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) TEST_NATIVE_OBJECT(cx, real)
cpBody* ret_val; cpBody* ret_val;
ret_val = real->_body; ret_val = real->getBody();
jsval ret_jsval = opaque_to_jsval(cx, ret_val); jsval ret_jsval = opaque_to_jsval(cx, ret_val);
JS_SET_RVAL(cx, vp, ret_jsval); JS_SET_RVAL(cx, vp, ret_jsval);
@ -83,7 +83,7 @@ JSBool JSPROXY_CCPhysicsSprite_ignoreBodyRotation(JSContext *cx, uint32_t argc,
bool ret_val; bool ret_val;
ret_val = real->_ignoreBodyRotation; ret_val = real->isIgnoreBodyRotation();
JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret_val)); JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret_val));
return JS_TRUE; return JS_TRUE;
} }