From bc53c1bc4621e172a20fb0966c7ee9342d9a8dda Mon Sep 17 00:00:00 2001 From: Josh Haberman Date: Wed, 14 Oct 2015 18:02:34 -0700 Subject: Add flag to MessageDef for whether fields have presence. --- upb/descriptor/reader.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'upb/descriptor/reader.c') diff --git a/upb/descriptor/reader.c b/upb/descriptor/reader.c index 17d6675..3cc6d14 100644 --- a/upb/descriptor/reader.c +++ b/upb/descriptor/reader.c @@ -203,6 +203,20 @@ static size_t file_onpackage(void *closure, const void *hd, const char *buf, return n; } +static size_t file_onsyntax(void *closure, const void *hd, const char *buf, + size_t n, const upb_bufhandle *handle) { + upb_descreader *r = closure; + UPB_UNUSED(hd); + UPB_UNUSED(handle); + /* XXX: see comment at the top of the file. */ + if (n == strlen("proto3") && memcmp(buf, "proto3", strlen("proto3")) == 0) { + /* TODO(haberman): set a flag in the scope so that all enclosing messages + * will set field presence to false. */ + UPB_UNUSED(r); + } + return n; +} + /* Handlers for google.protobuf.EnumValueDescriptorProto. */ static bool enumval_startmsg(void *closure, const void *hd) { upb_descreader *r = closure; @@ -572,6 +586,8 @@ static void reghandlers(const void *closure, upb_handlers *h) { upb_handlers_setendmsg(h, &file_endmsg, NULL); upb_handlers_setstring(h, D(FileDescriptorProto_package), &file_onpackage, NULL); + upb_handlers_setstring(h, D(FileDescriptorProto_syntax), &file_onsyntax, + NULL); upb_handlers_setendsubmsg(h, D(FileDescriptorProto_extension), &pushextension, NULL); } else if (m == D(EnumValueDescriptorProto)) { -- cgit v1.2.3