1 /*
2 ** $Id$
3 ** Tag methods
4 ** See Copyright Notice in lua.h
5 */
6 
7 #ifndef ltm_h
8 #define ltm_h
9 
10 
11 #include "lobject.h"
12 #include "lstate.h"
13 
14 /*
15 * WARNING: if you change the order of this enumeration,
16 * grep "ORDER TM"
17 */
18 typedef enum {
19   TM_GETTABLE = 0,
20   TM_SETTABLE,
21   TM_INDEX,
22   TM_GETGLOBAL,
23   TM_SETGLOBAL,
24   TM_ADD,
25   TM_SUB,
26   TM_MUL,
27   TM_DIV,
28   TM_POW,
29   TM_UNM,
30   TM_LT,
31   TM_CONCAT,
32   TM_GC,
33   TM_FUNCTION,
34   TM_N		/* number of elements in the enum */
35 } TMS;
36 
37 
38 struct TM {
39   Closure *method[TM_N];
40   TString *collected;  /* list of garbage-collected udata with this tag */
41 };
42 
43 
44 #define luaT_gettm(L,tag,event) (L->TMtable[tag].method[event])
45 #define luaT_gettmbyObj(L,o,e)  (luaT_gettm((L),luaT_tag(o),(e)))
46 
47 
48 #define validtag(t) (NUM_TAGS <= (t) && (t) <= L->last_tag)
49 
50 extern const char *const luaT_eventname[];
51 
52 
53 void luaT_init (lua_State *L);
54 void luaT_realtag (lua_State *L, int tag);
55 int luaT_tag (const TObject *o);
56 int luaT_validevent (int t, int e);  /* used by compatibility module */
57 
58 
59 #endif
60