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

Method get_object_addr

library/LuaWrapper.cpp:987–999  ·  view source on GitHub ↗

* Verify that the object is a DF ref with UPVAL_METATABLE. * If everything ok, extract the address. */

Source from the content-addressed store, hash-verified

985 * If everything ok, extract the address.
986 */
987uint8_t *LuaWrapper::get_object_addr(lua_State *state, int obj, int field, const char *mode)
988{
989 if (!lua_isuserdata(state, obj) ||
990 !lua_getmetatable(state, obj))
991 field_error(state, field, "invalid object", mode);
992
993 if (!lua_rawequal(state, -1, UPVAL_METATABLE))
994 field_error(state, field, "invalid object metatable", mode);
995
996 lua_pop(state, 1);
997
998 return (uint8_t*)get_object_ref(state, obj);
999}
1000
1001/**
1002 * Metamethod: represent a type node as string.

Callers

nothing calls this directly

Calls 3

lua_isuserdataFunction · 0.85
lua_getmetatableFunction · 0.85
lua_rawequalFunction · 0.85

Tested by

no test coverage detected