diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2006-01-10 10:51:53 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2006-01-10 10:51:53 -0200 |
| commit | ffb798e1e2deb1fe0f931e1f6c5b6d91f694051c (patch) | |
| tree | 325354bd5b01893821ae7aed0bab0409027ef431 /ltable.h | |
| parent | fa936f8fa9d391de08901339de044b783011adfa (diff) | |
| download | lua-ffb798e1e2deb1fe0f931e1f6c5b6d91f694051c.tar.gz lua-ffb798e1e2deb1fe0f931e1f6c5b6d91f694051c.tar.bz2 lua-ffb798e1e2deb1fe0f931e1f6c5b6d91f694051c.zip | |
avoids type punning for table keys
Diffstat (limited to 'ltable.h')
| -rw-r--r-- | ltable.h | 14 |
1 files changed, 8 insertions, 6 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ltable.h,v 2.7 2005/04/25 19:24:10 roberto Exp roberto $ | 2 | ** $Id: ltable.h,v 2.8 2005/06/06 13:30:25 roberto Exp roberto $ |
| 3 | ** Lua tables (hash) | 3 | ** Lua tables (hash) |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -11,15 +11,13 @@ | |||
| 11 | 11 | ||
| 12 | 12 | ||
| 13 | #define gnode(t,i) (&(t)->node[i]) | 13 | #define gnode(t,i) (&(t)->node[i]) |
| 14 | #define gkey(n) (&(n)->i_key) | 14 | #define gkey(n) (&(n)->i_key.nk) |
| 15 | #define gval(n) (&(n)->i_val) | 15 | #define gval(n) (&(n)->i_val) |
| 16 | #define gnext(n) ((n)->i_key.next) | 16 | #define gnext(n) ((n)->i_key.nk.next) |
| 17 | 17 | ||
| 18 | #define key2tval(n) (cast(const TValue *, gkey(n))) | 18 | #define key2tval(n) (&(n)->i_key.tvk) |
| 19 | 19 | ||
| 20 | 20 | ||
| 21 | LUAI_DATA const Node luaH_dummynode; | ||
| 22 | |||
| 23 | LUAI_FUNC const TValue *luaH_getnum (Table *t, int key); | 21 | LUAI_FUNC const TValue *luaH_getnum (Table *t, int key); |
| 24 | LUAI_FUNC TValue *luaH_setnum (lua_State *L, Table *t, int key); | 22 | LUAI_FUNC TValue *luaH_setnum (lua_State *L, Table *t, int key); |
| 25 | LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key); | 23 | LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key); |
| @@ -35,5 +33,9 @@ LUAI_FUNC int luaH_getn (Table *t); | |||
| 35 | /* exported only for debugging */ | 33 | /* exported only for debugging */ |
| 36 | LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key); | 34 | LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key); |
| 37 | 35 | ||
| 36 | #define luaH_dummynode (&luaH_dummynode_) | ||
| 37 | |||
| 38 | LUAI_DATA const Node luaH_dummynode_; | ||
| 39 | |||
| 38 | 40 | ||
| 39 | #endif | 41 | #endif |
