Merge pull request #14534 from xiaofeng11/v3_combine_JsLuaSim

V3 combine lua-binding, jsb, and simulator
This commit is contained in:
pandamicro 2015-12-01 23:34:05 +08:00
commit 83630d17c9
47 changed files with 316 additions and 78 deletions

View File

@ -35,6 +35,7 @@
#include "spidermonkey_specifics.h"
#include "js_manual_conversions.h"
#include "mozilla/Maybe.h"
#include "js-BindingsExport.h"
#include <assert.h>
#include <memory>
@ -75,7 +76,7 @@ public:
* - Invoke garbage collection of JavaScript context
* - etc...
*/
class ScriptingCore : public cocos2d::ScriptEngineProtocol
class CC_JS_DLL ScriptingCore : public cocos2d::ScriptEngineProtocol
{
private:
JSRuntime *_rt;

View File

@ -0,0 +1,30 @@
#pragma once
#if (defined(WIN32) && defined(_WINDOWS)) || defined(WINRT) || defined(WP8)
#ifdef __MINGW32__
#include <string.h>
#endif
#if defined(_USRJSSTATIC)
#define CC_JS_DLL
#else
#if defined(_USRJSDLL)
#define CC_JS_DLL __declspec(dllexport)
#else /* use a DLL library */
#define CC_JS_DLL __declspec(dllimport)
#endif
#endif
/* Define NULL pointer value */
#ifndef NULL
#ifdef __cplusplus
#define nullptr 0
#else
#define NULL ((void *)0)
#endif
#endif
#elif defined(_SHARED_)
#define CC_JS_DLL __attribute__((visibility("default")))
#else
#define CC_JS_DLL
#endif

View File

@ -31,6 +31,7 @@
#include "js_bindings_config.h"
#include "cocos2d.h"
#include "spidermonkey_specifics.h"
#include "js-BindingsExport.h"
#include "mozilla/Maybe.h"
#define JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES
@ -99,7 +100,7 @@ bool jsval_to_uint16( JSContext *cx, JS::HandleValue vp, uint16_t *ret );
bool jsval_to_long( JSContext *cx, JS::HandleValue vp, long *out);
bool jsval_to_ulong( JSContext *cx, JS::HandleValue vp, unsigned long *out);
bool jsval_to_long_long(JSContext *cx, JS::HandleValue v, long long* ret);
bool jsval_to_std_string(JSContext *cx, JS::HandleValue v, std::string* ret);
CC_JS_DLL bool jsval_to_std_string(JSContext *cx, JS::HandleValue v, std::string* ret);
bool jsval_to_ccpoint(JSContext *cx, JS::HandleValue v, cocos2d::Point* ret);
bool jsval_to_ccrect(JSContext *cx, JS::HandleValue v, cocos2d::Rect* ret);
bool jsval_to_ccsize(JSContext *cx, JS::HandleValue v, cocos2d::Size* ret);
@ -118,7 +119,7 @@ bool jsval_to_ray(JSContext *cx, JS::HandleValue vp, cocos2d::Ray* ret);
bool jsval_to_resoucedata(JSContext *cx, JS::HandleValue v, cocos2d::ResouceData* ret);
// forward declaration
js_proxy_t* jsb_get_js_proxy(JS::HandleObject jsObj);
CC_JS_DLL js_proxy_t* jsb_get_js_proxy(JS::HandleObject jsObj);
template <class T>
bool jsvals_variadic_to_ccvector( JSContext *cx, /*jsval *vp, int argc,*/const JS::CallArgs& args, cocos2d::Vector<T>* ret)
@ -184,7 +185,7 @@ bool jsval_to_ccvaluemap(JSContext* cx, JS::HandleValue v, cocos2d::ValueMap* re
bool jsval_to_ccvaluemapintkey(JSContext* cx, JS::HandleValue v, cocos2d::ValueMapIntKey* ret);
bool jsval_to_ccvaluevector(JSContext* cx, JS::HandleValue v, cocos2d::ValueVector* ret);
bool jsval_to_ssize( JSContext *cx, JS::HandleValue vp, ssize_t* ret);
bool jsval_to_std_vector_string( JSContext *cx, JS::HandleValue vp, std::vector<std::string>* ret);
CC_JS_DLL bool jsval_to_std_vector_string( JSContext *cx, JS::HandleValue vp, std::vector<std::string>* ret);
bool jsval_to_std_vector_int( JSContext *cx, JS::HandleValue vp, std::vector<int>* ret);
bool jsval_to_std_vector_float( JSContext *cx, JS::HandleValue vp, std::vector<float>* ret);
bool jsval_to_matrix(JSContext *cx, JS::HandleValue vp, cocos2d::Mat4* ret);

View File

@ -1,7 +1,5 @@
#ifndef __JS_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_JS_MODULE_REGISTER_H__
#define __JS_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_JS_MODULE_REGISTER_H__
#include "js_module_register.h"
#include "scripting/js-bindings/manual/ScriptingCore.h"
#include "jsb_cocos2dx_auto.hpp"
#include "jsb_cocos2dx_ui_auto.hpp"
#include "jsb_cocos2dx_studio_auto.hpp"
@ -121,5 +119,8 @@ int js_module_register()
return 1;
}
#endif // __JS_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_JS_MODULE_REGISTER_H__
JS::HandleObject get_jsb_cocos2d_FileUtils_prototype()
{
JS::RootedObject fileUtilsProto(ScriptingCore::getInstance()->getGlobalContext(), jsb_cocos2d_FileUtils_prototype);
return fileUtilsProto;
}

View File

@ -0,0 +1,12 @@
#ifndef __JS_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_JS_MODULE_REGISTER_H__
#define __JS_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_JS_MODULE_REGISTER_H__
#include "scripting/js-bindings/manual/ScriptingCore.h"
#include "js-BindingsExport.h"
CC_JS_DLL int js_module_register();
CC_JS_DLL JS::HandleObject get_jsb_cocos2d_FileUtils_prototype();
#endif // __JS_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_JS_MODULE_REGISTER_H__

View File

@ -40,6 +40,7 @@
<ClCompile Include="..\manual\js_bindings_core.cpp" />
<ClCompile Include="..\manual\js_bindings_opengl.cpp" />
<ClCompile Include="..\manual\js_manual_conversions.cpp" />
<ClCompile Include="..\manual\js_module_register.cpp" />
<ClCompile Include="..\manual\localstorage\js_bindings_system_functions.cpp" />
<ClCompile Include="..\manual\localstorage\js_bindings_system_registration.cpp" />
<ClCompile Include="..\manual\navmesh\jsb_cocos2dx_navmesh_conversions.cpp" />
@ -78,6 +79,7 @@
<ClInclude Include="..\manual\cocostudio\jsb_cocos2dx_studio_manual.h" />
<ClInclude Include="..\manual\component\CCComponentJS.h" />
<ClInclude Include="..\manual\extension\jsb_cocos2dx_extension_manual.h" />
<ClInclude Include="..\manual\js-BindingsExport.h" />
<ClInclude Include="..\manual\jsb_event_dispatcher_manual.h" />
<ClInclude Include="..\manual\jsb_helper.h" />
<ClInclude Include="..\manual\jsb_opengl_functions.h" />
@ -87,6 +89,7 @@
<ClInclude Include="..\manual\js_bindings_core.h" />
<ClInclude Include="..\manual\js_bindings_opengl.h" />
<ClInclude Include="..\manual\js_manual_conversions.h" />
<ClInclude Include="..\manual\js_module_register.h" />
<ClInclude Include="..\manual\localstorage\js_bindings_system_functions.h" />
<ClInclude Include="..\manual\localstorage\js_bindings_system_functions_registration.h" />
<ClInclude Include="..\manual\localstorage\js_bindings_system_registration.h" />
@ -160,7 +163,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;_LIB;COCOS2D_DEBUG=1;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;_LIB;COCOS2D_DEBUG=1;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_USRJSSTATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\base;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\navmesh;$(EngineRoot)cocos\physics3d;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\audio\include;$(EngineRoot)extensions;$(EngineRoot)external;$(ProjectDir)..\auto;$(ProjectDir)..\manual;$(ProjectDir)..\manual\cocostudio;$(ProjectDir)..\manual\navmesh;$(ProjectDir)..\manual\spine;$(ProjectDir)..\..\..\..\external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4068;4101;4800;4251;4244;4099;4083;4700;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
@ -186,7 +189,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\spidermonkey\prebuilt\win32\*.*"
<Optimization>MinSpace</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;_LIB;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;_LIB;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_USRJSSTATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\base;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\physics3d;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\navmesh;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\audio\include;$(EngineRoot)extensions;$(EngineRoot)external;$(ProjectDir)..\auto;$(ProjectDir)..\manual;$(ProjectDir)..\manual\cocostudio;$(ProjectDir)..\manual\navmesh;$(ProjectDir)..\manual\spine;$(ProjectDir)..\..\..\..\external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4068;4101;4800;4251;4244;4099;4083;4700;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
@ -208,4 +211,4 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\spidermonkey\prebuilt\win32\*.*"
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>

View File

@ -113,9 +113,6 @@
<ClCompile Include="..\manual\cocostudio\jsb_cocos2dx_studio_manual.cpp">
<Filter>manual\cocostudio</Filter>
</ClCompile>
<ClCompile Include="..\manual\component\CCComponentJS.cpp">
<Filter>manual\component</Filter>
</ClCompile>
<ClCompile Include="..\manual\extension\jsb_cocos2dx_extension_manual.cpp">
<Filter>manual\extension</Filter>
</ClCompile>
@ -167,6 +164,12 @@
<ClCompile Include="..\manual\navmesh\jsb_cocos2dx_navmesh_conversions.cpp">
<Filter>manual\navmesh</Filter>
</ClCompile>
<ClCompile Include="..\manual\component\CCComponentJS.cpp">
<Filter>manual</Filter>
</ClCompile>
<ClCompile Include="..\manual\js_module_register.cpp">
<Filter>manual</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\auto\jsb_cocos2dx_auto.hpp">
@ -253,9 +256,6 @@
<ClInclude Include="..\manual\cocostudio\jsb_cocos2dx_studio_manual.h">
<Filter>manual\cocostudio</Filter>
</ClInclude>
<ClInclude Include="..\manual\component\CCComponentJS.h">
<Filter>manual\component</Filter>
</ClInclude>
<ClInclude Include="..\manual\extension\jsb_cocos2dx_extension_manual.h">
<Filter>manual\extension</Filter>
</ClInclude>
@ -310,5 +310,14 @@
<ClInclude Include="..\manual\navmesh\jsb_cocos2dx_navmesh_conversions.h">
<Filter>manual\navmesh</Filter>
</ClInclude>
<ClInclude Include="..\manual\component\CCComponentJS.h">
<Filter>auto</Filter>
</ClInclude>
<ClInclude Include="..\manual\js_module_register.h">
<Filter>manual</Filter>
</ClInclude>
<ClInclude Include="..\manual\js-BindingsExport.h">
<Filter>manual</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -39,6 +39,7 @@
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\manual\cocostudio\jsb_cocos2dx_studio_manual.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\manual\component\CCComponentJS.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\manual\extension\jsb_cocos2dx_extension_manual.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\manual\js-BindingsExport.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\manual\jsb_event_dispatcher_manual.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\manual\jsb_helper.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\manual\jsb_opengl_functions.h" />
@ -48,6 +49,7 @@
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\manual\js_bindings_core.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\manual\js_bindings_opengl.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\manual\js_manual_conversions.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\manual\js_module_register.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\manual\localstorage\js_bindings_system_functions.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\manual\localstorage\js_bindings_system_functions_registration.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\manual\localstorage\js_bindings_system_registration.h" />
@ -93,6 +95,7 @@
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\manual\js_bindings_core.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\manual\js_bindings_opengl.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\manual\js_manual_conversions.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\manual\js_module_register.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\manual\localstorage\js_bindings_system_functions.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\manual\localstorage\js_bindings_system_registration.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\manual\navmesh\jsb_cocos2dx_navmesh_conversions.cpp" />

View File

@ -141,6 +141,12 @@
<Filter>auto</Filter>
</ClInclude>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\manual\component\CCComponentJS.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\manual\js_module_register.h">
<Filter>manual</Filter>
</ClInclude>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\manual\js-BindingsExport.h">
<Filter>manual</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\auto\jsb_cocos2dx_3d_auto.cpp">
@ -261,6 +267,9 @@
<Filter>auto</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\manual\component\CCComponentJS.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\manual\js_module_register.cpp">
<Filter>manual</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Filter Include="auto">

View File

@ -129,7 +129,7 @@
<AdditionalIncludeDirectories>$(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\navmesh;$(EngineRoot)cocos\physics3d;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)external\spidermonkey\include\winrt_8.1;$(ProjectDir)..\..\..\auto;$(ProjectDir)..\..\..\manual;$(ProjectDir)..\..\..\manual\cocostudio;$(ProjectDir)..\..\..\manual\navmesh;$(ProjectDir)..\..\..\manual\spine;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4800;4703;4101;4083;4700;4068;4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>CC_ENABLE_CHIPMUNK_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>CC_ENABLE_CHIPMUNK_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;_USRJSSTATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<FunctionLevelLinking>true</FunctionLevelLinking>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
@ -150,7 +150,7 @@
<AdditionalIncludeDirectories>$(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\navmesh;$(EngineRoot)cocos\physics3d;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)external\spidermonkey\include\winrt_8.1;$(ProjectDir)..\..\..\auto;$(ProjectDir)..\..\..\manual;$(ProjectDir)..\..\..\manual\cocostudio;$(ProjectDir)..\..\..\manua\navmesh;$(ProjectDir)..\..\..\manual\spine;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4800;4703;4101;4083;4700;4068;4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>CC_ENABLE_CHIPMUNK_INTEGRATION=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>CC_ENABLE_CHIPMUNK_INTEGRATION=1;_USRJSSTATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WholeProgramOptimization>false</WholeProgramOptimization>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>

View File

@ -94,7 +94,7 @@
<AdditionalIncludeDirectories>$(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\navmesh;$(EngineRoot)cocos\physics3d;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)external\spidermonkey\include\winrt_8.1;$(ProjectDir)..\..\..\auto;$(ProjectDir)..\..\..\manual;$(ProjectDir)..\..\..\manual\cocostudio;$(ProjectDir)..\..\..\manual\spine;$(ProjectDir)..\..\..\manual\navmesh;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4800;4703;4101;4083;4700;4068;4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>CC_ENABLE_CHIPMUNK_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>CC_ENABLE_CHIPMUNK_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;_USRJSSTATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<FunctionLevelLinking>true</FunctionLevelLinking>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
@ -115,7 +115,7 @@
<AdditionalIncludeDirectories>$(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\navmesh;$(EngineRoot)cocos\physics3d;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)external\spidermonkey\include\winrt_8.1;$(ProjectDir)..\..\..\auto;$(ProjectDir)..\..\..\manual;$(ProjectDir)..\..\..\manual\cocostudio;$(ProjectDir)..\..\..\manual\navmesh;$(ProjectDir)..\..\..\manual\spine;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4800;4703;4101;4083;4700;4068;4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>CC_ENABLE_CHIPMUNK_INTEGRATION=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>CC_ENABLE_CHIPMUNK_INTEGRATION=1;_USRJSSTATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WholeProgramOptimization>false</WholeProgramOptimization>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>

View File

@ -0,0 +1,33 @@
#ifndef __LUABINDINGEXPROT_H__
#define __LUABINDINGEXPROT_H__
#if (defined(WIN32) && defined(_WINDOWS)) || defined(WINRT) || defined(WP8)
#ifdef __MINGW32__
#include <string.h>
#endif
#if defined(_USRLUASTATIC)
#define CC_LUA_DLL
#else
#if defined(_USRLUADLL)
#define CC_LUA_DLL __declspec(dllexport)
#else /* use a DLL library */
#define CC_LUA_DLL __declspec(dllimport)
#endif
#endif
/* Define NULL pointer value */
#ifndef NULL
#ifdef __cplusplus
#define NULL 0
#else
#define NULL ((void *)0)
#endif
#endif
#elif defined(_SHARED_)
#define CC_LUA_DLL __attribute__((visibility("default")))
#else
#define CC_LUA_DLL
#endif
#endif /* __CCEXTENSIONEXPORT_H__*/

View File

@ -3386,3 +3386,13 @@ bool luaval_to_std_map_string_string(lua_State* L, int lo, std::map<std::string,
return ok;
}
bool luaval_to_node(lua_State* L, int lo, const char* type, cocos2d::Node** node)
{
return luaval_to_object<cocos2d::Node>(L, lo, type, node);
}
void node_to_luaval(lua_State* L, const char* type, cocos2d::Node* node)
{
object_to_luaval<cocos2d::Node>(L, type, node);
}

View File

@ -30,6 +30,7 @@ extern "C" {
}
#include "tolua_fix.h"
#include "cocos2d.h"
#include "Lua-BindingsExport.h"
using namespace cocos2d;
@ -145,7 +146,7 @@ extern bool luaval_to_uint16(lua_State* L,int lo,uint16_t* outValue, const char*
* @param funcName the name of calling function, it is used for error output in the debug model.
* @return Return true if the value at the given accpetable index of stack is a number or a string convertible to a number, otherwise return false.
*/
extern bool luaval_to_boolean(lua_State* L,int lo,bool* outValue, const char* funcName = "");
extern CC_LUA_DLL bool luaval_to_boolean(lua_State* L,int lo,bool* outValue, const char* funcName = "");
/**
* Get a double value from the given accpetable index of stack.
@ -181,7 +182,7 @@ extern bool luaval_to_long_long(lua_State* L,int lo,long long* outValue, const c
* @param funcName the name of calling function, it is used for error output in the debug model.
* @return Return true if the value at the given acceptable index of stack is a string or a number convertible to a string, otherwise return false.
*/
extern bool luaval_to_std_string(lua_State* L, int lo, std::string* outValue, const char* funcName = "");
extern CC_LUA_DLL bool luaval_to_std_string(lua_State* L, int lo, std::string* outValue, const char* funcName = "");
/**
* Get a long value from the given accpetable index of stack.
@ -244,7 +245,7 @@ extern bool luaval_to_rect(lua_State* L,int lo,Rect* outValue, const char* funcN
* @param funcName the name of calling function, it is used for error output in the debug model.
* @return Return true if the value at the given accpetable index of stack is a table, otherwise return false.
*/
extern bool luaval_to_color3b(lua_State* L,int lo,Color3B* outValue, const char* funcName = "");
extern CC_LUA_DLL bool luaval_to_color3b(lua_State* L,int lo,Color3B* outValue, const char* funcName = "");
/**
* Get a Color4B object value from the given accpetable index of stack.
@ -569,7 +570,7 @@ bool luaval_to_ccvector(lua_State* L, int lo , cocos2d::Vector<T>* ret, const ch
* @param funcName the name of calling function, it is used for error output in the debug model.
* @return Return true if the value at the given accpetable index of stack is a table, otherwise return false.
*/
bool luaval_to_std_vector_string(lua_State* L, int lo, std::vector<std::string>* ret, const char* funcName = "");
CC_LUA_DLL bool luaval_to_std_vector_string(lua_State* L, int lo, std::vector<std::string>* ret, const char* funcName = "");
/**
* Get a pointer points to a std::vector<std::int> from a Lua array table in the stack.
@ -905,7 +906,7 @@ extern void rect_to_luaval(lua_State* L,const Rect& rt);
* @param L the current lua_State.
* @param cc a cocos2d::Color3B object.
*/
extern void color3b_to_luaval(lua_State* L,const Color3B& cc);
extern CC_LUA_DLL void color3b_to_luaval(lua_State* L,const Color3B& cc);
/**
* Push a table converted from a cocos2d::Color4B object into the Lua stack.
@ -1293,6 +1294,10 @@ void std_vector_vec3_to_luaval(lua_State* L, const std::vector<cocos2d::Vec3>& i
*/
void std_map_string_string_to_luaval(lua_State* L, const std::map<std::string, std::string>& inValue);
// Follow 2 function is added for Cocos Studio to make lua lib can be compile as dynamic library
CC_LUA_DLL extern bool luaval_to_node(lua_State* L, int lo, const char* type, cocos2d::Node** node);
CC_LUA_DLL extern void node_to_luaval(lua_State* L, const char* type, cocos2d::Node* node);
// end group
/// @}
#endif //__COCOS2DX_SCRIPTING_LUA_COCOS2DXSUPPORT_LUABAISCCONVERSIONS_H__

View File

@ -1,5 +1,4 @@
#ifndef __LUA_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_LUA_MODULE_REGISTER_H__
#define __LUA_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_LUA_MODULE_REGISTER_H__
#include "lua_module_register.h"
#include "cocosdenshion/lua_cocos2dx_cocosdenshion_manual.h"
#include "network/lua_cocos2dx_network_manual.h"
@ -13,7 +12,8 @@
#include "physics3d/lua_cocos2dx_physics3d_manual.h"
#include "navmesh/lua_cocos2dx_navmesh_manual.h"
static int lua_module_register(lua_State* L)
int lua_module_register(lua_State* L)
{
//Dont' change the module register order unless you know what your are doing
register_cocosdenshion_module(L);
@ -34,5 +34,3 @@ static int lua_module_register(lua_State* L)
return 1;
}
#endif // __LUA_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_LUA_MODULE_REGISTER_H__

View File

@ -0,0 +1,10 @@
#ifndef __LUA_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_LUA_MODULE_REGISTER_H__
#define __LUA_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_LUA_MODULE_REGISTER_H__
#include "lua.h"
#include "Lua-bindingsExport.h"
CC_LUA_DLL int lua_module_register(lua_State* L);
#endif // __LUA_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_LUA_MODULE_REGISTER_H__

View File

@ -70,6 +70,7 @@
<ClCompile Include="..\manual\cocostudio\lua_cocos2dx_csloader_manual.cpp" />
<ClCompile Include="..\manual\extension\lua_cocos2dx_extension_manual.cpp" />
<ClCompile Include="..\manual\LuaBasicConversions.cpp" />
<ClCompile Include="..\manual\lua_module_register.cpp" />
<ClCompile Include="..\manual\navmesh\lua_cocos2dx_navmesh_conversions.cpp" />
<ClCompile Include="..\manual\navmesh\lua_cocos2dx_navmesh_manual.cpp" />
<ClCompile Include="..\manual\network\lua_cocos2dx_network_manual.cpp" />
@ -145,7 +146,9 @@
<ClInclude Include="..\manual\cocostudio\lua_cocos2dx_coco_studio_manual.hpp" />
<ClInclude Include="..\manual\cocostudio\lua_cocos2dx_csloader_manual.hpp" />
<ClInclude Include="..\manual\extension\lua_cocos2dx_extension_manual.h" />
<ClInclude Include="..\manual\Lua-BindingsExport.h" />
<ClInclude Include="..\manual\LuaBasicConversions.h" />
<ClInclude Include="..\manual\lua_module_register.h" />
<ClInclude Include="..\manual\navmesh\lua_cocos2dx_navmesh_conversions.h" />
<ClInclude Include="..\manual\navmesh\lua_cocos2dx_navmesh_manual.h" />
<ClInclude Include="..\manual\network\lua_cocos2dx_network_manual.h" />
@ -282,7 +285,7 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(EngineRoot);$(EngineRoot)cocos\2d;$(EngineRoot)cocos\base;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\physics3d;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\navmesh;$(EngineRoot)external;$(EngineRoot)external\lua;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\lua\luajit\include;$(EngineRoot)external\libwebsockets\win32\include;$(EngineRoot)extensions;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support\cocostudio\ActionTimeline;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\scripting\lua-bindings\manual;$(EngineRoot)cocos\scripting\lua-bindings\auto;$(EngineRoot)cocos\scripting\lua-bindings\manual\extension;$(EngineRoot)cocos\scripting\lua-bindings\manual\cocostudio;$(EngineRoot)cocos\scripting\lua-bindings\manual\ui;$(EngineRoot)cocos\scripting\lua-bindings\manual\cocos2d;$(EngineRoot)cocos\scripting\lua-bindings\manual\navmesh;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_USRLUASTATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>false</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
@ -314,7 +317,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\lua\luajit\prebuilt\win32\*.*" "$
<Optimization>MinSpace</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>$(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\lua\luajit\include;$(EngineRoot)external\lua;$(EngineRoot)cocos\scripting\lua-bindings\auto;$(EngineRoot)cocos\scripting\lua-bindings\manual;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\scripting\lua-bindings\manual\extension;$(EngineRoot)cocos\scripting\lua-bindings\manual\cocostudio;$(EngineRoot)cocos\scripting\lua-bindings\manual\ui;$(EngineRoot)cocos\scripting\lua-bindings\manual\cocos2d;$(EngineRoot)cocos\scripting\lua-bindings\manual\navmesh;$(EngineRoot)extensions;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support\cocostudio\ActionTimeline;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\libwebsockets\win32\include;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\physics3d;$(EngineRoot)cocos\navmesh;$(EngineRoot)external;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;LIBLUA_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;LIBLUA_EXPORTS;_CRT_SECURE_NO_WARNINGS;_USRLUASTATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
@ -344,4 +347,4 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\lua\luajit\prebuilt\win32\*.*" "$
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>

View File

@ -297,6 +297,9 @@
<ClCompile Include="..\manual\navmesh\lua_cocos2dx_navmesh_manual.cpp">
<Filter>manual\navmesh</Filter>
</ClCompile>
<ClCompile Include="..\manual\lua_module_register.cpp">
<Filter>manual</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\auto\lua_cocos2dx_auto.hpp">
@ -521,6 +524,12 @@
<ClInclude Include="..\manual\navmesh\lua_cocos2dx_navmesh_manual.h">
<Filter>manual\navmesh</Filter>
</ClInclude>
<ClInclude Include="..\manual\lua_module_register.h">
<Filter>manual</Filter>
</ClInclude>
<ClInclude Include="..\manual\Lua-BindingsExport.h">
<Filter>manual</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\script\CCBReaderLoad.lua">

View File

@ -47,7 +47,7 @@
]
},
{
"from": "tools/simulator/frameworks/runtime-src/Classes",
"from": "cocos/scripting/js-bindings/manual",
"to": "frameworks/runtime-src/Classes",
"include": [
"js_module_register.h"

View File

@ -145,7 +145,7 @@
]
},
{
"from": "tools/simulator/frameworks/runtime-src/Classes/lua_module_register.h",
"from": "cocos/scripting/lua-bindings/manual/lua_module_register.h",
"to": "frameworks/runtime-src/Classes/"
}
],

