Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/facebook/luaffifb.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Gross <colesbury@gmail.com>2015-08-17 22:36:45 +0300
committerSam Gross <colesbury@gmail.com>2015-08-17 22:39:01 +0300
commit82912f3127f1ad5559d6be753a77830195a1c4a0 (patch)
tree1bafda8e381176ec7d3f36ba1ed33c4f47a67c70
parent28bb3a85c295df72c619c9c99f6a3f3d99d33644 (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.md2
-rw-r--r--ffi.c5
2 files changed, 6 insertions, 1 deletions
diff --git a/README.md b/README.md
index b79fcdb..10f2ab3 100644
--- a/README.md
+++ b/README.md
@@ -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
diff --git a/ffi.c b/ffi.c
index 91f592a..4d1e140 100644
--- a/ffi.c
+++ b/ffi.c
@@ -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;