aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Janda <siffiejoe@gmx.net>2015-03-17 13:14:09 +0100
committerPhilipp Janda <siffiejoe@gmx.net>2015-03-17 13:14:09 +0100
commitba8686d6af119fc7ecf734a2d2b6e319c8d74df5 (patch)
tree0d7b6d618c30e09bc293c8fba6ed157e52e8ba8e
parent2e8e147bc5a23750ab3e2a145fccfbb39f9443df (diff)
downloadlua-compat-5.3-ba8686d6af119fc7ecf734a2d2b6e319c8d74df5.tar.gz
lua-compat-5.3-ba8686d6af119fc7ecf734a2d2b6e319c8d74df5.tar.bz2
lua-compat-5.3-ba8686d6af119fc7ecf734a2d2b6e319c8d74df5.zip
link to wiki for functions with compatibility issues
-rw-r--r--README.md88
1 files changed, 38 insertions, 50 deletions
diff --git a/README.md b/README.md
index 90dd063..519a67a 100644
--- a/README.md
+++ b/README.md
@@ -65,9 +65,9 @@ your project:
65* the `utf8` module backported from the Lua 5.3 sources 65* the `utf8` module backported from the Lua 5.3 sources
66* `string.pack`, `string.packsize`, and `string.unpack` from the Lua 66* `string.pack`, `string.packsize`, and `string.unpack` from the Lua
67 5.3 sources or from the `struct` module. (`struct` is not 100% 67 5.3 sources or from the `struct` module. (`struct` is not 100%
68 compatible to Lua 5.3's string packing!) 68 compatible to Lua 5.3's string packing!) (See [here][4])
69* `math.maxinteger` and `math.mininteger`, `math.tointeger`, `math.type`, 69* `math.maxinteger` and `math.mininteger`, `math.tointeger`, `math.type`,
70 and `math.ult` 70 and `math.ult` (See [here][5]
71* `ipairs` respects `__index` metamethod 71* `ipairs` respects `__index` metamethod
72* `table.move` 72* `table.move`
73* `table` library respects metamethods 73* `table` library respects metamethods
@@ -75,50 +75,53 @@ your project:
75For Lua 5.1 additionally: 75For Lua 5.1 additionally:
76* `load` and `loadfile` accept `mode` and `env` parameters 76* `load` and `loadfile` accept `mode` and `env` parameters
77* `table.pack` and `table.unpack` 77* `table.pack` and `table.unpack`
78* string patterns may contain embedded zeros 78* string patterns may contain embedded zeros (but see [here][6])
79* `string.rep` accepts `sep` argument 79* `string.rep` accepts `sep` argument
80* `string.format` calls `tostring` on arguments for `%s` 80* `string.format` calls `tostring` on arguments for `%s`
81* `math.log` accepts base argument 81* `math.log` accepts base argument
82* `xpcall` takes additional arguments 82* `xpcall` takes additional arguments
83* `pcall` and `xpcall` can execute functions that yield 83* `pcall` and `xpcall` can execute functions that yield
84* `pairs` respects `__pairs` metamethod 84* `pairs` respects `__pairs` metamethod (see [here][7])
85* `rawlen` (but `#` still doesn't respect `__len` for tables) 85* `rawlen` (but `#` still doesn't respect `__len` for tables)
86* `package.searchers` as alias for `package.loaders` 86* `package.searchers` as alias for `package.loaders`
87* `package.searchpath` 87* `package.searchpath` (see [here][8])
88* `coroutine` functions dealing with the main coroutine 88* `coroutine` functions dealing with the main coroutine
89* `coroutine.create` accepts functions written in C 89* `coroutine.create` accepts functions written in C
90* return code of `os.execute` 90* return code of `os.execute` (see [here][9])
91* `io.write` and `file:write` return file handle 91* `io.write` and `file:write` return file handle
92* `io.lines` and `file:lines` accept format arguments (like `io.read`) 92* `io.lines` and `file:lines` accept format arguments (like `io.read`)
93 (see [here][10] and [here][11])
93* `debug.setmetatable` returns object 94* `debug.setmetatable` returns object
94* `debug.getuservalue` and `debug.setuservalue` 95* `debug.getuservalue` (see [here][12])
96* `debug.setuservalue` (see [here][13])
95 97
96### C 98### C
97 99
98* `lua_KContext` 100* `lua_KContext` (see [here][14])
99* `lua_KFunction` 101* `lua_KFunction` (see [here][14])
100* `lua_dump` (extra `strip` parameter, ignored) 102* `lua_dump` (extra `strip` parameter, ignored, see [here][15])
101* `lua_getfield` (return value) 103* `lua_getfield` (return value)
102* `lua_geti` and `lua_seti` 104* `lua_geti` and `lua_seti`
103* `lua_getglobal` (return value) 105* `lua_getglobal` (return value)
104* `lua_getmetafield` (return value) 106* `lua_getmetafield` (return value)
105* `lua_gettable` (return value) 107* `lua_gettable` (return value)
106* `lua_getuservalue` and `lua_setuservalue` (limited compatibility) 108* `lua_getuservalue` (limited compatibility, see [here][16])
109* `lua_setuservalue` (limited compatibility, see [here][17])
107* `lua_isinteger` 110* `lua_isinteger`
108* `lua_numbertointeger` 111* `lua_numbertointeger`
109* `lua_callk` and `lua_pcallk` (limited compatibility) 112* `lua_callk` and `lua_pcallk` (limited compatibility, see [here][14])
110* `lua_rawget` and `lua_rawgeti` (return values) 113* `lua_rawget` and `lua_rawgeti` (return values)
111* `lua_rawgetp` and `lua_rawsetp` 114* `lua_rawgetp` and `lua_rawsetp`
112* `luaL_requiref` (now checks `package.loaded` first) 115* `luaL_requiref` (now checks `package.loaded` first)
113* `lua_rotate` 116* `lua_rotate`
114* `lua_stringtonumber` 117* `lua_stringtonumber` (see [here][18])
115 118
116For Lua 5.1 additionally: 119For Lua 5.1 additionally:
117* `LUA_OK` 120* `LUA_OK`
118* `LUA_OP*` macros for `lua_arith` and `lua_compare` 121* `LUA_OP*` macros for `lua_arith` and `lua_compare`
119* `lua_Unsigned` 122* `lua_Unsigned`
120* `lua_absindex` 123* `lua_absindex`
121* `lua_arith` 124* `lua_arith` (see [here][19])
122* `lua_compare` 125* `lua_compare`
123* `lua_len`, `lua_rawlen`, and `luaL_len` 126* `lua_len`, `lua_rawlen`, and `luaL_len`
124* `lua_copy` 127* `lua_copy`
@@ -129,9 +132,11 @@ For Lua 5.1 additionally:
129* `luaL_getsubtable` 132* `luaL_getsubtable`
130* `luaL_traceback` 133* `luaL_traceback`
131* `luaL_fileresult` 134* `luaL_fileresult`
132* `luaL_checkversion` (with empty body, only to avoid compile errors) 135* `luaL_checkversion` (with empty body, only to avoid compile errors,
136 see [here][20])
133* `luaL_tolstring` 137* `luaL_tolstring`
134* `luaL_buffinitsize`, `luaL_prepbuffsize`, and `luaL_pushresultsize` 138* `luaL_buffinitsize`, `luaL_prepbuffsize`, and `luaL_pushresultsize`
139 (see [here][21])
135* `lua_pushunsigned`, `lua_tounsignedx`, `lua_tounsigned`, 140* `lua_pushunsigned`, `lua_tounsignedx`, `lua_tounsigned`,
136 `luaL_checkunsigned`, `luaL_optunsigned`, if 141 `luaL_checkunsigned`, `luaL_optunsigned`, if
137 `LUA_COMPAT_APIINTCASTS` is defined. 142 `LUA_COMPAT_APIINTCASTS` is defined.
@@ -158,41 +163,6 @@ For Lua 5.1 additionally:
158 * `luaL_loadbufferx` (5.1) 163 * `luaL_loadbufferx` (5.1)
159 * `luaL_loadfilex` (5.1) 164 * `luaL_loadfilex` (5.1)
160 165
161### Yieldable C functions
162
163The emulation of `lua_(p)callk` for previous Lua versions is not 100%
164perfect, because the continuation functions in Lua 5.2 have different
165signatures than the ones in Lua 5.3 (and Lua 5.1 doesn't have
166continuation functions at all). But with the help of a small macro the
167same code can be used for all three Lua versions (the 5.1 version
168won't support yielding though).
169
170Original Lua 5.3 code (example adapted from the Lua 5.3 manual):
171
172```C
173static int k (lua_State *L, int status, lua_KContext ctx) {
174 ... /* code 2 */
175}
176
177int original_function (lua_State *L) {
178 ... /* code 1 */
179 return k(L, lua_pcallk(L, n, m, h, ctx2, k), ctx1);
180}
181```
182
183Portable version:
184
185```C
186LUA_KFUNCTION( k ) {
187 ... /* code 2; parameters L, status, and ctx available here */
188}
189
190int original_function (lua_State *L) {
191 ... /* code 1 */
192 return k(L, lua_pcallk(L, n, m, h, ctx2, k), ctx1);
193}
194```
195
196## See also 166## See also
197 167
198* For Lua-5.2-style APIs under Lua 5.1, see [lua-compat-5.2][2], 168* For Lua-5.2-style APIs under Lua 5.1, see [lua-compat-5.2][2],
@@ -213,4 +183,22 @@ This package contains code written by:
213 [1]: http://www.inf.puc-rio.br/~roberto/struct/ 183 [1]: http://www.inf.puc-rio.br/~roberto/struct/
214 [2]: http://github.com/keplerproject/lua-compat-5.2/ 184 [2]: http://github.com/keplerproject/lua-compat-5.2/
215 [3]: http://keplerproject.org/compat/ 185 [3]: http://keplerproject.org/compat/
186 [4]: https://github.com/keplerproject/lua-compat-5.3/wiki/string_packing
187 [5]: https://github.com/keplerproject/lua-compat-5.3/wiki/math.type
188 [6]: https://github.com/keplerproject/lua-compat-5.3/wiki/pattern_matching
189 [7]: https://github.com/keplerproject/lua-compat-5.3/wiki/pairs
190 [8]: https://github.com/keplerproject/lua-compat-5.3/wiki/package.searchpath
191 [9]: https://github.com/keplerproject/lua-compat-5.3/wiki/os.execute
192 [10]: https://github.com/keplerproject/lua-compat-5.3/wiki/io.lines
193 [11]: https://github.com/keplerproject/lua-compat-5.3/wiki/file.lines
194 [12]: https://github.com/keplerproject/lua-compat-5.3/wiki/debug.getuservalue
195 [13]: https://github.com/keplerproject/lua-compat-5.3/wiki/debug.setuservalue
196 [14]: https://github.com/keplerproject/lua-compat-5.3/wiki/yieldable_c_functions
197 [15]: https://github.com/keplerproject/lua-compat-5.3/wiki/lua_dump
198 [16]: https://github.com/keplerproject/lua-compat-5.3/wiki/lua_getuservalue
199 [17]: https://github.com/keplerproject/lua-compat-5.3/wiki/lua_setuservalue
200 [18]: https://github.com/keplerproject/lua-compat-5.3/wiki/lua_stringtonumber
201 [19]: https://github.com/keplerproject/lua-compat-5.3/wiki/lua_arith
202 [20]: https://github.com/keplerproject/lua-compat-5.3/wiki/luaL_checkversion
203 [21]: https://github.com/keplerproject/lua-compat-5.3/wiki/luaL_Buffer
216 204