private void createLuaObjectList(IntPtr luaState) { LuaAPI.lua_pushstring(luaState, "luaNet_objects"); LuaAPI.lua_newtable(luaState); LuaAPI.lua_pushvalue(luaState, -1); weakTableRef = LuaAPI.luaL_ref(luaState, LuaAPI.LUA_REGISTRYINDEX); LuaAPI.lua_pushvalue(luaState, -1); LuaAPI.lua_setmetatable(luaState, -2); LuaAPI.lua_pushstring(luaState, "__mode"); LuaAPI.lua_pushstring(luaState, "v"); LuaAPI.lua_settable(luaState, -3); LuaAPI.lua_settable(luaState, LuaAPI.LUA_REGISTRYINDEX); }
static void PushMetaTable(IntPtr L, Type t) { int reference = -1; if (!typeMetaMap.TryGetValue(t, out reference)) { LuaAPI.luaL_getmetatable(L, t.AssemblyQualifiedName); if (!LuaAPI.lua_isnil(L, -1)) { LuaAPI.lua_pushvalue(L, -1); reference = LuaAPI.luaL_ref(L, LuaAPI.LUA_REGISTRYINDEX); typeMetaMap.Add(t, reference); } } else { LuaAPI.ulua_rawgeti(L, LuaAPI.LUA_REGISTRYINDEX, reference); } }
/* * Gets the function in the index positon of the Lua stack. */ internal LuaFunction getFunction(IntPtr luaState, int index) { LuaAPI.lua_pushvalue(luaState, index); return(new LuaFunction(LuaAPI.luaL_ref(luaState, LuaAPI.LUA_REGISTRYINDEX), interpreter)); }
/* * Gets the table in the index positon of the Lua stack. */ internal LuaTable getTable(IntPtr luaState, int index) { LuaAPI.lua_pushvalue(luaState, index); return(new LuaTable(LuaAPI.luaL_ref(luaState, LuaAPI.LUA_REGISTRYINDEX), interpreter)); }