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

Method CheckDFObject

library/LuaTools.cpp:273–289  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

271
272
273void *DFHack::Lua::CheckDFObject(lua_State *state, const type_identity *type, int val_index, bool exact_type)
274{
275 check_valid_ptr_index(state, val_index);
276
277 if (lua_isnil(state, val_index))
278 return NULL;
279 if (lua_islightuserdata(state, val_index) && !lua_touserdata(state, val_index))
280 return NULL;
281
282 void *rv = get_object_internal(state, type, val_index, exact_type, false);
283
284 if (!rv)
285 signal_typeid_error(NULL, state, type, "invalid pointer type; expected: {}",
286 val_index, false, true);
287
288 return rv;
289}
290
291/*
292 * Console I/O wrappers

Callers

nothing calls this directly

Calls 3

check_valid_ptr_indexFunction · 0.85
lua_touserdataFunction · 0.85
signal_typeid_errorFunction · 0.85

Tested by

no test coverage detected