ltm.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. ** $Id: ltm.h,v 2.33 2018/02/23 13:13:31 roberto Exp roberto $
  3. ** Tag methods
  4. ** See Copyright Notice in lua.h
  5. */
  6. #ifndef ltm_h
  7. #define ltm_h
  8. #include "lobject.h"
  9. #include "lstate.h"
  10. /*
  11. * WARNING: if you change the order of this enumeration,
  12. * grep "ORDER TM" and "ORDER OP"
  13. */
  14. typedef enum {
  15. TM_INDEX,
  16. TM_NEWINDEX,
  17. TM_UNDEF,
  18. TM_ISDEF,
  19. TM_GC,
  20. TM_MODE,
  21. TM_LEN,
  22. TM_EQ, /* last tag method with fast access */
  23. TM_ADD,
  24. TM_SUB,
  25. TM_MUL,
  26. TM_MOD,
  27. TM_POW,
  28. TM_DIV,
  29. TM_IDIV,
  30. TM_BAND,
  31. TM_BOR,
  32. TM_BXOR,
  33. TM_SHL,
  34. TM_SHR,
  35. TM_UNM,
  36. TM_BNOT,
  37. TM_LT,
  38. TM_LE,
  39. TM_CONCAT,
  40. TM_CALL,
  41. TM_N /* number of elements in the enum */
  42. } TMS;
  43. /*
  44. ** Test whether there is no tagmethod.
  45. ** (Because tagmethods use raw accesses, the result may be an "empty" nil.)
  46. */
  47. #define notm(tm) ttisnilorempty(tm)
  48. #define gfasttm(g,et,e) ((et) == NULL ? NULL : \
  49. ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e]))
  50. #define fasttm(l,et,e) gfasttm(G(l), et, e)
  51. #define ttypename(x) luaT_typenames_[(x) + 1]
  52. LUAI_DDEC const char *const luaT_typenames_[LUA_TOTALTAGS];
  53. LUAI_FUNC const char *luaT_objtypename (lua_State *L, const TValue *o);
  54. LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename);
  55. LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o,
  56. TMS event);
  57. LUAI_FUNC void luaT_init (lua_State *L);
  58. LUAI_FUNC void luaT_callTM (lua_State *L, const TValue *f, const TValue *p1,
  59. const TValue *p2, const TValue *p3);
  60. LUAI_FUNC void luaT_callTMres (lua_State *L, const TValue *f,
  61. const TValue *p1, const TValue *p2, StkId p3);
  62. LUAI_FUNC void luaT_trybinTM (lua_State *L, const TValue *p1, const TValue *p2,
  63. StkId res, TMS event);
  64. LUAI_FUNC void luaT_trybinassocTM (lua_State *L, const TValue *p1,
  65. const TValue *p2, StkId res, int inv, TMS event);
  66. LUAI_FUNC void luaT_trybiniTM (lua_State *L, const TValue *p1, int i2,
  67. int inv, StkId res, TMS event);
  68. LUAI_FUNC int luaT_callorderTM (lua_State *L, const TValue *p1,
  69. const TValue *p2, TMS event);
  70. LUAI_FUNC int luaT_callorderiTM (lua_State *L, const TValue *p1, int v2,
  71. int inv, TMS event);
  72. LUAI_FUNC void luaT_adjustvarargs (lua_State *L, int nfixparams,
  73. struct CallInfo *ci, Proto *p);
  74. LUAI_FUNC void luaT_getvarargs (lua_State *L, struct CallInfo *ci,
  75. StkId where, int wanted);
  76. LUAI_FUNC int luaT_keydef (lua_State *L, TValue *obj, TValue *key, int remove);
  77. #endif