MCPcopy Create free account
hub / github.com/axmolengine/axmol / luaL_setfuncs

Function luaL_setfuncs

3rdparty/lua/lua-cjson/lua_cjson.c:1336–1348  ·  view source on GitHub ↗

Compatibility for Lua 5.1. * * luaL_setfuncs() is used to create a module table where the functions have * json_config_t as their first upvalue. Code borrowed from Lua 5.2 source. */

Source from the content-addressed store, hash-verified

1334 * luaL_setfuncs() is used to create a module table where the functions have
1335 * json_config_t as their first upvalue. Code borrowed from Lua 5.2 source. */
1336static void luaL_setfuncs (lua_State *l, const luaL_Reg *reg, int nup)
1337{
1338 int i;
1339
1340 luaL_checkstack(l, nup, "too many upvalues");
1341 for (; reg->name != NULL; reg++) { /* fill the table with given functions */
1342 for (i = 0; i < nup; i++) /* copy upvalues to the top */
1343 lua_pushvalue(l, -nup);
1344 lua_pushcclosure(l, reg->func, nup); /* closure with those upvalues */
1345 lua_setfield(l, -(nup + 2), reg->name);
1346 }
1347 lua_pop(l, nup); /* remove upvalues */
1348}
1349#endif
1350
1351/* Call target function in protected mode with all supplied args.

Callers 1

lua_cjson_newFunction · 0.70

Calls 4

lua_pushvalueFunction · 0.85
lua_pushcclosureFunction · 0.85
lua_setfieldFunction · 0.85
luaL_checkstackFunction · 0.50

Tested by

no test coverage detected