aboutsummaryrefslogtreecommitdiff
path: root/src/yue.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/yue.cpp')
-rw-r--r--src/yue.cpp9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/yue.cpp b/src/yue.cpp
index aebc31d..c6b35e6 100644
--- a/src/yue.cpp
+++ b/src/yue.cpp
@@ -77,21 +77,18 @@ int luaopen_colibc_json(lua_State* L);
77 77
78static void openlibs(void* state) { 78static void openlibs(void* state) {
79 lua_State* L = static_cast<lua_State*>(state); 79 lua_State* L = static_cast<lua_State*>(state);
80 luaL_openlibs(L);
81 int top = lua_gettop(L); 80 int top = lua_gettop(L);
81 DEFER(lua_settop(L, top));
82 luaL_openlibs(L);
82#if LUA_VERSION_NUM > 501 83#if LUA_VERSION_NUM > 501
83 luaL_requiref(L, "yue", luaopen_yue, 0); 84 luaL_requiref(L, "yue", luaopen_yue, 0);
84 luaL_requiref(L, "json", luaopen_colibc_json, 0); 85 luaL_requiref(L, "json", luaopen_colibc_json, 0);
85#else 86#else
86 lua_pushcfunction(L, luaopen_yue); 87 lua_pushcfunction(L, luaopen_yue);
87 lua_call(L, 0, 0); 88 lua_call(L, 0, 0);
88 lua_getglobal(L, "package"); // package
89 lua_getfield(L, -1, "loaded"); // package loaded
90 lua_pushcfunction(L, luaopen_colibc_json); 89 lua_pushcfunction(L, luaopen_colibc_json);
91 lua_call(L, 0, 1); // package loaded json 90 lua_call(L, 0, 0);
92 lua_setfield(L, -2, "json"); // loaded["json"] = json, package loaded
93#endif 91#endif
94 lua_settop(L, top);
95} 92}
96 93
97void pushYue(lua_State* L, std::string_view name) { 94void pushYue(lua_State* L, std::string_view name) {