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

Function base_open

deps/lua/src/lbaselib.c:626–645  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

624
625
626static 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
648LUALIB_API int luaopen_base (lua_State *L) {

Callers 1

luaopen_baseFunction · 0.85

Calls 6

lua_pushvalueFunction · 0.85
auxopenFunction · 0.85
lua_createtableFunction · 0.85
lua_setmetatableFunction · 0.85
lua_setfieldFunction · 0.85
lua_pushcclosureFunction · 0.85

Tested by

no test coverage detected