diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-12-19 11:36:32 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-12-19 11:36:32 -0200 |
commit | 2b83711fbac0509a40cfb616b9a68bdf683e8471 (patch) | |
tree | 1f244bc08de68b01df8b9d2ff558558703a1a6bb /lobject.h | |
parent | 3ae21a352c4cad550a97974c68cd57c3abc39570 (diff) | |
download | lua-2b83711fbac0509a40cfb616b9a68bdf683e8471.tar.gz lua-2b83711fbac0509a40cfb616b9a68bdf683e8471.tar.bz2 lua-2b83711fbac0509a40cfb616b9a68bdf683e8471.zip |
new macro 'nvalue' (to convert an object to a float when we know
object is a number)
Diffstat (limited to 'lobject.h')
-rw-r--r-- | lobject.h | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lobject.h,v 2.103 2014/10/01 11:52:33 roberto Exp roberto $ | 2 | ** $Id: lobject.h,v 2.104 2014/10/25 11:50:46 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 | */ |
@@ -154,6 +154,8 @@ typedef struct lua_TValue TValue; | |||
154 | /* Macros to access values */ | 154 | /* Macros to access values */ |
155 | #define ivalue(o) check_exp(ttisinteger(o), val_(o).i) | 155 | #define ivalue(o) check_exp(ttisinteger(o), val_(o).i) |
156 | #define fltvalue(o) check_exp(ttisfloat(o), val_(o).n) | 156 | #define fltvalue(o) check_exp(ttisfloat(o), val_(o).n) |
157 | #define nvalue(o) check_exp(ttisnumber(o), \ | ||
158 | (ttisinteger(o) ? cast_num(ivalue(o)) : fltvalue(o))) | ||
157 | #define gcvalue(o) check_exp(iscollectable(o), val_(o).gc) | 159 | #define gcvalue(o) check_exp(iscollectable(o), val_(o).gc) |
158 | #define pvalue(o) check_exp(ttislightuserdata(o), val_(o).p) | 160 | #define pvalue(o) check_exp(ttislightuserdata(o), val_(o).p) |
159 | #define tsvalue(o) check_exp(ttisstring(o), gco2ts(val_(o).gc)) | 161 | #define tsvalue(o) check_exp(ttisstring(o), gco2ts(val_(o).gc)) |