ltm.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. ** $Id: ltm.h,v 2.14 2013/04/25 16:07:52 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"
  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_DIV,
  24. TM_IDIV,
  25. TM_MOD,
  26. TM_POW,
  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 const TValue *luaT_getequalTM (lua_State *L, Table *mt1, Table *mt2);
  49. LUAI_FUNC int luaT_callorderTM (lua_State *L, const TValue *p1,
  50. const TValue *p2, TMS event);
  51. #endif