From 6408bc0b7f23b580cb51b591277b82eac58f6e2e Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 2 Mar 2015 13:04:52 -0300 Subject: new macros 'chgfltvalue'/'chgivalue' (numerical for loop does not need to set the type of its internal variable at each iteration) --- lobject.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lobject.h') diff --git a/lobject.h b/lobject.h index cb194105..2897deac 100644 --- a/lobject.h +++ b/lobject.h @@ -1,5 +1,5 @@ /* -** $Id: lobject.h,v 2.106 2015/01/05 13:52:37 roberto Exp roberto $ +** $Id: lobject.h,v 2.107 2015/01/16 16:54:37 roberto Exp roberto $ ** Type definitions for Lua objects ** See Copyright Notice in lua.h */ @@ -190,9 +190,15 @@ typedef struct lua_TValue TValue; #define setfltvalue(obj,x) \ { TValue *io=(obj); val_(io).n=(x); settt_(io, LUA_TNUMFLT); } +#define chgfltvalue(obj,x) \ + { TValue *io=(obj); lua_assert(ttisfloat(io)); val_(io).n=(x); } + #define setivalue(obj,x) \ { TValue *io=(obj); val_(io).i=(x); settt_(io, LUA_TNUMINT); } +#define chgivalue(obj,x) \ + { TValue *io=(obj); lua_assert(ttisinteger(io)); val_(io).i=(x); } + #define setnilvalue(obj) settt_(obj, LUA_TNIL) #define setfvalue(obj,x) \ -- cgit v1.2.3-55-g6feb