Make the library comptible with both Lua 5.1 and Lua 5.2

This commit is contained in:
Alexandre Erwin Ittner
2011-12-05 19:40:34 -02:00
parent 044877f838
commit 1fc031875f
2 changed files with 17 additions and 7 deletions

View File

@@ -1,6 +1,6 @@
/*
* luaiconv - Performs character set conversions in Lua
* (c) 2005-10 Alexandre Erwin Ittner <alexandre@ittner.com.br>
* (c) 2005-11 Alexandre Erwin Ittner <alexandre@ittner.com.br>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@@ -39,6 +39,16 @@
#define LIB_VERSION LIB_NAME " 7"
#define ICONV_TYPENAME "iconv_t"
#if LUA_VERSION_NUM < 501
#error "Unsuported Lua version. You must use Lua >= 5.1"
#endif
#if LUA_VERSION_NUM < 502
#define luaL_newlib(L, f) { lua_newtable(L); luaL_register(L, NULL, f); }
#define lua_rawlen(L, i) lua_objlen(L, i)
#endif
#define BOXPTR(L, p) (*(void**)(lua_newuserdata(L, sizeof(void*))) = (p))
#define UNBOXPTR(L, i) (*(void**)(lua_touserdata(L, i)))