aboutsummaryrefslogtreecommitdiff
path: root/c-api
diff options
context:
space:
mode:
Diffstat (limited to 'c-api')
-rw-r--r--c-api/compat-5.3.c4
-rw-r--r--c-api/compat-5.3.h16
2 files changed, 18 insertions, 2 deletions
diff --git a/c-api/compat-5.3.c b/c-api/compat-5.3.c
index fab89c0..811f248 100644
--- a/c-api/compat-5.3.c
+++ b/c-api/compat-5.3.c
@@ -101,11 +101,11 @@ COMPAT53_API void lua_copy (lua_State *L, int from, int to) {
101COMPAT53_API void lua_len (lua_State *L, int i) { 101COMPAT53_API void lua_len (lua_State *L, int i) {
102 switch (lua_type(L, i)) { 102 switch (lua_type(L, i)) {
103 case LUA_TSTRING: 103 case LUA_TSTRING:
104 lua_pushnumber(L, (lua_Integer)lua_objlen(L, i)); 104 lua_pushnumber(L, (lua_Number)lua_objlen(L, i));
105 break; 105 break;
106 case LUA_TTABLE: 106 case LUA_TTABLE:
107 if (!luaL_callmeta(L, i, "__len")) 107 if (!luaL_callmeta(L, i, "__len"))
108 lua_pushnumber(L, (lua_Integer)lua_objlen(L, i)); 108 lua_pushnumber(L, (lua_Number)lua_objlen(L, i));
109 break; 109 break;
110 case LUA_TUSERDATA: 110 case LUA_TUSERDATA:
111 if (luaL_callmeta(L, i, "__len")) 111 if (luaL_callmeta(L, i, "__len"))
diff --git a/c-api/compat-5.3.h b/c-api/compat-5.3.h
index 02712f3..a5b10d2 100644
--- a/c-api/compat-5.3.h
+++ b/c-api/compat-5.3.h
@@ -91,6 +91,19 @@ extern "C" {
91# define LUA_FILEHANDLE "FILE*" 91# define LUA_FILEHANDLE "FILE*"
92#endif 92#endif
93 93
94/* LuaJIT/Lua 5.1 does not have the updated
95 * error codes for thread status/function returns (but some patched versions do)
96 * define it only if it's not found
97 */
98#if !defined(LUA_ERRGCMM)
99/* Use + 2 because in some versions of Lua (Lua 5.1)
100 * LUA_ERRFILE is defined as (LUA_ERRERR+1)
101 * so we need to avoid it (LuaJIT might have something at this
102 * integer value too)
103 */
104# define LUA_ERRGCMM (LUA_ERRERR + 2)
105#endif /* LUA_ERRGCMM define */
106
94typedef size_t lua_Unsigned; 107typedef size_t lua_Unsigned;
95 108
96typedef struct luaL_Buffer_53 { 109typedef struct luaL_Buffer_53 {
@@ -198,6 +211,9 @@ COMPAT53_API int luaL_execresult (lua_State *L, int stat);
198#define lua_pcallk(L, na, nr, err, ctx, cont) \ 211#define lua_pcallk(L, na, nr, err, ctx, cont) \
199 ((void)(ctx), (void)(cont), lua_pcall((L), (na), (nr), (err))) 212 ((void)(ctx), (void)(cont), lua_pcall((L), (na), (nr), (err)))
200 213
214#define lua_resume(L, from, nargs) \
215 ((void)(from), lua_resume((L), (nargs)))
216
201#define luaL_buffinit COMPAT53_CONCAT(COMPAT53_PREFIX, _buffinit_53) 217#define luaL_buffinit COMPAT53_CONCAT(COMPAT53_PREFIX, _buffinit_53)
202COMPAT53_API void luaL_buffinit (lua_State *L, luaL_Buffer_53 *B); 218COMPAT53_API void luaL_buffinit (lua_State *L, luaL_Buffer_53 *B);
203 219