pull/13171/head
Joshua Haberman 5 years ago
parent 806c8c9c6e
commit 520ddc1f11
  1. 7
      upb/msg.h
  2. 14
      upb/reflection.c

@ -268,7 +268,9 @@ UPB_INLINE bool _upb_map_get(const upb_map *map, const void *key,
} }
UPB_INLINE void* _upb_map_next(const upb_map *map, size_t *iter) { UPB_INLINE void* _upb_map_next(const upb_map *map, size_t *iter) {
upb_strtable_iter it = {&map->table, *iter}; upb_strtable_iter it;
it.t = &map->table;
it.index = *iter;
upb_strtable_next(&it); upb_strtable_next(&it);
if (upb_strtable_done(&it)) return NULL; if (upb_strtable_done(&it)) return NULL;
*iter = it.index; *iter = it.index;
@ -345,7 +347,8 @@ UPB_INLINE void _upb_msg_map_clear(upb_msg *msg, size_t ofs) {
UPB_INLINE void _upb_msg_map_key(const void* msg, void* key, size_t size) { UPB_INLINE void _upb_msg_map_key(const void* msg, void* key, size_t size) {
const upb_tabent *ent = (const upb_tabent*)msg; const upb_tabent *ent = (const upb_tabent*)msg;
uint32_t u32len; uint32_t u32len;
upb_strview k = {upb_tabstr(ent->key, &u32len)}; upb_strview k;
k.data = upb_tabstr(ent->key, &u32len);
k.size = u32len; k.size = u32len;
_upb_map_fromkey(k, key, size); _upb_map_fromkey(k, key, size);
} }

@ -227,18 +227,20 @@ bool upb_mapiter_next(const upb_map *map, size_t *iter) {
/* Returns the key and value for this entry of the map. */ /* Returns the key and value for this entry of the map. */
upb_msgval upb_mapiter_key(const upb_map *map, size_t iter) { upb_msgval upb_mapiter_key(const upb_map *map, size_t iter) {
upb_strtable_iter i = {&map->table, iter}; upb_strtable_iter i;
upb_strview key = upb_strtable_iter_key(&i);
upb_msgval ret; upb_msgval ret;
_upb_map_fromkey(key, &ret, map->key_size); i.t = &map->table;
i.index = iter;
_upb_map_fromkey(upb_strtable_iter_key(&i), &ret, map->key_size);
return ret; return ret;
} }
upb_msgval upb_mapiter_value(const upb_map *map, size_t iter) { upb_msgval upb_mapiter_value(const upb_map *map, size_t iter) {
upb_strtable_iter i = {&map->table, iter}; upb_strtable_iter i;
upb_value val = upb_strtable_iter_value(&i);
upb_msgval ret; upb_msgval ret;
_upb_map_fromvalue(val, &ret, map->val_size); i.t = &map->table;
i.index = iter;
_upb_map_fromvalue(upb_strtable_iter_value(&i), &ret, map->val_size);
return ret; return ret;
} }

Loading…
Cancel
Save