MCPcopy Create free account
hub / github.com/9chu/LuaSTGPlus / luaL_setfuncs

Function luaL_setfuncs

LuaSTGPlus/LuaExtensions/cjson4lua/lua_cjson.c:1303–1315  ·  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

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

Callers 1

lua_cjson_newFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected