aboutsummaryrefslogtreecommitdiff
path: root/lobject.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-04-05 15:54:31 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-04-05 15:54:31 -0300
commit237969724f54eeefee057ae382237c8db54af44e (patch)
treefc4abd54f7cac0749023f1c021e7d86e3ee4f273 /lobject.h
parentf438d00ef31e3aea54023602f529b68834ffb80a (diff)
downloadlua-237969724f54eeefee057ae382237c8db54af44e.tar.gz
lua-237969724f54eeefee057ae382237c8db54af44e.tar.bz2
lua-237969724f54eeefee057ae382237c8db54af44e.zip
support for `light' userdata + simpler support for `boxed' udata
Diffstat (limited to 'lobject.h')
-rw-r--r--lobject.h17
1 files changed, 8 insertions, 9 deletions
diff --git a/lobject.h b/lobject.h
index dca2531a..a7286927 100644
--- a/lobject.h
+++ b/lobject.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lobject.h,v 1.127 2002/03/18 18:16:16 roberto Exp roberto $ 2** $Id: lobject.h,v 1.128 2002/03/25 17:47:14 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*/
@@ -13,15 +13,15 @@
13 13
14 14
15/* tags for values visible from Lua */ 15/* tags for values visible from Lua */
16#define NUM_TAGS 6 16#define NUM_TAGS LUA_TFUNCTION
17 17
18 18
19typedef union { 19typedef union {
20 void *p;
20 union TString *ts; 21 union TString *ts;
21 union Udata *u; 22 union Udata *u;
22 union Closure *cl; 23 union Closure *cl;
23 struct Table *h; 24 struct Table *h;
24 struct lua_TObject *v;
25 lua_Number n; 25 lua_Number n;
26 int b; 26 int b;
27} Value; 27} Value;
@@ -35,12 +35,12 @@ typedef struct lua_TObject {
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 nvalue(o) ((o)->value.n) 39#define nvalue(o) ((o)->value.n)
39#define tsvalue(o) ((o)->value.ts) 40#define tsvalue(o) ((o)->value.ts)
40#define uvalue(o) ((o)->value.u) 41#define uvalue(o) ((o)->value.u)
41#define clvalue(o) ((o)->value.cl) 42#define clvalue(o) ((o)->value.cl)
42#define hvalue(o) ((o)->value.h) 43#define hvalue(o) ((o)->value.h)
43#define vvalue(o) ((o)->value.v)
44#define bvalue(o) ((o)->value.b) 44#define bvalue(o) ((o)->value.b)
45 45
46#define l_isfalse(o) (ttype(o) == LUA_TNIL || \ 46#define l_isfalse(o) (ttype(o) == LUA_TNIL || \
@@ -52,6 +52,9 @@ typedef struct lua_TObject {
52 52
53#define chgnvalue(obj,x) ((obj)->value.n=(x)) 53#define chgnvalue(obj,x) ((obj)->value.n=(x))
54 54
55#define setpvalue(obj,x) \
56 { TObject *i_o=(obj); i_o->tt=LUA_TUDATAVAL; i_o->value.p=(x); }
57
55#define setbvalue(obj,x) \ 58#define setbvalue(obj,x) \
56 { TObject *i_o=(obj); i_o->tt=LUA_TBOOLEAN; i_o->value.b=(x); } 59 { TObject *i_o=(obj); i_o->tt=LUA_TBOOLEAN; i_o->value.b=(x); }
57 60
@@ -69,9 +72,6 @@ typedef struct lua_TObject {
69 72
70#define setnilvalue(obj) ((obj)->tt=LUA_TNIL) 73#define setnilvalue(obj) ((obj)->tt=LUA_TNIL)
71 74
72#define setupvalue(obj,x,t) \
73 { TObject *i_o=(obj); i_o->tt=(t); i_o->value.v=(x); }
74
75#define setobj(obj1,obj2) \ 75#define setobj(obj1,obj2) \
76 { TObject *o1=(obj1); const TObject *o2=(obj2); \ 76 { TObject *o1=(obj1); const TObject *o2=(obj2); \
77 o1->tt=o2->tt; o1->value = o2->value; } 77 o1->tt=o2->tt; o1->value = o2->value; }
@@ -106,9 +106,8 @@ typedef union Udata {
106 union L_Umaxalign dummy; /* ensures maximum alignment for `local' udata */ 106 union L_Umaxalign dummy; /* ensures maximum alignment for `local' udata */
107 struct { 107 struct {
108 struct Table *metatable; 108 struct Table *metatable;
109 void *value;
110 union Udata *next; /* chain for list of all udata */ 109 union Udata *next; /* chain for list of all udata */
111 size_t len; /* least bit reserved for gc mark */ 110 size_t len; /* least 2 bits reserved for gc mark */
112 } uv; 111 } uv;
113} Udata; 112} Udata;
114 113