MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / luaL_setfuncs

Function luaL_setfuncs

deps/lua/src/lua_cjson.c:1300–1312  ·  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

1298 * luaL_setfuncs() is used to create a module table where the functions have
1299 * json_config_t as their first upvalue. Code borrowed from Lua 5.2 source. */
1300static void luaL_setfuncs (lua_State *l, const luaL_Reg *reg, int nup)
1301{
1302 int i;
1303
1304 luaL_checkstack(l, nup, "too many upvalues");
1305 for (; reg->name != NULL; reg++) { /* fill the table with given functions */
1306 for (i = 0; i < nup; i++) /* copy upvalues to the top */
1307 lua_pushvalue(l, -nup);
1308 lua_pushcclosure(l, reg->func, nup); /* closure with those upvalues */
1309 lua_setfield(l, -(nup + 2), reg->name);
1310 }
1311 lua_pop(l, nup); /* remove upvalues */
1312}
1313#endif
1314
1315/* Call target function in protected mode with all supplied args.

Callers 1

lua_cjson_newFunction · 0.85

Calls 4

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

Tested by

no test coverage detected