Skip to content

Commit

Permalink
Merge fef7e77 into 9e44a75
Browse files Browse the repository at this point in the history
  • Loading branch information
TeBoring committed Dec 4, 2018
2 parents 9e44a75 + fef7e77 commit 4410059
Show file tree
Hide file tree
Showing 9 changed files with 1,157 additions and 253 deletions.
5 changes: 4 additions & 1 deletion BUILD
Expand Up @@ -115,7 +115,10 @@ cc_library(
"-pedantic",
"-Wno-long-long",
],
deps = [":upb"],
deps = [
":upb",
":upb_pb",
],
)

cc_library(
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Expand Up @@ -191,6 +191,9 @@ endif
upb_json_SRCS = \
upb/json/parser.c \
upb/json/printer.c \
upb/pb/encoder.c \
upb/pb/varint.c \
upb/sink.c \

# Ideally we could keep this uncommented, but Git apparently sometimes skews
# timestamps slightly at "clone" time, which makes "Make" think that it needs
Expand Down
2 changes: 1 addition & 1 deletion tests/json/test_json.cc
Expand Up @@ -177,7 +177,7 @@ void test_json_roundtrip_message(const char* json_src,
env.env(), serialize_handlers, data_sink.Sink());
upb::json::Parser* parser =
upb::json::Parser::Create(
env.env(), parser_method, printer->input(), false);
env.env(), parser_method, NULL, printer->input(), false);
env.ResetBytesSink(parser->input());
env.Reset(json_src, strlen(json_src), false, false);

Expand Down
12 changes: 11 additions & 1 deletion upb/def.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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) ?
Expand Down
3 changes: 3 additions & 0 deletions upb/def.h
Expand Up @@ -285,6 +285,7 @@ typedef enum {
*/
typedef enum {
UPB_WELLKNOWN_UNSPECIFIED,
UPB_WELLKNOWN_ANY,
UPB_WELLKNOWN_DURATION,
UPB_WELLKNOWN_TIMESTAMP,
/* number wrappers */
Expand Down Expand Up @@ -1543,6 +1544,8 @@ const upb_def *upb_symtab_resolve(const upb_symtab *s, const char *base,
const char *sym);
const upb_def *upb_symtab_lookup(const upb_symtab *s, const char *sym);
const upb_msgdef *upb_symtab_lookupmsg(const upb_symtab *s, const char *sym);
const upb_msgdef *upb_symtab_lookupmsg2(
const upb_symtab *s, const char *sym, size_t len);
const upb_enumdef *upb_symtab_lookupenum(const upb_symtab *s, const char *sym);
bool upb_symtab_add(upb_symtab *s, upb_def *const*defs, size_t n,
void *ref_donor, upb_status *status);
Expand Down

0 comments on commit 4410059

Please sign in to comment.