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

Function meta_isvalid

library/LuaWrapper.cpp:1085–1116  ·  view source on GitHub ↗

* Metamethod: df.isvalid(obj[,allow_null]) */

Source from the content-addressed store, hash-verified

1083 * Metamethod: df.isvalid(obj[,allow_null])
1084 */
1085static int meta_isvalid(lua_State *state)
1086{
1087 luaL_checkany(state, 1);
1088
1089 switch (Lua::IsDFObject(state, 1))
1090 {
1091 case Lua::OBJ_NULL:
1092 lua_settop(state, 2);
1093 if (lua_toboolean(state, 2))
1094 lua_pushvalue(state, lua_upvalueindex(1));
1095 else
1096 lua_pushnil(state);
1097 return 1;
1098
1099 case Lua::OBJ_TYPE:
1100 lua_pushvalue(state, lua_upvalueindex(2));
1101 return 1;
1102
1103 case Lua::OBJ_VOIDPTR:
1104 lua_pushvalue(state, lua_upvalueindex(3));
1105 return 1;
1106
1107 case Lua::OBJ_REF:
1108 lua_pushvalue(state, lua_upvalueindex(4));
1109 return 1;
1110
1111 case Lua::OBJ_INVALID:
1112 default:
1113 lua_pushnil(state);
1114 return 1;
1115 }
1116}
1117
1118/**
1119 * Metamethod: df.isnull(obj)

Callers

nothing calls this directly

Calls 5

luaL_checkanyFunction · 0.85
lua_settopFunction · 0.85
lua_tobooleanFunction · 0.85
lua_pushvalueFunction · 0.85
lua_pushnilFunction · 0.85

Tested by

no test coverage detected