Lines Matching defs:key

1079     upb_strview key = upb_strtable_iter_key(&i);
1082 map->key_size == UPB_MAPTYPE_STRING ? (void *)&key : key.data;
1412 /* A type to represent the lookup key of either a strtable or an inttable. */
1428 static lookupkey_t intkey(uintptr_t key) {
1430 k.num = key;
1434 typedef uint32_t hashfunc_t(upb_tabkey key);
1482 static const upb_tabent *findentry(const upb_table *t, lookupkey_t key,
1490 if (eql(e->key, key)) return e;
1495 static upb_tabent *findentry_mutable(upb_table *t, lookupkey_t key,
1497 return (upb_tabent*)findentry(t, key, hash, eql);
1500 static bool lookup(const upb_table *t, lookupkey_t key, upb_value *v,
1502 const upb_tabent *e = findentry(t, key, hash, eql);
1513 /* The given key must not already exist in the table. */
1514 static void insert(upb_table *t, lookupkey_t key, upb_tabkey tabkey,
1520 UPB_ASSERT(findentry(t, key, hash, eql) == NULL);
1533 upb_tabent *chain = getentry_mutable(t, hashfunc(mainpos_e->key));
1554 our_e->key = tabkey;
1556 UPB_ASSERT(findentry(t, key, hash, eql) == our_e);
1559 static bool rm(upb_table *t, lookupkey_t key, upb_value *val,
1563 if (eql(chain->key, key)) {
1567 if (removed) *removed = chain->key;
1571 move->key = 0; /* Make the slot empty. */
1573 chain->key = 0; /* Make the slot empty. */
1579 while (chain->next && !eql(chain->next->key, key)) {
1587 if (removed) *removed = rm->key;
1588 rm->key = 0; /* Make the slot empty. */
1626 static uint32_t strhash(upb_tabkey key) {
1628 char *str = upb_tabstr(key, &len);
1651 upb_free(a, (void*)t->t.entries[i].key);
1663 upb_strview key = upb_strtable_iter_key(&i);
1665 &new_table, key.data, key.size,
1675 lookupkey_t key;
1686 key = strkey2(k, len);
1687 tabkey = strcopy(key, a);
1690 hash = upb_murmur_hash2(key.str.str, key.str.len, 0);
1691 insert(&t->t, key, tabkey, v, hash, &strhash, &streql);
1695 bool upb_strtable_lookup2(const upb_strtable *t, const char *key, size_t len,
1697 uint32_t hash = upb_murmur_hash2(key, len, 0);
1698 return lookup(&t->t, strkey2(key, len), v, hash, &streql);
1701 bool upb_strtable_remove3(upb_strtable *t, const char *key, size_t len,
1703 uint32_t hash = upb_murmur_hash2(key, len, 0);
1705 if (rm(&t->t, strkey2(key, len), val, &tabkey, hash, &streql)) {
1734 upb_strview key;
1737 key.data = upb_tabstr(str_tabent(i)->key, &len);
1738 key.size = len;
1739 return key;
1765 static uint32_t inthash(upb_tabkey key) { return upb_inthash(key); }
1775 static upb_tabval *inttable_val(upb_inttable *t, uintptr_t key) {
1776 if (key < t->array_size) {
1777 return upb_arrhas(t->array[key]) ? &(mutable_array(t)[key]) : NULL;
1780 findentry_mutable(&t->t, intkey(key), upb_inthash(key), &inteql);
1786 uintptr_t key) {
1787 return inttable_val((upb_inttable*)t, key);
1815 /* Always make the array part at least 1 long, so that we know key 0
1839 bool upb_inttable_insert2(upb_inttable *t, uintptr_t key, upb_value val,
1845 if (key < t->array_size) {
1846 UPB_ASSERT(!upb_arrhas(t->array[key]));
1848 mutable_array(t)[key].val = val.val;
1865 hash = upb_inthash(e->key);
1866 insert(&new_table, intkey(e->key), e->key, v, hash, &inthash, &inteql);
1874 insert(&t->t, intkey(key), key, val, upb_inthash(key), &inthash, &inteql);
1880 bool upb_inttable_lookup(const upb_inttable *t, uintptr_t key, upb_value *v) {
1881 const upb_tabval *table_v = inttable_val_const(t, key);
1887 bool upb_inttable_replace(upb_inttable *t, uintptr_t key, upb_value val) {
1888 upb_tabval *table_v = inttable_val(t, key);
1894 bool upb_inttable_remove(upb_inttable *t, uintptr_t key, upb_value *val) {
1896 if (key < t->array_size) {
1897 if (upb_arrhas(t->array[key])) {
1901 _upb_value_setval(val, t->array[key].val);
1903 mutable_array(t)[key] = empty;
1909 success = rm(&t->t, intkey(key), val, NULL, upb_inthash(key), &inteql);
1926 bool upb_inttable_insertptr2(upb_inttable *t, const void *key, upb_value val,
1928 return upb_inttable_insert2(t, (uintptr_t)key, val, a);
1931 bool upb_inttable_lookupptr(const upb_inttable *t, const void *key,
1933 return upb_inttable_lookup(t, (uintptr_t)key, v);
1936 bool upb_inttable_removeptr(upb_inttable *t, const void *key, upb_value *val) {
1937 return upb_inttable_remove(t, (uintptr_t)key, val);
1944 /* The max key in each bucket. */
1954 uintptr_t key = upb_inttable_iter_key(&i);
1955 int bucket = log2ceil(key);
1956 max[bucket] = UPB_MAX(max[bucket], key);
2044 return i->array_part ? i->index : int_tabent(i)->key;
2078 uint32_t upb_murmur_hash2(const void *key, size_t len, uint32_t seed) {
2088 const uint8_t * data = (const uint8_t *)key;
2130 uint32_t upb_murmur_hash2(const void * key, size_t len, uint32_t seed) {
2133 const uint8_t * data = (const uint8_t *)key;
3924 const upb_fielddef *key = upb_msgdef_itof(m, 1);
3932 fields[0].descriptortype = upb_fielddef_descriptortype(key);
4913 upb_strview key = upb_strtable_iter_key(&iter);
4915 CHK_OOM(upb_strtable_insert3(&s->syms, key.data, key.size, value, alloc));
5251 const upb_fielddef *key = upb_msgdef_itof(entry, UPB_MAPENTRY_KEY);
5253 ret.map = upb_map_new(a, upb_fielddef_type(key), upb_fielddef_type(value));
5373 bool upb_map_get(const upb_map *map, upb_msgval key, upb_msgval *val) {
5374 return _upb_map_get(map, &key, map->key_size, val, map->val_size);
5377 bool upb_map_set(upb_map *map, upb_msgval key, upb_msgval val,
5379 return _upb_map_set(map, &key, map->key_size, &val, map->val_size, arena);
5382 bool upb_map_delete(upb_map *map, upb_msgval key) {
5383 return _upb_map_delete(map, &key, map->key_size);
5390 /* Returns the key and value for this entry of the map. */
10797 /* Helper: invoked during parse_mapentry() to emit the mapentry message's key
10804 /* Emit the key field. We do a bit of ad-hoc parsing here because the
10806 * name, and we are reinterpreting it as some arbitrary key type. In
10812 upb_status_seterrmsg(p->status, "mapentry message has no key");
10836 "Map bool key not 'true' or 'false'");
10854 upb_status_seterrmsg(p->status, "Invalid field type for map key");
10862 * is invoked from end_membername(), at the end of the map entry's key string,
10863 * with the map key in the accumulate buffer. It parses the key from that
10892 * the key field value to the sink, and these handlers will pop the frame
10894 * would have just seen the map-entry value, not key). */
12625 /* Print a map key given a field name. Called by scalar field handlers and by
12629 const strpc *key = handler_data;
12632 putstring(p, key->ptr, key->len);
13019 /* Set up handlers for a mapentry submessage (i.e., an individual key/value pair
13022 * TODO: Handle missing key, missing value, out-of-order key/value, or repeated
13023 * key or value cases properly. The right way to do this is to allocate a
13024 * temporary structure at the start of a mapentry submessage, store key and
13025 * value data in it as key and value handlers are called, and then print the
13026 * key/value pair once at the end of the submessage. If we don't do this, we
13028 * our sources that emit mapentry messages do so canonically (with one key
13035 /* A mapentry message is printed simply as '"key": value'. Rather than
13036 * special-case key and value for every type below, we just handle both