diff --git a/serialize.c b/serialize.c index 5e117a2..7b89e27 100644 --- a/serialize.c +++ b/serialize.c @@ -5,6 +5,26 @@ #include #include + +#if LUA_VERSION_NUM < 502 + +#define lua_rawlen(L, I) lua_objlen(L, I) +#define luaL_newlib(L, R) {lua_newtable(L); luaL_register(L, NULL, R);} + +#endif + +#if LUA_VERSION_NUM < 503 + +static int +lua_isinteger(lua_State *L, int index) { + int32_t x = (int32_t)lua_tointeger(L,index); + lua_Number n = lua_tonumber(L,index); + return ((lua_Number)x==n); +} + +#endif + + #define TYPE_NIL 0 #define TYPE_BOOLEAN 1 // hibits 0 false 1 true @@ -348,17 +368,6 @@ wb_table(lua_State *L, struct write_block *wb, int index, int depth) { wb_table_hash(L, wb, index, depth, array_size); } -#if LUA_VERSION_NUM < 503 - -static int -lua_isinteger(lua_State *L, int index) { - int32_t x = (int32_t)lua_tointeger(L,index); - lua_Number n = lua_tonumber(L,index); - return ((lua_Number)x==n); -} - -#endif - static void pack_one(lua_State *L, struct write_block *b, int index, int depth) { if (depth > MAX_DEPTH) {