Permalink
Browse files

Merge pull request #18 from piernov/master

Lua 5.3 compatibility
  • Loading branch information...
2 parents 458165b + b98b707 commit 339426fbe528f11cb3cd1af69a88f06bba367981 @brimworks committed Aug 4, 2015
Showing with 27 additions and 2 deletions.
  1. +8 −0 child_lua_ev.c
  2. +2 −2 cmake/Modules/FindLua5X.cmake
  3. +5 −0 io_lua_ev.c
  4. +4 −0 signal_lua_ev.c
  5. +4 −0 stat_lua_ev.c
  6. +4 −0 watcher_lua_ev.c
View
@@ -2,7 +2,11 @@
#include <sys/wait.h>
#endif
+#if LUA_VERSION_NUM > 502
+#define luaL_checkbool(L, i) (lua_isboolean(L, i) ? lua_toboolean(L, i) : (int)luaL_checkinteger(L, i))
+#else
#define luaL_checkbool(L, i) (lua_isboolean(L, i) ? lua_toboolean(L, i) : luaL_checkint(L, i))
+#endif
/**
* Create a table for ev.CHILD that gives access to the constructor for
@@ -55,7 +59,11 @@ static int create_child_mt(lua_State *L) {
* [+1, -0, ?]
*/
static int child_new(lua_State* L) {
+#if LUA_VERSION_NUM > 502
+ int pid = (int)luaL_checkinteger(L, 2);
+#else
int pid = luaL_checkint(L, 2);
+#endif
int trace = luaL_checkbool(L, 3);
ev_child* child;
@@ -2,7 +2,7 @@
find_path(LUA_INCLUDE_DIR lua.h
HINTS
$ENV{LUA_DIR}
- PATH_SUFFIXES include/lua52 include/lua5.2 include/lua include include/lua51 include/lua5.1
+ PATH_SUFFIXES include include/lua include/lua53 include/lua5.3 include/lua52 include/lua5.2 include/lua51 include/lua5.1
PATHS
~/Library/Frameworks
/Library/Frameworks
@@ -15,7 +15,7 @@ find_path(LUA_INCLUDE_DIR lua.h
)
find_library(LUA_LIBRARY
- NAMES lua52 lua5.2 lua-5.2 lua lua51 lua5.1 luajit-5.1 luajit51 luajit5.1
+ NAMES lua lua53 lua5.3 lua52 lua5.2 lua-5.2 lua51 lua5.1 luajit-5.1 luajit51 luajit5.1
HINTS
$ENV{LUA_DIR}
PATH_SUFFIXES lib64 lib
View
@@ -46,8 +46,13 @@ static int create_io_mt(lua_State *L) {
* [+1, -0, ?]
*/
static int io_new(lua_State* L) {
+#if LUA_VERSION_NUM > 502
+ int fd = (int)luaL_checkinteger(L, 2);
+ int events = (int)luaL_checkinteger(L, 3);
+#else
int fd = luaL_checkint(L, 2);
int events = luaL_checkint(L, 3);
+#endif
ev_io* io;
io = watcher_new(L, sizeof(ev_io), IO_MT);
View
@@ -44,7 +44,11 @@ static int create_signal_mt(lua_State *L) {
* [+1, -0, ?]
*/
static int signal_new(lua_State* L) {
+#if LUA_VERSION_NUM > 502
+ int signum = (int)luaL_checkinteger(L, 2);
+#else
int signum = luaL_checkint(L, 2);
+#endif
ev_signal* sig;
sig = watcher_new(L, sizeof(ev_signal), SIGNAL_MT);
View
@@ -47,7 +47,11 @@ static int create_stat_mt(lua_State *L) {
*/
static int stat_new(lua_State* L) {
const char* path = luaL_checkstring(L, 2);
+#if LUA_VERSION_NUM > 502
+ ev_tstamp interval = (int)luaL_optinteger(L, 3, 0);
+#else
ev_tstamp interval = luaL_optint(L, 3, 0);
+#endif
ev_stat* stat;
stat = watcher_new(L, sizeof(ev_stat), STAT_MT);
View
@@ -219,7 +219,11 @@ static int watcher_priority(lua_State *L) {
ev_watcher *w = check_watcher(L, 1);
int old_pri = ev_priority(w);
+#if LUA_VERSION_NUM > 502
+ if ( has_pri ) ev_set_priority(w, (int)luaL_checkinteger(L, 2));
+#else
if ( has_pri ) ev_set_priority(w, luaL_checkint(L, 2));
+#endif
lua_pushinteger(L, old_pri);
return 1;
}

0 comments on commit 339426f

Please sign in to comment.