| | |
| | | { |
| | | using Utils = XLua.Utils; |
| | | |
| | | public class XLuaTestMyEnumWrap |
| | | { |
| | | public static void __Register(RealStatePtr L) |
| | | { |
| | | ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); |
| | | Utils.BeginObjectRegister(typeof(XLuaTest.MyEnum), L, translator, 0, 0, 0, 0); |
| | | Utils.EndObjectRegister(typeof(XLuaTest.MyEnum), L, translator, null, null, null, null, null); |
| | | |
| | | Utils.BeginClassRegister(typeof(XLuaTest.MyEnum), L, null, 3, 0, 0); |
| | | |
| | | Utils.RegisterObject(L, translator, Utils.CLS_IDX, "E1", XLuaTest.MyEnum.E1); |
| | | |
| | | Utils.RegisterObject(L, translator, Utils.CLS_IDX, "E2", XLuaTest.MyEnum.E2); |
| | | |
| | | Utils.RegisterFunc(L, Utils.CLS_IDX, "__CastFrom", __CastFrom); |
| | | |
| | | Utils.EndClassRegister(typeof(XLuaTest.MyEnum), L, translator); |
| | | } |
| | | |
| | | [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] |
| | | static int __CastFrom(RealStatePtr L) |
| | | { |
| | | ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); |
| | | LuaTypes lua_type = LuaAPI.lua_type(L, 1); |
| | | if (lua_type == LuaTypes.LUA_TNUMBER) |
| | | { |
| | | translator.PushXLuaTestMyEnum(L, (XLuaTest.MyEnum)LuaAPI.xlua_tointeger(L, 1)); |
| | | } |
| | | |
| | | else if(lua_type == LuaTypes.LUA_TSTRING) |
| | | { |
| | | if (LuaAPI.xlua_is_eq_str(L, 1, "E1")) |
| | | { |
| | | translator.PushXLuaTestMyEnum(L, XLuaTest.MyEnum.E1); |
| | | } |
| | | else if (LuaAPI.xlua_is_eq_str(L, 1, "E2")) |
| | | { |
| | | translator.PushXLuaTestMyEnum(L, XLuaTest.MyEnum.E2); |
| | | } |
| | | else |
| | | { |
| | | return LuaAPI.luaL_error(L, "invalid string for XLuaTest.MyEnum!"); |
| | | } |
| | | } |
| | | |
| | | else |
| | | { |
| | | return LuaAPI.luaL_error(L, "invalid lua type for XLuaTest.MyEnum! Expect number or string, got + " + lua_type); |
| | | } |
| | | |
| | | return 1; |
| | | } |
| | | } |
| | | |
| | | public class TutorialTestEnumWrap |
| | | { |
| | | public static void __Register(RealStatePtr L) |
| | | { |
| | | ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); |
| | | Utils.BeginObjectRegister(typeof(Tutorial.TestEnum), L, translator, 0, 0, 0, 0); |
| | | Utils.EndObjectRegister(typeof(Tutorial.TestEnum), L, translator, null, null, null, null, null); |
| | | |
| | | Utils.BeginClassRegister(typeof(Tutorial.TestEnum), L, null, 3, 0, 0); |
| | | |
| | | Utils.RegisterObject(L, translator, Utils.CLS_IDX, "E1", Tutorial.TestEnum.E1); |
| | | |
| | | Utils.RegisterObject(L, translator, Utils.CLS_IDX, "E2", Tutorial.TestEnum.E2); |
| | | |
| | | Utils.RegisterFunc(L, Utils.CLS_IDX, "__CastFrom", __CastFrom); |
| | | |
| | | Utils.EndClassRegister(typeof(Tutorial.TestEnum), L, translator); |
| | | } |
| | | |
| | | [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] |
| | | static int __CastFrom(RealStatePtr L) |
| | | { |
| | | ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); |
| | | LuaTypes lua_type = LuaAPI.lua_type(L, 1); |
| | | if (lua_type == LuaTypes.LUA_TNUMBER) |
| | | { |
| | | translator.PushTutorialTestEnum(L, (Tutorial.TestEnum)LuaAPI.xlua_tointeger(L, 1)); |
| | | } |
| | | |
| | | else if(lua_type == LuaTypes.LUA_TSTRING) |
| | | { |
| | | if (LuaAPI.xlua_is_eq_str(L, 1, "E1")) |
| | | { |
| | | translator.PushTutorialTestEnum(L, Tutorial.TestEnum.E1); |
| | | } |
| | | else if (LuaAPI.xlua_is_eq_str(L, 1, "E2")) |
| | | { |
| | | translator.PushTutorialTestEnum(L, Tutorial.TestEnum.E2); |
| | | } |
| | | else |
| | | { |
| | | return LuaAPI.luaL_error(L, "invalid string for Tutorial.TestEnum!"); |
| | | } |
| | | } |
| | | |
| | | else |
| | | { |
| | | return LuaAPI.luaL_error(L, "invalid lua type for Tutorial.TestEnum! Expect number or string, got + " + lua_type); |
| | | } |
| | | |
| | | return 1; |
| | | } |
| | | } |
| | | |
| | | public class TutorialDrivenClassTestEnumInnerWrap |
| | | { |
| | | public static void __Register(RealStatePtr L) |
| | | { |
| | | ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); |
| | | Utils.BeginObjectRegister(typeof(Tutorial.DrivenClass.TestEnumInner), L, translator, 0, 0, 0, 0); |
| | | Utils.EndObjectRegister(typeof(Tutorial.DrivenClass.TestEnumInner), L, translator, null, null, null, null, null); |
| | | |
| | | Utils.BeginClassRegister(typeof(Tutorial.DrivenClass.TestEnumInner), L, null, 3, 0, 0); |
| | | |
| | | Utils.RegisterObject(L, translator, Utils.CLS_IDX, "E3", Tutorial.DrivenClass.TestEnumInner.E3); |
| | | |
| | | Utils.RegisterObject(L, translator, Utils.CLS_IDX, "E4", Tutorial.DrivenClass.TestEnumInner.E4); |
| | | |
| | | Utils.RegisterFunc(L, Utils.CLS_IDX, "__CastFrom", __CastFrom); |
| | | |
| | | Utils.EndClassRegister(typeof(Tutorial.DrivenClass.TestEnumInner), L, translator); |
| | | } |
| | | |
| | | [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] |
| | | static int __CastFrom(RealStatePtr L) |
| | | { |
| | | ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); |
| | | LuaTypes lua_type = LuaAPI.lua_type(L, 1); |
| | | if (lua_type == LuaTypes.LUA_TNUMBER) |
| | | { |
| | | translator.PushTutorialDrivenClassTestEnumInner(L, (Tutorial.DrivenClass.TestEnumInner)LuaAPI.xlua_tointeger(L, 1)); |
| | | } |
| | | |
| | | else if(lua_type == LuaTypes.LUA_TSTRING) |
| | | { |
| | | if (LuaAPI.xlua_is_eq_str(L, 1, "E3")) |
| | | { |
| | | translator.PushTutorialDrivenClassTestEnumInner(L, Tutorial.DrivenClass.TestEnumInner.E3); |
| | | } |
| | | else if (LuaAPI.xlua_is_eq_str(L, 1, "E4")) |
| | | { |
| | | translator.PushTutorialDrivenClassTestEnumInner(L, Tutorial.DrivenClass.TestEnumInner.E4); |
| | | } |
| | | else |
| | | { |
| | | return LuaAPI.luaL_error(L, "invalid string for Tutorial.DrivenClass.TestEnumInner!"); |
| | | } |
| | | } |
| | | |
| | | else |
| | | { |
| | | return LuaAPI.luaL_error(L, "invalid lua type for Tutorial.DrivenClass.TestEnumInner! Expect number or string, got + " + lua_type); |
| | | } |
| | | |
| | | return 1; |
| | | } |
| | | } |
| | | |
| | | } |