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

Method PushContainerMethod

library/LuaWrapper.cpp:1263–1279  ·  view source on GitHub ↗

* Add a 6 upvalue metamethod to the metatable. */

Source from the content-addressed store, hash-verified

1261 * Add a 6 upvalue metamethod to the metatable.
1262 */
1263void LuaWrapper::PushContainerMethod(lua_State *state, int meta_idx, int ftable_idx,
1264 lua_CFunction function,
1265 const type_identity *container, const type_identity *item, int count)
1266{
1267 lua_rawgetp(state, LUA_REGISTRYINDEX, &DFHACK_TYPETABLE_TOKEN);
1268 lua_pushvalue(state, meta_idx);
1269 lua_pushvalue(state, ftable_idx);
1270
1271 lua_pushlightuserdata(state, const_cast<type_identity*>(container));
1272 lua_pushlightuserdata(state, const_cast<type_identity*>(item));
1273 if (count < 0)
1274 lua_pushnil(state);
1275 else
1276 lua_pushinteger(state, count);
1277
1278 lua_pushcclosure(state, function, 6);
1279}
1280
1281/**
1282 * Add a 6 upvalue metamethod to the metatable.

Callers

nothing calls this directly

Calls 6

lua_rawgetpFunction · 0.85
lua_pushvalueFunction · 0.85
lua_pushlightuserdataFunction · 0.85
lua_pushnilFunction · 0.85
lua_pushintegerFunction · 0.85
lua_pushcclosureFunction · 0.85

Tested by

no test coverage detected