diff options
author | Paul Yang <TeBoring@users.noreply.github.com> | 2018-12-04 15:21:32 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-04 15:21:32 -0800 |
commit | 13c59cb051c4deee5367f9c5fc7b5d07363496a0 (patch) | |
tree | d71ca4fa8ee5a0feed15eed99f8da51af21aa1d1 /upb/def.c | |
parent | 9e44a757edb7ba7155469d3305da32b3dc11c756 (diff) |
Implement json decoding for Any message. (#130)
* Implement json decoding for Any message.
type url may not appear as the first value in json. As a result,
other data cannot be resolved before resolving type url. To solve that,
this change caches the start and end position of unparsed values and
resolve them in end_any_object when type url has been resolved.
* Handle Any in switch
* Update json parser size
* Fix comments
* Sync upstream
* Add dependency on upb_pb for upb_json
* Debug failed test
* Fix cmake
* Update test generated files
* Remove debug tests
Diffstat (limited to 'upb/def.c')
-rw-r--r-- | upb/def.c | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -371,7 +371,9 @@ static void assign_msg_wellknowntype(upb_msgdef *m) { m->well_known_type = UPB_WELLKNOWN_UNSPECIFIED; return; } - if (!strcmp(name, "google.protobuf.Duration")) { + if (!strcmp(name, "google.protobuf.Any")) { + m->well_known_type = UPB_WELLKNOWN_ANY; + } else if (!strcmp(name, "google.protobuf.Duration")) { m->well_known_type = UPB_WELLKNOWN_DURATION; } else if (!strcmp(name, "google.protobuf.Timestamp")) { m->well_known_type = UPB_WELLKNOWN_TIMESTAMP; @@ -2146,6 +2148,14 @@ const upb_msgdef *upb_symtab_lookupmsg(const upb_symtab *s, const char *sym) { return def ? upb_dyncast_msgdef(def) : NULL; } +const upb_msgdef *upb_symtab_lookupmsg2(const upb_symtab *s, const char *sym, + size_t len) { + upb_value v; + upb_def *def = upb_strtable_lookup2(&s->symtab, sym, len, &v) ? + upb_value_getptr(v) : NULL; + return def ? upb_dyncast_msgdef(def) : NULL; +} + const upb_enumdef *upb_symtab_lookupenum(const upb_symtab *s, const char *sym) { upb_value v; upb_def *def = upb_strtable_lookup(&s->symtab, sym, &v) ? |