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)); }
public static void Init() { luaState = new LuaState(LuaNameSpace); L = luaState.L; LuaStateCacheMan.AddLuaStateCache(L); printFunction = new LuaCSFunction(LuaFuncs.print); LuaDLL.wlua_pushcfunction(L, printFunction); LuaDLL.wlua_setglobal(L, "print"); Lua_Register.Register(L, LuaNameSpace); LuaExtend.SetSearcher(L, loader); }
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)); }