ltable.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. ** $Id: ltable.h $
  3. ** Lua tables (hash)
  4. ** See Copyright Notice in lua.h
  5. */
  6. #ifndef ltable_h
  7. #define ltable_h
  8. #include "lobject.h"
  9. #define gnode(t,i) (&(t)->node[i])
  10. #define gval(n) (&(n)->i_val)
  11. #define gnext(n) ((n)->u.next)
  12. /*
  13. ** Clear all bits of fast-access metamethods, which means that the table
  14. ** may have any of these metamethods. (First access that fails after the
  15. ** clearing will set the bit again.)
  16. */
  17. #define invalidateTMcache(t) ((t)->flags &= ~maskflags)
  18. /*
  19. ** Bit BITDUMMY set in 'flags' means the table is using the dummy node
  20. ** for its hash part.
  21. */
  22. #define BITDUMMY (1 << 6)
  23. #define NOTBITDUMMY cast_byte(~BITDUMMY)
  24. #define isdummy(t) ((t)->flags & BITDUMMY)
  25. #define setnodummy(t) ((t)->flags &= NOTBITDUMMY)
  26. #define setdummy(t) ((t)->flags |= BITDUMMY)
  27. /* allocated size for hash nodes */
  28. #define allocsizenode(t) (isdummy(t) ? 0 : sizenode(t))
  29. /* returns the Node, given the value of a table entry */
  30. #define nodefromval(v) cast(Node *, (v))
  31. LUAI_FUNC const TValue *luaH_getint (Table *t, lua_Integer key);
  32. LUAI_FUNC void luaH_setint (lua_State *L, Table *t, lua_Integer key,
  33. TValue *value);
  34. LUAI_FUNC const TValue *luaH_getshortstr (Table *t, TString *key);
  35. LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key);
  36. LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key);
  37. LUAI_FUNC void luaH_set (lua_State *L, Table *t, const TValue *key,
  38. TValue *value);
  39. LUAI_FUNC void luaH_finishset (lua_State *L, Table *t, const TValue *key,
  40. const TValue *slot, TValue *value);
  41. LUAI_FUNC Table *luaH_new (lua_State *L);
  42. LUAI_FUNC void luaH_resize (lua_State *L, Table *t, unsigned int nasize,
  43. unsigned int nhsize);
  44. LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, unsigned int nasize);
  45. LUAI_FUNC void luaH_free (lua_State *L, Table *t);
  46. LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key);
  47. LUAI_FUNC lua_Unsigned luaH_getn (Table *t);
  48. LUAI_FUNC unsigned int luaH_realasize (const Table *t);
  49. #if defined(LUA_DEBUG)
  50. LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key);
  51. #endif
  52. #endif