diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-11-08 12:50:23 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-11-08 12:50:23 -0200 |
| commit | 26679ea35bf261f2b5edc2fb2f5cc4df483fd50d (patch) | |
| tree | 94c99ed74251cdf3e10a7e52560c3a7a78053ad1 /lvm.h | |
| parent | c3e5946fb2b7b5781d9bca9d303967abe6263482 (diff) | |
| download | lua-26679ea35bf261f2b5edc2fb2f5cc4df483fd50d.tar.gz lua-26679ea35bf261f2b5edc2fb2f5cc4df483fd50d.tar.bz2 lua-26679ea35bf261f2b5edc2fb2f5cc4df483fd50d.zip | |
new function 'luaV_flttointeger' to convert floats to integers (without
string coercions) + string operands to bitwise operations handled
by string metamethods
Diffstat (limited to 'lvm.h')
| -rw-r--r-- | lvm.h | 9 |
1 files changed, 8 insertions, 1 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lvm.h,v 2.45 2017/06/29 15:06:44 roberto Exp roberto $ | 2 | ** $Id: lvm.h,v 2.46 2017/07/07 16:34:32 roberto Exp roberto $ |
| 3 | ** Lua virtual machine | 3 | ** Lua virtual machine |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -53,6 +53,12 @@ | |||
| 53 | (ttisinteger(o) ? (*(i) = ivalue(o), 1) : luaV_tointeger(o,i,LUA_FLOORN2I)) | 53 | (ttisinteger(o) ? (*(i) = ivalue(o), 1) : luaV_tointeger(o,i,LUA_FLOORN2I)) |
| 54 | 54 | ||
| 55 | 55 | ||
| 56 | /* convert an object to an integer (without string coercion) */ | ||
| 57 | #define tointegerns(o,i) \ | ||
| 58 | (ttisinteger(o) ? (*(i) = ivalue(o), 1) \ | ||
| 59 | : luaV_flttointeger(o,i,LUA_FLOORN2I)) | ||
| 60 | |||
| 61 | |||
| 56 | #define intop(op,v1,v2) l_castU2S(l_castS2U(v1) op l_castS2U(v2)) | 62 | #define intop(op,v1,v2) l_castU2S(l_castS2U(v1) op l_castS2U(v2)) |
| 57 | 63 | ||
| 58 | #define luaV_rawequalobj(t1,t2) luaV_equalobj(NULL,t1,t2) | 64 | #define luaV_rawequalobj(t1,t2) luaV_equalobj(NULL,t1,t2) |
| @@ -100,6 +106,7 @@ LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r); | |||
| 100 | LUAI_FUNC int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r); | 106 | LUAI_FUNC int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r); |
| 101 | LUAI_FUNC int luaV_tonumber_ (const TValue *obj, lua_Number *n); | 107 | LUAI_FUNC int luaV_tonumber_ (const TValue *obj, lua_Number *n); |
| 102 | LUAI_FUNC int luaV_tointeger (const TValue *obj, lua_Integer *p, int mode); | 108 | LUAI_FUNC int luaV_tointeger (const TValue *obj, lua_Integer *p, int mode); |
| 109 | LUAI_FUNC int luaV_flttointeger (const TValue *obj, lua_Integer *p, int mode); | ||
| 103 | LUAI_FUNC void luaV_finishget (lua_State *L, const TValue *t, TValue *key, | 110 | LUAI_FUNC void luaV_finishget (lua_State *L, const TValue *t, TValue *key, |
| 104 | StkId val, const TValue *slot); | 111 | StkId val, const TValue *slot); |
| 105 | LUAI_FUNC void luaV_finishset (lua_State *L, const TValue *t, TValue *key, | 112 | LUAI_FUNC void luaV_finishset (lua_State *L, const TValue *t, TValue *key, |
