10#if defined(__cplusplus)
19#include "ruby/config.h"
23RUBY_SYMBOL_EXPORT_BEGIN
25#if SIZEOF_LONG == SIZEOF_VOIDP
26typedef unsigned long parser_st_data_t;
27#elif SIZEOF_LONG_LONG == SIZEOF_VOIDP
28typedef unsigned LONG_LONG parser_st_data_t;
30# error ---->> parser_st.c requires sizeof(void*) == sizeof(long) or sizeof(LONG_LONG) to be compiled. <<----
32#define ST2_DATA_T_DEFINED
54typedef parser_st_data_t parser_st_index_t;
57#define MAX_ST2_INDEX_VAL (~(parser_st_index_t) 0)
59typedef int parser_st_compare_func(parser_st_data_t, parser_st_data_t);
60typedef parser_st_index_t parser_st_hash_func(parser_st_data_t);
62typedef char st_check_for_sizeof_parser_st_index_t[SIZEOF_VOIDP == (int)
sizeof(parser_st_index_t) ? 1 : -1];
63#define SIZEOF_ST_INDEX_T SIZEOF_VOIDP
66 int (*compare)(parser_st_data_t, parser_st_data_t);
67 parser_st_index_t (*hash)(parser_st_data_t);
70#define ST_INDEX_BITS (SIZEOF_ST_INDEX_T * CHAR_BIT)
72#if defined(HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR) && defined(HAVE_BUILTIN___BUILTIN_TYPES_COMPATIBLE_P)
73# define ST2_DATA_COMPATIBLE_P(type) \
74 __builtin_choose_expr(__builtin_types_compatible_p(type, parser_st_data_t), 1, 0)
76# define ST2_DATA_COMPATIBLE_P(type) 0
79typedef struct parser_st_table_entry parser_st_table_entry;
81struct parser_st_table_entry;
85 unsigned char entry_power, bin_power, size_ind;
87 unsigned int rebuilds_num;
90 parser_st_index_t num_entries;
92 parser_st_index_t *bins;
96 parser_st_index_t entries_start, entries_bound;
98 parser_st_table_entry *entries;
101#define parser_st_is_member(table,key) rb_parser_st_lookup((table),(key),(parser_st_data_t *)0)
103enum parser_st_retval {ST2_CONTINUE, ST2_STOP, ST2_DELETE, ST2_CHECK, ST2_REPLACE};
110parser_st_table *rb_parser_st_init_numtable_with_size(parser_st_index_t);
112parser_st_table *rb_parser_st_init_strtable_with_size(parser_st_index_t);
114parser_st_table *rb_parser_st_init_strcasetable_with_size(parser_st_index_t);
115int rb_parser_st_delete(
parser_st_table *, parser_st_data_t *, parser_st_data_t *);
116int rb_parser_st_delete_safe(
parser_st_table *, parser_st_data_t *, parser_st_data_t *, parser_st_data_t);
117int rb_parser_st_shift(
parser_st_table *, parser_st_data_t *, parser_st_data_t *);
118int rb_parser_st_insert(
parser_st_table *, parser_st_data_t, parser_st_data_t);
119int rb_parser_st_insert2(
parser_st_table *, parser_st_data_t, parser_st_data_t, parser_st_data_t (*)(parser_st_data_t));
120int rb_parser_st_lookup(
parser_st_table *, parser_st_data_t, parser_st_data_t *);
121int rb_parser_st_get_key(
parser_st_table *, parser_st_data_t, parser_st_data_t *);
122typedef int parser_st_update_callback_func(parser_st_data_t *key, parser_st_data_t *value, parser_st_data_t arg,
int existing);
126int rb_parser_st_update(
parser_st_table *table, parser_st_data_t key, parser_st_update_callback_func *func, parser_st_data_t arg);
127typedef int parser_st_foreach_callback_func(parser_st_data_t, parser_st_data_t, parser_st_data_t);
128typedef int parser_st_foreach_check_callback_func(parser_st_data_t, parser_st_data_t, parser_st_data_t,
int);
129int rb_parser_st_foreach_with_replace(
parser_st_table *tab, parser_st_foreach_check_callback_func *func, parser_st_update_callback_func *replace, parser_st_data_t arg);
130int rb_parser_st_foreach(
parser_st_table *, parser_st_foreach_callback_func *, parser_st_data_t);
131int rb_parser_st_foreach_check(
parser_st_table *, parser_st_foreach_check_callback_func *, parser_st_data_t, parser_st_data_t);
132parser_st_index_t rb_parser_st_keys(
parser_st_table *table, parser_st_data_t *keys, parser_st_index_t size);
133parser_st_index_t rb_parser_st_keys_check(
parser_st_table *table, parser_st_data_t *keys, parser_st_index_t size, parser_st_data_t never);
134parser_st_index_t rb_parser_st_values(
parser_st_table *table, parser_st_data_t *values, parser_st_index_t size);
135parser_st_index_t rb_parser_st_values_check(
parser_st_table *table, parser_st_data_t *values, parser_st_index_t size, parser_st_data_t never);
136void rb_parser_st_add_direct(
parser_st_table *, parser_st_data_t, parser_st_data_t);
142CONSTFUNC(
int rb_parser_st_numcmp(parser_st_data_t, parser_st_data_t));
143CONSTFUNC(parser_st_index_t rb_parser_st_numhash(parser_st_data_t));
144PUREFUNC(
int rb_parser_st_locale_insensitive_strcasecmp(
const char *s1,
const char *s2));
145PUREFUNC(
int rb_parser_st_locale_insensitive_strncasecmp(
const char *s1,
const char *s2,
size_t n));
147PUREFUNC(parser_st_index_t rb_parser_st_hash(
const void *ptr,
size_t len, parser_st_index_t h));
148CONSTFUNC(parser_st_index_t rb_parser_st_hash_uint32(parser_st_index_t h, uint32_t i));
149CONSTFUNC(parser_st_index_t rb_parser_st_hash_uint(parser_st_index_t h, parser_st_index_t i));
150CONSTFUNC(parser_st_index_t rb_parser_st_hash_end(parser_st_index_t h));
151CONSTFUNC(parser_st_index_t rb_parser_st_hash_start(parser_st_index_t h));
153RUBY_SYMBOL_EXPORT_END
155#if defined(__cplusplus)
int len
Length of the buffer.