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

Function meta_delete

library/LuaWrapper.cpp:962–981  ·  view source on GitHub ↗

* Method: deallocation for DF object references. */

Source from the content-addressed store, hash-verified

960 * Method: deallocation for DF object references.
961 */
962static int meta_delete(lua_State *state)
963{
964 int argc = lua_gettop(state);
965
966 if (argc != 1)
967 luaL_error(state, "Usage: object:delete() or df.delete(object)");
968
969 if (lua_isnil(state, 1))
970 {
971 lua_pushboolean(state, true);
972 return 1;
973 }
974
975 const type_identity *id = get_object_identity(state, 1, "df.delete()", false);
976
977 bool ok = id->destroy(get_object_ref(state, 1));
978
979 lua_pushboolean(state, ok);
980 return 1;
981}
982
983/**
984 * Verify that the object is a DF ref with UPVAL_METATABLE.

Callers

nothing calls this directly

Calls 4

lua_gettopFunction · 0.85
luaL_errorFunction · 0.85
lua_pushbooleanFunction · 0.85
destroyMethod · 0.80

Tested by

no test coverage detected