diff options
author | Li Jin <dragon-fly@qq.com> | 2023-03-24 09:06:11 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2023-03-24 09:06:11 +0800 |
commit | 40d2e58584fe1dc71db23716f67ded166d4489ce (patch) | |
tree | 4e3bd1c7490f21f81c9496804410db790f11b003 | |
parent | 40b4b41d27573904203bdbba311e78aa44ae421d (diff) | |
download | yuescript-40d2e58584fe1dc71db23716f67ded166d4489ce.tar.gz yuescript-40d2e58584fe1dc71db23716f67ded166d4489ce.tar.bz2 yuescript-40d2e58584fe1dc71db23716f67ded166d4489ce.zip |
stop adding yue to globals, fix issue #128.
-rw-r--r-- | src/yue.cpp | 2 | ||||
-rw-r--r-- | src/yuescript/yue_compiler.cpp | 2 | ||||
-rw-r--r-- | src/yuescript/yuescript.cpp | 4 |
3 files changed, 5 insertions, 3 deletions
diff --git a/src/yue.cpp b/src/yue.cpp index 8edac36..98bf4b4 100644 --- a/src/yue.cpp +++ b/src/yue.cpp | |||
@@ -44,7 +44,7 @@ static void openlibs(void* state) { | |||
44 | lua_State* L = static_cast<lua_State*>(state); | 44 | lua_State* L = static_cast<lua_State*>(state); |
45 | luaL_openlibs(L); | 45 | luaL_openlibs(L); |
46 | #if LUA_VERSION_NUM > 501 | 46 | #if LUA_VERSION_NUM > 501 |
47 | luaL_requiref(L, "yue", luaopen_yue, 1); | 47 | luaL_requiref(L, "yue", luaopen_yue, 0); |
48 | #else | 48 | #else |
49 | lua_pushcfunction(L, luaopen_yue); | 49 | lua_pushcfunction(L, luaopen_yue); |
50 | lua_call(L, 0, 0); | 50 | lua_call(L, 0, 0); |
diff --git a/src/yuescript/yue_compiler.cpp b/src/yuescript/yue_compiler.cpp index 8c99303..6b2b27d 100644 --- a/src/yuescript/yue_compiler.cpp +++ b/src/yuescript/yue_compiler.cpp | |||
@@ -72,7 +72,7 @@ static std::unordered_set<std::string> Metamethods = { | |||
72 | "close"s // Lua 5.4 | 72 | "close"s // Lua 5.4 |
73 | }; | 73 | }; |
74 | 74 | ||
75 | const std::string_view version = "0.15.30"sv; | 75 | const std::string_view version = "0.16.0"sv; |
76 | const std::string_view extension = "yue"sv; | 76 | const std::string_view extension = "yue"sv; |
77 | 77 | ||
78 | class CompileError : public std::logic_error { | 78 | class CompileError : public std::logic_error { |
diff --git a/src/yuescript/yuescript.cpp b/src/yuescript/yuescript.cpp index c8a7d42..ead2841 100644 --- a/src/yuescript/yuescript.cpp +++ b/src/yuescript/yuescript.cpp | |||
@@ -379,7 +379,9 @@ YUE_API int luaopen_yue(lua_State* L) { | |||
379 | #if LUA_VERSION_NUM > 501 | 379 | #if LUA_VERSION_NUM > 501 |
380 | luaL_newlib(L, yuelib); // yue | 380 | luaL_newlib(L, yuelib); // yue |
381 | #else | 381 | #else |
382 | luaL_register(L, "yue", yuelib); // yue | 382 | lua_getglobal(L, "package"); |
383 | lua_getfield(L, "loaded"); | ||
384 | luaL_register(L, nullptr, yuelib); // yue | ||
383 | #endif | 385 | #endif |
384 | lua_pushlstring(L, &yue::version.front(), yue::version.size()); // yue version | 386 | lua_pushlstring(L, &yue::version.front(), yue::version.size()); // yue version |
385 | lua_setfield(L, -2, "version"); // yue["version"] = version, yue | 387 | lua_setfield(L, -2, "version"); // yue["version"] = version, yue |