aboutsummaryrefslogtreecommitdiff
path: root/lobject.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-06-13 10:39:55 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-06-13 10:39:55 -0300
commit864c96f36ce8410b03652b1cb9800e4b3c76bcf7 (patch)
treed5061c0babf25cf222953e5195673534f8287f34 /lobject.h
parent0052930ffe8c86f0df7ab99dd1b6668f9e10c781 (diff)
downloadlua-864c96f36ce8410b03652b1cb9800e4b3c76bcf7.tar.gz
lua-864c96f36ce8410b03652b1cb9800e4b3c76bcf7.tar.bz2
lua-864c96f36ce8410b03652b1cb9800e4b3c76bcf7.zip
new fallback for equality `__eq'
Diffstat (limited to 'lobject.h')
-rw-r--r--lobject.h26
1 files changed, 14 insertions, 12 deletions
diff --git a/lobject.h b/lobject.h
index e818029e..8438881f 100644
--- a/lobject.h
+++ b/lobject.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lobject.h,v 1.133 2002/05/16 18:39:46 roberto Exp roberto $ 2** $Id: lobject.h,v 1.134 2002/06/12 14:56:22 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*/
@@ -34,14 +34,14 @@ typedef struct lua_TObject {
34 34
35 35
36/* Macros to access values */ 36/* Macros to access values */
37#define ttype(o) ((o)->tt) 37#define ttype(o) ((o)->tt)
38#define pvalue(o) ((o)->value.p) 38#define pvalue(o) check_exp(ttype(o)==LUA_TUDATAVAL, (o)->value.p)
39#define nvalue(o) ((o)->value.n) 39#define nvalue(o) check_exp(ttype(o)==LUA_TNUMBER, (o)->value.n)
40#define tsvalue(o) ((o)->value.ts) 40#define tsvalue(o) check_exp(ttype(o)==LUA_TSTRING, (o)->value.ts)
41#define uvalue(o) ((o)->value.u) 41#define uvalue(o) check_exp(ttype(o)==LUA_TUSERDATA, (o)->value.u)
42#define clvalue(o) ((o)->value.cl) 42#define clvalue(o) check_exp(ttype(o)==LUA_TFUNCTION, (o)->value.cl)
43#define hvalue(o) ((o)->value.h) 43#define hvalue(o) check_exp(ttype(o)==LUA_TTABLE, (o)->value.h)
44#define bvalue(o) ((o)->value.b) 44#define bvalue(o) check_exp(ttype(o)==LUA_TBOOLEAN, (o)->value.b)
45 45
46#define l_isfalse(o) (ttype(o) == LUA_TNIL || \ 46#define l_isfalse(o) (ttype(o) == LUA_TNIL || \
47 (ttype(o) == LUA_TBOOLEAN && bvalue(o) == 0)) 47 (ttype(o) == LUA_TBOOLEAN && bvalue(o) == 0))
@@ -50,7 +50,8 @@ typedef struct lua_TObject {
50#define setnvalue(obj,x) \ 50#define setnvalue(obj,x) \
51 { TObject *i_o=(obj); i_o->tt=LUA_TNUMBER; i_o->value.n=(x); } 51 { TObject *i_o=(obj); i_o->tt=LUA_TNUMBER; i_o->value.n=(x); }
52 52
53#define chgnvalue(obj,x) ((obj)->value.n=(x)) 53#define chgnvalue(obj,x) \
54 check_exp(ttype(obj)==LUA_TNUMBER, (obj)->value.n=(x))
54 55
55#define setpvalue(obj,x) \ 56#define setpvalue(obj,x) \
56 { TObject *i_o=(obj); i_o->tt=LUA_TUDATAVAL; i_o->value.p=(x); } 57 { TObject *i_o=(obj); i_o->tt=LUA_TUDATAVAL; i_o->value.p=(x); }
@@ -222,7 +223,8 @@ typedef struct Table {
222/* 223/*
223** `module' operation for hashing (size is always a power of 2) 224** `module' operation for hashing (size is always a power of 2)
224*/ 225*/
225#define lmod(s,size) (cast(int, (s) & ((size)-1))) 226#define lmod(s,size) \
227 check_exp((size&(size-1))==0, (cast(int, (s) & ((size)-1))))
226 228
227 229
228#define twoto(x) (1<<(x)) 230#define twoto(x) (1<<(x))
@@ -239,7 +241,7 @@ int luaO_log2 (unsigned int x);
239#define luaO_openspace(L,n,t) cast(t *, luaO_openspaceaux(L,(n)*sizeof(t))) 241#define luaO_openspace(L,n,t) cast(t *, luaO_openspaceaux(L,(n)*sizeof(t)))
240void *luaO_openspaceaux (lua_State *L, size_t n); 242void *luaO_openspaceaux (lua_State *L, size_t n);
241 243
242int luaO_equalObj (const TObject *t1, const TObject *t2); 244int luaO_rawequalObj (const TObject *t1, const TObject *t2);
243int luaO_str2d (const char *s, lua_Number *result); 245int luaO_str2d (const char *s, lua_Number *result);
244 246
245const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp); 247const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp);