diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-08-05 11:50:39 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-08-05 11:50:39 -0300 |
commit | 5037196f6fddb828056578b1c0d352cdef672d6a (patch) | |
tree | d1be52a5ad8fd5cebf30f7023a9c66b7bdc9563f /lobject.h | |
parent | 9fb80bde3c80557f8ad2d5642bcbeac343999994 (diff) | |
download | lua-5037196f6fddb828056578b1c0d352cdef672d6a.tar.gz lua-5037196f6fddb828056578b1c0d352cdef672d6a.tar.bz2 lua-5037196f6fddb828056578b1c0d352cdef672d6a.zip |
new macros `ttis*'
Diffstat (limited to 'lobject.h')
-rw-r--r-- | lobject.h | 31 |
1 files changed, 20 insertions, 11 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lobject.h,v 1.139 2002/07/01 17:06:58 roberto Exp roberto $ | 2 | ** $Id: lobject.h,v 1.140 2002/07/17 16:25:13 roberto Exp $ |
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 | */ |
@@ -33,18 +33,27 @@ typedef struct lua_TObject { | |||
33 | } TObject; | 33 | } TObject; |
34 | 34 | ||
35 | 35 | ||
36 | /* Macros to test type */ | ||
37 | #define ttisnil(o) (ttype(o) == LUA_TNIL) | ||
38 | #define ttisnumber(o) (ttype(o) == LUA_TNUMBER) | ||
39 | #define ttisstring(o) (ttype(o) == LUA_TSTRING) | ||
40 | #define ttistable(o) (ttype(o) == LUA_TTABLE) | ||
41 | #define ttisfunction(o) (ttype(o) == LUA_TFUNCTION) | ||
42 | #define ttisboolean(o) (ttype(o) == LUA_TBOOLEAN) | ||
43 | #define ttisuserdata(o) (ttype(o) == LUA_TUSERDATA) | ||
44 | #define ttislightuserdata(o) (ttype(o) == LUA_TLIGHTUSERDATA) | ||
45 | |||
36 | /* Macros to access values */ | 46 | /* Macros to access values */ |
37 | #define ttype(o) ((o)->tt) | 47 | #define ttype(o) ((o)->tt) |
38 | #define pvalue(o) check_exp(ttype(o)==LUA_TLIGHTUSERDATA, (o)->value.p) | 48 | #define pvalue(o) check_exp(ttislightuserdata(o), (o)->value.p) |
39 | #define nvalue(o) check_exp(ttype(o)==LUA_TNUMBER, (o)->value.n) | 49 | #define nvalue(o) check_exp(ttisnumber(o), (o)->value.n) |
40 | #define tsvalue(o) check_exp(ttype(o)==LUA_TSTRING, (o)->value.ts) | 50 | #define tsvalue(o) check_exp(ttisstring(o), (o)->value.ts) |
41 | #define uvalue(o) check_exp(ttype(o)==LUA_TUSERDATA, (o)->value.u) | 51 | #define uvalue(o) check_exp(ttisuserdata(o), (o)->value.u) |
42 | #define clvalue(o) check_exp(ttype(o)==LUA_TFUNCTION, (o)->value.cl) | 52 | #define clvalue(o) check_exp(ttisfunction(o), (o)->value.cl) |
43 | #define hvalue(o) check_exp(ttype(o)==LUA_TTABLE, (o)->value.h) | 53 | #define hvalue(o) check_exp(ttistable(o), (o)->value.h) |
44 | #define bvalue(o) check_exp(ttype(o)==LUA_TBOOLEAN, (o)->value.b) | 54 | #define bvalue(o) check_exp(ttisboolean(o), (o)->value.b) |
45 | 55 | ||
46 | #define l_isfalse(o) (ttype(o) == LUA_TNIL || \ | 56 | #define l_isfalse(o) (ttisnil(o) || (ttisboolean(o) && bvalue(o) == 0)) |
47 | (ttype(o) == LUA_TBOOLEAN && bvalue(o) == 0)) | ||
48 | 57 | ||
49 | /* Macros to set values */ | 58 | /* Macros to set values */ |
50 | #define setnvalue(obj,x) \ | 59 | #define setnvalue(obj,x) \ |