View File

@ -145,7 +145,7 @@
]
},
{
"from": "tools/simulator/frameworks/runtime-src/Classes/lua_module_register.h",
"from": "cocos/scripting/lua-bindings/manual/lua_module_register.h",
"to": "frameworks/runtime-src/Classes/"
}
],

@ -1 +1 @@
Subproject commit e82bd71212e53e016bf5f262f8e4bc1c50b54203
Subproject commit 636129882b612b5fe6d1d21be1eec136a2b1340b

@ -1 +1 @@
Subproject commit 250673608e23c9644b96a8e9ef886ab4db96aaf7
Subproject commit 2f9a05f30839f9733da97ca0fffdc9dd20a71575

@ -1 +1 @@
Subproject commit 5089eb347b1d252c8f0a0d0c94c0e67d6bba723e
Subproject commit be4cc39610b447788cb60be470ed4122a314809c

View File

@ -15,6 +15,7 @@
#include "runtime/FileServer.h"
// js
#include "scripting/js-bindings/manual/ScriptingCore.h"
#include "js_module_register.h"
@ -49,7 +50,7 @@ bool runtime_FileUtils_addSearchPath(JSContext *cx, uint32_t argc, jsval *vp)
{
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
bool ok = true;
JSObject *obj = JS_THIS_OBJECT(cx, vp);
JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
js_proxy_t *proxy = jsb_get_js_proxy(obj);
cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, false, "cocos2dx_FileUtils_addSearchPath : Invalid Native Object");
@ -94,7 +95,7 @@ bool runtime_FileUtils_setSearchPaths(JSContext *cx, uint32_t argc, jsval *vp)
{
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
bool ok = true;
JSObject *obj = JS_THIS_OBJECT(cx, vp);
JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
js_proxy_t *proxy = jsb_get_js_proxy(obj);
cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FileUtils_setSearchPaths : Invalid Native Object");
@ -143,11 +144,11 @@ void register_FileUtils(JSContext *cx, JS::HandleObject global)
JS_GetProperty(cx, global, "cc", &nsval);
if (nsval == JSVAL_VOID) {
return;
} else {
}
else {
ns.set(nsval.toObjectOrNull());
}
JS::RootedObject proto(cx, jsb_cocos2d_FileUtils_prototype);
JS::RootedObject proto(cx, get_jsb_cocos2d_FileUtils_prototype());
JS_DefineFunction(cx, proto, "addSearchPath", runtime_FileUtils_addSearchPath, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE);
JS_DefineFunction(cx, proto, "setSearchPaths", runtime_FileUtils_setSearchPaths, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE);
}
@ -230,7 +231,12 @@ void RuntimeJsImpl::onPrecompile(const rapidjson::Document& dArgParse, rapidjson
const rapidjson::Value& objectfiles = dArgParse["modulefiles"];
for (rapidjson::SizeType i = 0; i < objectfiles.Size(); i++)
{
ScriptingCore::getInstance()->compileScript(objectfiles[i].GetString());
ScriptingCore* sc = ScriptingCore::getInstance();
JSContext* gc = sc->getGlobalContext();
sc->compileScript(objectfiles[i].GetString(),
JS::RootedObject(gc, sc->getGlobalObject()),
gc);
}
dReplyParse.AddMember("code",0,dReplyParse.GetAllocator());

View File

@ -20,8 +20,6 @@
#include "runtime/ConfigParser.h"
#include "runtime/FileServer.h"
extern std::string g_projectPath; // Runtime.cpp
USING_NS_CC;
using namespace std;

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
@ -21,7 +21,7 @@
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '11.0'">v110</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0'">v120</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '14.0'">v140</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '14.0'">v140</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '14.0' and exists('$(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A')">v140_xp</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
@ -30,7 +30,7 @@
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '11.0'">v110</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0'">v120</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '14.0'">v140</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '14.0'">v140</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '14.0' and exists('$(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A')">v140_xp</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
@ -76,7 +76,7 @@
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_WINDOWS;STRICT;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS_DEBUG;COCOS2D_DEBUG=1;GLFW_EXPOSE_NATIVE_WIN32;GLFW_EXPOSE_NATIVE_WGL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_WINDOWS;STRICT;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS_DEBUG;COCOS2D_DEBUG=1;GLFW_EXPOSE_NATIVE_WIN32;GLFW_EXPOSE_NATIVE_WGL;_USRLUASTATIC;_USRJSSTATIC;_USRLIBSIMSTATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DisableSpecificWarnings>4267;4251;4244;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<ProgramDataBaseFileName>$(IntDir)vc$(PlatformToolsetVersion).pdb</ProgramDataBaseFileName>
@ -141,7 +141,7 @@ xcopy /Y /Q "$(OutDir)lang" "$(ProjectDir)..\..\..\runtime\win32"
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<ExceptionHandling>Sync</ExceptionHandling>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<PreprocessorDefinitions>COCOS2D_DEBUG=1;WIN32;_WINDOWS;STRICT;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGSNDEBUG;GLFW_EXPOSE_NATIVE_WIN32;GLFW_EXPOSE_NATIVE_WGL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>COCOS2D_DEBUG=1;WIN32;_WINDOWS;STRICT;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGSNDEBUG;GLFW_EXPOSE_NATIVE_WIN32;GLFW_EXPOSE_NATIVE_WGL;_USRLUASTATIC;_USRJSSTATIC;_USRLIBSIMSTATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DisableSpecificWarnings>4267;4251;4244;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<ProgramDataBaseFileName>$(IntDir)vc$(PlatformToolsetVersion).pdb</ProgramDataBaseFileName>
@ -244,4 +244,4 @@ xcopy /Y /Q "$(OutDir)lang" "$(ProjectDir)..\..\..\runtime\win32"
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>

View File

@ -15,6 +15,7 @@
#include "json/filestream.h"
#include "json/stringbuffer.h"
#include "json/writer.h"
#include "SimulatorExport.h"
enum
{
@ -25,7 +26,7 @@ enum
#define kAppEventDropName "APP.EVENT.DROP"
#define kAppEventName "APP.EVENT"
class AppEvent : public cocos2d::EventCustom
class CC_LIBSIM_DLL AppEvent : public cocos2d::EventCustom
{
public:
/** Constructor */

View File

@ -11,8 +11,9 @@
#include "json/document.h"
#include "DeviceEx.h"
#include "SimulatorExport.h"
class AppLang
class CC_LIBSIM_DLL AppLang
{
public:
static AppLang* getInstance();

View File

@ -2,10 +2,11 @@
#include <string>
#include "PlayerMacros.h"
#include "SimulatorExport.h"
PLAYER_NS_BEGIN
class DeviceEx
class CC_LIBSIM_DLL DeviceEx
{
public:
static DeviceEx *getInstance();

View File

@ -7,6 +7,7 @@
#include "cocos2d.h"
#include "PlayerMacros.h"
#include "PlayerServiceProtocol.h"
#include "SimulatorExport.h"
PLAYER_NS_BEGIN
@ -15,7 +16,7 @@ PLAYER_NS_BEGIN
#define kPlayerCtrlModifyKey "ctrl"
#define kPlayerAltModifyKey "alt"
class PlayerMenuItem : public cocos2d::Ref
class CC_LIBSIM_DLL PlayerMenuItem : public cocos2d::Ref
{
public:
virtual ~PlayerMenuItem();

View File

@ -12,10 +12,11 @@
#include "PlayerTaskServiceProtocol.h"
#include "ProjectConfig/ProjectConfig.h"
#include "SimulatorExport.h"
PLAYER_NS_BEGIN
class PlayerProtocol
class CC_LIBSIM_DLL PlayerProtocol
{
public:
virtual ~PlayerProtocol();

View File

@ -8,6 +8,7 @@
using namespace std;
#include "cocos2d.h"
#include "SimulatorExport.h"
#define kCCRuntimeDebuggerNone 0
#define kCCRuntimeDebuggerLDT 1
@ -37,7 +38,7 @@ using namespace std;
#define kProjectConfigUploadPort 6020
#define kProjectConfigDebugPort 5086
class ProjectConfig
class CC_LIBSIM_DLL ProjectConfig
{
public:
ProjectConfig();

View File

@ -8,6 +8,7 @@
using namespace std;
#include "cocos2d.h"
#include "SimulatorExport.h"
#if defined(_WINDOWS)
#define DIRECTORY_SEPARATOR "\\"
@ -33,7 +34,7 @@ typedef struct _SimulatorScreenSize {
typedef vector<SimulatorScreenSize> ScreenSizeArray;
typedef ScreenSizeArray::iterator ScreenSizeArrayIterator;
class SimulatorConfig
class CC_LIBSIM_DLL SimulatorConfig
{
public:
static SimulatorConfig *getInstance();

View File

@ -0,0 +1,30 @@
#pragma once
#if (defined(WIN32) && defined(_WINDOWS)) || defined(WINRT) || defined(WP8)
#ifdef __MINGW32__
#include <string.h>
#endif
#if defined(_USRLIBSIMSTATIC)
#define CC_LIBSIM_DLL
#else
#if defined(_USRLIBSIMDLL)
#define CC_LIBSIM_DLL __declspec(dllexport)
#else /* use a DLL library */
#define CC_LIBSIM_DLL __declspec(dllimport)
#endif
#endif
/* Define NULL pointer value */
#ifndef NULL
#ifdef __cplusplus
#define NULL 0
#else
#define NULL ((void *)0)
#endif
#endif
#elif defined(_SHARED_)
#define CC_LIBSIM_DLL __attribute__((visibility("default")))
#else
#define CC_LIBSIM_DLL
#endif

View File

@ -8,10 +8,11 @@
#include "cocos2d.h"
#include "stdafx.h"
#include "PlayerMenuServiceProtocol.h"
#include "SimulatorExport.h"
PLAYER_NS_BEGIN
class PlayerMenuItemWin : public PlayerMenuItem
class CC_LIBSIM_DLL PlayerMenuItemWin : public PlayerMenuItem
{
public:
static PlayerMenuItemWin *create(const std::string &menuId, const std::string &title);
@ -34,7 +35,7 @@ protected:
friend class PlayerMenuServiceWin;
};
class PlayerMenuServiceWin : public PlayerMenuServiceProtocol
class CC_LIBSIM_DLL PlayerMenuServiceWin : public PlayerMenuServiceProtocol
{
public:
PlayerMenuServiceWin(HWND hwnd);

View File

@ -9,10 +9,11 @@
#include "PlayerFileDialogServiceWin.h"
#include "PlayerEditBoxServiceWin.h"
#include "PlayerTaskServiceWin.h"
#include "SimulatorExport.h"
PLAYER_NS_BEGIN
class PlayerWin : public PlayerProtocol, public cocos2d::Ref
class CC_LIBSIM_DLL PlayerWin : public PlayerProtocol, public cocos2d::Ref
{
public:
static PlayerWin *createWithHwnd(HWND hWnd);

View File

@ -7,13 +7,15 @@
#include "json/document.h"
#include "ProjectConfig/SimulatorConfig.h"
#include "ProjectConfig/ProjectConfig.h"
#include "SimulatorExport.h"
using namespace std;
USING_NS_CC;
#define CONFIG_FILE "config.json"
typedef vector<SimulatorScreenSize> ScreenSizeArray;
class ConfigParser
class CC_LIBSIM_DLL ConfigParser
{
public:
static ConfigParser *getInstance(void);

View File

@ -211,8 +211,10 @@ void ConsoleCommand::onSendCommand(int fd, const std::string &args)
} else if(strcmp(strcmd.c_str(), "shutdownapp") == 0)
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
extern void shutDownApp();
shutDownApp();
#include <windows.h>
auto glview = dynamic_cast<GLViewImpl*> (Director::getInstance()->getOpenGLView());
HWND hWnd = glview->getWin32Window();
::SendMessage(hWnd, WM_CLOSE, NULL, NULL);
#else
exit(0);
#endif

View File

@ -257,7 +257,7 @@ _responseEndThread(false)
_writePath = FileUtils::getInstance()->getWritablePath();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
std::string getCurAppName(void);
#include "Widget_mac.h"
_writePath += getCurAppName();
_writePath += "/";
#endif

View File

@ -32,6 +32,7 @@ THE SOFTWARE.
#include "json/writer.h"
#include "Protos.pb.h"
#include <string>
#include "SimulatorExport.h"
// header files for socket
#ifdef _WIN32
@ -53,7 +54,7 @@ THE SOFTWARE.
#include <unistd.h>
#endif
class FileServer
class CC_LIBSIM_DLL FileServer
{
static FileServer *s_sharedFileServer;
public:

View File

@ -190,10 +190,28 @@ void RuntimeEngine::setProjectPath(const std::string &workPath)
if (workPath.empty())
{
extern std::string getCurAppPath();
std::string appPath = getCurAppPath();
std::string appPath = std::string("");
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
appPath.append("/../../");
TCHAR szAppDir[MAX_PATH] = { 0 };
if (GetModuleFileName(NULL, szAppDir, MAX_PATH))
{
int nEnd = 0;
for (int i = 0; szAppDir[i]; i++)
{
if (szAppDir[i] == '\\')
nEnd = i;
}
szAppDir[nEnd] = 0;
int iLen = 2 * wcslen(szAppDir);
char* chRtn = new char[iLen + 1];
wcstombs(chRtn, szAppDir, iLen + 1);
std::string strPath = chRtn;
delete[] chRtn;
chRtn = NULL;
char fuldir[MAX_PATH] = { 0 };
_fullpath(fuldir, strPath.c_str(), MAX_PATH);
appPath = fuldir;
}
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
appPath.append("/../../../");
#endif

View File

@ -28,14 +28,17 @@ THE SOFTWARE.
#include <string>
#include <functional>
#include <unordered_map>
#include "SimulatorExport.h"
void recvBuf(int fd, char *pbuf, unsigned long bufsize);
void sendBuf(int fd, const char *pbuf, unsigned long bufsize);
std::string& replaceAll(std::string& str, const std::string& old_value, const std::string& new_value);
CC_LIBSIM_DLL extern std::string g_projectPath;
std::string getIPAddress();
CC_LIBSIM_DLL std::string& replaceAll(std::string& str, const std::string& old_value, const std::string& new_value);
CC_LIBSIM_DLL std::string getIPAddress();
const char* getRuntimeVersion();

View File

@ -9,8 +9,9 @@
#include <string>
#include "json/document.h"
#include "SimulatorExport.h"
class RuntimeProtocol
class CC_LIBSIM_DLL RuntimeProtocol
{
public:
virtual void end();

View File

@ -0,0 +1,11 @@
//
// Widget_mac.h
// Simulator
//
//
#pragma once
std::string getCurAppName();
#endif

View File

@ -0,0 +1,20 @@
//
// Widget_mac.cpp
// Simulator
//
//
#include <string>
#include "Widget_mac.h"
using namespace std;
std::string getCurAppName(void)
{
string appName = [[[NSProcessInfo processInfo] processName] UTF8String];
size_t found = appName.find(" ");
if (found!=std::string::npos)
appName = appName.substr(0,found);
return appName;
}

View File

@ -60,7 +60,7 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_WINDOWS;STRICT;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS_DEBUG;COCOS2D_DEBUG=1;GLFW_EXPOSE_NATIVE_WIN32;GLFW_EXPOSE_NATIVE_WGL;%(PreprocessorDefinitions);_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_WINDOWS;STRICT;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS_DEBUG;COCOS2D_DEBUG=1;GLFW_EXPOSE_NATIVE_WIN32;GLFW_EXPOSE_NATIVE_WGL;%(PreprocessorDefinitions);_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS;_USRLIBSIMSTATIC</PreprocessorDefinitions>
<SDLCheck>
</SDLCheck>
<AdditionalIncludeDirectories>$(ProjectDir);$(ProjectDir)..\lib\protobuf-lite;$(ProjectDir)..\lib;$(EngineRoot)external\win32-specific\zlib\include;$(EngineRoot)cocos\scripting\lua-bindings\auto;$(EngineRoot)cocos\scripting\lua-bindings\manual;$(EngineRoot)cocos\audio\include;$(EngineRoot)external;$(EngineRoot)external\lua\lua;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\curl\include\win32;$(EngineRoot)extensions;$(EngineRoot);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
@ -84,7 +84,7 @@
<Optimization>MinSpace</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>COCOS2D_DEBUG=1;WIN32;_WINDOWS;STRICT;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS_DEBUG;GLFW_EXPOSE_NATIVE_WIN32;GLFW_EXPOSE_NATIVE_WGL;_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS;%(PreprocessorDefinitions);_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS</PreprocessorDefinitions>
<PreprocessorDefinitions>COCOS2D_DEBUG=1;WIN32;_WINDOWS;STRICT;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS_DEBUG;GLFW_EXPOSE_NATIVE_WIN32;GLFW_EXPOSE_NATIVE_WGL;_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS;_USRLIBSIMSTATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(ProjectDir);$(ProjectDir)..\lib\protobuf-lite;$(ProjectDir)..\lib;$(EngineRoot)external\win32-specific\zlib\include;$(EngineRoot)cocos\scripting\lua-bindings\auto;$(EngineRoot)cocos\scripting\lua-bindings\manual;$(EngineRoot)cocos\audio\include;$(EngineRoot)external;$(EngineRoot)external\lua\lua;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\curl\include\win32;$(EngineRoot)extensions;$(EngineRoot);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<CompileAs>CompileAsCpp</CompileAs>