Last active
May 6, 2017 06:59
-
-
Save JamesKim2998/32bfc79593ee8c7fca80e9246aabdec9 to your computer and use it in GitHub Desktop.
automatic lua binding by xLua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if USE_UNI_LUA | |
using LuaAPI = UniLua.Lua; | |
using RealStatePtr = UniLua.ILuaState; | |
using LuaCSFunction = UniLua.CSharpFunctionDelegate; | |
#else | |
using LuaAPI = XLua.LuaDLL.Lua; | |
using RealStatePtr = System.IntPtr; | |
using LuaCSFunction = XLua.LuaDLL.lua_CSFunction; | |
#endif | |
using XLua; | |
using System.Collections.Generic; | |
namespace XLua.CSObjectWrap | |
{ | |
using Utils = XLua.Utils; | |
public class Foo1ChildWrap | |
{ | |
public static void __Register(RealStatePtr L) | |
{ | |
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); | |
Utils.BeginObjectRegister(typeof(Foo1Child), L, translator, 0, 3, 0, 0); | |
Utils.RegisterFunc(L, Utils.METHOD_IDX, "PlainExtension", _m_PlainExtension); | |
Utils.RegisterFunc(L, Utils.METHOD_IDX, "Extension1", _m_Extension1); | |
Utils.RegisterFunc(L, Utils.METHOD_IDX, "Extension2", _m_Extension2); | |
Utils.EndObjectRegister(typeof(Foo1Child), L, translator, null, null, | |
null, null, null); | |
Utils.BeginClassRegister(typeof(Foo1Child), L, __CreateInstance, 1, 0, 0); | |
Utils.RegisterObject(L, translator, Utils.CLS_IDX, "UnderlyingSystemType", typeof(Foo1Child)); | |
Utils.EndClassRegister(typeof(Foo1Child), L, translator); | |
} | |
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] | |
static int __CreateInstance(RealStatePtr L) | |
{ | |
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); | |
try { | |
if(LuaAPI.lua_gettop(L) == 1) | |
{ | |
Foo1Child __cl_gen_ret = new Foo1Child(); | |
translator.Push(L, __cl_gen_ret); | |
return 1; | |
} | |
} | |
catch(System.Exception __gen_e) { | |
return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); | |
} | |
return LuaAPI.luaL_error(L, "invalid arguments to Foo1Child constructor!"); | |
} | |
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] | |
static int _m_PlainExtension(RealStatePtr L) | |
{ | |
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); | |
Foo1Child __cl_gen_to_be_invoked = (Foo1Child)translator.FastGetCSObj(L, 1); | |
try { | |
{ | |
__cl_gen_to_be_invoked.PlainExtension( ); | |
return 0; | |
} | |
} catch(System.Exception __gen_e) { | |
return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); | |
} | |
} | |
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] | |
static int _m_Extension1(RealStatePtr L) | |
{ | |
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); | |
Foo1Child __cl_gen_to_be_invoked = (Foo1Child)translator.FastGetCSObj(L, 1); | |
try { | |
{ | |
Foo1Parent __cl_gen_ret = __cl_gen_to_be_invoked.Extension1( ); | |
translator.Push(L, __cl_gen_ret); | |
return 1; | |
} | |
} catch(System.Exception __gen_e) { | |
return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); | |
} | |
} | |
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] | |
static int _m_Extension2(RealStatePtr L) | |
{ | |
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); | |
Foo1Child __cl_gen_to_be_invoked = (Foo1Child)translator.FastGetCSObj(L, 1); | |
int __gen_param_count = LuaAPI.lua_gettop(L); | |
try { | |
if(__gen_param_count == 2&& translator.Assignable<UnityEngine.GameObject>(L, 2)) | |
{ | |
UnityEngine.GameObject b = (UnityEngine.GameObject)translator.GetObject(L, 2, typeof(UnityEngine.GameObject)); | |
Foo1Parent __cl_gen_ret = __cl_gen_to_be_invoked.Extension2( b ); | |
translator.Push(L, __cl_gen_ret); | |
return 1; | |
} | |
if(__gen_param_count == 2&& translator.Assignable<Foo2Parent>(L, 2)) | |
{ | |
Foo2Parent b = (Foo2Parent)translator.GetObject(L, 2, typeof(Foo2Parent)); | |
__cl_gen_to_be_invoked.Extension2( b ); | |
return 0; | |
} | |
} catch(System.Exception __gen_e) { | |
return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); | |
} | |
return LuaAPI.luaL_error(L, "invalid arguments to Foo1Child.Extension2!"); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if USE_UNI_LUA | |
using LuaAPI = UniLua.Lua; | |
using RealStatePtr = UniLua.ILuaState; | |
using LuaCSFunction = UniLua.CSharpFunctionDelegate; | |
#else | |
using LuaAPI = XLua.LuaDLL.Lua; | |
using RealStatePtr = System.IntPtr; | |
using LuaCSFunction = XLua.LuaDLL.lua_CSFunction; | |
#endif | |
using XLua; | |
using System.Collections.Generic; | |
namespace XLua.CSObjectWrap | |
{ | |
using Utils = XLua.Utils; | |
public class Foo1ParentWrap | |
{ | |
public static void __Register(RealStatePtr L) | |
{ | |
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); | |
Utils.BeginObjectRegister(typeof(Foo1Parent), L, translator, 0, 3, 0, 0); | |
Utils.RegisterFunc(L, Utils.METHOD_IDX, "PlainExtension", _m_PlainExtension); | |
Utils.RegisterFunc(L, Utils.METHOD_IDX, "Extension1", _m_Extension1); | |
Utils.RegisterFunc(L, Utils.METHOD_IDX, "Extension2", _m_Extension2); | |
Utils.EndObjectRegister(typeof(Foo1Parent), L, translator, null, null, | |
null, null, null); | |
Utils.BeginClassRegister(typeof(Foo1Parent), L, __CreateInstance, 1, 0, 0); | |
Utils.RegisterObject(L, translator, Utils.CLS_IDX, "UnderlyingSystemType", typeof(Foo1Parent)); | |
Utils.EndClassRegister(typeof(Foo1Parent), L, translator); | |
} | |
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] | |
static int __CreateInstance(RealStatePtr L) | |
{ | |
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); | |
try { | |
if(LuaAPI.lua_gettop(L) == 1) | |
{ | |
Foo1Parent __cl_gen_ret = new Foo1Parent(); | |
translator.Push(L, __cl_gen_ret); | |
return 1; | |
} | |
} | |
catch(System.Exception __gen_e) { | |
return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); | |
} | |
return LuaAPI.luaL_error(L, "invalid arguments to Foo1Parent constructor!"); | |
} | |
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] | |
static int _m_PlainExtension(RealStatePtr L) | |
{ | |
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); | |
Foo1Parent __cl_gen_to_be_invoked = (Foo1Parent)translator.FastGetCSObj(L, 1); | |
try { | |
{ | |
__cl_gen_to_be_invoked.PlainExtension( ); | |
return 0; | |
} | |
} catch(System.Exception __gen_e) { | |
return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); | |
} | |
} | |
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] | |
static int _m_Extension1(RealStatePtr L) | |
{ | |
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); | |
Foo1Parent __cl_gen_to_be_invoked = (Foo1Parent)translator.FastGetCSObj(L, 1); | |
try { | |
{ | |
Foo1Parent __cl_gen_ret = __cl_gen_to_be_invoked.Extension1( ); | |
translator.Push(L, __cl_gen_ret); | |
return 1; | |
} | |
} catch(System.Exception __gen_e) { | |
return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); | |
} | |
} | |
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] | |
static int _m_Extension2(RealStatePtr L) | |
{ | |
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); | |
Foo1Parent __cl_gen_to_be_invoked = (Foo1Parent)translator.FastGetCSObj(L, 1); | |
int __gen_param_count = LuaAPI.lua_gettop(L); | |
try { | |
if(__gen_param_count == 2&& translator.Assignable<UnityEngine.GameObject>(L, 2)) | |
{ | |
UnityEngine.GameObject b = (UnityEngine.GameObject)translator.GetObject(L, 2, typeof(UnityEngine.GameObject)); | |
Foo1Parent __cl_gen_ret = __cl_gen_to_be_invoked.Extension2( b ); | |
translator.Push(L, __cl_gen_ret); | |
return 1; | |
} | |
if(__gen_param_count == 2&& translator.Assignable<Foo2Parent>(L, 2)) | |
{ | |
Foo2Parent b = (Foo2Parent)translator.GetObject(L, 2, typeof(Foo2Parent)); | |
__cl_gen_to_be_invoked.Extension2( b ); | |
return 0; | |
} | |
} catch(System.Exception __gen_e) { | |
return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); | |
} | |
return LuaAPI.luaL_error(L, "invalid arguments to Foo1Parent.Extension2!"); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if USE_UNI_LUA | |
using LuaAPI = UniLua.Lua; | |
using RealStatePtr = UniLua.ILuaState; | |
using LuaCSFunction = UniLua.CSharpFunctionDelegate; | |
#else | |
using LuaAPI = XLua.LuaDLL.Lua; | |
using RealStatePtr = System.IntPtr; | |
using LuaCSFunction = XLua.LuaDLL.lua_CSFunction; | |
#endif | |
using XLua; | |
using System.Collections.Generic; | |
namespace XLua.CSObjectWrap | |
{ | |
using Utils = XLua.Utils; | |
public class Foo2ChildWrap | |
{ | |
public static void __Register(RealStatePtr L) | |
{ | |
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); | |
Utils.BeginObjectRegister(typeof(Foo2Child), L, translator, 0, 0, 0, 0); | |
Utils.EndObjectRegister(typeof(Foo2Child), L, translator, null, null, | |
null, null, null); | |
Utils.BeginClassRegister(typeof(Foo2Child), L, __CreateInstance, 1, 0, 0); | |
Utils.RegisterObject(L, translator, Utils.CLS_IDX, "UnderlyingSystemType", typeof(Foo2Child)); | |
Utils.EndClassRegister(typeof(Foo2Child), L, translator); | |
} | |
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] | |
static int __CreateInstance(RealStatePtr L) | |
{ | |
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); | |
try { | |
if(LuaAPI.lua_gettop(L) == 1) | |
{ | |
Foo2Child __cl_gen_ret = new Foo2Child(); | |
translator.Push(L, __cl_gen_ret); | |
return 1; | |
} | |
} | |
catch(System.Exception __gen_e) { | |
return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); | |
} | |
return LuaAPI.luaL_error(L, "invalid arguments to Foo2Child constructor!"); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if USE_UNI_LUA | |
using LuaAPI = UniLua.Lua; | |
using RealStatePtr = UniLua.ILuaState; | |
using LuaCSFunction = UniLua.CSharpFunctionDelegate; | |
#else | |
using LuaAPI = XLua.LuaDLL.Lua; | |
using RealStatePtr = System.IntPtr; | |
using LuaCSFunction = XLua.LuaDLL.lua_CSFunction; | |
#endif | |
using XLua; | |
using System.Collections.Generic; | |
namespace XLua.CSObjectWrap | |
{ | |
using Utils = XLua.Utils; | |
public class Foo2ParentWrap | |
{ | |
public static void __Register(RealStatePtr L) | |
{ | |
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); | |
Utils.BeginObjectRegister(typeof(Foo2Parent), L, translator, 0, 0, 0, 0); | |
Utils.EndObjectRegister(typeof(Foo2Parent), L, translator, null, null, | |
null, null, null); | |
Utils.BeginClassRegister(typeof(Foo2Parent), L, __CreateInstance, 1, 0, 0); | |
Utils.RegisterObject(L, translator, Utils.CLS_IDX, "UnderlyingSystemType", typeof(Foo2Parent)); | |
Utils.EndClassRegister(typeof(Foo2Parent), L, translator); | |
} | |
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] | |
static int __CreateInstance(RealStatePtr L) | |
{ | |
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); | |
try { | |
if(LuaAPI.lua_gettop(L) == 1) | |
{ | |
Foo2Parent __cl_gen_ret = new Foo2Parent(); | |
translator.Push(L, __cl_gen_ret); | |
return 1; | |
} | |
} | |
catch(System.Exception __gen_e) { | |
return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); | |
} | |
return LuaAPI.luaL_error(L, "invalid arguments to Foo2Parent constructor!"); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if USE_UNI_LUA | |
using LuaAPI = UniLua.Lua; | |
using RealStatePtr = UniLua.ILuaState; | |
using LuaCSFunction = UniLua.CSharpFunctionDelegate; | |
#else | |
using LuaAPI = XLua.LuaDLL.Lua; | |
using RealStatePtr = System.IntPtr; | |
using LuaCSFunction = XLua.LuaDLL.lua_CSFunction; | |
#endif | |
using XLua; | |
using System.Collections.Generic; | |
namespace XLua.CSObjectWrap | |
{ | |
using Utils = XLua.Utils; | |
public class FooExtensionWrap | |
{ | |
public static void __Register(RealStatePtr L) | |
{ | |
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); | |
Utils.BeginObjectRegister(typeof(FooExtension), L, translator, 0, 0, 0, 0); | |
Utils.EndObjectRegister(typeof(FooExtension), L, translator, null, null, | |
null, null, null); | |
Utils.BeginClassRegister(typeof(FooExtension), L, __CreateInstance, 1, 0, 0); | |
Utils.RegisterObject(L, translator, Utils.CLS_IDX, "UnderlyingSystemType", typeof(FooExtension)); | |
Utils.EndClassRegister(typeof(FooExtension), L, translator); | |
} | |
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] | |
static int __CreateInstance(RealStatePtr L) | |
{ | |
return LuaAPI.luaL_error(L, "FooExtension does not have a constructor!"); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if USE_UNI_LUA | |
using LuaAPI = UniLua.Lua; | |
using RealStatePtr = UniLua.ILuaState; | |
using LuaCSFunction = UniLua.CSharpFunctionDelegate; | |
#else | |
using LuaAPI = XLua.LuaDLL.Lua; | |
using RealStatePtr = System.IntPtr; | |
using LuaCSFunction = XLua.LuaDLL.lua_CSFunction; | |
#endif | |
using XLua; | |
using System.Collections.Generic; | |
namespace XLua.CSObjectWrap | |
{ | |
using Utils = XLua.Utils; | |
public class FooWrap | |
{ | |
public static void __Register(RealStatePtr L) | |
{ | |
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); | |
Utils.BeginObjectRegister(typeof(Foo), L, translator, 0, 2, 0, 0); | |
Utils.RegisterFunc(L, Utils.METHOD_IDX, "Test1", _m_Test1); | |
Utils.RegisterFunc(L, Utils.METHOD_IDX, "Test2", _m_Test2); | |
Utils.EndObjectRegister(typeof(Foo), L, translator, null, null, | |
null, null, null); | |
Utils.BeginClassRegister(typeof(Foo), L, __CreateInstance, 1, 0, 0); | |
Utils.RegisterObject(L, translator, Utils.CLS_IDX, "UnderlyingSystemType", typeof(Foo)); | |
Utils.EndClassRegister(typeof(Foo), L, translator); | |
} | |
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] | |
static int __CreateInstance(RealStatePtr L) | |
{ | |
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); | |
try { | |
if(LuaAPI.lua_gettop(L) == 1) | |
{ | |
Foo __cl_gen_ret = new Foo(); | |
translator.Push(L, __cl_gen_ret); | |
return 1; | |
} | |
} | |
catch(System.Exception __gen_e) { | |
return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); | |
} | |
return LuaAPI.luaL_error(L, "invalid arguments to Foo constructor!"); | |
} | |
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] | |
static int _m_Test1(RealStatePtr L) | |
{ | |
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); | |
Foo __cl_gen_to_be_invoked = (Foo)translator.FastGetCSObj(L, 1); | |
try { | |
{ | |
Foo1Parent a = (Foo1Parent)translator.GetObject(L, 2, typeof(Foo1Parent)); | |
__cl_gen_to_be_invoked.Test1( a ); | |
return 0; | |
} | |
} catch(System.Exception __gen_e) { | |
return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); | |
} | |
} | |
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] | |
static int _m_Test2(RealStatePtr L) | |
{ | |
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); | |
Foo __cl_gen_to_be_invoked = (Foo)translator.FastGetCSObj(L, 1); | |
try { | |
{ | |
Foo1Parent a = (Foo1Parent)translator.GetObject(L, 2, typeof(Foo1Parent)); | |
Foo2Parent b = (Foo2Parent)translator.GetObject(L, 3, typeof(Foo2Parent)); | |
UnityEngine.GameObject c = (UnityEngine.GameObject)translator.GetObject(L, 4, typeof(UnityEngine.GameObject)); | |
Foo1Parent __cl_gen_ret = __cl_gen_to_be_invoked.Test2( a, b, c ); | |
translator.Push(L, __cl_gen_ret); | |
return 1; | |
} | |
} catch(System.Exception __gen_e) { | |
return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment