ltm.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. ** $Id: ltm.h,v 2.16 2013/04/29 16:56:50 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. /*
  10. * WARNING: if you change the order of this enumeration,
  11. * grep "ORDER TM" and "ORDER OP"
  12. */
  13. typedef enum {
  14. TM_INDEX,
  15. TM_NEWINDEX,
  16. TM_GC,
  17. TM_MODE,
  18. TM_LEN,
  19. TM_EQ, /* last tag method with `fast' access */
  20. TM_ADD,
  21. TM_SUB,
  22. TM_MUL,
  23. TM_MOD,
  24. TM_POW,
  25. TM_DIV,
  26. TM_IDIV,
  27. TM_UNM,
  28. TM_LT,
  29. TM_LE,
  30. TM_CONCAT,
  31. TM_CALL,
  32. TM_N /* number of elements in the enum */
  33. } TMS;
  34. #define gfasttm(g,et,e) ((et) == NULL ? NULL : \
  35. ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e]))
  36. #define fasttm(l,et,e) gfasttm(G(l), et, e)
  37. #define ttypename(x) luaT_typenames_[(x) + 1]
  38. #define objtypename(x) ttypename(ttnov(x))
  39. LUAI_DDEC const char *const luaT_typenames_[LUA_TOTALTAGS];
  40. LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename);
  41. LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o,
  42. TMS event);
  43. LUAI_FUNC void luaT_init (lua_State *L);
  44. LUAI_FUNC void luaT_callTM (lua_State *L, const TValue *f, const TValue *p1,
  45. const TValue *p2, TValue *p3, int hasres);
  46. LUAI_FUNC int luaT_callbinTM (lua_State *L, const TValue *p1, const TValue *p2,
  47. StkId res, TMS event);
  48. LUAI_FUNC void luaT_trybinTM (lua_State *L, const TValue *p1, const TValue *p2,
  49. StkId res, TMS event);
  50. LUAI_FUNC const TValue *luaT_getequalTM (lua_State *L, Table *mt1, Table *mt2);
  51. LUAI_FUNC int luaT_callorderTM (lua_State *L, const TValue *p1,
  52. const TValue *p2, TMS event);
  53. #endif