ltable.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. ** $Id: ltable.h,v 2.24 2017/05/19 12:48:15 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. #if defined(LUA_DEBUG)
  35. LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key);
  36. LUAI_FUNC int luaH_isdummy (const Table *t);
  37. #endif
  38. #endif