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