(RealStatePtr L)
| 877 | } |
| 878 | |
| 879 | [MonoPInvokeCallback(typeof(LuaCSFunction))] |
| 880 | public static int ImportGenericType(RealStatePtr L) |
| 881 | { |
| 882 | try |
| 883 | { |
| 884 | int top = LuaAPI.lua_gettop(L); |
| 885 | if (top < 2) return LuaAPI.luaL_error(L, "import generic type need at lease 2 arguments"); |
| 886 | ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); |
| 887 | string className = LuaAPI.lua_tostring(L, 1); |
| 888 | if (className.EndsWith("<>")) className = className.Substring(0, className.Length - 2); |
| 889 | Type genericDef = translator.FindType(className + "`" + (top - 1)); |
| 890 | if (genericDef == null || !genericDef.IsGenericTypeDefinition()) |
| 891 | { |
| 892 | LuaAPI.lua_pushnil(L); |
| 893 | } |
| 894 | else |
| 895 | { |
| 896 | Type[] typeArguments = new Type[top - 1]; |
| 897 | for(int i = 2; i <= top; i++) |
| 898 | { |
| 899 | |
| 900 | typeArguments[i - 2] = getType(L, translator, i); |
| 901 | if (typeArguments[i - 2] == null) |
| 902 | { |
| 903 | return LuaAPI.luaL_error(L, "param need a type"); |
| 904 | } |
| 905 | } |
| 906 | Type genericInc = genericDef.MakeGenericType(typeArguments); |
| 907 | translator.GetTypeId(L, genericInc); |
| 908 | translator.PushAny(L, genericInc); |
| 909 | } |
| 910 | |
| 911 | return 1; |
| 912 | } |
| 913 | catch (System.Exception e) |
| 914 | { |
| 915 | return LuaAPI.luaL_error(L, "c# exception in xlua.import_type:" + e); |
| 916 | } |
| 917 | } |
| 918 | |
| 919 | [MonoPInvokeCallback(typeof(LuaCSFunction))] |
| 920 | public static int Cast(RealStatePtr L) |
nothing calls this directly
no test coverage detected