1 #ifndef INTERNAL_HASH_H
2 #define INTERNAL_HASH_H
11 #include "ruby/internal/config.h"
17 #define RHASH_AR_TABLE_MAX_SIZE SIZEOF_VALUE
20 typedef unsigned char ar_hint_t;
22 enum ruby_rhash_flags {
27 RHASH_AR_TABLE_SIZE_SHIFT = (
FL_USHIFT+4),
29 RHASH_AR_TABLE_BOUND_SHIFT = (
FL_USHIFT+8),
32 #define RHASH_LEV_MASK (FL_USER13 | FL_USER14 | FL_USER15 | \
33 FL_USER16 | FL_USER17 | FL_USER18 | FL_USER19)
46 ar_hint_t ary[RHASH_AR_TABLE_MAX_SIZE];
58 #define RHASH(obj) ((struct RHash *)(obj))
76 long rb_dbl_long_hash(
double d);
78 st_index_t rb_any_hash(
VALUE a);
86 int rb_hash_stlike_delete(
VALUE hash, st_data_t *pkey, st_data_t *pval);
87 int rb_hash_stlike_foreach_with_replace(
VALUE hash, st_foreach_check_callback_func *func, st_update_callback_func *replace, st_data_t arg);
88 int rb_hash_stlike_update(
VALUE hash, st_data_t key, st_update_callback_func *func, st_data_t arg);
89 VALUE rb_ident_hash_new_with_size(st_index_t size);
90 void rb_hash_free(
VALUE hash);
93 static inline unsigned RHASH_AR_TABLE_SIZE_RAW(
VALUE h);
97 static inline bool RHASH_AR_TABLE_P(
VALUE h);
98 static inline bool RHASH_ST_TABLE_P(
VALUE h);
101 static inline size_t RHASH_ST_SIZE(
VALUE h);
102 static inline void RHASH_ST_CLEAR(
VALUE h);
104 RUBY_SYMBOL_EXPORT_BEGIN
107 VALUE rb_ident_hash_new(
void);
108 int rb_hash_stlike_foreach(
VALUE hash, st_foreach_callback_func *func, st_data_t arg);
109 RUBY_SYMBOL_EXPORT_END
111 VALUE rb_hash_new_with_size(st_index_t size);
113 int rb_hash_stlike_lookup(
VALUE hash, st_data_t key, st_data_t *pval);
118 st_table *rb_hash_tbl_raw(
VALUE hash,
const char *file,
int line);
119 #define RHASH_TBL_RAW(h) rb_hash_tbl_raw(h, __FILE__, __LINE__)
124 RHASH_AR_TABLE_P(
VALUE h)
131 RHASH_AR_TABLE(
VALUE h)
138 RHASH_ST_TABLE(
VALUE h)
146 return RHASH(h)->ifnone;
152 if (RHASH_AR_TABLE_P(h)) {
153 return RHASH_AR_TABLE_SIZE_RAW(h);
156 return RHASH_ST_SIZE(h);
167 RHASH_ST_TABLE_P(
VALUE h)
169 return ! RHASH_AR_TABLE_P(h);
173 RHASH_ST_SIZE(
VALUE h)
175 return RHASH_ST_TABLE(h)->num_entries;
179 RHASH_ST_CLEAR(
VALUE h)
181 memset(RHASH_ST_TABLE(h), 0,
sizeof(
st_table));
184 static inline unsigned
185 RHASH_AR_TABLE_SIZE_RAW(
VALUE h)
188 ret >>= RHASH_AR_TABLE_SIZE_SHIFT;
189 return (
unsigned)ret;
#define RUBY_EXTERN
Declaration of externally visible global variables.
#define FL_USER3
Old name of RUBY_FL_USER3.
#define FL_USER7
Old name of RUBY_FL_USER7.
#define FL_USER10
Old name of RUBY_FL_USER10.
#define FL_USER6
Old name of RUBY_FL_USER6.
#define FL_USER1
Old name of RUBY_FL_USER1.
#define FL_USER11
Old name of RUBY_FL_USER11.
#define FL_USER8
Old name of RUBY_FL_USER8.
#define FL_TEST_RAW
Old name of RB_FL_TEST_RAW.
#define FL_USER2
Old name of RUBY_FL_USER2.
#define FL_USER9
Old name of RUBY_FL_USER9.
#define FL_USER5
Old name of RUBY_FL_USER5.
#define FL_USHIFT
Old name of RUBY_FL_USHIFT.
#define FL_USER4
Old name of RUBY_FL_USER4.
#define inline
Old Visual Studio versions do not support the inline keyword, so we need to define it to be __inline.
#define RBIMPL_ATTR_RETURNS_NONNULL()
Wraps (or simulates) __attribute__((returns_nonnull))
#define RHASH_SIZE(h)
Queries the size of the hash.
#define RHASH_EMPTY_P(h)
Checks if the hash is empty.
Ruby object's base components.
uintptr_t VALUE
Type that represents a Ruby object.