MCPcopy Create free account
hub / github.com/Tencent/xLua / GenericMethodWraper

Function GenericMethodWraper

Assets/XLua/Src/StaticLuaCallbacks.cs:1145–1173  ·  view source on GitHub ↗
(RealStatePtr L)

Source from the content-addressed store, hash-verified

1143 }
1144
1145 [MonoPInvokeCallback(typeof(LuaCSFunction))]
1146 public static int GenericMethodWraper(RealStatePtr L)
1147 {
1148 try
1149 {
1150 ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
1151 MethodInfo genericMethod;
1152 translator.Get(L, LuaAPI.xlua_upvalueindex(1), out genericMethod);
1153 int n = LuaAPI.lua_gettop(L);
1154 Type[] typeArguments = new Type[n];
1155 for(int i = 0; i < n; i++)
1156 {
1157 Type type = getType(L, translator, i + 1);
1158 if (type == null)
1159 {
1160 return LuaAPI.luaL_error(L, "param #" + (i + 1) + " is not a type");
1161 }
1162 typeArguments[i] = type;
1163 }
1164 var method = genericMethod.MakeGenericMethod(typeArguments);
1165 translator.PushFixCSFunction(L,
1166 new LuaCSFunction(translator.methodWrapsCache._GenMethodWrap(method.DeclaringType, method.Name, new MethodBase[] { method }).Call));
1167 return 1;
1168 }
1169 catch (Exception e)
1170 {
1171 return LuaAPI.luaL_error(L, "c# exception in GenericMethodWraper: " + e);
1172 }
1173 }
1174
1175 [MonoPInvokeCallback(typeof(LuaCSFunction))]
1176 public static int GetGenericMethod(RealStatePtr L)

Callers

nothing calls this directly

Calls 9

FindMethod · 0.80
xlua_upvalueindexMethod · 0.80
lua_gettopMethod · 0.80
luaL_errorMethod · 0.80
MakeGenericMethodMethod · 0.80
PushFixCSFunctionMethod · 0.80
_GenMethodWrapMethod · 0.80
getTypeFunction · 0.70
GetMethod · 0.45

Tested by

no test coverage detected