improve lcurses and lua package
This commit is contained in:
@@ -63,6 +63,9 @@ Notes:
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef LUAJIT
|
||||
# define LUA_COMPAT_5_1
|
||||
#endif
|
||||
#include "luaconf.h"
|
||||
#undef LUA_API
|
||||
#if defined(__cplusplus)
|
||||
@@ -71,7 +74,11 @@ Notes:
|
||||
#define LUA_API extern
|
||||
#endif
|
||||
|
||||
#include "luajit.h"
|
||||
#ifdef LUAJIT
|
||||
# include "luajit.h"
|
||||
#else
|
||||
# include "lua.h"
|
||||
#endif
|
||||
#include "lualib.h"
|
||||
#include "lauxlib.h"
|
||||
|
||||
@@ -339,7 +346,10 @@ static chtype lc_checkch(lua_State *L, int index)
|
||||
if (lua_type(L, index) == LUA_TSTRING)
|
||||
return *lua_tostring(L, index);
|
||||
|
||||
#if LUA_VERSION_NUM <= 501
|
||||
luaL_typerror(L, index, "chtype");
|
||||
#endif
|
||||
|
||||
/* never executes */
|
||||
return (chtype)0;
|
||||
}
|
||||
@@ -2330,7 +2340,11 @@ __export int luaopen_ltui_lcurses (lua_State *L)
|
||||
lua_pushliteral(L, "__index");
|
||||
lua_pushvalue(L, -2); /* push metatable */
|
||||
lua_rawset(L, -3); /* metatable.__index = metatable */
|
||||
#if LUA_VERSION_NUM <= 501
|
||||
luaL_openlib(L, NULL, windowlib, 0);
|
||||
#else
|
||||
luaL_setfuncs(L, windowlib, 0);
|
||||
#endif
|
||||
|
||||
lua_pop(L, 1); /* remove metatable from stack */
|
||||
|
||||
@@ -2341,7 +2355,11 @@ __export int luaopen_ltui_lcurses (lua_State *L)
|
||||
lua_pushliteral(L, "__index");
|
||||
lua_pushvalue(L, -2); /* push metatable */
|
||||
lua_rawset(L, -3); /* metatable.__index = metatable */
|
||||
#if LUA_VERSION_NUM <= 501
|
||||
luaL_openlib(L, NULL, chstrlib, 0);
|
||||
#else
|
||||
luaL_setfuncs(L, chstrlib, 0);
|
||||
#endif
|
||||
|
||||
lua_pop(L, 1); /* remove metatable from stack */
|
||||
|
||||
@@ -2350,7 +2368,12 @@ __export int luaopen_ltui_lcurses (lua_State *L)
|
||||
** create global table with curses methods/variables/constants
|
||||
*/
|
||||
lua_newtable(L);
|
||||
#if LUA_VERSION_NUM <= 501
|
||||
luaL_register(L, NULL, curseslib);
|
||||
#else
|
||||
lua_newtable(L);
|
||||
luaL_setfuncs(L, curseslib, 0);
|
||||
#endif
|
||||
|
||||
lua_pushstring(L, "init");
|
||||
lua_pushvalue(L, -2);
|
||||
|
@@ -13,7 +13,12 @@ target("lcurses")
|
||||
add_files("lcurses.c")
|
||||
|
||||
-- add packages
|
||||
if has_config("luajit") then
|
||||
add_defines("LUAJIT")
|
||||
add_packages("luajit")
|
||||
else
|
||||
add_packages("lua")
|
||||
end
|
||||
|
||||
-- add links
|
||||
if is_plat("windows") then
|
||||
|
@@ -28,8 +28,20 @@ if is_plat("windows") then
|
||||
add_links("kernel32", "user32", "gdi32", "advapi32")
|
||||
end
|
||||
|
||||
-- option: luajit
|
||||
option("luajit")
|
||||
set_default(false)
|
||||
set_showmenu(true)
|
||||
set_category("option")
|
||||
set_description("Enable the luajit runtime engine.")
|
||||
option_end()
|
||||
|
||||
-- add requires
|
||||
add_requires("luajit")
|
||||
if has_config("luajit") then
|
||||
add_requires("luajit", {nolink = true})
|
||||
else
|
||||
add_requires("lua", {nolink = true})
|
||||
end
|
||||
|
||||
-- add target
|
||||
target("ltui")
|
||||
@@ -43,6 +55,11 @@ target("ltui")
|
||||
-- set target directory
|
||||
set_targetdir("$(buildir)")
|
||||
|
||||
-- dynamic lookup liblua symbols
|
||||
if is_plat("macosx") then
|
||||
add_shflags("-undefined dynamic_lookup")
|
||||
end
|
||||
|
||||
-- add projects
|
||||
includes("lcurses")
|
||||
if is_plat("windows") then
|
||||
|
@@ -1,4 +1,3 @@
|
||||
-- init load directories
|
||||
package.path = package.path .. ';./src/?.lua'
|
||||
package.cpath = package.cpath .. ';./build/ltui.dll;./build/libltui.so;./build/libltui.dylib'
|
||||
|
||||
|
Reference in New Issue
Block a user