Home | History | Annotate | Line # | Download | only in src
      1 /*	$NetBSD: ltable.h,v 1.10 2023/06/08 21:12:08 nikita Exp $	*/
      2 
      3 /*
      4 ** Id: ltable.h
      5 ** Lua tables (hash)
      6 ** See Copyright Notice in lua.h
      7 */
      8 
      9 #ifndef ltable_h
     10 #define ltable_h
     11 
     12 #include "lobject.h"
     13 
     14 
     15 #define gnode(t,i)	(&(t)->node[i])
     16 #define gval(n)		(&(n)->i_val)
     17 #define gnext(n)	((n)->u.next)
     18 
     19 
     20 /*
     21 ** Clear all bits of fast-access metamethods, which means that the table
     22 ** may have any of these metamethods. (First access that fails after the
     23 ** clearing will set the bit again.)
     24 */
     25 #define invalidateTMcache(t)	((t)->flags &= ~maskflags)
     26 
     27 
     28 /* true when 't' is using 'dummynode' as its hash part */
     29 #define isdummy(t)		((t)->lastfree == NULL)
     30 
     31 
     32 /* allocated size for hash nodes */
     33 #define allocsizenode(t)	(isdummy(t) ? 0 : sizenode(t))
     34 
     35 
     36 /* returns the Node, given the value of a table entry */
     37 #define nodefromval(v)	cast(Node *, (v))
     38 
     39 
     40 LUAI_FUNC const TValue *luaH_getint (Table *t, lua_Integer key);
     41 LUAI_FUNC void luaH_setint (lua_State *L, Table *t, lua_Integer key,
     42                                                     TValue *value);
     43 LUAI_FUNC const TValue *luaH_getshortstr (Table *t, TString *key);
     44 LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key);
     45 LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key);
     46 LUAI_FUNC void luaH_newkey (lua_State *L, Table *t, const TValue *key,
     47                                                     TValue *value);
     48 LUAI_FUNC void luaH_set (lua_State *L, Table *t, const TValue *key,
     49                                                  TValue *value);
     50 LUAI_FUNC void luaH_finishset (lua_State *L, Table *t, const TValue *key,
     51                                        const TValue *slot, TValue *value);
     52 LUAI_FUNC Table *luaH_new (lua_State *L);
     53 LUAI_FUNC void luaH_resize (lua_State *L, Table *t, unsigned int nasize,
     54                                                     unsigned int nhsize);
     55 LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, unsigned int nasize);
     56 LUAI_FUNC void luaH_free (lua_State *L, Table *t);
     57 LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key);
     58 LUAI_FUNC lua_Unsigned luaH_getn (Table *t);
     59 LUAI_FUNC unsigned int luaH_realasize (const Table *t);
     60 
     61 
     62 #if defined(LUA_DEBUG)
     63 LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key);
     64 #endif
     65 
     66 
     67 #endif
     68