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

Function Cast

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

Source from the content-addressed store, hash-verified

917 }
918
919 [MonoPInvokeCallback(typeof(LuaCSFunction))]
920 public static int Cast(RealStatePtr L)
921 {
922 try
923 {
924 ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
925 Type type;
926 translator.Get(L, 2, out type);
927
928 if (type == null)
929 {
930 return LuaAPI.luaL_error(L, "#2 param[" + LuaAPI.lua_tostring(L, 2) + "]is not valid type indicator");
931 }
932 LuaAPI.luaL_getmetatable(L, type.FullName);
933 if (LuaAPI.lua_isnil(L, -1))
934 {
935 return LuaAPI.luaL_error(L, "no gen code for " + LuaAPI.lua_tostring(L, 2));
936 }
937 LuaAPI.lua_setmetatable(L, 1);
938 return 0;
939 }
940 catch (System.Exception e)
941 {
942 return LuaAPI.luaL_error(L, "c# exception in xlua.cast:" + e);
943 }
944 }
945
946 static Type getType(RealStatePtr L, ObjectTranslator translator, int idx)
947 {

Callers

nothing calls this directly

Calls 7

FindMethod · 0.80
luaL_errorMethod · 0.80
lua_tostringMethod · 0.80
luaL_getmetatableMethod · 0.80
lua_isnilMethod · 0.80
lua_setmetatableMethod · 0.80
GetMethod · 0.45

Tested by

no test coverage detected