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

Method push_object_ref

library/LuaWrapper.cpp:168–184  ·  view source on GitHub ↗

* Push the pointer as DF object ref using metatable on the stack. */

Source from the content-addressed store, hash-verified

166 * Push the pointer as DF object ref using metatable on the stack.
167 */
168void LuaWrapper::push_object_ref(lua_State *state, void *ptr)
169{
170 // stack: [metatable]
171 void* stg = lua_newuserdata(state, sizeof(DFRefHeader));
172 new (stg) DFRefHeader
173 {
174 .ptr = ptr,
175 .field_info = NULL,
176 .tag_ptr = NULL,
177 .tag_identity = NULL,
178 .tag_attr = NULL,
179 };
180
181 lua_swap(state);
182 lua_setmetatable(state, -2);
183 // stack: [userdata]
184}
185
186DFRefHeader *LuaWrapper::get_object_ref_header(lua_State *state, int val_index)
187{

Callers

nothing calls this directly

Calls 3

lua_newuserdataFunction · 0.85
lua_swapFunction · 0.85
lua_setmetatableFunction · 0.85

Tested by

no test coverage detected