Skip to content

Commit

Permalink
Unity3D下增加Windows平台的支持
Browse files Browse the repository at this point in the history
Former-commit-id: 9d1e95cd55b711682842f2ab1bb6b28d42c4cb26
  • Loading branch information
vimfung committed Mar 7, 2017
1 parent 52343e5 commit 5ba9d14
Show file tree
Hide file tree
Showing 8 changed files with 132 additions and 7 deletions.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,21 @@ internal extern static int registerClass (

#elif UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN

/// <summary>
/// 绑定设置原生对象ID处理器
/// </summary>
/// <param name="handler">处理器对象</param>
[DllImport("LuaScriptCore-Unity-Win64")]
internal extern static void bindSetNativeObjectIdHandler(IntPtr handler);

/// <summary>
/// 绑定根据实例获取类型名称处理器
/// </summary>
/// <param name="handler">处理器对象</param>
[DllImport("LuaScriptCore-Unity-Win64")]
internal extern static void bindGetClassNameByInstanceHandler(IntPtr handler);


/// <summary>
/// 创建Lua上下文对象
/// </summary>
Expand Down Expand Up @@ -297,18 +312,84 @@ internal extern static int registerClass (
[DllImport("LuaScriptCore-Unity-Win64")]
internal extern static void registerMethod (int nativeContextId, string methodName, IntPtr methodHandler);

/// <summary>
/// 释放本地对象
/// <summary>
/// 调用Lua方法
/// </summary>
/// <param name="objectId">本地对象标识.</param>
/// <returns>返回值的缓冲区大小</returns>
/// <param name="nativeContextId">Lua上下文对象的本地标识.</param>
/// <param name="function">方法.</param>
/// <param name="arguments">参数列表.</param>
/// <param name="resultBuffer">返回值缓冲区.</param>
[DllImport("LuaScriptCore-Unity-Win64")]
internal extern static int invokeLuaFunction(int nativeContextId, IntPtr function, IntPtr arguments, out IntPtr resultBuffer);

/// <summary>
/// 释放本地对象
/// </summary>
/// <param name="objectId">本地对象标识.</param>
[DllImport("LuaScriptCore-Unity-Win64")]
internal extern static void releaseObject(int objectId);

/// <summary>
/// 设置Unity调试日志接口,用于Lua中输出日志到Unity的编辑器控制台, Editor特有。
/// <summary>
/// 注册模块
/// </summary>
/// <param name="fp">方法回调</param>
/// <param name="nativeContextId">Lua上下文对象的本地标识</param>
/// <param name="moduleName">模块名称</param>
/// <param name="exportsMethodNames">导出方法名称列表.</param>
/// <param name="methodRouteHandler">方法路由处理器,所有的方法都会由此方法来回调</param>
/// <returns>模块的本地标识</returns>
[DllImport("LuaScriptCore-Unity-Win64")]
internal extern static int registerModule(int nativeContextId, string moduleName, IntPtr exportsMethodNames, IntPtr methodRouteHandler);

/// <summary>
/// 判断模块是否注册
/// </summary>
/// <returns>true表示注册,false表示尚未注册</returns>
/// <param name="nativeContextId">Lua上下文对象的本地标识</param>
/// <param name="moduleName">模块名称</param>
[DllImport("LuaScriptCore-Unity-Win64")]
internal extern static bool isModuleRegisted(int nativeContextId, string moduleName);

/// <summary>
/// 注册类型
/// </summary>
/// <returns>类标识</returns>
/// <param name="nativeContextId">原生上下文标识</param>
/// <param name="className">类名</param>
/// <param name="superClassName">父类名称</param>
/// <param name="exportsSetterNames">导出Setter名称列表.</param>
/// <param name="exportsGetterNames">导出Getter名称列表.</param>
/// <param name="exportsInstanceMethodNames">导出实例方法名称列表</param>
/// <param name="exportsClassMethodNames">导出类方法名称列表</param>
/// <param name="instanceCreateHandler">实例创建处理器</param>
/// <param name="instanceDestroyHandler">实例销毁处理器</param>
/// <param name="instanceDescriptionHandler">实例描述处理器</param>
/// <param name="fieldGetterHandler">字段获取器.</param>
/// <param name="fieldSetterHandler">字段设置器.</param>
/// <param name="instanceMethodRouteHandler">实例方法处理器.</param>
/// <param name="classMethodRouteHandler">类方法处理器.</param>
[DllImport("LuaScriptCore-Unity-Win64")]
internal extern static int registerClass(
int nativeContextId,
string className,
string superClassName,
IntPtr exportsSetterNames,
IntPtr exportsGetterNames,
IntPtr exportsInstanceMethodNames,
IntPtr exportsClassMethodNames,
IntPtr instanceCreateHandler,
IntPtr instanceDestroyHandler,
IntPtr instanceDescriptionHandler,
IntPtr fieldGetterHandler,
IntPtr fieldSetterHandler,
IntPtr instanceMethodRouteHandler,
IntPtr classMethodRouteHandler);

/// <summary>
/// 设置Unity调试日志接口,用于Lua中输出日志到Unity的编辑器控制台, Editor特有。
/// </summary>
/// <param name="fp">方法回调</param>
[DllImport("LuaScriptCore-Unity-Win64")]
private extern static void setUnityDebugLog (IntPtr fp);

#elif UNITY_IPHONE
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
m_EditorVersion: 5.3.4f1
m_EditorVersion: 5.4.3f1
m_StandardAssetsVersion: 0
Binary file modified Source/Unity3D/Windows/.vs/Windows/v14/.suo
Binary file not shown.
11 changes: 11 additions & 0 deletions Source/Unity3D/Windows/LuaScriptCore/LuaScriptCore.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,10 @@
<ClCompile Include="..\..\..\lua-common\LuaObjectDecoder.cpp" />
<ClCompile Include="..\..\..\lua-common\LuaObjectDescriptor.cpp" />
<ClCompile Include="..\..\..\lua-common\LuaObjectEncoder.cpp" />
<ClCompile Include="..\..\..\lua-common\LuaObjectInstanceDescriptor.cpp" />
<ClCompile Include="..\..\..\lua-common\LuaObjectManager.cpp" />
<ClCompile Include="..\..\..\lua-common\LuaPointer.cpp" />
<ClCompile Include="..\..\..\lua-common\LuaTuple.cpp" />
<ClCompile Include="..\..\..\lua-common\LuaValue.cpp" />
<ClCompile Include="..\..\..\lua-core\src\lapi.c" />
<ClCompile Include="..\..\..\lua-core\src\lauxlib.c" />
Expand Down Expand Up @@ -130,6 +132,9 @@
<ClCompile Include="..\..\..\lua-core\src\lvm.c" />
<ClCompile Include="..\..\..\lua-core\src\lzio.c" />
<ClCompile Include="..\..\UnityCommon\LuaScriptCoreForUnity.cpp" />
<ClCompile Include="..\..\UnityCommon\LuaUnityEnv.cpp" />
<ClCompile Include="..\..\UnityCommon\LuaUnityModule.cpp" />
<ClCompile Include="..\..\UnityCommon\LuaUnityObjectClass.cpp" />
<ClCompile Include="dllmain.cpp" />
</ItemGroup>
<ItemGroup>
Expand All @@ -144,9 +149,11 @@
<ClInclude Include="..\..\..\lua-common\LuaObjectDecoder.hpp" />
<ClInclude Include="..\..\..\lua-common\LuaObjectDescriptor.h" />
<ClInclude Include="..\..\..\lua-common\LuaObjectEncoder.hpp" />
<ClInclude Include="..\..\..\lua-common\LuaObjectInstanceDescriptor.h" />
<ClInclude Include="..\..\..\lua-common\LuaObjectManager.h" />
<ClInclude Include="..\..\..\lua-common\LuaObjectSerializationTypes.h" />
<ClInclude Include="..\..\..\lua-common\LuaPointer.h" />
<ClInclude Include="..\..\..\lua-common\LuaTuple.h" />
<ClInclude Include="..\..\..\lua-common\LuaValue.h" />
<ClInclude Include="..\..\..\lua-core\src\lapi.h" />
<ClInclude Include="..\..\..\lua-core\src\lauxlib.h" />
Expand Down Expand Up @@ -176,6 +183,10 @@
<ClInclude Include="..\..\..\lua-core\src\lvm.h" />
<ClInclude Include="..\..\..\lua-core\src\lzio.h" />
<ClInclude Include="..\..\UnityCommon\LuaScriptCoreForUnity.h" />
<ClInclude Include="..\..\UnityCommon\LuaUnityDefined.h" />
<ClInclude Include="..\..\UnityCommon\LuaUnityEnv.hpp" />
<ClInclude Include="..\..\UnityCommon\LuaUnityModule.hpp" />
<ClInclude Include="..\..\UnityCommon\LuaUnityObjectClass.hpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets" />
Expand Down
33 changes: 33 additions & 0 deletions Source/Unity3D/Windows/LuaScriptCore/LuaScriptCore.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,21 @@
<ClCompile Include="..\..\UnityCommon\LuaScriptCoreForUnity.cpp">
<Filter>Source Files\UnityCommon</Filter>
</ClCompile>
<ClCompile Include="..\..\UnityCommon\LuaUnityEnv.cpp">
<Filter>Source Files\UnityCommon</Filter>
</ClCompile>
<ClCompile Include="..\..\UnityCommon\LuaUnityModule.cpp">
<Filter>Source Files\UnityCommon</Filter>
</ClCompile>
<ClCompile Include="..\..\UnityCommon\LuaUnityObjectClass.cpp">
<Filter>Source Files\UnityCommon</Filter>
</ClCompile>
<ClCompile Include="..\..\..\lua-common\LuaTuple.cpp">
<Filter>Source Files\lua-common</Filter>
</ClCompile>
<ClCompile Include="..\..\..\lua-common\LuaObjectInstanceDescriptor.cpp">
<Filter>Source Files\lua-common</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\lua-core\src\lapi.h">
Expand Down Expand Up @@ -311,5 +326,23 @@
<ClInclude Include="..\..\UnityCommon\LuaScriptCoreForUnity.h">
<Filter>Header Files\UnityCommon</Filter>
</ClInclude>
<ClInclude Include="..\..\UnityCommon\LuaUnityDefined.h">
<Filter>Header Files\UnityCommon</Filter>
</ClInclude>
<ClInclude Include="..\..\UnityCommon\LuaUnityEnv.hpp">
<Filter>Header Files\UnityCommon</Filter>
</ClInclude>
<ClInclude Include="..\..\UnityCommon\LuaUnityModule.hpp">
<Filter>Header Files\UnityCommon</Filter>
</ClInclude>
<ClInclude Include="..\..\UnityCommon\LuaUnityObjectClass.hpp">
<Filter>Header Files\UnityCommon</Filter>
</ClInclude>
<ClInclude Include="..\..\..\lua-common\LuaObjectInstanceDescriptor.h">
<Filter>Header Files\lua-common</Filter>
</ClInclude>
<ClInclude Include="..\..\..\lua-common\LuaTuple.h">
<Filter>Header Files\lua-common</Filter>
</ClInclude>
</ItemGroup>
</Project>

0 comments on commit 5ba9d14

Please sign in to comment.