* If ienum refers to a valid enum, attach its keys to UPVAL_FIELDTABLE, * and the enum itself to the _enum metafield. Pushes the key table on the stack */
| 1294 | * and the enum itself to the _enum metafield. Pushes the key table on the stack |
| 1295 | */ |
| 1296 | void LuaWrapper::AttachEnumKeys(lua_State *state, int meta_idx, int ftable_idx, const type_identity *ienum) |
| 1297 | { |
| 1298 | EnableMetaField(state, ftable_idx, "_enum"); |
| 1299 | |
| 1300 | LookupInTable(state, const_cast<type_identity*>(ienum), &DFHACK_TYPEID_TABLE_TOKEN); |
| 1301 | lua_setfield(state, meta_idx, "_enum"); |
| 1302 | |
| 1303 | LookupInTable(state, const_cast<type_identity*>(ienum), &DFHACK_ENUM_TABLE_TOKEN); |
| 1304 | |
| 1305 | if (!lua_isnil(state, -1)) |
| 1306 | { |
| 1307 | lua_dup(state); |
| 1308 | lua_newtable(state); |
| 1309 | lua_swap(state); |
| 1310 | lua_setfield(state, -2, "__index"); |
| 1311 | lua_setmetatable(state, ftable_idx); |
| 1312 | } |
| 1313 | else |
| 1314 | { |
| 1315 | lua_pop(state, 1); |
| 1316 | lua_rawgetp(state, LUA_REGISTRYINDEX, &DFHACK_EMPTY_TABLE_TOKEN); |
| 1317 | } |
| 1318 | |
| 1319 | lua_dup(state); |
| 1320 | lua_setfield(state, meta_idx, "_index_table"); |
| 1321 | } |
| 1322 | |
| 1323 | static void BuildTypeMetatable(lua_State *state, const type_identity *type) |
| 1324 | { |
nothing calls this directly
no test coverage detected