Go to the source code of this file.
◆ srn_map_assoc()
Definition at line 71 of file maps.c.
74 {
79
81 return srn_errors_make_error(ctx, metadata,
ABSURD,
"expected a map");
82 }
83
84
85
87 return srn_errors_make_error(ctx, metadata,
ABSURD,
"map key is not hashable");
88 }
89
90 hmap_key_t k = {.data = key, .len =
sizeof(*key)};
91
94
97}
srn_value_t * srn_value_make(srn_context_t *ctx, srn_value_tag_t tag, srn_metadata_t *metadata, void *payload)
Creates a new serene value.
#define AS_MAP(value_ref)
#define IS_A(value_ref, field)
static const hmap_control_t value_map
bool srn_value_hashable(const srn_value_t *v)
Whether v can be a hash key.
Note: For key equality we use the memcpy function.
A persistent, immutable map.
#define PANIC_IF_NULL(ptr)
◆ srn_map_empty()
Definition at line 64 of file maps.c.
64 {
69}
hmap_t hmap_empty(const srn_context_t *ctx)
Create, initialize and return a new hashmap pinned to ctx.
◆ srn_vmap_cmp()
Definition at line 28 of file maps.c.
28 {
34 return false;
36 return true;
37 default:
38 PANIC(
"Should never happen");
39 }
40}
srn_value_t * srn_value_eq(const srn_context_t *ctx, const srn_value_t *a, const srn_value_t *b)
Check to values for equality. Return a boolean.
void * data
len 0 -> data == nullptr
const srn_context_t * map_ctx
The context that owns every allocation the map retains.
◆ srn_vmap_hash()
Definition at line 43 of file maps.c.
43 {
47
50}
srn_hash_t srn_value_hash(const srn_context_t *ctx, const srn_value_t *v)
Compute the xxHash32 of a value using the engine seed.
◆ value_map
Initial value: = {
}
void * hmap_lookup_ctl(const hmap_control_t *ctl, const hmap_t *hmap, const hmap_key_t *k, void *default_value)
Just like the hmap_lookup function but, it receives a hmap_control_t to customize the comparison and ...
hmap_t hmap_insert_ctl(const hmap_control_t *ctl, const hmap_t *hmap, hmap_key_t *k, void *v)
Just like the hmap_insert function but, it receives a hmap_control_t to customize the comparison and ...
hmap_key_t * hmap_copy_key(const hmap_t *hmap, const hmap_key_t *k)
The default copy_key hook.
static bool srn_vmap_cmp(const hmap_t *hmap, const hmap_key_t *a, const hmap_key_t *b)
static hmap_hash_t srn_vmap_hash(const hmap_t *hmap, const hmap_key_t *k)
Definition at line 52 of file maps.c.