diff options
author | Sam Gross <colesbury@gmail.com> | 2015-08-17 22:36:45 +0300 |
---|---|---|
committer | Sam Gross <colesbury@gmail.com> | 2015-08-17 22:39:01 +0300 |
commit | 82912f3127f1ad5559d6be753a77830195a1c4a0 (patch) | |
tree | 1bafda8e381176ec7d3f36ba1ed33c4f47a67c70 | |
parent | 28bb3a85c295df72c619c9c99f6a3f3d99d33644 (diff) |
Add ffi.NULL as a copy of ffi.C.NULL
The ffi.NULL constant is preferable to ffi.C.NULL because it can be used in
both LuaJIT and LuaFFI code. (In LuaJIT it's just nil)
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | ffi.c | 5 |
2 files changed, 6 insertions, 1 deletions
@@ -27,7 +27,7 @@ Build Known Issues
------------
- Comparing a ctype pointer to nil doesn't work the same as luajit. This is
- unfixable with the current metamethod semantics. Instead use ffi.C.NULL
+ unfixable with the current metamethod semantics. Instead use ffi.NULL
- Constant expressions can't handle non integer intermediate values (eg
offsetof won't work because it manipulates pointers)
- Not all metamethods work with lua 5.1 (eg char* + number). This is due to
@@ -3287,9 +3287,14 @@ static int setup_upvals(lua_State* L) ct.pointers = 1; ct.is_null = 1; + /* add ffi.C.NULL */ push_cdata(L, 0, &ct); lua_setfield(L, -2, "NULL"); + /* add ffi.NULL */ + push_cdata(L, 0, &ct); + lua_setfield(L, 1, "NULL"); + memset(&ct, 0, sizeof(ct)); ct.type = COMPLEX_DOUBLE_TYPE; ct.is_defined = 1; |