public static int msgHandler(IntPtr L) { if (!LuaDLL.lua_isstring(L, 1)) { return(1); } LuaDLL.wlua_getglobal(L, "debug"); //msg,debug if (!LuaDLL.lua_istable(L, -1)) { LuaDLL.lua_pop(L, 1); return(1); } LuaDLL.wlua_getfield(L, -1, "traceback"); //msg,debug,traceback if (!LuaDLL.lua_isfunction(L, -1)) { LuaDLL.lua_pop(L, 2); return(1); } LuaStateCache cache = LuaStateCacheMan.GetLuaStateCache(L); LuaDLL.lua_pushvalue(L, 1); //msg,debug,traceback,msg LuaDLL.lua_pushinteger(L, 2 + (cache.isException() ? 2 : 0)); //msg,debug,traceback,msg,level LuaDLL.lua_pcall(L, 2, 1, 0); //msg,debug,tracebackstring cache.clearException(); return(1); }
public static System.Object GetObject(IntPtr L, int index) { LuaTypes type = (LuaTypes)LuaDLL.lua_type(L, index); if (type != LuaTypes.LUA_TUSERDATA) { return(null); } IntPtr idptr = LuaDLL.lua_touserdata(L, index); LuaStateCache cache = LuaStateCacheMan.GetLuaStateCache(L); return(cache.GetObject(idptr)); }
void DisposeException(IntPtr L) { LuaStateCache cache = LuaStateCacheMan.GetLuaStateCache(L); cache.setException(); }
public static void RemoveObject(IntPtr L, IntPtr userdata) { LuaStateCache cache = LuaStateCacheMan.GetLuaStateCache(L); cache.RemoveObject(userdata); }
//L: [namespace Table] public static bool AddObject2Lua(IntPtr L, System.Object obj, string metatable /*nullable*/) { LuaStateCache cache = LuaStateCacheMan.GetLuaStateCache(L); return(cache.AddObject(L, obj, metatable)); }