ltable.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. ** $Id: ltable.h,v 2.16.1.1 2013/04/12 18:48:47 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 gkey(n) (&(n)->i_key.tvk)
  11. #define gval(n) (&(n)->i_val)
  12. #define gnext(n) ((n)->i_key.nk.next)
  13. #define invalidateTMcache(t) ((t)->flags = 0)
  14. /* returns the key, given the value of a table entry */
  15. #define keyfromval(v) \
  16. (gkey(cast(Node *, cast(char *, (v)) - offsetof(Node, i_val))))
  17. LUAI_FUNC const TValue *luaH_getint (Table *t, int key);
  18. LUAI_FUNC void luaH_setint (lua_State *L, Table *t, int key, TValue *value);
  19. LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key);
  20. LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key);
  21. LUAI_FUNC TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key);
  22. LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key);
  23. LUAI_FUNC Table *luaH_new (lua_State *L);
  24. LUAI_FUNC void luaH_resize (lua_State *L, Table *t, int nasize, int nhsize);
  25. LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, int nasize);
  26. LUAI_FUNC void luaH_free (lua_State *L, Table *t);
  27. LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key);
  28. LUAI_FUNC int luaH_getn (Table *t);
  29. #if defined(LUA_DEBUG)
  30. LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key);
  31. LUAI_FUNC int luaH_isdummy (Node *n);
  32. #endif
  33. #endif