xref: /freebsd/sys/contrib/openzfs/module/lua/ltm.h (revision c03c5b1c)
1*eda14cbcSMatt Macy /*
2*eda14cbcSMatt Macy ** $Id: ltm.h,v 2.11.1.1 2013/04/12 18:48:47 roberto Exp $
3*eda14cbcSMatt Macy ** Tag methods
4*eda14cbcSMatt Macy ** See Copyright Notice in lua.h
5*eda14cbcSMatt Macy */
6*eda14cbcSMatt Macy 
7*eda14cbcSMatt Macy #ifndef ltm_h
8*eda14cbcSMatt Macy #define ltm_h
9*eda14cbcSMatt Macy 
10*eda14cbcSMatt Macy 
11*eda14cbcSMatt Macy #include "lobject.h"
12*eda14cbcSMatt Macy 
13*eda14cbcSMatt Macy 
14*eda14cbcSMatt Macy /*
15*eda14cbcSMatt Macy * WARNING: if you change the order of this enumeration,
16*eda14cbcSMatt Macy * grep "ORDER TM"
17*eda14cbcSMatt Macy */
18*eda14cbcSMatt Macy typedef enum {
19*eda14cbcSMatt Macy   TM_INDEX,
20*eda14cbcSMatt Macy   TM_NEWINDEX,
21*eda14cbcSMatt Macy   TM_GC,
22*eda14cbcSMatt Macy   TM_MODE,
23*eda14cbcSMatt Macy   TM_LEN,
24*eda14cbcSMatt Macy   TM_EQ,  /* last tag method with `fast' access */
25*eda14cbcSMatt Macy   TM_ADD,
26*eda14cbcSMatt Macy   TM_SUB,
27*eda14cbcSMatt Macy   TM_MUL,
28*eda14cbcSMatt Macy   TM_DIV,
29*eda14cbcSMatt Macy   TM_MOD,
30*eda14cbcSMatt Macy   TM_POW,
31*eda14cbcSMatt Macy   TM_UNM,
32*eda14cbcSMatt Macy   TM_LT,
33*eda14cbcSMatt Macy   TM_LE,
34*eda14cbcSMatt Macy   TM_CONCAT,
35*eda14cbcSMatt Macy   TM_CALL,
36*eda14cbcSMatt Macy   TM_N		/* number of elements in the enum */
37*eda14cbcSMatt Macy } TMS;
38*eda14cbcSMatt Macy 
39*eda14cbcSMatt Macy 
40*eda14cbcSMatt Macy 
41*eda14cbcSMatt Macy #define gfasttm(g,et,e) ((et) == NULL ? NULL : \
42*eda14cbcSMatt Macy   ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e]))
43*eda14cbcSMatt Macy 
44*eda14cbcSMatt Macy #define fasttm(l,et,e)	gfasttm(G(l), et, e)
45*eda14cbcSMatt Macy 
46*eda14cbcSMatt Macy #define ttypename(x)	luaT_typenames_[(x) + 1]
47*eda14cbcSMatt Macy #define objtypename(x)	ttypename(ttypenv(x))
48*eda14cbcSMatt Macy 
49*eda14cbcSMatt Macy LUAI_DDEC const char *const luaT_typenames_[LUA_TOTALTAGS];
50*eda14cbcSMatt Macy 
51*eda14cbcSMatt Macy 
52*eda14cbcSMatt Macy LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename);
53*eda14cbcSMatt Macy LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o,
54*eda14cbcSMatt Macy                                                        TMS event);
55*eda14cbcSMatt Macy LUAI_FUNC void luaT_init (lua_State *L);
56*eda14cbcSMatt Macy 
57*eda14cbcSMatt Macy #endif
58