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

Method SetPairsMethod

library/LuaWrapper.cpp:1226–1236  ·  view source on GitHub ↗

* Add a __pairs/__ipairs metamethod using iterator on the top of stack. */

Source from the content-addressed store, hash-verified

1224 * Add a __pairs/__ipairs metamethod using iterator on the top of stack.
1225 */
1226void LuaWrapper::SetPairsMethod(lua_State *state, int meta_idx, const char *name)
1227{
1228 if (lua_isnil(state, -1))
1229 {
1230 lua_pop(state, 1);
1231 lua_pushcfunction(state, meta_nodata);
1232 }
1233
1234 lua_pushcclosure(state, meta_pairs, 1);
1235 lua_setfield(state, meta_idx, name);
1236}
1237
1238/**
1239 * Add a struct-style (3 upvalues) metamethod to the metatable.

Callers

nothing calls this directly

Calls 2

lua_pushcclosureFunction · 0.85
lua_setfieldFunction · 0.85

Tested by

no test coverage detected