34#define API_SPECENUM_INDEX_NAME(type) api_specenum_##type##_index
35#define API_SPECENUM_CREATE_TABLE(L, type, name) \
36 api_specenum_create_table((L), (name), API_SPECENUM_INDEX_NAME(type))
44#define API_SPECENUM_DEFINE_INDEX(type_name, prefix) \
45 static int (API_SPECENUM_INDEX_NAME(type_name))(lua_State *L) \
47 static char _buf[128]; \
49 enum type_name _value; \
50 luaL_checktype(L, 1, LUA_TTABLE); \
51 _key = luaL_checkstring(L, 2); \
52 fc_snprintf(_buf, sizeof(_buf), prefix "%s", _key); \
53 _value = type_name##_by_name(_buf, strcmp); \
54 if (_value != type_name##_invalid()) { \
56 lua_pushstring(L, _key); \
57 lua_pushinteger(L, _value); \
59 lua_pushinteger(L, _value); \
74 lua_getglobal(L,
name);
75 if (lua_isnil(L, -1)) {
78 lua_setglobal(L,
name);
83 lua_pushliteral(L,
"__index");
84 lua_pushcfunction(L, findex);
86 lua_setmetatable(L, -2);
#define API_SPECENUM_CREATE_TABLE(L, type, name)
static void api_specenum_create_table(lua_State *L, const char *name, lua_CFunction findex)
#define API_SPECENUM_DEFINE_INDEX(type_name, prefix)
int api_specenum_open(lua_State *L)
#define fc_assert_ret(condition)