From bd51baf8f99a4439b0db764b347693a47704fe28 Mon Sep 17 00:00:00 2001 From: Li Linfeng Date: Tue, 30 Jul 2019 14:22:29 +0800 Subject: [PATCH] Use lua version defined in lua.h --- CMakeLists.txt | 1 - src/celestia/celx.cpp | 10 +++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f845328d..97802b17 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -171,7 +171,6 @@ if(ENABLE_CELX) if(NOT LUAJIT_FOUND) find_package(Lua REQUIRED) endif() - add_definitions(-DLUA_VER=0x0${LUA_VERSION_MAJOR}0${LUA_VERSION_MINOR}00) include_directories(${LUA_INCLUDE_DIR}) link_libraries(${LUA_LIBRARIES}) endif() diff --git a/src/celestia/celx.cpp b/src/celestia/celx.cpp index 2521ea5b..ce71b4f0 100644 --- a/src/celestia/celx.cpp +++ b/src/celestia/celx.cpp @@ -103,7 +103,7 @@ const char* MouseDownHandler = "mousedown"; const char* MouseUpHandler = "mouseup"; -#if LUA_VER < 0x050300 +#if LUA_VERSION_NUM < 503 int lua_isinteger(lua_State *L, int index) { if (lua_type(L, index) == LUA_TNUMBER) @@ -322,7 +322,7 @@ static void openLuaLibrary(lua_State* l, const char* name, lua_CFunction func) { -#if LUA_VER >= 0x050200 +#if LUA_VERSION_NUM >= 502 luaL_requiref(l, name, func, 1); #else lua_pushcfunction(l, func); @@ -607,7 +607,7 @@ static int resumeLuaThread(lua_State *L, lua_State *co, int narg) //if (!lua_checkstack(co, narg)) // luaL_error(L, "too many arguments to resume"); lua_xmove(L, co, narg); -#if LUA_VER >= 0x050200 +#if LUA_VERSION_NUM >= 502 status = lua_resume(co, nullptr, narg); #else status = lua_resume(co, narg); @@ -898,7 +898,7 @@ int LuaState::loadScript(istream& in, const string& streamname) lua_settable(state, LUA_REGISTRYINDEX); } -#if LUA_VER >= 0x050200 +#if LUA_VERSION_NUM >= 502 int status = lua_load(state, readStreamChunk, &info, streamname.c_str(), nullptr); #else @@ -1296,7 +1296,7 @@ bool LuaState::init(CelestiaCore* appCore) openLuaLibrary(state, LUA_MATHLIBNAME, luaopen_math); openLuaLibrary(state, LUA_TABLIBNAME, luaopen_table); openLuaLibrary(state, LUA_STRLIBNAME, luaopen_string); -#if LUA_VER >= 0x050200 +#if LUA_VERSION_NUM >= 502 openLuaLibrary(state, LUA_COLIBNAME, luaopen_coroutine); #endif // Make the package library, except the loadlib function, available