ltable.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. /* true when 't' is using 'dummynode' as its hash part */
  19. #define isdummy(t) ((t)->lastfree == NULL)
  20. /* allocated size for hash nodes */
  21. #define allocsizenode(t) (isdummy(t) ? 0 : sizenode(t))
  22. /* returns the Node, given the value of a table entry */
  23. #define nodefromval(v) cast(Node *, (v))
  24. LUAI_FUNC const TValue *luaH_getint (Table *t, lua_Integer key);
  25. LUAI_FUNC void luaH_setint (lua_State *L, Table *t, lua_Integer key,
  26. TValue *value);
  27. LUAI_FUNC const TValue *luaH_getshortstr (Table *t, TString *key);
  28. LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key);
  29. LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key);
  30. LUAI_FUNC void luaH_newkey (lua_State *L, Table *t, const TValue *key,
  31. TValue *value);
  32. LUAI_FUNC void luaH_set (lua_State *L, Table *t, const TValue *key,
  33. TValue *value);
  34. LUAI_FUNC void luaH_finishset (lua_State *L, Table *t, const TValue *key,
  35. const TValue *slot, TValue *value);
  36. LUAI_FUNC Table *luaH_new (lua_State *L);
  37. LUAI_FUNC void luaH_resize (lua_State *L, Table *t, unsigned int nasize,
  38. unsigned int nhsize);
  39. LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, unsigned int nasize);
  40. LUAI_FUNC void luaH_free (lua_State *L, Table *t);
  41. LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key);
  42. LUAI_FUNC lua_Unsigned luaH_getn (Table *t);
  43. LUAI_FUNC unsigned int luaH_realasize (const Table *t);
  44. #if defined(LUA_DEBUG)
  45. LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key);
  46. #endif
  47. #endif