summaryrefslogtreecommitdiff
path: root/upb/descriptor/reader.c
diff options
context:
space:
mode:
authorJosh Haberman <jhaberman@gmail.com>2015-10-14 18:02:34 -0700
committerJosh Haberman <jhaberman@gmail.com>2015-10-14 18:02:34 -0700
commitbc53c1bc4621e172a20fb0966c7ee9342d9a8dda (patch)
tree37d3be5287e3078cfa35efc81634977236000c5a /upb/descriptor/reader.c
parent77d45edfb39171aef5e0ae09a471e5d8e2679a7f (diff)
Add flag to MessageDef for whether fields have presence.
Diffstat (limited to 'upb/descriptor/reader.c')
-rw-r--r--upb/descriptor/reader.c16
1 files changed, 16 insertions, 0 deletions
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)) {
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback