diff options
-rw-r--r-- | lobject.h | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lobject.h,v 2.64 2011/10/31 17:48:22 roberto Exp roberto $ | 2 | ** $Id: lobject.h,v 2.65 2012/01/20 22:05:50 roberto Exp roberto $ |
3 | ** Type definitions for Lua objects | 3 | ** Type definitions for Lua objects |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -36,6 +36,9 @@ | |||
36 | ** bit 6: whether value is collectable | 36 | ** bit 6: whether value is collectable |
37 | */ | 37 | */ |
38 | 38 | ||
39 | #define VARBITS (3 << 4) | ||
40 | |||
41 | |||
39 | /* | 42 | /* |
40 | ** LUA_TFUNCTION variants: | 43 | ** LUA_TFUNCTION variants: |
41 | ** 0 - Lua function | 44 | ** 0 - Lua function |
@@ -121,13 +124,14 @@ typedef struct lua_TValue TValue; | |||
121 | 124 | ||
122 | /* Macros to test type */ | 125 | /* Macros to test type */ |
123 | #define checktag(o,t) (rttype(o) == (t)) | 126 | #define checktag(o,t) (rttype(o) == (t)) |
127 | #define checktype(o,t) (ttypenv(o) == (t)) | ||
124 | #define ttisnumber(o) checktag((o), LUA_TNUMBER) | 128 | #define ttisnumber(o) checktag((o), LUA_TNUMBER) |
125 | #define ttisnil(o) checktag((o), LUA_TNIL) | 129 | #define ttisnil(o) checktag((o), LUA_TNIL) |
126 | #define ttisboolean(o) checktag((o), LUA_TBOOLEAN) | 130 | #define ttisboolean(o) checktag((o), LUA_TBOOLEAN) |
127 | #define ttislightuserdata(o) checktag((o), LUA_TLIGHTUSERDATA) | 131 | #define ttislightuserdata(o) checktag((o), LUA_TLIGHTUSERDATA) |
128 | #define ttisstring(o) checktag((o), ctb(LUA_TSTRING)) | 132 | #define ttisstring(o) checktag((o), ctb(LUA_TSTRING)) |
129 | #define ttistable(o) checktag((o), ctb(LUA_TTABLE)) | 133 | #define ttistable(o) checktag((o), ctb(LUA_TTABLE)) |
130 | #define ttisfunction(o) (ttypenv(o) == LUA_TFUNCTION) | 134 | #define ttisfunction(o) checktype(o, LUA_TFUNCTION) |
131 | #define ttisclosure(o) ((rttype(o) & 0x1F) == LUA_TFUNCTION) | 135 | #define ttisclosure(o) ((rttype(o) & 0x1F) == LUA_TFUNCTION) |
132 | #define ttisCclosure(o) checktag((o), ctb(LUA_TCCL)) | 136 | #define ttisCclosure(o) checktag((o), ctb(LUA_TCCL)) |
133 | #define ttisLclosure(o) checktag((o), ctb(LUA_TLCL)) | 137 | #define ttisLclosure(o) checktag((o), ctb(LUA_TLCL)) |
@@ -350,7 +354,9 @@ typedef struct lua_TValue TValue; | |||
350 | */ | 354 | */ |
351 | 355 | ||
352 | #undef checktag | 356 | #undef checktag |
357 | #undef checktype | ||
353 | #define checktag(o,t) (tt_(o) == tag2tt(t)) | 358 | #define checktag(o,t) (tt_(o) == tag2tt(t)) |
359 | #define checktype(o,t) (ctb(tt_(o) | VARBITS) == ctb(tag2tt(t) | VARBITS)) | ||
354 | 360 | ||
355 | #undef ttisequal | 361 | #undef ttisequal |
356 | #define ttisequal(o1,o2) \ | 362 | #define ttisequal(o1,o2) \ |