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),
31 #if USE_TRANSIENT_HEAP
36 #define RHASH_LEV_MASK (FL_USER13 | FL_USER14 | FL_USER15 | \
37 FL_USER16 | FL_USER17 | FL_USER18 | FL_USER19)
51 ar_hint_t ary[RHASH_AR_TABLE_MAX_SIZE];
56 #define RHASH(obj) ((struct RHash *)(obj))
74 long rb_dbl_long_hash(
double d);
82 int rb_hash_stlike_delete(
VALUE hash, st_data_t *pkey, st_data_t *pval);
83 int rb_hash_stlike_foreach_with_replace(
VALUE hash, st_foreach_check_callback_func *func, st_update_callback_func *replace, st_data_t arg);
84 int rb_hash_stlike_update(
VALUE hash, st_data_t key, st_update_callback_func *func, st_data_t arg);
86 VALUE rb_ident_hash_new_with_size(st_index_t size);
88 static inline unsigned RHASH_AR_TABLE_SIZE_RAW(
VALUE h);
92 static inline bool RHASH_AR_TABLE_P(
VALUE h);
93 static inline bool RHASH_ST_TABLE_P(
VALUE h);
96 static inline size_t RHASH_ST_SIZE(
VALUE h);
97 static inline void RHASH_ST_CLEAR(
VALUE h);
98 static inline bool RHASH_TRANSIENT_P(
VALUE h);
99 static inline void RHASH_SET_TRANSIENT_FLAG(
VALUE h);
100 static inline void RHASH_UNSET_TRANSIENT_FLAG(
VALUE h);
102 RUBY_SYMBOL_EXPORT_BEGIN
105 VALUE rb_ident_hash_new(
void);
106 int rb_hash_stlike_foreach(
VALUE hash, st_foreach_callback_func *func, st_data_t arg);
107 RUBY_SYMBOL_EXPORT_END
109 MJIT_SYMBOL_EXPORT_BEGIN
110 VALUE rb_hash_new_with_size(st_index_t size);
112 int rb_hash_stlike_lookup(
VALUE hash, st_data_t key, st_data_t *pval);
117 st_table *rb_hash_tbl_raw(
VALUE hash,
const char *file,
int line);
118 #define RHASH_TBL_RAW(h) rb_hash_tbl_raw(h, __FILE__, __LINE__)
119 MJIT_SYMBOL_EXPORT_END
126 RHASH_AR_TABLE_P(
VALUE h)
128 extern int rb_hash_ar_table_p(
VALUE hash);
129 return rb_hash_ar_table_p(h)
133 RHASH_AR_TABLE(
VALUE h)
136 return rb_hash_ar_table(h)
140 RHASH_ST_TABLE(
VALUE h)
142 return rb_hash_st_table(h)
148 RHASH_AR_TABLE_P(
VALUE h)
154 RHASH_AR_TABLE(
VALUE h)
156 return RHASH(h)->as.ar;
160 RHASH_ST_TABLE(
VALUE h)
162 return RHASH(h)->as.st;
170 return RHASH(h)->ifnone;
176 if (RHASH_AR_TABLE_P(h)) {
177 return RHASH_AR_TABLE_SIZE_RAW(h);
180 return RHASH_ST_SIZE(h);
191 RHASH_ST_TABLE_P(
VALUE h)
193 return ! RHASH_AR_TABLE_P(h);
197 RHASH_ST_SIZE(
VALUE h)
199 return RHASH_ST_TABLE(h)->num_entries;
203 RHASH_ST_CLEAR(
VALUE h)
206 RHASH(h)->as.ar = NULL;
209 static inline unsigned
210 RHASH_AR_TABLE_SIZE_RAW(
VALUE h)
213 ret >>= RHASH_AR_TABLE_SIZE_SHIFT;
214 return (
unsigned)ret;
218 RHASH_TRANSIENT_P(
VALUE h)
220 #if USE_TRANSIENT_HEAP
228 RHASH_SET_TRANSIENT_FLAG(
VALUE h)
230 #if USE_TRANSIENT_HEAP
236 RHASH_UNSET_TRANSIENT_FLAG(
VALUE h)
238 #if USE_TRANSIENT_HEAP
#define FL_UNSET_RAW
Old name of RB_FL_UNSET_RAW.
#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_USER12
Old name of RUBY_FL_USER12.
#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 FL_SET_RAW
Old name of RB_FL_SET_RAW.
#define RHASH_SIZE(h)
Queries the size of the hash.
#define RHASH_EMPTY_P(h)
Checks if the hash is empty.
Ruby's object's, base components.
uintptr_t VALUE
Type that represents a Ruby object.