summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xtravis.sh20
-rw-r--r--upb/descriptor/reader.c28
2 files changed, 38 insertions, 10 deletions
diff --git a/travis.sh b/travis.sh
index 79c4a78..5df7726 100755
--- a/travis.sh
+++ b/travis.sh
@@ -1,5 +1,10 @@
#!/bin/bash
+install_protoc() {
+ sudo apt-get install protobuf-compiler
+ protoc --version || true
+}
+
# Bare build: no dependencies installed, no JIT enabled.
bare_install() {
:
@@ -21,7 +26,8 @@ barejit_script() {
# Build with Google protobuf support and tests (with JIT).
withprotobuf_install() {
sudo apt-get update -qq
- sudo apt-get install protobuf-compiler libprotobuf-dev
+ sudo apt-get install libprotobuf-dev
+ install_protoc
}
withprotobuf_script() {
make -j12 tests googlepbtests WITH_JIT=yes
@@ -66,9 +72,13 @@ lua_script() {
# don't want the test to be brittle.
genfiles_install() {
sudo apt-get update -qq
- sudo apt-get install lua5.2 liblua5.2-dev protobuf-compiler
+ sudo apt-get install lua5.2 liblua5.2-dev
}
genfiles_script() {
+ # Avoid regenerating descriptor.pb, since its output can vary based on the
+ # version of protoc.
+ touch upb/descriptor/descriptor.pb
+
make -j12 genfiles USER_CPPFLAGS="$USER_CPPFLAGS `pkg-config lua5.2 --cflags`"
# Will fail if any differences were observed.
git diff --exit-code
@@ -77,7 +87,8 @@ genfiles_script() {
# Tests the ndebug build.
ndebug_install() {
sudo apt-get update -qq
- sudo apt-get install lua5.2 liblua5.2-dev protobuf-compiler libprotobuf-dev
+ sudo apt-get install lua5.2 liblua5.2-dev libprotobuf-dev
+ install_protoc
}
ndebug_script() {
# Override of USER_CPPFLAGS removes -UNDEBUG.
@@ -89,7 +100,8 @@ ndebug_script() {
# A run that executes with coverage support and uploads to coveralls.io
coverage_install() {
sudo apt-get update -qq
- sudo apt-get install protobuf-compiler libprotobuf-dev lua5.2 liblua5.2-dev
+ sudo apt-get install libprotobuf-dev lua5.2 liblua5.2-dev
+ install_protoc
sudo pip install cpp-coveralls
}
coverage_script() {
diff --git a/upb/descriptor/reader.c b/upb/descriptor/reader.c
index 3cc6d14..1d6ed94 100644
--- a/upb/descriptor/reader.c
+++ b/upb/descriptor/reader.c
@@ -53,6 +53,9 @@ struct upb_descreader {
upb_descreader_frame stack[UPB_MAX_MESSAGE_NESTING];
int stack_len;
+ bool primitives_have_presence;
+ int file_start;
+
uint32_t number;
char *name;
bool saw_number;
@@ -179,9 +182,12 @@ void upb_descreader_setscopename(upb_descreader *r, char *str) {
}
/* Handlers for google.protobuf.FileDescriptorProto. */
-static bool file_startmsg(void *r, const void *hd) {
+static bool file_startmsg(void *closure, const void *hd) {
+ upb_descreader *r = closure;
UPB_UNUSED(hd);
upb_descreader_startcontainer(r);
+ r->primitives_have_presence = true;
+ r->file_start = r->defs.len;
return true;
}
@@ -210,9 +216,17 @@ static size_t file_onsyntax(void *closure, const void *hd, const char *buf,
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);
+ uint32_t i;
+ /* Cover messages created previously. */
+ for (i = r->file_start; i < r->defs.len; i++) {
+ upb_msgdef *m = upb_dyncast_msgdef_mutable(r->defs.defs[i]);
+ if (m) {
+ upb_msgdef_setprimitiveshavepresence(m, false);
+ }
+ }
+
+ /* Cover messages created subsequently. */
+ r->primitives_have_presence = false;
}
return n;
}
@@ -511,10 +525,12 @@ static size_t field_ondefaultval(void *closure, const void *hd, const char *buf,
/* Handlers for google.protobuf.DescriptorProto (representing a message). */
static bool msg_startmsg(void *closure, const void *hd) {
upb_descreader *r = closure;
+ upb_msgdef *m;
UPB_UNUSED(hd);
- upb_deflist_push(&r->defs,
- upb_msgdef_upcast_mutable(upb_msgdef_new(&r->defs)));
+ m = upb_msgdef_new(&r->defs);
+ upb_msgdef_setprimitiveshavepresence(m, r->primitives_have_presence);
+ upb_deflist_push(&r->defs, upb_msgdef_upcast_mutable(m));
upb_descreader_startcontainer(r);
return true;
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback