aboutsummaryrefslogtreecommitdiff
path: root/lobject.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-10-05 09:14:08 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-10-05 09:14:08 -0300
commit001f2bdd0e2f8803889c1b5164b57a51e44aef5b (patch)
treed200cf4d708be3c61e64640c45b47050c9c6a375 /lobject.h
parentcd2ddaded97f7f2b2af02cecfd165cf70e6f83f4 (diff)
downloadlua-001f2bdd0e2f8803889c1b5164b57a51e44aef5b.tar.gz
lua-001f2bdd0e2f8803889c1b5164b57a51e44aef5b.tar.bz2
lua-001f2bdd0e2f8803889c1b5164b57a51e44aef5b.zip
new definition for types-tags
Diffstat (limited to 'lobject.h')
-rw-r--r--lobject.h55
1 files changed, 21 insertions, 34 deletions
diff --git a/lobject.h b/lobject.h
index d6f667f4..dd7adeda 100644
--- a/lobject.h
+++ b/lobject.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lobject.h,v 1.77 2000/09/29 12:42:13 roberto Exp roberto $ 2** $Id: lobject.h,v 1.78 2000/10/02 20:10:55 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*/
@@ -31,41 +31,24 @@
31#endif 31#endif
32 32
33 33
34/* 34/* mark for closures active in the stack */
35** Lua TYPES 35#define LUA_TMARK 6
36** WARNING: if you change the order of this enumeration,
37** grep "ORDER LUA_T"
38*/
39typedef enum {
40 TAG_USERDATA = 0, /* default tag for userdata */
41 TAG_NUMBER, /* fixed tag for numbers */
42 TAG_STRING, /* fixed tag for strings */
43 TAG_TABLE, /* default tag for tables */
44 TAG_LCLOSURE, /* fixed tag for Lua closures */
45 TAG_CCLOSURE, /* fixed tag for C closures */
46 TAG_NIL, /* last "pre-defined" tag */
47
48 TAG_LMARK, /* mark for Lua closures */
49 TAG_CMARK /* mark for C closures */
50 36
51} lua_Tag;
52 37
53/* tags for values visible from Lua == first user-created tag */ 38/* tags for values visible from Lua == first user-created tag */
54#define NUM_TAGS 7 39#define NUM_TAGS 6
55 40
56 41
57/* 42/* check whether `t' is a mark */
58** check whether `t' is a mark 43#define is_T_MARK(t) ((t) == LUA_TMARK)
59*/
60#define is_T_MARK(t) ((t) == TAG_LMARK || (t) == TAG_CMARK)
61 44
62 45
63typedef union { 46typedef union {
64 struct TString *ts; /* TAG_STRING, TAG_USERDATA */ 47 struct TString *ts; /* LUA_TSTRING, LUA_TUSERDATA */
65 struct Closure *cl; /* TAG_[CL]CLOSURE, TAG_CMARK */ 48 struct Closure *cl; /* LUA_TFUNCTION */
66 struct Hash *a; /* TAG_TABLE */ 49 struct Hash *a; /* LUA_TTABLE */
67 struct CallInfo *i; /* TAG_LMARK */ 50 struct CallInfo *i; /* LUA_TLMARK */
68 Number n; /* TAG_NUMBER */ 51 Number n; /* LUA_TNUMBER */
69} Value; 52} Value;
70 53
71 54
@@ -80,7 +63,7 @@ typedef union {
80 63
81 64
82typedef struct lua_TObject { 65typedef struct lua_TObject {
83 lua_Tag ttype; 66 int ttype;
84 Value value; 67 Value value;
85} TObject; 68} TObject;
86 69
@@ -150,11 +133,15 @@ typedef struct Closure {
150 } f; 133 } f;
151 struct Closure *next; 134 struct Closure *next;
152 struct Closure *mark; /* marked closures (point to itself when not marked) */ 135 struct Closure *mark; /* marked closures (point to itself when not marked) */
153 int nupvalues; 136 short isC; /* 0 for Lua functions, 1 for C functions */
137 short nupvalues;
154 TObject upvalue[1]; 138 TObject upvalue[1];
155} Closure; 139} Closure;
156 140
157 141
142#define iscfunction(o) (ttype(o) == LUA_TFUNCTION && clvalue(o)->isC)
143
144
158typedef struct Node { 145typedef struct Node {
159 TObject key; 146 TObject key;
160 TObject val; 147 TObject val;
@@ -189,12 +176,12 @@ typedef struct CallInfo {
189} CallInfo; 176} CallInfo;
190 177
191 178
192extern const lua_Type luaO_typearr[];
193extern const TObject luaO_nilobject; 179extern const TObject luaO_nilobject;
180extern const char *const luaO_typenames[];
181
182
183#define luaO_typename(o) (luaO_typenames[ttype(o)])
194 184
195#define luaO_tag2type(t) (luaO_typearr[(int)(t)])
196#define luaO_type(o) (luaO_tag2type(ttype(o)))
197#define luaO_typename(L, o) (lua_typename(L, luaO_type(o)))
198 185
199lint32 luaO_power2 (lint32 n); 186lint32 luaO_power2 (lint32 n);
200char *luaO_openspace (lua_State *L, size_t n); 187char *luaO_openspace (lua_State *L, size_t n);