diff options
Diffstat (limited to 'ltm.h')
-rw-r--r-- | ltm.h | 49 |
1 files changed, 8 insertions, 41 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltm.h,v 1.28 2001/10/02 16:43:54 roberto Exp $ | 2 | ** $Id: ltm.h,v 1.1 2001/11/29 22:14:34 rieru Exp rieru $ |
3 | ** Tag methods | 3 | ** Tag methods |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -9,7 +9,6 @@ | |||
9 | 9 | ||
10 | 10 | ||
11 | #include "lobject.h" | 11 | #include "lobject.h" |
12 | #include "lstate.h" | ||
13 | 12 | ||
14 | /* | 13 | /* |
15 | * WARNING: if you change the order of this enumeration, | 14 | * WARNING: if you change the order of this enumeration, |
@@ -19,8 +18,7 @@ typedef enum { | |||
19 | TM_GETTABLE = 0, | 18 | TM_GETTABLE = 0, |
20 | TM_SETTABLE, | 19 | TM_SETTABLE, |
21 | TM_INDEX, | 20 | TM_INDEX, |
22 | TM_GETGLOBAL, | 21 | TM_GC, |
23 | TM_SETGLOBAL, | ||
24 | TM_ADD, | 22 | TM_ADD, |
25 | TM_SUB, | 23 | TM_SUB, |
26 | TM_MUL, | 24 | TM_MUL, |
@@ -29,51 +27,20 @@ typedef enum { | |||
29 | TM_UNM, | 27 | TM_UNM, |
30 | TM_LT, | 28 | TM_LT, |
31 | TM_CONCAT, | 29 | TM_CONCAT, |
32 | TM_GC, | 30 | TM_CALL, |
33 | TM_FUNCTION, | ||
34 | TM_N /* number of elements in the enum */ | 31 | TM_N /* number of elements in the enum */ |
35 | } TMS; | 32 | } TMS; |
36 | 33 | ||
37 | 34 | ||
38 | 35 | ||
39 | /* | 36 | #define fasttm(l,et,e) \ |
40 | ** masks for allowable tag methods | 37 | (((et)->flags & (1<<(e))) ? NULL : luaT_gettm(et, e, G(l)->tmname[e])) |
41 | ** (see `luaT_validevents') | ||
42 | */ | ||
43 | #define HAS_TM_GETGLOBAL(L,t) ((1<<(t)) & ((1<<LUA_TUSERDATA) | \ | ||
44 | (1<<LUA_TTABLE) | \ | ||
45 | (1<<LUA_TNIL))) | ||
46 | |||
47 | #define HAS_TM_SETGLOBAL(L,t) ((1<<(t)) & ((1<<LUA_TUSERDATA) | \ | ||
48 | (1<<LUA_TTABLE) | \ | ||
49 | (1<<LUA_TNIL) | \ | ||
50 | (1<<LUA_TFUNCTION))) | ||
51 | |||
52 | |||
53 | |||
54 | struct TM { | ||
55 | Closure *method[TM_N]; | ||
56 | Udata *collected; /* list of garbage-collected udata with this tag */ | ||
57 | TString *name; /* type name */ | ||
58 | int basictype; | ||
59 | }; | ||
60 | |||
61 | |||
62 | #define luaT_gettm(G,tag,event) (G->TMtable[tag].method[event]) | ||
63 | #define luaT_gettmbyObj(G,o,e) (luaT_gettm((G),luaT_tag(o),(e))) | ||
64 | |||
65 | #define typenamebytag(G, t) getstr(G->TMtable[t].name) | ||
66 | |||
67 | |||
68 | #define validtag(G,t) (NUM_TAGS <= (t) && (t) < G->ntag) | ||
69 | |||
70 | extern const char *const luaT_eventname[]; | ||
71 | 38 | ||
72 | 39 | ||
40 | const TObject *luaT_gettm (Table *events, TMS event, TString *ename); | ||
41 | const TObject *luaT_gettmbyobj (lua_State *L, const TObject *o, TMS event); | ||
73 | void luaT_init (lua_State *L); | 42 | void luaT_init (lua_State *L); |
74 | int luaT_newtag (lua_State *L, const char *name, int basictype); | ||
75 | const char *luaT_typename (global_State *G, const TObject *o); | ||
76 | int luaT_tag (const TObject *o); | ||
77 | 43 | ||
44 | extern const char *const luaT_typenames[]; | ||
78 | 45 | ||
79 | #endif | 46 | #endif |