更新Xlua 到最新版本
This commit is contained in:
@ -16,4 +16,120 @@ namespace XLua.CSObjectWrap
|
||||
{
|
||||
using Utils = XLua.Utils;
|
||||
|
||||
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 TutorialDerivedClassTestEnumInnerWrap
|
||||
{
|
||||
public static void __Register(RealStatePtr L)
|
||||
{
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
Utils.BeginObjectRegister(typeof(Tutorial.DerivedClass.TestEnumInner), L, translator, 0, 0, 0, 0);
|
||||
Utils.EndObjectRegister(typeof(Tutorial.DerivedClass.TestEnumInner), L, translator, null, null, null, null, null);
|
||||
|
||||
Utils.BeginClassRegister(typeof(Tutorial.DerivedClass.TestEnumInner), L, null, 3, 0, 0);
|
||||
|
||||
|
||||
Utils.RegisterObject(L, translator, Utils.CLS_IDX, "E3", Tutorial.DerivedClass.TestEnumInner.E3);
|
||||
|
||||
Utils.RegisterObject(L, translator, Utils.CLS_IDX, "E4", Tutorial.DerivedClass.TestEnumInner.E4);
|
||||
|
||||
|
||||
Utils.RegisterFunc(L, Utils.CLS_IDX, "__CastFrom", __CastFrom);
|
||||
|
||||
Utils.EndClassRegister(typeof(Tutorial.DerivedClass.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.PushTutorialDerivedClassTestEnumInner(L, (Tutorial.DerivedClass.TestEnumInner)LuaAPI.xlua_tointeger(L, 1));
|
||||
}
|
||||
|
||||
else if(lua_type == LuaTypes.LUA_TSTRING)
|
||||
{
|
||||
|
||||
if (LuaAPI.xlua_is_eq_str(L, 1, "E3"))
|
||||
{
|
||||
translator.PushTutorialDerivedClassTestEnumInner(L, Tutorial.DerivedClass.TestEnumInner.E3);
|
||||
}
|
||||
else if (LuaAPI.xlua_is_eq_str(L, 1, "E4"))
|
||||
{
|
||||
translator.PushTutorialDerivedClassTestEnumInner(L, Tutorial.DerivedClass.TestEnumInner.E4);
|
||||
}
|
||||
else
|
||||
{
|
||||
return LuaAPI.luaL_error(L, "invalid string for Tutorial.DerivedClass.TestEnumInner!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
return LuaAPI.luaL_error(L, "invalid lua type for Tutorial.DerivedClass.TestEnumInner! Expect number or string, got + " + lua_type);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user