9
3

ltable.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key);
  31. LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key);
  32. LUAI_FUNC Table *luaH_new (lua_State *L);
  33. LUAI_FUNC void luaH_resize (lua_State *L, Table *t, unsigned int nasize,
  34. unsigned int nhsize);
  35. LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, unsigned int nasize);
  36. LUAI_FUNC void luaH_free (lua_State *L, Table *t);
  37. LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key);
  38. LUAI_FUNC lua_Unsigned luaH_getn (Table *t);
  39. LUAI_FUNC unsigned int luaH_realasize (const Table *t);
  40. #if defined(LUA_DEBUG)
  41. LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key);
  42. LUAI_FUNC int luaH_isdummy (const Table *t);
  43. #endif
  44. #endif