ltm.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. ** $Id: ltm.h,v 2.22 2016/02/26 19:20:15 roberto Exp $
  3. ** Tag methods
  4. ** See Copyright Notice in lua.h
  5. */
  6. #ifndef ltm_h
  7. #define ltm_h
  8. #include "lobject.h"
  9. /*
  10. * WARNING: if you change the order of this enumeration,
  11. * grep "ORDER TM" and "ORDER OP"
  12. */
  13. typedef enum
  14. {
  15. TM_INDEX,
  16. TM_NEWINDEX,
  17. TM_GC,
  18. TM_MODE,
  19. TM_LEN,
  20. TM_EQ, /* last tag method with fast access */
  21. TM_ADD,
  22. TM_SUB,
  23. TM_MUL,
  24. TM_MOD,
  25. TM_POW,
  26. TM_DIV,
  27. TM_IDIV,
  28. TM_BAND,
  29. TM_BOR,
  30. TM_BXOR,
  31. TM_SHL,
  32. TM_SHR,
  33. TM_UNM,
  34. TM_BNOT,
  35. TM_LT,
  36. TM_LE,
  37. TM_CONCAT,
  38. TM_CALL,
  39. TM_N /* number of elements in the enum */
  40. } TMS;
  41. #define gfasttm(g,et,e) ((et) == NULL ? NULL : \
  42. ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e]))
  43. #define fasttm(l,et,e) gfasttm(G(l), et, e)
  44. #define ttypename(x) luaT_typenames_[(x) + 1]
  45. LUAI_DDEC const char *const luaT_typenames_[LUA_TOTALTAGS];
  46. LUAI_FUNC const char *luaT_objtypename(lua_State *L, const TValue *o);
  47. LUAI_FUNC const TValue *luaT_gettm(Table *events, TMS event, TString *ename);
  48. LUAI_FUNC const TValue *luaT_gettmbyobj(lua_State *L, const TValue *o,
  49. TMS event);
  50. LUAI_FUNC void luaT_init(lua_State *L);
  51. LUAI_FUNC void luaT_callTM(lua_State *L, const TValue *f, const TValue *p1,
  52. const TValue *p2, TValue *p3, int hasres);
  53. LUAI_FUNC int luaT_callbinTM(lua_State *L, const TValue *p1, const TValue *p2,
  54. StkId res, TMS event);
  55. LUAI_FUNC void luaT_trybinTM(lua_State *L, const TValue *p1, const TValue *p2,
  56. StkId res, TMS event);
  57. LUAI_FUNC int luaT_callorderTM(lua_State *L, const TValue *p1,
  58. const TValue *p2, TMS event);
  59. #endif