From 237969724f54eeefee057ae382237c8db54af44e Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 5 Apr 2002 15:54:31 -0300 Subject: support for `light' userdata + simpler support for `boxed' udata --- lobject.h | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'lobject.h') diff --git a/lobject.h b/lobject.h index dca2531a..a7286927 100644 --- a/lobject.h +++ b/lobject.h @@ -1,5 +1,5 @@ /* -** $Id: lobject.h,v 1.127 2002/03/18 18:16:16 roberto Exp roberto $ +** $Id: lobject.h,v 1.128 2002/03/25 17:47:14 roberto Exp roberto $ ** Type definitions for Lua objects ** See Copyright Notice in lua.h */ @@ -13,15 +13,15 @@ /* tags for values visible from Lua */ -#define NUM_TAGS 6 +#define NUM_TAGS LUA_TFUNCTION typedef union { + void *p; union TString *ts; union Udata *u; union Closure *cl; struct Table *h; - struct lua_TObject *v; lua_Number n; int b; } Value; @@ -35,12 +35,12 @@ typedef struct lua_TObject { /* Macros to access values */ #define ttype(o) ((o)->tt) +#define pvalue(o) ((o)->value.p) #define nvalue(o) ((o)->value.n) #define tsvalue(o) ((o)->value.ts) #define uvalue(o) ((o)->value.u) #define clvalue(o) ((o)->value.cl) #define hvalue(o) ((o)->value.h) -#define vvalue(o) ((o)->value.v) #define bvalue(o) ((o)->value.b) #define l_isfalse(o) (ttype(o) == LUA_TNIL || \ @@ -52,6 +52,9 @@ typedef struct lua_TObject { #define chgnvalue(obj,x) ((obj)->value.n=(x)) +#define setpvalue(obj,x) \ + { TObject *i_o=(obj); i_o->tt=LUA_TUDATAVAL; i_o->value.p=(x); } + #define setbvalue(obj,x) \ { TObject *i_o=(obj); i_o->tt=LUA_TBOOLEAN; i_o->value.b=(x); } @@ -69,9 +72,6 @@ typedef struct lua_TObject { #define setnilvalue(obj) ((obj)->tt=LUA_TNIL) -#define setupvalue(obj,x,t) \ - { TObject *i_o=(obj); i_o->tt=(t); i_o->value.v=(x); } - #define setobj(obj1,obj2) \ { TObject *o1=(obj1); const TObject *o2=(obj2); \ o1->tt=o2->tt; o1->value = o2->value; } @@ -106,9 +106,8 @@ typedef union Udata { union L_Umaxalign dummy; /* ensures maximum alignment for `local' udata */ struct { struct Table *metatable; - void *value; union Udata *next; /* chain for list of all udata */ - size_t len; /* least bit reserved for gc mark */ + size_t len; /* least 2 bits reserved for gc mark */ } uv; } Udata; -- cgit v1.2.3-55-g6feb