From 6e73ca6ada8a41692809dae5db89c8db0675ce1e Mon Sep 17 00:00:00 2001 From: chai Date: Sun, 17 Oct 2021 16:01:30 +0800 Subject: -Runner --- Runner/Scripting/luax_enum.cpp | 67 ------------------------------------------ 1 file changed, 67 deletions(-) delete mode 100644 Runner/Scripting/luax_enum.cpp (limited to 'Runner/Scripting/luax_enum.cpp') diff --git a/Runner/Scripting/luax_enum.cpp b/Runner/Scripting/luax_enum.cpp deleted file mode 100644 index ec73fce..0000000 --- a/Runner/Scripting/luax_enum.cpp +++ /dev/null @@ -1,67 +0,0 @@ -#include "luax_enum.h" -#include "luax_state.h" -#include "luax_vm.h" - -namespace Luax -{ - - /// - /// Ö»¶ÁmetatableµÄ__index - /// - int _rmt__index(lua_State* L) - { - // params: - // 1: enum table - // 2: key - - // upvalues: - // 1: metatable - - int mt = lua_upvalueindex(1); - lua_pushvalue(L, 2); - lua_rawget(L, mt); - - return 1; - } - - int _rmt__newindex(lua_State* L) - { - // upvalue: - // 1: enum table name - - cc8* name = lua_tostring(L, lua_upvalueindex(1)); - - return luaL_error(L, "Enum called \"%s\" is readonly.", name); - } - - //--------------------------------------------------------------------------------// -#if LUAX_ENABLE_PLAIN_ENUM - int LuaxPlainEnum::registry(lua_State* L) - { - // params: - // 1: enum name - // 2: metatable - - cc8* name = luaL_checkstring(L, 1); - - if (!lua_istable(L, 2)) - { - return luaL_error(L, "Create plain enum failed. Require table, but get %s", luaL_typename(L, 2)); - } - - lua_pushvalue(L, -1); - lua_setfield(L, -2, "__index"); - - lua_pushstring(L, name); - lua_pushcclosure(L, _rmt__newindex, 1); - lua_setfield(L, -2, "__newindex"); - - lua_newtable(L); // enum table - - lua_pushvalue(L, -2); // metatable - lua_setmetatable(L, -2); - - return 1; - } -#endif -} \ No newline at end of file -- cgit v1.1-26-g67d0