brimworks / lua-ev

Lua integration with libev.
MIT License
225 stars 55 forks source link

Update lua-ev for Lua 5.2 #14

Closed blitmap closed 11 years ago

blitmap commented 11 years ago

Hi! I've been trying to get familiar with libev and libevent through Lua. I really love what you've written here and I thought I could help by updating it for 5.2!

What Changed: 1) invalid type: luaL_reg -> luaL_Reg 2) luaL_register() has become luaL_setfuncs() & luaL_newlib() respectively 3) getfenv()/setfenv() on userdata became getuservalue()/setuservalue() 4) luaL_typerror() became a private function in 5.2 (upstream-Lua sucks sometimes) 5) dumper.lua was unnecessarily escaping ] which 5.2 didn't like (5.1 did not care) 6) added a FindLua52.cmake for figuring out where liblua.so is 7) made a macro for quicker "constant pushing" in lua_ev.c & alphabetized said constants

I tested building this for Lua 5.1 and 5.2, everything cleared -- all the tests succeeded. If you want to build for 5.1 again you change the 52 in CMakeLists.txt to 51 and all is happy in the Land of Lua. Hope you'll accept this :-)

brimworks commented 11 years ago

Thanks for doing this! However, I think we can switch between supporting Lua 5.1 and 5.2 automatically (so nobody has to edit the CMakeLists.txt file). I'll merge your pull request and test it out this weekend.

Thanks, -Brian

blitmap commented 11 years ago

Quite welcome, good sir! :-) I unfortunately don't know much about cmake or any build systems, so I welcome the autodetection if you can figure it out.

brimworks commented 11 years ago

Thanks for the pull request, I've pulled your code and did a bit of refactoring so the code uses Lua 5.2 APIs (with backwards compatible shims). I also noticed a small bug when -DNDEBUG flag is set. I also removed the test dependency on the "alien" library so that people are more encouraged to run the tests. I also auto-detect Lua 5.1, 5.2, or LuaJIT 2.0.

Thanks! -Brian

blitmap commented 11 years ago

Yay! Looks good, man :-) Glad I could help!