ltable.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. ** $Id: ltable.h,v 2.27 2018/06/01 16:51:34 roberto Exp roberto $
  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. #define invalidateTMcache(t) ((t)->flags = 0)
  13. /* true when 't' is using 'dummynode' as its hash part */
  14. #define isdummy(t) ((t)->lastfree == NULL)
  15. /* allocated size for hash nodes */
  16. #define allocsizenode(t) (isdummy(t) ? 0 : sizenode(t))
  17. /* returns the Node, given the value of a table entry */
  18. #define nodefromval(v) cast(Node *, (v))
  19. LUAI_FUNC const TValue *luaH_getint (Table *t, lua_Integer key);
  20. LUAI_FUNC void luaH_setint (lua_State *L, Table *t, lua_Integer key,
  21. TValue *value);
  22. LUAI_FUNC const TValue *luaH_getshortstr (Table *t, TString *key);
  23. LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key);
  24. LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key);
  25. LUAI_FUNC TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key);
  26. LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key);
  27. LUAI_FUNC Table *luaH_new (lua_State *L);
  28. LUAI_FUNC void luaH_resize (lua_State *L, Table *t, unsigned int nasize,
  29. unsigned int nhsize);
  30. LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, unsigned int nasize);
  31. LUAI_FUNC void luaH_free (lua_State *L, Table *t);
  32. LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key);
  33. LUAI_FUNC lua_Unsigned luaH_getn (Table *t);
  34. LUAI_FUNC unsigned int luaH_realasize (const Table *t);
  35. #if defined(LUA_DEBUG)
  36. LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key);
  37. LUAI_FUNC int luaH_isdummy (const Table *t);
  38. #endif
  39. #endif