moved back to old acc
[vox.git] / src / core / table.hpp
blob0e0eb9a08f97bfa41e41066da968e9d4b6e5c2b0
2 #ifndef _VXTABLE_H_
3 #define _VXTABLE_H_
4 /*
5 * The following code is based on Lua 4.0 (Copyright 1994-2002 Tecgraf, PUC-Rio.)
6 * http://www.lua.org/copyright.html#4
7 * http://www.lua.org/source/4.0.1/src_ltable.c.html
8 */
10 #include "string.hpp"
12 //#define hashptr(p) ((VXHash)(((VXInteger)p) >> 3))
13 #define hashptr(p) (((*reinterpret_cast<VXInteger*>(p)) >> 3))
15 inline VXHash HashObj(const VXObject &key)
17 switch(type(key))
19 case VX_OT_STRING:
20 return _string(key)->_hash;
21 case VX_OT_FLOAT:
22 return (VXHash)((VXInteger)_float(key));
23 case VX_OT_BOOL:
24 case VX_OT_INTEGER:
25 return (VXHash)((VXInteger)_integer(key));
26 default:
27 return hashptr(key._unVal.pRefCounted);
32 #endif //_VXTABLE_H_