| 624 | |
| 625 | |
| 626 | static void base_open (lua_State *L) { |
| 627 | /* set global _G */ |
| 628 | lua_pushvalue(L, LUA_GLOBALSINDEX); |
| 629 | lua_setglobal(L, "_G"); |
| 630 | /* open lib into global table */ |
| 631 | luaL_register(L, "_G", base_funcs); |
| 632 | lua_pushliteral(L, LUA_VERSION); |
| 633 | lua_setglobal(L, "_VERSION"); /* set global _VERSION */ |
| 634 | /* `ipairs' and `pairs' need auxiliary functions as upvalues */ |
| 635 | auxopen(L, "ipairs", luaB_ipairs, ipairsaux); |
| 636 | auxopen(L, "pairs", luaB_pairs, luaB_next); |
| 637 | /* `newproxy' needs a weaktable as upvalue */ |
| 638 | lua_createtable(L, 0, 1); /* new table `w' */ |
| 639 | lua_pushvalue(L, -1); /* `w' will be its own metatable */ |
| 640 | lua_setmetatable(L, -2); |
| 641 | lua_pushliteral(L, "kv"); |
| 642 | lua_setfield(L, -2, "__mode"); /* metatable(w).__mode = "kv" */ |
| 643 | lua_pushcclosure(L, luaB_newproxy, 1); |
| 644 | lua_setglobal(L, "newproxy"); /* set global `newproxy' */ |
| 645 | } |
| 646 | |
| 647 | |
| 648 | LUALIB_API int luaopen_base (lua_State *L) { |
no test coverage detected