MCPcopy Create free account
hub / github.com/DFHack/dfhack / is_valid_metatable

Function is_valid_metatable

library/LuaWrapper.cpp:402–419  ·  view source on GitHub ↗

* Check if the object and metatable are a valid DF reference or type. */

Source from the content-addressed store, hash-verified

400 * Check if the object and metatable are a valid DF reference or type.
401 */
402static bool is_valid_metatable(lua_State *state, int objidx, int metaidx)
403{
404 // Verify object type validity
405 if (lua_isuserdata(state, objidx))
406 {
407 lua_pushvalue(state, metaidx);
408 lua_rawget(state, UPVAL_TYPETABLE);
409 }
410 else
411 {
412 lua_pushvalue(state, objidx);
413 LookupInTable(state, &DFHACK_TYPEID_TABLE_TOKEN);
414 }
415
416 bool ok = !lua_isnil(state, -1);
417 lua_pop(state, 1);
418 return ok;
419}
420
421bool Lua::IsDFNull(lua_State *state, int val_index)
422{

Callers 1

get_object_identityMethod · 0.85

Calls 4

lua_isuserdataFunction · 0.85
lua_pushvalueFunction · 0.85
lua_rawgetFunction · 0.85
LookupInTableFunction · 0.85

Tested by

no test coverage detected