public void UpdateXLuaTestMyEnum(RealStatePtr L, int index, XLuaTest.MyEnum val) { if (LuaAPI.lua_type(L, index) == LuaTypes.LUA_TUSERDATA) { if (LuaAPI.xlua_gettypeid(L, index) != XLuaTestMyEnum_TypeID) { throw new Exception("invalid userdata for XLuaTest.MyEnum"); } IntPtr buff = LuaAPI.lua_touserdata(L, index); if (!CopyByValue.Pack(buff, 0, (int)val)) { throw new Exception("pack fail for XLuaTest.MyEnum ,value=" + val); } } else { throw new Exception("try to update a data with lua type:" + LuaAPI.lua_type(L, index)); } }
public void UpdateUnityEngineColor(RealStatePtr L, int index, UnityEngine.Color val) { if (LuaAPI.lua_type(L, index) == LuaTypes.LUA_TUSERDATA) { if (LuaAPI.xlua_gettypeid(L, index) != UnityEngineColor_TypeID) { throw new Exception("invalid userdata for UnityEngine.Color"); } IntPtr buff = LuaAPI.lua_touserdata(L, index); if (!CopyByValue.Pack(buff, 0, val)) { throw new Exception("pack fail for UnityEngine.Color ,value=" + val); } } else { throw new Exception("try to update a data with lua type:" + LuaAPI.lua_type(L, index)); } }
public void UpdateMinecraftBlocksDataBlockVertexType(RealStatePtr L, int index, Minecraft.BlocksData.BlockVertexType val) { if (LuaAPI.lua_type(L, index) == LuaTypes.LUA_TUSERDATA) { if (LuaAPI.xlua_gettypeid(L, index) != MinecraftBlocksDataBlockVertexType_TypeID) { throw new Exception("invalid userdata for Minecraft.BlocksData.BlockVertexType"); } IntPtr buff = LuaAPI.lua_touserdata(L, index); if (!CopyByValue.Pack(buff, 0, (int)val)) { throw new Exception("pack fail for Minecraft.BlocksData.BlockVertexType ,value=" + val); } } else { throw new Exception("try to update a data with lua type:" + LuaAPI.lua_type(L, index)); } }
public void UpdateVVMUIScriptXLuaXLuaCommandType(RealStatePtr L, int index, VVMUI.Script.XLua.XLuaCommandType val) { if (LuaAPI.lua_type(L, index) == LuaTypes.LUA_TUSERDATA) { if (LuaAPI.xlua_gettypeid(L, index) != VVMUIScriptXLuaXLuaCommandType_TypeID) { throw new Exception("invalid userdata for VVMUI.Script.XLua.XLuaCommandType"); } IntPtr buff = LuaAPI.lua_touserdata(L, index); if (!CopyByValue.Pack(buff, 0, (int)val)) { throw new Exception("pack fail for VVMUI.Script.XLua.XLuaCommandType ,value=" + val); } } else { throw new Exception("try to update a data with lua type:" + LuaAPI.lua_type(L, index)); } }
public void UpdateUtopiaLogLevel(RealStatePtr L, int index, Utopia.LogLevel val) { if (LuaAPI.lua_type(L, index) == LuaTypes.LUA_TUSERDATA) { if (LuaAPI.xlua_gettypeid(L, index) != UtopiaLogLevel_TypeID) { throw new Exception("invalid userdata for Utopia.LogLevel"); } IntPtr buff = LuaAPI.lua_touserdata(L, index); if (!CopyByValue.Pack(buff, 0, (int)val)) { throw new Exception("pack fail for Utopia.LogLevel ,value=" + val); } } else { throw new Exception("try to update a data with lua type:" + LuaAPI.lua_type(L, index)); } }
public void UpdateSystemReflectionBindingFlags(RealStatePtr L, int index, System.Reflection.BindingFlags val) { if (LuaAPI.lua_type(L, index) == LuaTypes.LUA_TUSERDATA) { if (LuaAPI.xlua_gettypeid(L, index) != SystemReflectionBindingFlags_TypeID) { throw new Exception("invalid userdata for System.Reflection.BindingFlags"); } IntPtr buff = LuaAPI.lua_touserdata(L, index); if (!CopyByValue.Pack(buff, 0, (int)val)) { throw new Exception("pack fail for System.Reflection.BindingFlags ,value=" + val); } } else { throw new Exception("try to update a data with lua type:" + LuaAPI.lua_type(L, index)); } }
public void UpdateResourcePrioritizedCacheLoadPriority(RealStatePtr L, int index, ResourcePrioritizedCache.LoadPriority val) { if (LuaAPI.lua_type(L, index) == LuaTypes.LUA_TUSERDATA) { if (LuaAPI.xlua_gettypeid(L, index) != ResourcePrioritizedCacheLoadPriority_TypeID) { throw new Exception("invalid userdata for ResourcePrioritizedCache.LoadPriority"); } IntPtr buff = LuaAPI.lua_touserdata(L, index); if (!CopyByValue.Pack(buff, 0, (int)val)) { throw new Exception("pack fail for ResourcePrioritizedCache.LoadPriority ,value=" + val); } } else { throw new Exception("try to update a data with lua type:" + LuaAPI.lua_type(L, index)); } }
public void UpdateUnityEngineUICanvasScalerScreenMatchMode(RealStatePtr L, int index, UnityEngine.UI.CanvasScaler.ScreenMatchMode val) { if (LuaAPI.lua_type(L, index) == LuaTypes.LUA_TUSERDATA) { if (LuaAPI.xlua_gettypeid(L, index) != UnityEngineUICanvasScalerScreenMatchMode_TypeID) { throw new Exception("invalid userdata for UnityEngine.UI.CanvasScaler.ScreenMatchMode"); } IntPtr buff = LuaAPI.lua_touserdata(L, index); if (!CopyByValue.Pack(buff, 0, (int)val)) { throw new Exception("pack fail for UnityEngine.UI.CanvasScaler.ScreenMatchMode ,value=" + val); } } else { throw new Exception("try to update a data with lua type:" + LuaAPI.lua_type(L, index)); } }
public void UpdateIFrameworkHotfixLuaMyStruct(RealStatePtr L, int index, IFramework.Hotfix.Lua.MyStruct val) { if (LuaAPI.lua_type(L, index) == LuaTypes.LUA_TUSERDATA) { if (LuaAPI.xlua_gettypeid(L, index) != IFrameworkHotfixLuaMyStruct_TypeID) { throw new Exception("invalid userdata for IFramework.Hotfix.Lua.MyStruct"); } IntPtr buff = LuaAPI.lua_touserdata(L, index); if (!CopyByValue.Pack(buff, 0, val)) { throw new Exception("pack fail for IFramework.Hotfix.Lua.MyStruct ,value=" + val); } } else { throw new Exception("try to update a data with lua type:" + LuaAPI.lua_type(L, index)); } }
public void UpdateTutorialDerivedClassTestEnumInner(RealStatePtr L, int index, Tutorial.DerivedClass.TestEnumInner val) { if (LuaAPI.lua_type(L, index) == LuaTypes.LUA_TUSERDATA) { if (LuaAPI.xlua_gettypeid(L, index) != TutorialDerivedClassTestEnumInner_TypeID) { throw new Exception("invalid userdata for Tutorial.DerivedClass.TestEnumInner"); } IntPtr buff = LuaAPI.lua_touserdata(L, index); if (!CopyByValue.Pack(buff, 0, (int)val)) { throw new Exception("pack fail for Tutorial.DerivedClass.TestEnumInner ,value=" + val); } } else { throw new Exception("try to update a data with lua type:" + LuaAPI.lua_type(L, index)); } }
public void Get(RealStatePtr L, int index, out System.Reflection.BindingFlags val) { LuaTypes type = LuaAPI.lua_type(L, index); if (type == LuaTypes.LUA_TUSERDATA) { if (LuaAPI.xlua_gettypeid(L, index) != SystemReflectionBindingFlags_TypeID) { throw new Exception("invalid userdata for System.Reflection.BindingFlags"); } IntPtr buff = LuaAPI.lua_touserdata(L, index); int e; if (!CopyByValue.UnPack(buff, 0, out e)) { throw new Exception("unpack fail for System.Reflection.BindingFlags"); } val = (System.Reflection.BindingFlags)e; } else { val = (System.Reflection.BindingFlags)objectCasters.GetCaster(typeof(System.Reflection.BindingFlags))(L, index, null); } }
public void Get(RealStatePtr L, int index, out Minecraft.BlocksData.BlockVertexType val) { LuaTypes type = LuaAPI.lua_type(L, index); if (type == LuaTypes.LUA_TUSERDATA) { if (LuaAPI.xlua_gettypeid(L, index) != MinecraftBlocksDataBlockVertexType_TypeID) { throw new Exception("invalid userdata for Minecraft.BlocksData.BlockVertexType"); } IntPtr buff = LuaAPI.lua_touserdata(L, index); int e; if (!CopyByValue.UnPack(buff, 0, out e)) { throw new Exception("unpack fail for Minecraft.BlocksData.BlockVertexType"); } val = (Minecraft.BlocksData.BlockVertexType)e; } else { val = (Minecraft.BlocksData.BlockVertexType)objectCasters.GetCaster(typeof(Minecraft.BlocksData.BlockVertexType))(L, index, null); } }
public void Get(RealStatePtr L, int index, out ResourcePrioritizedCache.LoadPriority val) { LuaTypes type = LuaAPI.lua_type(L, index); if (type == LuaTypes.LUA_TUSERDATA) { if (LuaAPI.xlua_gettypeid(L, index) != ResourcePrioritizedCacheLoadPriority_TypeID) { throw new Exception("invalid userdata for ResourcePrioritizedCache.LoadPriority"); } IntPtr buff = LuaAPI.lua_touserdata(L, index); int e; if (!CopyByValue.UnPack(buff, 0, out e)) { throw new Exception("unpack fail for ResourcePrioritizedCache.LoadPriority"); } val = (ResourcePrioritizedCache.LoadPriority)e; } else { val = (ResourcePrioritizedCache.LoadPriority)objectCasters.GetCaster(typeof(ResourcePrioritizedCache.LoadPriority))(L, index, null); } }
public void Get(RealStatePtr L, int index, out System.Net.Sockets.ProtocolType val) { LuaTypes type = LuaAPI.lua_type(L, index); if (type == LuaTypes.LUA_TUSERDATA) { if (LuaAPI.xlua_gettypeid(L, index) != SystemNetSocketsProtocolType_TypeID) { throw new Exception("invalid userdata for System.Net.Sockets.ProtocolType"); } IntPtr buff = LuaAPI.lua_touserdata(L, index); int e; if (!CopyByValue.UnPack(buff, 0, out e)) { throw new Exception("unpack fail for System.Net.Sockets.ProtocolType"); } val = (System.Net.Sockets.ProtocolType)e; } else { val = (System.Net.Sockets.ProtocolType)objectCasters.GetCaster(typeof(System.Net.Sockets.ProtocolType))(L, index, null); } }
public void Get(RealStatePtr L, int index, out Tutorial.DrivenClass.TestEnumInner val) { LuaTypes type = LuaAPI.lua_type(L, index); if (type == LuaTypes.LUA_TUSERDATA) { if (LuaAPI.xlua_gettypeid(L, index) != TutorialDrivenClassTestEnumInner_TypeID) { throw new Exception("invalid userdata for Tutorial.DrivenClass.TestEnumInner"); } IntPtr buff = LuaAPI.lua_touserdata(L, index); int e; if (!CopyByValue.UnPack(buff, 0, out e)) { throw new Exception("unpack fail for Tutorial.DrivenClass.TestEnumInner"); } val = (Tutorial.DrivenClass.TestEnumInner)e; } else { val = (Tutorial.DrivenClass.TestEnumInner)objectCasters.GetCaster(typeof(Tutorial.DrivenClass.TestEnumInner))(L, index, null); } }
public void Get(RealStatePtr L, int index, out VVMUI.Script.XLua.XLuaCommandType val) { LuaTypes type = LuaAPI.lua_type(L, index); if (type == LuaTypes.LUA_TUSERDATA) { if (LuaAPI.xlua_gettypeid(L, index) != VVMUIScriptXLuaXLuaCommandType_TypeID) { throw new Exception("invalid userdata for VVMUI.Script.XLua.XLuaCommandType"); } IntPtr buff = LuaAPI.lua_touserdata(L, index); int e; if (!CopyByValue.UnPack(buff, 0, out e)) { throw new Exception("unpack fail for VVMUI.Script.XLua.XLuaCommandType"); } val = (VVMUI.Script.XLua.XLuaCommandType)e; } else { val = (VVMUI.Script.XLua.XLuaCommandType)objectCasters.GetCaster(typeof(VVMUI.Script.XLua.XLuaCommandType))(L, index, null); } }
public void Get(RealStatePtr L, int index, out XLuaTest.MyEnum val) { LuaTypes type = LuaAPI.lua_type(L, index); if (type == LuaTypes.LUA_TUSERDATA) { if (LuaAPI.xlua_gettypeid(L, index) != XLuaTestMyEnum_TypeID) { throw new Exception("invalid userdata for XLuaTest.MyEnum"); } IntPtr buff = LuaAPI.lua_touserdata(L, index); int e; if (!CopyByValue.UnPack(buff, 0, out e)) { throw new Exception("unpack fail for XLuaTest.MyEnum"); } val = (XLuaTest.MyEnum)e; } else { val = (XLuaTest.MyEnum)objectCasters.GetCaster(typeof(XLuaTest.MyEnum))(L, index, null); } }
public void Get(RealStatePtr L, int index, out DotEngine.UI.UILayerLevel val) { LuaTypes type = LuaAPI.lua_type(L, index); if (type == LuaTypes.LUA_TUSERDATA) { if (LuaAPI.xlua_gettypeid(L, index) != DotEngineUIUILayerLevel_TypeID) { throw new Exception("invalid userdata for DotEngine.UI.UILayerLevel"); } IntPtr buff = LuaAPI.lua_touserdata(L, index); int e; if (!CopyByValue.UnPack(buff, 0, out e)) { throw new Exception("unpack fail for DotEngine.UI.UILayerLevel"); } val = (DotEngine.UI.UILayerLevel)e; } else { val = (DotEngine.UI.UILayerLevel)objectCasters.GetCaster(typeof(DotEngine.UI.UILayerLevel))(L, index, null); } }
public void Get(RealStatePtr L, int index, out UnityEngine.SystemLanguage val) { LuaTypes type = LuaAPI.lua_type(L, index); if (type == LuaTypes.LUA_TUSERDATA) { if (LuaAPI.xlua_gettypeid(L, index) != UnityEngineSystemLanguage_TypeID) { throw new Exception("invalid userdata for UnityEngine.SystemLanguage"); } IntPtr buff = LuaAPI.lua_touserdata(L, index); int e; if (!CopyByValue.UnPack(buff, 0, out e)) { throw new Exception("unpack fail for UnityEngine.SystemLanguage"); } val = (UnityEngine.SystemLanguage)e; } else { val = (UnityEngine.SystemLanguage)objectCasters.GetCaster(typeof(UnityEngine.SystemLanguage))(L, index, null); } }
public void Init(ObjectCheckers objCheckers, ObjectCasters objCasters) { if (typeof(Delegate).IsAssignableFrom(targetType) || !method.IsStatic || method.IsConstructor) { luaStackPosStart = 2; if (!method.IsConstructor) { targetNeeded = true; } } var paramInfos = method.GetParameters(); refPos = new int[paramInfos.Length]; List <int> inPosList = new List <int>(); List <int> outPosList = new List <int>(); List <ObjectCheck> paramsChecks = new List <ObjectCheck>(); List <ObjectCast> paramsCasts = new List <ObjectCast>(); List <bool> isOptionalList = new List <bool>(); List <object> defaultValueList = new List <object>(); for (int i = 0; i < paramInfos.Length; i++) { refPos[i] = -1; if (!paramInfos[i].IsIn && paramInfos[i].IsOut) // out parameter { outPosList.Add(i); } else { if (paramInfos[i].ParameterType.IsByRef) { var ttype = paramInfos[i].ParameterType.GetElementType(); if (CopyByValue.IsStruct(ttype) && ttype != typeof(decimal)) { refPos[i] = inPosList.Count; } outPosList.Add(i); } inPosList.Add(i); var paramType = paramInfos[i].IsDefined(typeof(ParamArrayAttribute), false) || (!paramInfos[i].ParameterType.IsArray && paramInfos[i].ParameterType.IsByRef) ? paramInfos[i].ParameterType.GetElementType() : paramInfos[i].ParameterType; paramsChecks.Add(objCheckers.GetChecker(paramType)); paramsCasts.Add(objCasters.GetCaster(paramType)); isOptionalList.Add(paramInfos[i].IsOptional); var defalutValue = paramInfos[i].DefaultValue; if (paramInfos[i].IsOptional) { if (defalutValue != null && defalutValue.GetType() != paramInfos[i].ParameterType) { defalutValue = defalutValue.GetType() == typeof(Missing) ? Activator.CreateInstance(paramInfos[i].ParameterType) : Convert.ChangeType(defalutValue, paramInfos[i].ParameterType); } HasDefalutValue = true; } defaultValueList.Add(paramInfos[i].IsOptional ? defalutValue : null); } } checkArray = paramsChecks.ToArray(); castArray = paramsCasts.ToArray(); inPosArray = inPosList.ToArray(); outPosArray = outPosList.ToArray(); isOptionalArray = isOptionalList.ToArray(); defaultValueArray = defaultValueList.ToArray(); if (paramInfos.Length > 0 && paramInfos[paramInfos.Length - 1].IsDefined(typeof(ParamArrayAttribute), false)) { paramsType = paramInfos[paramInfos.Length - 1].ParameterType.GetElementType(); } args = new object[paramInfos.Length]; if (method is MethodInfo) //constructor is not MethodInfo? { isVoid = (method as MethodInfo).ReturnType == typeof(void); } else if (method is ConstructorInfo) { isVoid = false; } }