diff options
author | Philipp Janda <siffiejoe@gmx.net> | 2017-09-16 13:09:49 +0200 |
---|---|---|
committer | Philipp Janda <siffiejoe@gmx.net> | 2017-09-16 13:09:49 +0200 |
commit | 9435c6c2e1f1373a5a9ffdb85a1a63ee0b7e6057 (patch) | |
tree | a0fe768542ff46def4691e29935a89dcf17954b7 | |
parent | 7fc7aba7defda15b7f9c56282e585eb91379fe3b (diff) | |
parent | bf96f3d583e0dcd0e78f167b1d54ff90dcf0de64 (diff) | |
download | lua-compat-5.3-9435c6c2e1f1373a5a9ffdb85a1a63ee0b7e6057.tar.gz lua-compat-5.3-9435c6c2e1f1373a5a9ffdb85a1a63ee0b7e6057.tar.bz2 lua-compat-5.3-9435c6c2e1f1373a5a9ffdb85a1a63ee0b7e6057.zip |
Merge branch 'daurnimator-luaL_Stream'
-rw-r--r-- | README.md | 15 | ||||
-rw-r--r-- | c-api/compat-5.3.h | 15 |
2 files changed, 21 insertions, 9 deletions
@@ -144,9 +144,11 @@ For Lua 5.1 additionally: | |||
144 | * `LUA_OK` | 144 | * `LUA_OK` |
145 | * `LUA_ERRGCMM` | 145 | * `LUA_ERRGCMM` |
146 | * `LUA_OP*` macros for `lua_arith` and `lua_compare` | 146 | * `LUA_OP*` macros for `lua_arith` and `lua_compare` |
147 | * `LUA_FILEHANDLE` | ||
147 | * `lua_Unsigned` | 148 | * `lua_Unsigned` |
149 | * `luaL_Stream` (limited compatibility, see[here][19]) | ||
148 | * `lua_absindex` | 150 | * `lua_absindex` |
149 | * `lua_arith` (see [here][19]) | 151 | * `lua_arith` (see [here][20]) |
150 | * `lua_compare` | 152 | * `lua_compare` |
151 | * `lua_len`, `lua_rawlen`, and `luaL_len` | 153 | * `lua_len`, `lua_rawlen`, and `luaL_len` |
152 | * `lua_pushstring`, `lua_pushlstring` (return value) | 154 | * `lua_pushstring`, `lua_pushlstring` (return value) |
@@ -160,10 +162,10 @@ For Lua 5.1 additionally: | |||
160 | * `luaL_execresult` | 162 | * `luaL_execresult` |
161 | * `luaL_fileresult` | 163 | * `luaL_fileresult` |
162 | * `luaL_checkversion` (with empty body, only to avoid compile errors, | 164 | * `luaL_checkversion` (with empty body, only to avoid compile errors, |
163 | see [here][20]) | 165 | see [here][21]) |
164 | * `luaL_tolstring` | 166 | * `luaL_tolstring` |
165 | * `luaL_buffinitsize`, `luaL_prepbuffsize`, and `luaL_pushresultsize` | 167 | * `luaL_buffinitsize`, `luaL_prepbuffsize`, and `luaL_pushresultsize` |
166 | (see [here][21]) | 168 | (see [here][22]) |
167 | * `lua_pushunsigned`, `lua_tounsignedx`, `lua_tounsigned`, | 169 | * `lua_pushunsigned`, `lua_tounsignedx`, `lua_tounsigned`, |
168 | `luaL_checkunsigned`, `luaL_optunsigned`, if | 170 | `luaL_checkunsigned`, `luaL_optunsigned`, if |
169 | `LUA_COMPAT_APIINTCASTS` is defined. | 171 | `LUA_COMPAT_APIINTCASTS` is defined. |
@@ -225,7 +227,8 @@ This package contains code written by: | |||
225 | [17]: https://github.com/keplerproject/lua-compat-5.3/wiki/lua_setuservalue | 227 | [17]: https://github.com/keplerproject/lua-compat-5.3/wiki/lua_setuservalue |
226 | [18]: https://github.com/keplerproject/lua-compat-5.3/wiki/lua_stringtonumber | 228 | [18]: https://github.com/keplerproject/lua-compat-5.3/wiki/lua_stringtonumber |
227 | [19]: https://github.com/keplerproject/lua-compat-5.3/wiki/lua_arith | 229 | [19]: https://github.com/keplerproject/lua-compat-5.3/wiki/lua_arith |
228 | [20]: https://github.com/keplerproject/lua-compat-5.3/wiki/luaL_checkversion | 230 | [20]: https://github.com/keplerproject/lua-compat-5.3/wiki/luaL_Stream |
229 | [21]: https://github.com/keplerproject/lua-compat-5.3/wiki/luaL_Buffer | 231 | [21]: https://github.com/keplerproject/lua-compat-5.3/wiki/luaL_checkversion |
230 | [22]: https://github.com/keplerproject/lua-compat-5.3/wiki/coroutine.running | 232 | [22]: https://github.com/keplerproject/lua-compat-5.3/wiki/luaL_Buffer |
233 | [23]: https://github.com/keplerproject/lua-compat-5.3/wiki/coroutine.running | ||
231 | 234 | ||
diff --git a/c-api/compat-5.3.h b/c-api/compat-5.3.h index 6c76930..d8e6827 100644 --- a/c-api/compat-5.3.h +++ b/c-api/compat-5.3.h | |||
@@ -9,11 +9,13 @@ extern "C" { | |||
9 | #endif | 9 | #endif |
10 | #include <lua.h> | 10 | #include <lua.h> |
11 | #include <lauxlib.h> | 11 | #include <lauxlib.h> |
12 | #include <lualib.h> | ||
12 | #if defined(__cplusplus) && !defined(COMPAT53_LUA_CPP) | 13 | #if defined(__cplusplus) && !defined(COMPAT53_LUA_CPP) |
13 | } | 14 | } |
14 | #endif | 15 | #endif |
15 | 16 | ||
16 | 17 | ||
18 | #undef COMPAT53_INCLUDE_SOURCE | ||
17 | #if defined(COMPAT53_PREFIX) | 19 | #if defined(COMPAT53_PREFIX) |
18 | /* - change the symbol names of functions to avoid linker conflicts | 20 | /* - change the symbol names of functions to avoid linker conflicts |
19 | * - compat-5.3.c needs to be compiled (and linked) separately | 21 | * - compat-5.3.c needs to be compiled (and linked) separately |
@@ -21,7 +23,6 @@ extern "C" { | |||
21 | # if !defined(COMPAT53_API) | 23 | # if !defined(COMPAT53_API) |
22 | # define COMPAT53_API extern | 24 | # define COMPAT53_API extern |
23 | # endif | 25 | # endif |
24 | # undef COMPAT53_INCLUDE_SOURCE | ||
25 | #else /* COMPAT53_PREFIX */ | 26 | #else /* COMPAT53_PREFIX */ |
26 | /* - make all functions static and include the source. | 27 | /* - make all functions static and include the source. |
27 | * - compat-5.3.c doesn't need to be compiled (and linked) separately | 28 | * - compat-5.3.c doesn't need to be compiled (and linked) separately |
@@ -88,12 +89,12 @@ extern "C" { | |||
88 | # define LUA_OPLE 2 | 89 | # define LUA_OPLE 2 |
89 | #endif | 90 | #endif |
90 | 91 | ||
91 | /* LuaJIT/Lua 5.1 does not have the updated | 92 | /* LuaJIT/Lua 5.1 does not have the updated |
92 | * error codes for thread status/function returns (but some patched versions do) | 93 | * error codes for thread status/function returns (but some patched versions do) |
93 | * define it only if it's not found | 94 | * define it only if it's not found |
94 | */ | 95 | */ |
95 | #if !defined(LUA_ERRGCMM) | 96 | #if !defined(LUA_ERRGCMM) |
96 | /* Use + 2 because in some versions of Lua (Lua 5.1) | 97 | /* Use + 2 because in some versions of Lua (Lua 5.1) |
97 | * LUA_ERRFILE is defined as (LUA_ERRERR+1) | 98 | * LUA_ERRFILE is defined as (LUA_ERRERR+1) |
98 | * so we need to avoid it (LuaJIT might have something at this | 99 | * so we need to avoid it (LuaJIT might have something at this |
99 | * integer value too) | 100 | * integer value too) |
@@ -112,6 +113,14 @@ typedef struct luaL_Buffer_53 { | |||
112 | } luaL_Buffer_53; | 113 | } luaL_Buffer_53; |
113 | #define luaL_Buffer luaL_Buffer_53 | 114 | #define luaL_Buffer luaL_Buffer_53 |
114 | 115 | ||
116 | /* In PUC-Rio 5.1, userdata is a simple FILE* | ||
117 | * In LuaJIT, it's a struct where the first member is a FILE* | ||
118 | * We can't support the `closef` member | ||
119 | */ | ||
120 | typedef struct luaL_Stream { | ||
121 | FILE *f; | ||
122 | } luaL_Stream; | ||
123 | |||
115 | #define lua_absindex COMPAT53_CONCAT(COMPAT53_PREFIX, _absindex) | 124 | #define lua_absindex COMPAT53_CONCAT(COMPAT53_PREFIX, _absindex) |
116 | COMPAT53_API int lua_absindex (lua_State *L, int i); | 125 | COMPAT53_API int lua_absindex (lua_State *L, int i); |
117 | 126 | ||