From e9e5a578aa10ba9abd95ebbe3d5e719a9bbe9079 Mon Sep 17 00:00:00 2001 From: chenxi Date: Thu, 1 Jun 2023 10:28:19 +0800 Subject: [PATCH] xlua --- Assets/Editor/LuaGenConfig.cs | 2 + Assets/XLua/Gen/BF_BFGridLayoutWrap.cs | 4 +- Assets/XLua/Gen/EnumWrap.cs | 134 +++++++++++++++++ Assets/XLua/Gen/WrapPusher.cs | 194 +++++++++++++++++++++++++ Assets/XLua/Gen/XLuaGenAutoRegister.cs | 6 + Assets/XLua/Gen/link.xml | 2 + 6 files changed, 340 insertions(+), 2 deletions(-) diff --git a/Assets/Editor/LuaGenConfig.cs b/Assets/Editor/LuaGenConfig.cs index adaf29d6b..740644436 100644 --- a/Assets/Editor/LuaGenConfig.cs +++ b/Assets/Editor/LuaGenConfig.cs @@ -452,6 +452,8 @@ namespace BFEditor typeof(BF.ScrollRectBaseOld.ScrollbarVisibility), typeof(BF.NetServiceType), typeof(BF.NetIncomingMessageType), + typeof(BF.BFGridLayout.Corner), + typeof(BF.BFGridLayout.Constraint), }; return unityTypes.Concat(customTypes).Concat(otherTypes); } diff --git a/Assets/XLua/Gen/BF_BFGridLayoutWrap.cs b/Assets/XLua/Gen/BF_BFGridLayoutWrap.cs index b3b735d93..9f6fa0369 100644 --- a/Assets/XLua/Gen/BF_BFGridLayoutWrap.cs +++ b/Assets/XLua/Gen/BF_BFGridLayoutWrap.cs @@ -205,7 +205,7 @@ namespace XLua.CSObjectWrap ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); BF.BFGridLayout gen_to_be_invoked = (BF.BFGridLayout)translator.FastGetCSObj(L, 1); - translator.Push(L, gen_to_be_invoked.StartCorner); + translator.PushBFBFGridLayoutCorner(L, gen_to_be_invoked.StartCorner); } catch(System.Exception gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + gen_e); } @@ -219,7 +219,7 @@ namespace XLua.CSObjectWrap ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); BF.BFGridLayout gen_to_be_invoked = (BF.BFGridLayout)translator.FastGetCSObj(L, 1); - translator.Push(L, gen_to_be_invoked.ConstraintType); + translator.PushBFBFGridLayoutConstraint(L, gen_to_be_invoked.ConstraintType); } catch(System.Exception gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + gen_e); } diff --git a/Assets/XLua/Gen/EnumWrap.cs b/Assets/XLua/Gen/EnumWrap.cs index 664ff1cb9..7f909c92c 100644 --- a/Assets/XLua/Gen/EnumWrap.cs +++ b/Assets/XLua/Gen/EnumWrap.cs @@ -5442,4 +5442,138 @@ namespace XLua.CSObjectWrap } } + public class BFBFGridLayoutCornerWrap + { + public static void __Register(RealStatePtr L) + { + ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); + Utils.BeginObjectRegister(typeof(BF.BFGridLayout.Corner), L, translator, 0, 0, 0, 0); + Utils.EndObjectRegister(typeof(BF.BFGridLayout.Corner), L, translator, null, null, null, null, null); + + Utils.BeginClassRegister(typeof(BF.BFGridLayout.Corner), L, null, 5, 0, 0); + + + Utils.RegisterObject(L, translator, Utils.CLS_IDX, "UpperLeft", BF.BFGridLayout.Corner.UpperLeft); + + Utils.RegisterObject(L, translator, Utils.CLS_IDX, "UpperRight", BF.BFGridLayout.Corner.UpperRight); + + Utils.RegisterObject(L, translator, Utils.CLS_IDX, "LowerLeft", BF.BFGridLayout.Corner.LowerLeft); + + Utils.RegisterObject(L, translator, Utils.CLS_IDX, "LowerRight", BF.BFGridLayout.Corner.LowerRight); + + + Utils.RegisterFunc(L, Utils.CLS_IDX, "__CastFrom", __CastFrom); + + Utils.EndClassRegister(typeof(BF.BFGridLayout.Corner), 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.PushBFBFGridLayoutCorner(L, (BF.BFGridLayout.Corner)LuaAPI.xlua_tointeger(L, 1)); + } + + else if(lua_type == LuaTypes.LUA_TSTRING) + { + + if (LuaAPI.xlua_is_eq_str(L, 1, "UpperLeft")) + { + translator.PushBFBFGridLayoutCorner(L, BF.BFGridLayout.Corner.UpperLeft); + } + else if (LuaAPI.xlua_is_eq_str(L, 1, "UpperRight")) + { + translator.PushBFBFGridLayoutCorner(L, BF.BFGridLayout.Corner.UpperRight); + } + else if (LuaAPI.xlua_is_eq_str(L, 1, "LowerLeft")) + { + translator.PushBFBFGridLayoutCorner(L, BF.BFGridLayout.Corner.LowerLeft); + } + else if (LuaAPI.xlua_is_eq_str(L, 1, "LowerRight")) + { + translator.PushBFBFGridLayoutCorner(L, BF.BFGridLayout.Corner.LowerRight); + } + else + { + return LuaAPI.luaL_error(L, "invalid string for BF.BFGridLayout.Corner!"); + } + + } + + else + { + return LuaAPI.luaL_error(L, "invalid lua type for BF.BFGridLayout.Corner! Expect number or string, got + " + lua_type); + } + + return 1; + } + } + + public class BFBFGridLayoutConstraintWrap + { + public static void __Register(RealStatePtr L) + { + ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); + Utils.BeginObjectRegister(typeof(BF.BFGridLayout.Constraint), L, translator, 0, 0, 0, 0); + Utils.EndObjectRegister(typeof(BF.BFGridLayout.Constraint), L, translator, null, null, null, null, null); + + Utils.BeginClassRegister(typeof(BF.BFGridLayout.Constraint), L, null, 4, 0, 0); + + + Utils.RegisterObject(L, translator, Utils.CLS_IDX, "Flexible", BF.BFGridLayout.Constraint.Flexible); + + Utils.RegisterObject(L, translator, Utils.CLS_IDX, "FixedColumnCount", BF.BFGridLayout.Constraint.FixedColumnCount); + + Utils.RegisterObject(L, translator, Utils.CLS_IDX, "FixedRowCount", BF.BFGridLayout.Constraint.FixedRowCount); + + + Utils.RegisterFunc(L, Utils.CLS_IDX, "__CastFrom", __CastFrom); + + Utils.EndClassRegister(typeof(BF.BFGridLayout.Constraint), 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.PushBFBFGridLayoutConstraint(L, (BF.BFGridLayout.Constraint)LuaAPI.xlua_tointeger(L, 1)); + } + + else if(lua_type == LuaTypes.LUA_TSTRING) + { + + if (LuaAPI.xlua_is_eq_str(L, 1, "Flexible")) + { + translator.PushBFBFGridLayoutConstraint(L, BF.BFGridLayout.Constraint.Flexible); + } + else if (LuaAPI.xlua_is_eq_str(L, 1, "FixedColumnCount")) + { + translator.PushBFBFGridLayoutConstraint(L, BF.BFGridLayout.Constraint.FixedColumnCount); + } + else if (LuaAPI.xlua_is_eq_str(L, 1, "FixedRowCount")) + { + translator.PushBFBFGridLayoutConstraint(L, BF.BFGridLayout.Constraint.FixedRowCount); + } + else + { + return LuaAPI.luaL_error(L, "invalid string for BF.BFGridLayout.Constraint!"); + } + + } + + else + { + return LuaAPI.luaL_error(L, "invalid lua type for BF.BFGridLayout.Constraint! Expect number or string, got + " + lua_type); + } + + return 1; + } + } + } \ No newline at end of file diff --git a/Assets/XLua/Gen/WrapPusher.cs b/Assets/XLua/Gen/WrapPusher.cs index 2b82e4d96..bb5ec3755 100644 --- a/Assets/XLua/Gen/WrapPusher.cs +++ b/Assets/XLua/Gen/WrapPusher.cs @@ -110,6 +110,8 @@ namespace XLua translator.RegisterPushAndGetAndUpdate(translator.PushBFScrollRectBaseOldScrollbarVisibility, translator.Get, translator.UpdateBFScrollRectBaseOldScrollbarVisibility); translator.RegisterPushAndGetAndUpdate(translator.PushBFNetServiceType, translator.Get, translator.UpdateBFNetServiceType); translator.RegisterPushAndGetAndUpdate(translator.PushBFNetIncomingMessageType, translator.Get, translator.UpdateBFNetIncomingMessageType); + translator.RegisterPushAndGetAndUpdate(translator.PushBFBFGridLayoutCorner, translator.Get, translator.UpdateBFBFGridLayoutCorner); + translator.RegisterPushAndGetAndUpdate(translator.PushBFBFGridLayoutConstraint, translator.Get, translator.UpdateBFBFGridLayoutConstraint); } } @@ -7030,6 +7032,174 @@ namespace XLua } } + int BFBFGridLayoutCorner_TypeID = -1; + int BFBFGridLayoutCorner_EnumRef = -1; + + public void PushBFBFGridLayoutCorner(RealStatePtr L, BF.BFGridLayout.Corner val) + { + if (BFBFGridLayoutCorner_TypeID == -1) + { + bool is_first; + BFBFGridLayoutCorner_TypeID = getTypeId(L, typeof(BF.BFGridLayout.Corner), out is_first); + + if (BFBFGridLayoutCorner_EnumRef == -1) + { + Utils.LoadCSTable(L, typeof(BF.BFGridLayout.Corner)); + BFBFGridLayoutCorner_EnumRef = LuaAPI.luaL_ref(L, LuaIndexes.LUA_REGISTRYINDEX); + } + + } + + if (LuaAPI.xlua_tryget_cachedud(L, (int)val, BFBFGridLayoutCorner_EnumRef) == 1) + { + return; + } + + IntPtr buff = LuaAPI.xlua_pushstruct(L, 4, BFBFGridLayoutCorner_TypeID); + if (!CopyByValue.Pack(buff, 0, (int)val)) + { + throw new Exception("pack fail fail for BF.BFGridLayout.Corner ,value="+val); + } + + LuaAPI.lua_getref(L, BFBFGridLayoutCorner_EnumRef); + LuaAPI.lua_pushvalue(L, -2); + LuaAPI.xlua_rawseti(L, -2, (int)val); + LuaAPI.lua_pop(L, 1); + + } + + public void Get(RealStatePtr L, int index, out BF.BFGridLayout.Corner val) + { + LuaTypes type = LuaAPI.lua_type(L, index); + if (type == LuaTypes.LUA_TUSERDATA ) + { + if (LuaAPI.xlua_gettypeid(L, index) != BFBFGridLayoutCorner_TypeID) + { + throw new Exception("invalid userdata for BF.BFGridLayout.Corner"); + } + + IntPtr buff = LuaAPI.lua_touserdata(L, index); + int e; + if (!CopyByValue.UnPack(buff, 0, out e)) + { + throw new Exception("unpack fail for BF.BFGridLayout.Corner"); + } + val = (BF.BFGridLayout.Corner)e; + + } + else + { + val = (BF.BFGridLayout.Corner)objectCasters.GetCaster(typeof(BF.BFGridLayout.Corner))(L, index, null); + } + } + + public void UpdateBFBFGridLayoutCorner(RealStatePtr L, int index, BF.BFGridLayout.Corner val) + { + + if (LuaAPI.lua_type(L, index) == LuaTypes.LUA_TUSERDATA) + { + if (LuaAPI.xlua_gettypeid(L, index) != BFBFGridLayoutCorner_TypeID) + { + throw new Exception("invalid userdata for BF.BFGridLayout.Corner"); + } + + IntPtr buff = LuaAPI.lua_touserdata(L, index); + if (!CopyByValue.Pack(buff, 0, (int)val)) + { + throw new Exception("pack fail for BF.BFGridLayout.Corner ,value="+val); + } + } + + else + { + throw new Exception("try to update a data with lua type:" + LuaAPI.lua_type(L, index)); + } + } + + int BFBFGridLayoutConstraint_TypeID = -1; + int BFBFGridLayoutConstraint_EnumRef = -1; + + public void PushBFBFGridLayoutConstraint(RealStatePtr L, BF.BFGridLayout.Constraint val) + { + if (BFBFGridLayoutConstraint_TypeID == -1) + { + bool is_first; + BFBFGridLayoutConstraint_TypeID = getTypeId(L, typeof(BF.BFGridLayout.Constraint), out is_first); + + if (BFBFGridLayoutConstraint_EnumRef == -1) + { + Utils.LoadCSTable(L, typeof(BF.BFGridLayout.Constraint)); + BFBFGridLayoutConstraint_EnumRef = LuaAPI.luaL_ref(L, LuaIndexes.LUA_REGISTRYINDEX); + } + + } + + if (LuaAPI.xlua_tryget_cachedud(L, (int)val, BFBFGridLayoutConstraint_EnumRef) == 1) + { + return; + } + + IntPtr buff = LuaAPI.xlua_pushstruct(L, 4, BFBFGridLayoutConstraint_TypeID); + if (!CopyByValue.Pack(buff, 0, (int)val)) + { + throw new Exception("pack fail fail for BF.BFGridLayout.Constraint ,value="+val); + } + + LuaAPI.lua_getref(L, BFBFGridLayoutConstraint_EnumRef); + LuaAPI.lua_pushvalue(L, -2); + LuaAPI.xlua_rawseti(L, -2, (int)val); + LuaAPI.lua_pop(L, 1); + + } + + public void Get(RealStatePtr L, int index, out BF.BFGridLayout.Constraint val) + { + LuaTypes type = LuaAPI.lua_type(L, index); + if (type == LuaTypes.LUA_TUSERDATA ) + { + if (LuaAPI.xlua_gettypeid(L, index) != BFBFGridLayoutConstraint_TypeID) + { + throw new Exception("invalid userdata for BF.BFGridLayout.Constraint"); + } + + IntPtr buff = LuaAPI.lua_touserdata(L, index); + int e; + if (!CopyByValue.UnPack(buff, 0, out e)) + { + throw new Exception("unpack fail for BF.BFGridLayout.Constraint"); + } + val = (BF.BFGridLayout.Constraint)e; + + } + else + { + val = (BF.BFGridLayout.Constraint)objectCasters.GetCaster(typeof(BF.BFGridLayout.Constraint))(L, index, null); + } + } + + public void UpdateBFBFGridLayoutConstraint(RealStatePtr L, int index, BF.BFGridLayout.Constraint val) + { + + if (LuaAPI.lua_type(L, index) == LuaTypes.LUA_TUSERDATA) + { + if (LuaAPI.xlua_gettypeid(L, index) != BFBFGridLayoutConstraint_TypeID) + { + throw new Exception("invalid userdata for BF.BFGridLayout.Constraint"); + } + + IntPtr buff = LuaAPI.lua_touserdata(L, index); + if (!CopyByValue.Pack(buff, 0, (int)val)) + { + throw new Exception("pack fail for BF.BFGridLayout.Constraint ,value="+val); + } + } + + else + { + throw new Exception("try to update a data with lua type:" + LuaAPI.lua_type(L, index)); + } + } + // table cast optimze @@ -7545,6 +7715,18 @@ namespace XLua translator.PushBFNetIncomingMessageType(L, array[index]); return true; } + else if (type == typeof(BF.BFGridLayout.Corner[])) + { + BF.BFGridLayout.Corner[] array = obj as BF.BFGridLayout.Corner[]; + translator.PushBFBFGridLayoutCorner(L, array[index]); + return true; + } + else if (type == typeof(BF.BFGridLayout.Constraint[])) + { + BF.BFGridLayout.Constraint[] array = obj as BF.BFGridLayout.Constraint[]; + translator.PushBFBFGridLayoutConstraint(L, array[index]); + return true; + } return false; } @@ -8055,6 +8237,18 @@ namespace XLua translator.Get(L, obj_idx, out array[array_idx]); return true; } + else if (type == typeof(BF.BFGridLayout.Corner[])) + { + BF.BFGridLayout.Corner[] array = obj as BF.BFGridLayout.Corner[]; + translator.Get(L, obj_idx, out array[array_idx]); + return true; + } + else if (type == typeof(BF.BFGridLayout.Constraint[])) + { + BF.BFGridLayout.Constraint[] array = obj as BF.BFGridLayout.Constraint[]; + translator.Get(L, obj_idx, out array[array_idx]); + return true; + } return false; } } diff --git a/Assets/XLua/Gen/XLuaGenAutoRegister.cs b/Assets/XLua/Gen/XLuaGenAutoRegister.cs index 9a89bca8e..c01ff7616 100644 --- a/Assets/XLua/Gen/XLuaGenAutoRegister.cs +++ b/Assets/XLua/Gen/XLuaGenAutoRegister.cs @@ -3047,6 +3047,12 @@ namespace XLua.CSObjectWrap translator.DelayWrapLoader(typeof(BF.NetIncomingMessageType), BFNetIncomingMessageTypeWrap.__Register); + translator.DelayWrapLoader(typeof(BF.BFGridLayout.Corner), BFBFGridLayoutCornerWrap.__Register); + + + translator.DelayWrapLoader(typeof(BF.BFGridLayout.Constraint), BFBFGridLayoutConstraintWrap.__Register); + + } diff --git a/Assets/XLua/Gen/link.xml b/Assets/XLua/Gen/link.xml index c8006180a..487ec2815 100644 --- a/Assets/XLua/Gen/link.xml +++ b/Assets/XLua/Gen/link.xml @@ -316,6 +316,8 @@ + +