From d86170662017645cf22884641f33a9d6b48d16e6 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 30 Jul 2014 11:42:44 -0300 Subject: new macro 'cvt2num' to better control whether strings are convertible to numbers --- lvm.h | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'lvm.h') diff --git a/lvm.h b/lvm.h index 0a4984cb..86fb874c 100644 --- a/lvm.h +++ b/lvm.h @@ -1,5 +1,5 @@ /* -** $Id: lvm.h,v 2.31 2014/05/26 17:10:22 roberto Exp roberto $ +** $Id: lvm.h,v 2.32 2014/07/30 14:00:14 roberto Exp roberto $ ** Lua virtual machine ** See Copyright Notice in lua.h */ @@ -13,6 +13,20 @@ #include "ltm.h" +#if !defined(LUA_NOCVTN2S) +#define cvt2str(o) ttisnumber(o) +#else +#define cvt2str(o) 0 /* no convertion from numbers to strings */ +#endif + + +#if !defined(LUA_NOCVTS2N) +#define cvt2num(o) ttisstring(o) +#else +#define cvt2num(o) 0 /* no convertion from strings to numbers */ +#endif + + #define tonumber(o,n) \ (ttisfloat(o) ? (*(n) = fltvalue(o), 1) : luaV_tonumber_(o,n)) @@ -24,13 +38,6 @@ #define luaV_rawequalobj(t1,t2) luaV_equalobj(NULL,t1,t2) -#if !defined(LUA_NOCVTN2S) -#define cvt2str(o) ttisnumber(o) -#else -#define cvt2str(o) 0 /* no convertion from numbers to strings */ -#endif - - LUAI_FUNC int luaV_equalobj (lua_State *L, const TValue *t1, const TValue *t2); LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r); LUAI_FUNC int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r); -- cgit v1.2.3-55-g6feb