New compat.h module implements luaL_setfuncs.

Makes initialization code simpler everywhere.
This commit is contained in:
Diego Nehab 2015-08-21 15:39:34 -03:00
parent 321c0c9b1f
commit e75444ccd1
20 changed files with 164 additions and 173 deletions

View file

@ -17,6 +17,7 @@
\*=========================================================================*/
#include "lua.h"
#include "lauxlib.h"
#include "compat.h"
/*=========================================================================*\
* LuaSocket includes
@ -83,12 +84,8 @@ static int global_unload(lua_State *L) {
static int base_open(lua_State *L) {
if (socket_open()) {
/* export functions (and leave namespace table on top of stack) */
#if LUA_VERSION_NUM > 501 && !defined(LUA_COMPAT_MODULE)
lua_newtable(L);
luaL_setfuncs(L, func, 0);
#else
luaL_openlib(L, "socket", func, 0);
#endif
#ifdef LUASOCKET_DEBUG
lua_pushstring(L, "_DEBUG");
lua_pushboolean(L, 1);