aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am29
-rw-r--r--src/google/protobuf/any.pb.cc6
-rw-r--r--src/google/protobuf/any.pb.h4
-rw-r--r--src/google/protobuf/api.pb.cc10
-rw-r--r--src/google/protobuf/api.pb.h4
-rw-r--r--[-rwxr-xr-x]src/google/protobuf/arena.cc0
-rw-r--r--[-rwxr-xr-x]src/google/protobuf/arenastring.h0
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_enum_field.cc6
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_file.cc6
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_message.cc2
-rw-r--r--src/google/protobuf/compiler/csharp/csharp_helpers.cc2
-rw-r--r--src/google/protobuf/compiler/importer.cc2
-rw-r--r--src/google/protobuf/compiler/importer.h15
-rw-r--r--src/google/protobuf/compiler/java/java_enum_field.cc8
-rw-r--r--src/google/protobuf/compiler/java/java_lazy_message_field.cc5
-rw-r--r--src/google/protobuf/compiler/java/java_message_field.cc23
-rw-r--r--src/google/protobuf/compiler/java/java_primitive_field.cc22
-rw-r--r--src/google/protobuf/compiler/java/java_string_field.cc8
-rw-r--r--src/google/protobuf/compiler/js/embed.cc110
-rw-r--r--[-rwxr-xr-x]src/google/protobuf/compiler/js/js_generator.cc9
-rw-r--r--[-rwxr-xr-x]src/google/protobuf/compiler/js/js_generator.h0
-rw-r--r--src/google/protobuf/compiler/js/well_known_types_embed.cc225
-rw-r--r--src/google/protobuf/compiler/php/php_generator.cc438
-rw-r--r--src/google/protobuf/compiler/php/php_generator.h1
-rw-r--r--src/google/protobuf/compiler/plugin.pb.cc6
-rw-r--r--src/google/protobuf/compiler/plugin.pb.h4
-rw-r--r--src/google/protobuf/compiler/ruby/ruby_generator.cc19
-rw-r--r--src/google/protobuf/descriptor.cc34
-rw-r--r--src/google/protobuf/descriptor.pb.cc457
-rw-r--r--src/google/protobuf/descriptor.pb.h308
-rw-r--r--src/google/protobuf/descriptor.proto11
-rw-r--r--src/google/protobuf/descriptor_database.h40
-rw-r--r--src/google/protobuf/duration.pb.cc8
-rw-r--r--src/google/protobuf/duration.pb.h4
-rw-r--r--src/google/protobuf/dynamic_message.cc12
-rw-r--r--src/google/protobuf/dynamic_message.h2
-rw-r--r--src/google/protobuf/empty.pb.cc8
-rw-r--r--src/google/protobuf/empty.pb.h4
-rw-r--r--src/google/protobuf/extension_set.h2
-rw-r--r--src/google/protobuf/extension_set_heavy.cc4
-rw-r--r--src/google/protobuf/field_mask.pb.cc6
-rw-r--r--src/google/protobuf/field_mask.pb.h4
-rw-r--r--src/google/protobuf/generated_message_reflection.h239
-rw-r--r--src/google/protobuf/generated_message_util.h13
-rw-r--r--src/google/protobuf/io/gzip_stream.h2
-rw-r--r--src/google/protobuf/io/zero_copy_stream_impl.h69
-rw-r--r--src/google/protobuf/io/zero_copy_stream_impl_lite.h41
-rw-r--r--src/google/protobuf/map_entry.h13
-rw-r--r--src/google/protobuf/map_entry_lite.h35
-rw-r--r--src/google/protobuf/map_field.h59
-rw-r--r--src/google/protobuf/message.cc2
-rw-r--r--src/google/protobuf/message.h20
-rw-r--r--src/google/protobuf/message_lite.cc6
-rw-r--r--[-rwxr-xr-x]src/google/protobuf/reflection.h0
-rw-r--r--src/google/protobuf/reflection_internal.h102
-rw-r--r--src/google/protobuf/repeated_field.h6
-rw-r--r--src/google/protobuf/source_context.pb.cc6
-rw-r--r--src/google/protobuf/source_context.pb.h4
-rw-r--r--src/google/protobuf/struct.pb.cc14
-rw-r--r--src/google/protobuf/struct.pb.h4
-rw-r--r--src/google/protobuf/stubs/bytestream.h25
-rw-r--r--src/google/protobuf/stubs/callback.h22
-rw-r--r--[-rwxr-xr-x]src/google/protobuf/stubs/common.cc0
-rw-r--r--src/google/protobuf/stubs/common.h10
-rw-r--r--src/google/protobuf/stubs/int128.cc52
-rw-r--r--src/google/protobuf/stubs/mutex.h20
-rw-r--r--src/google/protobuf/stubs/platform_macros.h8
-rw-r--r--src/google/protobuf/stubs/port.h8
-rw-r--r--src/google/protobuf/text_format.cc38
-rw-r--r--src/google/protobuf/text_format_unittest.cc5
-rw-r--r--src/google/protobuf/timestamp.pb.cc8
-rw-r--r--src/google/protobuf/timestamp.pb.h4
-rw-r--r--src/google/protobuf/type.pb.cc24
-rw-r--r--src/google/protobuf/type.pb.h4
-rw-r--r--src/google/protobuf/util/field_comparator.h6
-rw-r--r--src/google/protobuf/util/internal/default_value_objectwriter.h28
-rw-r--r--src/google/protobuf/util/internal/error_listener.h12
-rw-r--r--src/google/protobuf/util/internal/json_objectwriter.h34
-rw-r--r--src/google/protobuf/util/internal/object_location_tracker.h4
-rw-r--r--src/google/protobuf/util/internal/proto_writer.h10
-rw-r--r--src/google/protobuf/util/internal/protostream_objectsource.cc7
-rw-r--r--src/google/protobuf/util/internal/protostream_objectsource.h4
-rw-r--r--src/google/protobuf/util/internal/protostream_objectsource_test.cc78
-rw-r--r--src/google/protobuf/util/internal/protostream_objectwriter.cc2
-rw-r--r--src/google/protobuf/util/internal/protostream_objectwriter.h16
-rw-r--r--src/google/protobuf/util/internal/protostream_objectwriter_test.cc16
-rw-r--r--src/google/protobuf/util/internal/testdata/books.proto3
-rw-r--r--src/google/protobuf/util/internal/testdata/maps.proto3
-rw-r--r--src/google/protobuf/util/internal/type_info.cc10
-rw-r--r--src/google/protobuf/util/json_util.cc12
-rw-r--r--src/google/protobuf/util/json_util.h2
-rw-r--r--src/google/protobuf/util/json_util_test.cc2
-rw-r--r--src/google/protobuf/util/message_differencer.cc2
-rw-r--r--src/google/protobuf/util/message_differencer.h21
-rw-r--r--[-rwxr-xr-x]src/google/protobuf/util/message_differencer_unittest.cc0
-rw-r--r--src/google/protobuf/util/type_resolver_util.cc4
-rw-r--r--src/google/protobuf/wire_format.h8
-rw-r--r--src/google/protobuf/wire_format_lite.h6
-rw-r--r--src/google/protobuf/wrappers.pb.cc24
-rw-r--r--src/google/protobuf/wrappers.pb.h4
100 files changed, 1918 insertions, 1131 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 7310210e..cb1b1006 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -56,9 +56,7 @@ clean-local:
CLEANFILES = $(protoc_outputs) unittest_proto_middleman \
testzip.jar testzip.list testzip.proto testzip.zip \
- no_warning_test.cc \
- google/protobuf/compiler/js/well_known_types_embed.cc \
- js_embed$(EXEEXT)
+ no_warning_test.cc
MAINTAINERCLEANFILES = \
Makefile.in
@@ -166,7 +164,7 @@ nobase_include_HEADERS = \
lib_LTLIBRARIES = libprotobuf-lite.la libprotobuf.la libprotoc.la
libprotobuf_lite_la_LIBADD = $(PTHREAD_LIBS)
-libprotobuf_lite_la_LDFLAGS = -version-info 15:1:0 -export-dynamic -no-undefined
+libprotobuf_lite_la_LDFLAGS = -version-info 16:0:0 -export-dynamic -no-undefined
if HAVE_LD_VERSION_SCRIPT
libprotobuf_lite_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libprotobuf-lite.map
EXTRA_libprotobuf_lite_la_DEPENDENCIES = libprotobuf-lite.map
@@ -212,7 +210,7 @@ libprotobuf_lite_la_SOURCES = \
google/protobuf/io/zero_copy_stream_impl_lite.cc
libprotobuf_la_LIBADD = $(PTHREAD_LIBS)
-libprotobuf_la_LDFLAGS = -version-info 15:1:0 -export-dynamic -no-undefined
+libprotobuf_la_LDFLAGS = -version-info 16:0:0 -export-dynamic -no-undefined
if HAVE_LD_VERSION_SCRIPT
libprotobuf_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libprotobuf.map
EXTRA_libprotobuf_la_DEPENDENCIES = libprotobuf.map
@@ -303,7 +301,7 @@ libprotobuf_la_SOURCES = \
nodist_libprotobuf_la_SOURCES = $(nodist_libprotobuf_lite_la_SOURCES)
libprotoc_la_LIBADD = $(PTHREAD_LIBS) libprotobuf.la
-libprotoc_la_LDFLAGS = -version-info 15:1:0 -export-dynamic -no-undefined
+libprotoc_la_LDFLAGS = -version-info 16:0:0 -export-dynamic -no-undefined
if HAVE_LD_VERSION_SCRIPT
libprotoc_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libprotoc.map
EXTRA_libprotoc_la_DEPENDENCIES = libprotoc.map
@@ -471,22 +469,6 @@ bin_PROGRAMS = protoc
protoc_LDADD = $(PTHREAD_LIBS) libprotobuf.la libprotoc.la
protoc_SOURCES = google/protobuf/compiler/main.cc
-# The special JS code for the well-known types is linked into the compiler via
-# well_known_types_embed.cc, which is generated from .js source files. We have
-# to build the js_embed binary using $(CXX_FOR_BUILD) so that it is executable
-# on the build machine in a cross-compilation setup.
-js_embed$(EXEEXT): $(srcdir)/google/protobuf/compiler/js/embed.cc
- $(CXX_FOR_BUILD) -o $@ $<
-js_well_known_types_sources = \
- google/protobuf/compiler/js/well_known_types/any.js \
- google/protobuf/compiler/js/well_known_types/struct.js \
- google/protobuf/compiler/js/well_known_types/timestamp.js
-# We have to cd to $(srcdir) so that out-of-tree builds work properly.
-google/protobuf/compiler/js/well_known_types_embed.cc: js_embed$(EXEEXT) $(js_well_known_types_sources)
- mkdir -p `dirname $@` && \
- oldpwd=`pwd` && cd $(srcdir) && \
- $$oldpwd/js_embed$(EXEEXT) $(js_well_known_types_sources) > $$oldpwd/$@
-
# Tests ==============================================================
protoc_inputs = \
@@ -565,7 +547,6 @@ EXTRA_DIST = \
google/protobuf/package_info.h \
google/protobuf/io/package_info.h \
google/protobuf/util/package_info.h \
- google/protobuf/compiler/js/embed.cc \
google/protobuf/compiler/ruby/ruby_generated_code.proto \
google/protobuf/compiler/ruby/ruby_generated_code_pb.rb \
google/protobuf/compiler/package_info.h \
@@ -895,7 +876,7 @@ no_warning_test.cc:
no_warning_test_LDADD = $(PTHREAD_LIBS) libprotobuf.la libprotoc.la
no_warning_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(PTHREAD_DEF) $(ZLIB_DEF) \
- -Wall -Wextra -Werror -Wno-unused-parameter
+ -Wall -Wextra -Werror -Wno-unused-parameter -Og
nodist_no_warning_test_SOURCES = no_warning_test.cc $(protoc_outputs)
TESTS = protobuf-test protobuf-lazy-descriptor-test protobuf-lite-test \
diff --git a/src/google/protobuf/any.pb.cc b/src/google/protobuf/any.pb.cc
index 9d632efe..d0fc2905 100644
--- a/src/google/protobuf/any.pb.cc
+++ b/src/google/protobuf/any.pb.cc
@@ -66,14 +66,14 @@ static ::google::protobuf::Message const * const file_default_instances[] = {
reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_Any_default_instance_),
};
-void protobuf_AssignDescriptors() {
+static void protobuf_AssignDescriptors() {
AddDescriptors();
AssignDescriptors(
"google/protobuf/any.proto", schemas, file_default_instances, TableStruct::offsets,
file_level_metadata, NULL, NULL);
}
-void protobuf_AssignDescriptorsOnce() {
+static void protobuf_AssignDescriptorsOnce() {
static ::google::protobuf::internal::once_flag once;
::google::protobuf::internal::call_once(once, protobuf_AssignDescriptors);
}
@@ -84,7 +84,7 @@ void protobuf_RegisterTypes(const ::std::string&) {
::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 1);
}
-void AddDescriptorsImpl() {
+static void AddDescriptorsImpl() {
InitDefaults();
static const char descriptor[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
"\n\031google/protobuf/any.proto\022\017google.prot"
diff --git a/src/google/protobuf/any.pb.h b/src/google/protobuf/any.pb.h
index bc537999..8a4c7f97 100644
--- a/src/google/protobuf/any.pb.h
+++ b/src/google/protobuf/any.pb.h
@@ -8,12 +8,12 @@
#include <google/protobuf/stubs/common.h>
-#if GOOGLE_PROTOBUF_VERSION < 3005000
+#if GOOGLE_PROTOBUF_VERSION < 3006000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
-#if 3005001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 3006000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
diff --git a/src/google/protobuf/api.pb.cc b/src/google/protobuf/api.pb.cc
index e0a249d0..273307c7 100644
--- a/src/google/protobuf/api.pb.cc
+++ b/src/google/protobuf/api.pb.cc
@@ -149,14 +149,14 @@ static ::google::protobuf::Message const * const file_default_instances[] = {
reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_Mixin_default_instance_),
};
-void protobuf_AssignDescriptors() {
+static void protobuf_AssignDescriptors() {
AddDescriptors();
AssignDescriptors(
"google/protobuf/api.proto", schemas, file_default_instances, TableStruct::offsets,
file_level_metadata, NULL, NULL);
}
-void protobuf_AssignDescriptorsOnce() {
+static void protobuf_AssignDescriptorsOnce() {
static ::google::protobuf::internal::once_flag once;
::google::protobuf::internal::call_once(once, protobuf_AssignDescriptors);
}
@@ -167,7 +167,7 @@ void protobuf_RegisterTypes(const ::std::string&) {
::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 3);
}
-void AddDescriptorsImpl() {
+static void AddDescriptorsImpl() {
InitDefaults();
static const char descriptor[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
"\n\031google/protobuf/api.proto\022\017google.prot"
@@ -414,7 +414,7 @@ bool Api::MergePartialFromCodedStream(
case 7: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(56u /* 56 & 0xFF */)) {
- int value;
+ int value = 0;
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
input, &value)));
@@ -947,7 +947,7 @@ bool Method::MergePartialFromCodedStream(
case 7: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(56u /* 56 & 0xFF */)) {
- int value;
+ int value = 0;
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
input, &value)));
diff --git a/src/google/protobuf/api.pb.h b/src/google/protobuf/api.pb.h
index 5a720cce..0f90f411 100644
--- a/src/google/protobuf/api.pb.h
+++ b/src/google/protobuf/api.pb.h
@@ -8,12 +8,12 @@
#include <google/protobuf/stubs/common.h>
-#if GOOGLE_PROTOBUF_VERSION < 3005000
+#if GOOGLE_PROTOBUF_VERSION < 3006000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
-#if 3005001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 3006000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
diff --git a/src/google/protobuf/arena.cc b/src/google/protobuf/arena.cc
index c117c9e5..c117c9e5 100755..100644
--- a/src/google/protobuf/arena.cc
+++ b/src/google/protobuf/arena.cc
diff --git a/src/google/protobuf/arenastring.h b/src/google/protobuf/arenastring.h
index 168fc972..168fc972 100755..100644
--- a/src/google/protobuf/arenastring.h
+++ b/src/google/protobuf/arenastring.h
diff --git a/src/google/protobuf/compiler/cpp/cpp_enum_field.cc b/src/google/protobuf/compiler/cpp/cpp_enum_field.cc
index 50c7b5f3..828d0be5 100644
--- a/src/google/protobuf/compiler/cpp/cpp_enum_field.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_enum_field.cc
@@ -128,7 +128,7 @@ GenerateCopyConstructorCode(io::Printer* printer) const {
void EnumFieldGenerator::
GenerateMergeFromCodedStream(io::Printer* printer) const {
printer->Print(variables_,
- "int value;\n"
+ "int value = 0;\n"
"DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n"
" int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(\n"
" input, &value)));\n");
@@ -334,7 +334,7 @@ void RepeatedEnumFieldGenerator::
GenerateMergeFromCodedStream(io::Printer* printer) const {
// Don't use ReadRepeatedPrimitive here so that the enum can be validated.
printer->Print(variables_,
- "int value;\n"
+ "int value = 0;\n"
"DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n"
" int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(\n"
" input, &value)));\n");
@@ -399,7 +399,7 @@ GenerateMergeFromCodedStreamWithPacking(io::Printer* printer) const {
"::google::protobuf::io::CodedInputStream::Limit limit = "
"input->PushLimit(static_cast<int>(length));\n"
"while (input->BytesUntilLimit() > 0) {\n"
- " int value;\n"
+ " int value = 0;\n"
" DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n"
" int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(\n"
" input, &value)));\n");
diff --git a/src/google/protobuf/compiler/cpp/cpp_file.cc b/src/google/protobuf/compiler/cpp/cpp_file.cc
index 42525687..02f360bb 100644
--- a/src/google/protobuf/compiler/cpp/cpp_file.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_file.cc
@@ -791,7 +791,7 @@ void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) {
// AssignDescriptors(). All later times, waits for the first call to
// complete and then returns.
printer->Print(
- "void protobuf_AssignDescriptors() {\n"
+ "static void protobuf_AssignDescriptors() {\n"
// Make sure the file has found its way into the pool. If a descriptor
// is requested *during* static init then AddDescriptors() may not have
// been called yet, so we call it manually. Note that it's fine if
@@ -812,7 +812,7 @@ void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) {
printer->Print(
"}\n"
"\n"
- "void protobuf_AssignDescriptorsOnce() {\n"
+ "static void protobuf_AssignDescriptorsOnce() {\n"
" static ::google::protobuf::internal::once_flag once;\n"
" ::google::protobuf::internal::call_once(once, protobuf_AssignDescriptors);\n"
"}\n"
@@ -850,7 +850,7 @@ void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) {
// Now generate the AddDescriptors() function.
printer->Print(
- "void AddDescriptorsImpl() {\n"
+ "static void AddDescriptorsImpl() {\n"
" InitDefaults();\n");
printer->Indent();
diff --git a/src/google/protobuf/compiler/cpp/cpp_message.cc b/src/google/protobuf/compiler/cpp/cpp_message.cc
index 8c2336af..778fc406 100644
--- a/src/google/protobuf/compiler/cpp/cpp_message.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_message.cc
@@ -2280,7 +2280,7 @@ GenerateArenaDestructorCode(io::Printer* printer) {
"classname", classname_);
} else {
printer->Print(
- "void $classname$::RegisterArenaDtor(::google::protobuf::Arena* arena) {\n"
+ "void $classname$::RegisterArenaDtor(::google::protobuf::Arena*) {\n"
"}\n",
"classname", classname_);
}
diff --git a/src/google/protobuf/compiler/csharp/csharp_helpers.cc b/src/google/protobuf/compiler/csharp/csharp_helpers.cc
index 5bca1ffa..04b61074 100644
--- a/src/google/protobuf/compiler/csharp/csharp_helpers.cc
+++ b/src/google/protobuf/compiler/csharp/csharp_helpers.cc
@@ -169,7 +169,7 @@ std::string UnderscoresToCamelCase(const std::string& input,
}
}
// Add a trailing "_" if the name should be altered.
- if (input[input.size() - 1] == '#') {
+ if (input.size() > 0 && input[input.size() - 1] == '#') {
result += '_';
}
return result;
diff --git a/src/google/protobuf/compiler/importer.cc b/src/google/protobuf/compiler/importer.cc
index c3831e72..58498aaa 100644
--- a/src/google/protobuf/compiler/importer.cc
+++ b/src/google/protobuf/compiler/importer.cc
@@ -103,7 +103,7 @@ class SourceTreeDescriptorDatabase::SingleFileErrorCollector
bool had_errors() { return had_errors_; }
// implements ErrorCollector ---------------------------------------
- void AddError(int line, int column, const string& message) {
+ void AddError(int line, int column, const string& message) override {
if (multi_file_error_collector_ != NULL) {
multi_file_error_collector_->AddError(filename_, line, column, message);
}
diff --git a/src/google/protobuf/compiler/importer.h b/src/google/protobuf/compiler/importer.h
index a4ffcf87..bf6d3de3 100644
--- a/src/google/protobuf/compiler/importer.h
+++ b/src/google/protobuf/compiler/importer.h
@@ -96,12 +96,13 @@ class LIBPROTOBUF_EXPORT SourceTreeDescriptorDatabase : public DescriptorDatabas
}
// implements DescriptorDatabase -----------------------------------
- bool FindFileByName(const string& filename, FileDescriptorProto* output);
+ bool FindFileByName(const string& filename,
+ FileDescriptorProto* output) override;
bool FindFileContainingSymbol(const string& symbol_name,
- FileDescriptorProto* output);
+ FileDescriptorProto*output) override;
bool FindFileContainingExtension(const string& containing_type,
int field_number,
- FileDescriptorProto* output);
+ FileDescriptorProto* output) override;
private:
class SingleFileErrorCollector;
@@ -119,13 +120,13 @@ class LIBPROTOBUF_EXPORT SourceTreeDescriptorDatabase : public DescriptorDatabas
const string& element_name,
const Message* descriptor,
ErrorLocation location,
- const string& message);
+ const string& message) override;
virtual void AddWarning(const string& filename,
const string& element_name,
const Message* descriptor,
ErrorLocation location,
- const string& message);
+ const string& message) override;
private:
SourceTreeDescriptorDatabase* owner_;
@@ -293,9 +294,9 @@ class LIBPROTOBUF_EXPORT DiskSourceTree : public SourceTree {
bool VirtualFileToDiskFile(const string& virtual_file, string* disk_file);
// implements SourceTree -------------------------------------------
- virtual io::ZeroCopyInputStream* Open(const string& filename);
+ virtual io::ZeroCopyInputStream* Open(const string& filename) override;
- virtual string GetLastErrorMessage();
+ virtual string GetLastErrorMessage() override;
private:
struct Mapping {
diff --git a/src/google/protobuf/compiler/java/java_enum_field.cc b/src/google/protobuf/compiler/java/java_enum_field.cc
index 0686ea0f..ef64d88b 100644
--- a/src/google/protobuf/compiler/java/java_enum_field.cc
+++ b/src/google/protobuf/compiler/java/java_enum_field.cc
@@ -305,11 +305,15 @@ GenerateBuildingCode(io::Printer* printer) const {
if (SupportFieldPresence(descriptor_->file())) {
printer->Print(variables_,
"if ($get_has_field_bit_from_local$) {\n"
+ " result.$name$_ = $name$_;\n"
" $set_has_field_bit_to_local$;\n"
+ "} else {\n"
+ " result.$name$_ = $default_number$;\n"
"}\n");
+ } else {
+ printer->Print(variables_,
+ "result.$name$_ = $name$_;\n");
}
- printer->Print(variables_,
- "result.$name$_ = $name$_;\n");
}
void ImmutableEnumFieldGenerator::
diff --git a/src/google/protobuf/compiler/java/java_lazy_message_field.cc b/src/google/protobuf/compiler/java/java_lazy_message_field.cc
index abf8e55c..6544bea0 100644
--- a/src/google/protobuf/compiler/java/java_lazy_message_field.cc
+++ b/src/google/protobuf/compiler/java/java_lazy_message_field.cc
@@ -233,12 +233,9 @@ void ImmutableLazyMessageFieldGenerator::
GenerateBuildingCode(io::Printer* printer) const {
printer->Print(variables_,
"if ($get_has_field_bit_from_local$) {\n"
+ " result.$name$_.set($name$_);\n"
" $set_has_field_bit_to_local$;\n"
"}\n");
-
- printer->Print(variables_,
- "result.$name$_.set(\n"
- " $name$_);\n");
}
void ImmutableLazyMessageFieldGenerator::
diff --git a/src/google/protobuf/compiler/java/java_message_field.cc b/src/google/protobuf/compiler/java/java_message_field.cc
index baa7f872..bda4fcc0 100644
--- a/src/google/protobuf/compiler/java/java_message_field.cc
+++ b/src/google/protobuf/compiler/java/java_message_field.cc
@@ -255,7 +255,7 @@ GenerateBuilderMembers(io::Printer* printer) const {
bool support_field_presence = SupportFieldPresence(descriptor_->file());
printer->Print(variables_,
- "private $type$ $name$_ = null;\n");
+ "private $type$ $name$_;\n");
printer->Print(variables_,
// If this builder is non-null, it is used and the other fields are
@@ -444,15 +444,20 @@ void ImmutableMessageFieldGenerator::
GenerateBuildingCode(io::Printer* printer) const {
if (SupportFieldPresence(descriptor_->file())) {
printer->Print(variables_,
- "if ($get_has_field_bit_from_local$) {\n"
- " $set_has_field_bit_to_local$;\n"
- "}\n");
+ "if ($get_has_field_bit_from_local$) {\n");
+ printer->Indent();
+ PrintNestedBuilderCondition(printer,
+ "result.$name$_ = $name$_;\n",
+ "result.$name$_ = $name$Builder_.build();\n");
+ printer->Outdent();
+ printer->Print(variables_,
+ " $set_has_field_bit_to_local$;\n"
+ "}\n");
+ } else {
+ PrintNestedBuilderCondition(printer,
+ "result.$name$_ = $name$_;\n",
+ "result.$name$_ = $name$Builder_.build();\n");
}
-
- PrintNestedBuilderCondition(printer,
- "result.$name$_ = $name$_;\n",
-
- "result.$name$_ = $name$Builder_.build();\n");
}
void ImmutableMessageFieldGenerator::
diff --git a/src/google/protobuf/compiler/java/java_primitive_field.cc b/src/google/protobuf/compiler/java/java_primitive_field.cc
index 71ee0992..e6ce69c7 100644
--- a/src/google/protobuf/compiler/java/java_primitive_field.cc
+++ b/src/google/protobuf/compiler/java/java_primitive_field.cc
@@ -264,7 +264,9 @@ GenerateFieldBuilderInitializationCode(io::Printer* printer) const {
void ImmutablePrimitiveFieldGenerator::
GenerateInitializationCode(io::Printer* printer) const {
- printer->Print(variables_, "$name$_ = $default$;\n");
+ if (!IsDefaultValueJavaDefault(descriptor_)) {
+ printer->Print(variables_, "$name$_ = $default$;\n");
+ }
}
void ImmutablePrimitiveFieldGenerator::
@@ -294,11 +296,21 @@ GenerateBuildingCode(io::Printer* printer) const {
if (SupportFieldPresence(descriptor_->file())) {
printer->Print(variables_,
"if ($get_has_field_bit_from_local$) {\n"
- " $set_has_field_bit_to_local$;\n"
- "}\n");
+ " result.$name$_ = $name$_;\n"
+ " $set_has_field_bit_to_local$;\n");
+ if (IsDefaultValueJavaDefault(descriptor_)) {
+ printer->Print(variables_,
+ "}\n");
+ } else {
+ printer->Print(variables_,
+ "} else {\n"
+ " result.$name$_ = $default$;\n"
+ "}\n");
+ }
+ } else {
+ printer->Print(variables_,
+ "result.$name$_ = $name$_;\n");
}
- printer->Print(variables_,
- "result.$name$_ = $name$_;\n");
}
void ImmutablePrimitiveFieldGenerator::
diff --git a/src/google/protobuf/compiler/java/java_string_field.cc b/src/google/protobuf/compiler/java/java_string_field.cc
index 2b6e9381..b08febc0 100644
--- a/src/google/protobuf/compiler/java/java_string_field.cc
+++ b/src/google/protobuf/compiler/java/java_string_field.cc
@@ -405,11 +405,15 @@ GenerateBuildingCode(io::Printer* printer) const {
if (SupportFieldPresence(descriptor_->file())) {
printer->Print(variables_,
"if ($get_has_field_bit_from_local$) {\n"
+ " result.$name$_ = $name$_;\n"
" $set_has_field_bit_to_local$;\n"
+ "} else {\n"
+ " result.$name$_ = $default$;\n"
"}\n");
+ } else {
+ printer->Print(variables_,
+ "result.$name$_ = $name$_;\n");
}
- printer->Print(variables_,
- "result.$name$_ = $name$_;\n");
}
void ImmutableStringFieldGenerator::
diff --git a/src/google/protobuf/compiler/js/embed.cc b/src/google/protobuf/compiler/js/embed.cc
deleted file mode 100644
index f0f946e5..00000000
--- a/src/google/protobuf/compiler/js/embed.cc
+++ /dev/null
@@ -1,110 +0,0 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#include <cassert>
-#include <cstdlib>
-#include <fstream>
-#include <iostream>
-#include <string>
-
-static bool AsciiIsPrint(unsigned char c) {
- return c >= 32 && c < 127;
-}
-
-static char ToDecimalDigit(int num) {
- assert(num < 10);
- return '0' + num;
-}
-
-static std::string CEscape(const std::string& str) {
- std::string dest;
-
- for (size_t i = 0; i < str.size(); ++i) {
- unsigned char ch = str[i];
- switch (ch) {
- case '\n': dest += "\\n"; break;
- case '\r': dest += "\\r"; break;
- case '\t': dest += "\\t"; break;
- case '\"': dest += "\\\""; break;
- case '\\': dest += "\\\\"; break;
- default:
- if (AsciiIsPrint(ch)) {
- dest += ch;
- } else {
- dest += "\\";
- dest += ToDecimalDigit(ch / 64);
- dest += ToDecimalDigit((ch % 64) / 8);
- dest += ToDecimalDigit(ch % 8);
- }
- break;
- }
- }
-
- return dest;
-}
-
-static void AddFile(const char* name, std::basic_ostream<char>* out) {
- std::ifstream in(name);
-
- if (!in.is_open()) {
- std::cerr << "Couldn't open input file: " << name << "\n";
- std::exit(EXIT_FAILURE);
- }
-
- // Make canonical name only include the final element.
- for (const char *p = name; *p; p++) {
- if (*p == '/') {
- name = p + 1;
- }
- }
-
- *out << "{\"" << CEscape(name) << "\",\n";
-
- for (std::string line; std::getline(in, line); ) {
- *out << " \"" << CEscape(line) << "\\n\"\n";
- }
-
- *out << "},\n";
-}
-
-int main(int argc, char *argv[]) {
- std::cout << "#include "
- "\"google/protobuf/compiler/js/well_known_types_embed.h\"\n";
- std::cout << "struct FileToc well_known_types_js[] = {\n";
-
- for (int i = 1; i < argc; i++) {
- AddFile(argv[i], &std::cout);
- }
-
- std::cout << " {NULL, NULL} // Terminate the list.\n";
- std::cout << "};\n";
-
- return EXIT_SUCCESS;
-}
diff --git a/src/google/protobuf/compiler/js/js_generator.cc b/src/google/protobuf/compiler/js/js_generator.cc
index 0d9eeb95..d25a3668 100755..100644
--- a/src/google/protobuf/compiler/js/js_generator.cc
+++ b/src/google/protobuf/compiler/js/js_generator.cc
@@ -2974,8 +2974,12 @@ void Generator::GenerateClassDeserializeBinaryField(
if (value_field->type() == FieldDescriptor::TYPE_MESSAGE) {
printer->Print(", $messageType$.deserializeBinaryFromReader",
"messageType", GetMessagePath(options, value_field->message_type()));
+ } else {
+ printer->Print(", null");
}
-
+ printer->Print(", $defaultKey$",
+ "defaultKey", JSFieldDefault(key_field)
+ );
printer->Print(");\n");
printer->Print(" });\n");
} else {
@@ -3499,7 +3503,8 @@ void Generator::GenerateFile(const GeneratorOptions& options,
GenerateExtension(options, printer, *it);
}
- if (options.import_style == GeneratorOptions::kImportCommonJs) {
+ // if provided is empty, do not export anything
+ if (options.import_style == GeneratorOptions::kImportCommonJs && !provided.empty()) {
printer->Print("goog.object.extend(exports, $package$);\n",
"package", GetFilePath(options, file));
} else if(options.import_style == GeneratorOptions::kImportCommonJsStrict) {
diff --git a/src/google/protobuf/compiler/js/js_generator.h b/src/google/protobuf/compiler/js/js_generator.h
index b50ef7fd..b50ef7fd 100755..100644
--- a/src/google/protobuf/compiler/js/js_generator.h
+++ b/src/google/protobuf/compiler/js/js_generator.h
diff --git a/src/google/protobuf/compiler/js/well_known_types_embed.cc b/src/google/protobuf/compiler/js/well_known_types_embed.cc
new file mode 100644
index 00000000..e5ee5510
--- /dev/null
+++ b/src/google/protobuf/compiler/js/well_known_types_embed.cc
@@ -0,0 +1,225 @@
+#include <google/protobuf/compiler/js/well_known_types_embed.h>
+
+struct FileToc well_known_types_js[] = {
+ {"any.js",
+ "/* This code will be inserted into generated code for\n"
+ " * google/protobuf/any.proto. */\n"
+ "\n"
+ "/**\n"
+ " * Returns the type name contained in this instance, if any.\n"
+ " * @return {string|undefined}\n"
+ " */\n"
+ "proto.google.protobuf.Any.prototype.getTypeName = function() {\n"
+ " return this.getTypeUrl().split('/').pop();\n"
+ "};\n"
+ "\n"
+ "\n"
+ "/**\n"
+ " * Packs the given message instance into this Any.\n"
+ " * @param {!Uint8Array} serialized The serialized data to pack.\n"
+ " * @param {string} name The type name of this message object.\n"
+ " * @param {string=} opt_typeUrlPrefix the type URL prefix.\n"
+ " */\n"
+ "proto.google.protobuf.Any.prototype.pack = function(serialized, name,\n"
+ " opt_typeUrlPrefix) "
+ "{\n"
+ " if (!opt_typeUrlPrefix) {\n"
+ " opt_typeUrlPrefix = 'type.googleapis.com/';\n"
+ " }\n"
+ "\n"
+ " if (opt_typeUrlPrefix.substr(-1) != '/') {\n"
+ " this.setTypeUrl(opt_typeUrlPrefix + '/' + name);\n"
+ " } else {\n"
+ " this.setTypeUrl(opt_typeUrlPrefix + name);\n"
+ " }\n"
+ "\n"
+ " this.setValue(serialized);\n"
+ "};\n"
+ "\n"
+ "\n"
+ "/**\n"
+ " * @template T\n"
+ " * Unpacks this Any into the given message object.\n"
+ " * @param {function(Uint8Array):T} deserialize Function that will "
+ "deserialize\n"
+ " * the binary data properly.\n"
+ " * @param {string} name The expected type name of this message object.\n"
+ " * @return {?T} If the name matched the expected name, returns the "
+ "deserialized\n"
+ " * object, otherwise returns null.\n"
+ " */\n"
+ "proto.google.protobuf.Any.prototype.unpack = function(deserialize, name) "
+ "{\n"
+ " if (this.getTypeName() == name) {\n"
+ " return deserialize(this.getValue_asU8());\n"
+ " } else {\n"
+ " return null;\n"
+ " }\n"
+ "};\n"},
+ {"timestamp.js",
+ "/* This code will be inserted into generated code for\n"
+ " * google/protobuf/timestamp.proto. */\n"
+ "\n"
+ "/**\n"
+ " * Returns a JavaScript 'Date' object corresponding to this Timestamp.\n"
+ " * @return {!Date}\n"
+ " */\n"
+ "proto.google.protobuf.Timestamp.prototype.toDate = function() {\n"
+ " var seconds = this.getSeconds();\n"
+ " var nanos = this.getNanos();\n"
+ "\n"
+ " return new Date((seconds * 1000) + (nanos / 1000000));\n"
+ "};\n"
+ "\n"
+ "\n"
+ "/**\n"
+ " * Sets the value of this Timestamp object to be the given Date.\n"
+ " * @param {!Date} value The value to set.\n"
+ " */\n"
+ "proto.google.protobuf.Timestamp.prototype.fromDate = function(value) {\n"
+ " this.setSeconds(Math.floor(value.getTime() / 1000));\n"
+ " this.setNanos(value.getMilliseconds() * 1000000);\n"
+ "};\n"},
+ {"struct.js",
+ "/* This code will be inserted into generated code for\n"
+ " * google/protobuf/struct.proto. */\n"
+ "\n"
+ "/**\n"
+ " * Typedef representing plain JavaScript values that can go into a\n"
+ " * Struct.\n"
+ " * @typedef {null|number|string|boolean|Array|Object}\n"
+ " */\n"
+ "proto.google.protobuf.JavaScriptValue;\n"
+ "\n"
+ "\n"
+ "/**\n"
+ " * Converts this Value object to a plain JavaScript value.\n"
+ " * @return {?proto.google.protobuf.JavaScriptValue} a plain JavaScript\n"
+ " * value representing this Struct.\n"
+ " */\n"
+ "proto.google.protobuf.Value.prototype.toJavaScript = function() {\n"
+ " var kindCase = proto.google.protobuf.Value.KindCase;\n"
+ " switch (this.getKindCase()) {\n"
+ " case kindCase.NULL_VALUE:\n"
+ " return null;\n"
+ " case kindCase.NUMBER_VALUE:\n"
+ " return this.getNumberValue();\n"
+ " case kindCase.STRING_VALUE:\n"
+ " return this.getStringValue();\n"
+ " case kindCase.BOOL_VALUE:\n"
+ " return this.getBoolValue();\n"
+ " case kindCase.STRUCT_VALUE:\n"
+ " return this.getStructValue().toJavaScript();\n"
+ " case kindCase.LIST_VALUE:\n"
+ " return this.getListValue().toJavaScript();\n"
+ " default:\n"
+ " throw new Error('Unexpected struct type');\n"
+ " }\n"
+ "};\n"
+ "\n"
+ "\n"
+ "/**\n"
+ " * Converts this JavaScript value to a new Value proto.\n"
+ " * @param {!proto.google.protobuf.JavaScriptValue} value The value to\n"
+ " * convert.\n"
+ " * @return {!proto.google.protobuf.Value} The newly constructed value.\n"
+ " */\n"
+ "proto.google.protobuf.Value.fromJavaScript = function(value) {\n"
+ " var ret = new proto.google.protobuf.Value();\n"
+ " switch (goog.typeOf(value)) {\n"
+ " case 'string':\n"
+ " ret.setStringValue(/** @type {string} */ (value));\n"
+ " break;\n"
+ " case 'number':\n"
+ " ret.setNumberValue(/** @type {number} */ (value));\n"
+ " break;\n"
+ " case 'boolean':\n"
+ " ret.setBoolValue(/** @type {boolean} */ (value));\n"
+ " break;\n"
+ " case 'null':\n"
+ " ret.setNullValue(proto.google.protobuf.NullValue.NULL_VALUE);\n"
+ " break;\n"
+ " case 'array':\n"
+ " ret.setListValue(proto.google.protobuf.ListValue.fromJavaScript(\n"
+ " /** @type{!Array} */ (value)));\n"
+ " break;\n"
+ " case 'object':\n"
+ " ret.setStructValue(proto.google.protobuf.Struct.fromJavaScript(\n"
+ " /** @type{!Object} */ (value)));\n"
+ " break;\n"
+ " default:\n"
+ " throw new Error('Unexpected struct type.');\n"
+ " }\n"
+ "\n"
+ " return ret;\n"
+ "};\n"
+ "\n"
+ "\n"
+ "/**\n"
+ " * Converts this ListValue object to a plain JavaScript array.\n"
+ " * @return {!Array} a plain JavaScript array representing this List.\n"
+ " */\n"
+ "proto.google.protobuf.ListValue.prototype.toJavaScript = function() {\n"
+ " var ret = [];\n"
+ " var values = this.getValuesList();\n"
+ "\n"
+ " for (var i = 0; i < values.length; i++) {\n"
+ " ret[i] = values[i].toJavaScript();\n"
+ " }\n"
+ "\n"
+ " return ret;\n"
+ "};\n"
+ "\n"
+ "\n"
+ "/**\n"
+ " * Constructs a ListValue protobuf from this plain JavaScript array.\n"
+ " * @param {!Array} array a plain JavaScript array\n"
+ " * @return {proto.google.protobuf.ListValue} a new ListValue object\n"
+ " */\n"
+ "proto.google.protobuf.ListValue.fromJavaScript = function(array) {\n"
+ " var ret = new proto.google.protobuf.ListValue();\n"
+ "\n"
+ " for (var i = 0; i < array.length; i++) {\n"
+ " "
+ "ret.addValues(proto.google.protobuf.Value.fromJavaScript(array[i]));\n"
+ " }\n"
+ "\n"
+ " return ret;\n"
+ "};\n"
+ "\n"
+ "\n"
+ "/**\n"
+ " * Converts this Struct object to a plain JavaScript object.\n"
+ " * @return {!Object<string, !proto.google.protobuf.JavaScriptValue>} a "
+ "plain\n"
+ " * JavaScript object representing this Struct.\n"
+ " */\n"
+ "proto.google.protobuf.Struct.prototype.toJavaScript = function() {\n"
+ " var ret = {};\n"
+ "\n"
+ " this.getFieldsMap().forEach(function(value, key) {\n"
+ " ret[key] = value.toJavaScript();\n"
+ " });\n"
+ "\n"
+ " return ret;\n"
+ "};\n"
+ "\n"
+ "\n"
+ "/**\n"
+ " * Constructs a Struct protobuf from this plain JavaScript object.\n"
+ " * @param {!Object} obj a plain JavaScript object\n"
+ " * @return {proto.google.protobuf.Struct} a new Struct object\n"
+ " */\n"
+ "proto.google.protobuf.Struct.fromJavaScript = function(obj) {\n"
+ " var ret = new proto.google.protobuf.Struct();\n"
+ " var map = ret.getFieldsMap();\n"
+ "\n"
+ " for (var property in obj) {\n"
+ " var val = obj[property];\n"
+ " map.set(property, proto.google.protobuf.Value.fromJavaScript(val));\n"
+ " }\n"
+ "\n"
+ " return ret;\n"
+ "};\n"},
+ {NULL, NULL} // Terminate the list.
+};
diff --git a/src/google/protobuf/compiler/php/php_generator.cc b/src/google/protobuf/compiler/php/php_generator.cc
index 4e237fc7..a58e1754 100644
--- a/src/google/protobuf/compiler/php/php_generator.cc
+++ b/src/google/protobuf/compiler/php/php_generator.cc
@@ -83,7 +83,7 @@ std::string PhpName(const std::string& full_name, bool is_descriptor);
std::string DefaultForField(FieldDescriptor* field);
std::string IntToString(int32 value);
std::string FilenameToClassname(const string& filename);
-std::string GeneratedMetadataFileName(const std::string& proto_file,
+std::string GeneratedMetadataFileName(const FileDescriptor* file,
bool is_descriptor);
std::string LabelForField(FieldDescriptor* field);
std::string TypeName(FieldDescriptor* field);
@@ -94,6 +94,9 @@ void Indent(io::Printer* printer);
void Outdent(io::Printer* printer);
void GenerateMessageDocComment(io::Printer* printer, const Descriptor* message,
int is_descriptor);
+void GenerateMessageConstructorDocComment(io::Printer* printer,
+ const Descriptor* message,
+ int is_descriptor);
void GenerateFieldDocComment(io::Printer* printer, const FieldDescriptor* field,
int is_descriptor, int function_type);
void GenerateEnumDocComment(io::Printer* printer, const EnumDescriptor* enum_,
@@ -105,31 +108,40 @@ void GenerateServiceDocComment(io::Printer* printer,
void GenerateServiceMethodDocComment(io::Printer* printer,
const MethodDescriptor* method);
-std::string RenameEmpty(const std::string& name) {
- if (name == "Empty") {
- return "GPBEmpty";
- } else {
- return name;
+
+std::string ReservedNamePrefix(const string& classname,
+ const FileDescriptor* file) {
+ bool is_reserved = false;
+
+ string lower = classname;
+ transform(lower.begin(), lower.end(), lower.begin(), ::tolower);
+
+ for (int i = 0; i < kReservedNamesSize; i++) {
+ if (lower == kReservedNames[i]) {
+ is_reserved = true;
+ break;
+ }
}
-}
-std::string MessageFullName(const Descriptor* message, bool is_descriptor) {
- if (is_descriptor) {
- return StringReplace(message->full_name(),
- "google.protobuf",
- "google.protobuf.internal", false);
- } else {
- return message->full_name();
+ if (is_reserved) {
+ if (file->package() == "google.protobuf") {
+ return "GPB";
+ } else {
+ return "PB";
+ }
}
+
+ return "";
}
-std::string EnumFullName(const EnumDescriptor* envm, bool is_descriptor) {
+template <typename DescriptorType>
+std::string DescriptorFullName(const DescriptorType* desc, bool is_descriptor) {
if (is_descriptor) {
- return StringReplace(envm->full_name(),
+ return StringReplace(desc->full_name(),
"google.protobuf",
"google.protobuf.internal", false);
} else {
- return envm->full_name();
+ return desc->full_name();
}
}
@@ -141,22 +153,55 @@ std::string ClassNamePrefix(const string& classname,
return prefix;
}
- bool is_reserved = false;
+ return ReservedNamePrefix(classname, desc->file());
+}
+
+template <typename DescriptorType>
+std::string GeneratedClassNameImpl(const DescriptorType* desc) {
+ std::string classname = ClassNamePrefix(desc->name(), desc) + desc->name();
+ const Descriptor* containing = desc->containing_type();
+ while (containing != NULL) {
+ classname = ClassNamePrefix(containing->name(), desc) + containing->name()
+ + '\\' + classname;
+ containing = containing->containing_type();
+ }
+ return classname;
+}
+
+std::string GeneratedClassNameImpl(const ServiceDescriptor* desc) {
+ std::string classname = desc->name();
+ return ClassNamePrefix(classname, desc) + classname;
+}
+
+std::string GeneratedClassName(const Descriptor* desc) {
+ return GeneratedClassNameImpl(desc);
+}
+
+std::string GeneratedClassName(const EnumDescriptor* desc) {
+ return GeneratedClassNameImpl(desc);
+}
+
+std::string GeneratedClassName(const ServiceDescriptor* desc) {
+ return GeneratedClassNameImpl(desc);
+}
+template <typename DescriptorType>
+std::string LegacyGeneratedClassName(const DescriptorType* desc) {
+ std::string classname = desc->name();
+ const Descriptor* containing = desc->containing_type();
+ while (containing != NULL) {
+ classname = containing->name() + '_' + classname;
+ containing = containing->containing_type();
+ }
+ return ClassNamePrefix(classname, desc) + classname;
+}
+
+std::string ClassNamePrefix(const string& classname) {
string lower = classname;
transform(lower.begin(), lower.end(), lower.begin(), ::tolower);
for (int i = 0; i < kReservedNamesSize; i++) {
if (lower == kReservedNames[i]) {
- is_reserved = true;
- break;
- }
- }
-
- if (is_reserved) {
- if (desc->file()->package() == "google.protobuf") {
- return "GPB";
- } else {
return "PB";
}
}
@@ -192,34 +237,39 @@ std::string ConstantNamePrefix(const string& classname) {
}
template <typename DescriptorType>
-std::string NamespacedName(const string& classname,
- const DescriptorType* desc, bool is_descriptor) {
+std::string RootPhpNamespace(const DescriptorType* desc, bool is_descriptor) {
if (desc->file()->options().has_php_namespace()) {
const string& php_namespace = desc->file()->options().php_namespace();
if (php_namespace != "") {
- return php_namespace + '\\' + classname;
- } else {
- return classname;
+ return php_namespace;
}
+ return "";
}
- if (desc->file()->package() == "") {
- return classname;
- } else {
- return PhpName(desc->file()->package(), is_descriptor) + '\\' +
- classname;
+ if (desc->file()->package() != "") {
+ return PhpName(desc->file()->package(), is_descriptor);
}
+ return "";
}
template <typename DescriptorType>
std::string FullClassName(const DescriptorType* desc, bool is_descriptor) {
- string classname = GeneratedClassName(desc);
- return NamespacedName(classname, desc, is_descriptor);
+ string classname = GeneratedClassNameImpl(desc);
+ string php_namespace = RootPhpNamespace(desc, is_descriptor);
+ if (php_namespace != "") {
+ return php_namespace + "\\" + classname;
+ }
+ return classname;
}
-std::string FullClassName(const ServiceDescriptor* desc, bool is_descriptor) {
- string classname = GeneratedClassName(desc);
- return NamespacedName(classname, desc, is_descriptor);
+template <typename DescriptorType>
+std::string LegacyFullClassName(const DescriptorType* desc, bool is_descriptor) {
+ string classname = LegacyGeneratedClassName(desc);
+ string php_namespace = RootPhpNamespace(desc, is_descriptor);
+ if (php_namespace != "") {
+ return php_namespace + "\\" + classname;
+ }
+ return classname;
}
std::string PhpName(const std::string& full_name, bool is_descriptor) {
@@ -227,20 +277,23 @@ std::string PhpName(const std::string& full_name, bool is_descriptor) {
return kDescriptorPackageName;
}
+ std::string segment;
std::string result;
bool cap_next_letter = true;
for (int i = 0; i < full_name.size(); i++) {
if ('a' <= full_name[i] && full_name[i] <= 'z' && cap_next_letter) {
- result += full_name[i] + ('A' - 'a');
+ segment += full_name[i] + ('A' - 'a');
cap_next_letter = false;
} else if (full_name[i] == '.') {
- result += '\\';
+ result += ClassNamePrefix(segment) + segment + '\\';
+ segment = "";
cap_next_letter = true;
} else {
- result += full_name[i];
+ segment += full_name[i];
cap_next_letter = false;
}
}
+ result += ClassNamePrefix(segment) + segment;
return result;
}
@@ -268,11 +321,13 @@ std::string DefaultForField(const FieldDescriptor* field) {
}
}
-std::string GeneratedMetadataFileName(const std::string& proto_file,
+std::string GeneratedMetadataFileName(const FileDescriptor* file,
bool is_descriptor) {
+ const string& proto_file = file->name();
int start_index = 0;
int first_index = proto_file.find_first_of("/", start_index);
- std::string result = "GPBMetadata/";
+ std::string result = "";
+ std::string segment = "";
if (proto_file == kEmptyFile) {
return kEmptyMetadataFile;
@@ -290,24 +345,44 @@ std::string GeneratedMetadataFileName(const std::string& proto_file,
file_no_suffix = proto_file.substr(0, lastindex);
}
- while (first_index != string::npos) {
- result += UnderscoresToCamelCase(
- file_no_suffix.substr(start_index, first_index - start_index), true);
- result += "/";
- start_index = first_index + 1;
- first_index = file_no_suffix.find_first_of("/", start_index);
+ if (file->options().has_php_metadata_namespace()) {
+ const string& php_metadata_namespace =
+ file->options().php_metadata_namespace();
+ if (php_metadata_namespace != "" && php_metadata_namespace != "\\") {
+ result += php_metadata_namespace;
+ std::replace(result.begin(), result.end(), '\\', '/');
+ if (result.at(result.size() - 1) != '/') {
+ result += "/";
+ }
+ }
+ } else {
+ result += "GPBMetadata/";
+ while (first_index != string::npos) {
+ segment = UnderscoresToCamelCase(
+ file_no_suffix.substr(start_index, first_index - start_index), true);
+ result += ReservedNamePrefix(segment, file) + segment + "/";
+ start_index = first_index + 1;
+ first_index = file_no_suffix.find_first_of("/", start_index);
+ }
}
// Append file name.
- result += RenameEmpty(UnderscoresToCamelCase(
- file_no_suffix.substr(start_index, first_index - start_index), true));
+ int file_name_start = file_no_suffix.find_last_of("/");
+ if (file_name_start == string::npos) {
+ file_name_start = 0;
+ } else {
+ file_name_start += 1;
+ }
+ segment = UnderscoresToCamelCase(
+ file_no_suffix.substr(file_name_start, first_index - file_name_start), true);
- return result += ".php";
+ return result + ReservedNamePrefix(segment, file) + segment + ".php";
}
-std::string GeneratedMessageFileName(const Descriptor* message,
+template <typename DescriptorType>
+std::string GeneratedClassFileName(const DescriptorType* desc,
bool is_descriptor) {
- std::string result = FullClassName(message, is_descriptor);
+ std::string result = FullClassName(desc, is_descriptor);
for (int i = 0; i < result.size(); i++) {
if (result[i] == '\\') {
result[i] = '/';
@@ -316,9 +391,11 @@ std::string GeneratedMessageFileName(const Descriptor* message,
return result + ".php";
}
-std::string GeneratedEnumFileName(const EnumDescriptor* en,
- bool is_descriptor) {
- std::string result = FullClassName(en, is_descriptor);
+template <typename DescriptorType>
+std::string LegacyGeneratedClassFileName(const DescriptorType* desc,
+ bool is_descriptor) {
+ std::string result = LegacyFullClassName(desc, is_descriptor);
+
for (int i = 0; i < result.size(); i++) {
if (result[i] == '\\') {
result[i] = '/';
@@ -461,10 +538,10 @@ std::string PhpGetterTypeName(const FieldDescriptor* field, bool is_descriptor)
std::string EnumOrMessageSuffix(
const FieldDescriptor* field, bool is_descriptor) {
if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
- return ", '" + MessageFullName(field->message_type(), is_descriptor) + "'";
+ return ", '" + DescriptorFullName(field->message_type(), is_descriptor) + "'";
}
if (field->cpp_type() == FieldDescriptor::CPPTYPE_ENUM) {
- return ", '" + EnumFullName(field->enum_type(), is_descriptor) + "'";
+ return ", '" + DescriptorFullName(field->enum_type(), is_descriptor) + "'";
}
return "";
}
@@ -651,11 +728,11 @@ void GenerateFieldAccessor(const FieldDescriptor* field, bool is_descriptor,
} else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
printer->Print(
"GPBUtil::checkMessage($var, \\^class_name^::class);\n",
- "class_name", FullClassName(field->message_type(), is_descriptor));
+ "class_name", LegacyFullClassName(field->message_type(), is_descriptor));
} else if (field->cpp_type() == FieldDescriptor::CPPTYPE_ENUM) {
printer->Print(
"GPBUtil::checkEnum($var, \\^class_name^::class);\n",
- "class_name", FullClassName(field->enum_type(), is_descriptor));
+ "class_name", LegacyFullClassName(field->enum_type(), is_descriptor));
} else if (field->cpp_type() == FieldDescriptor::CPPTYPE_STRING) {
printer->Print(
"GPBUtil::checkString($var, ^utf8^);\n",
@@ -711,7 +788,7 @@ void GenerateEnumToPool(const EnumDescriptor* en, io::Printer* printer) {
printer->Print(
"$pool->addEnum('^name^', "
"\\Google\\Protobuf\\Internal\\^class_name^::class)\n",
- "name", EnumFullName(en, true),
+ "name", DescriptorFullName(en, true),
"class_name", en->name());
Indent(printer);
@@ -743,13 +820,13 @@ void GenerateMessageToPool(const string& name_prefix, const Descriptor* message,
if (message->options().map_entry()) {
return;
}
- string class_name = name_prefix.empty()?
- message->name() : name_prefix + "_" + message->name();
+ string class_name = (name_prefix.empty() ? "" : name_prefix + "\\") +
+ ReservedNamePrefix(message->name(), message->file()) + message->name();
printer->Print(
"$pool->addMessage('^message^', "
"\\Google\\Protobuf\\Internal\\^class_name^::class)\n",
- "message", MessageFullName(message, true),
+ "message", DescriptorFullName(message, true),
"class_name", class_name);
Indent(printer);
@@ -851,7 +928,7 @@ void GenerateAddFileToPool(const FileDescriptor* file, bool is_descriptor,
continue;
}
std::string dependency_filename =
- GeneratedMetadataFileName(name, is_descriptor);
+ GeneratedMetadataFileName(file->dependency(i), is_descriptor);
printer->Print(
"\\^name^::initOnce();\n",
"name", FilenameToClassname(dependency_filename));
@@ -945,7 +1022,7 @@ std::string FilenameToClassname(const string& filename) {
void GenerateMetadataFile(const FileDescriptor* file,
bool is_descriptor,
GeneratorContext* generator_context) {
- std::string filename = GeneratedMetadataFileName(file->name(), is_descriptor);
+ std::string filename = GeneratedMetadataFileName(file, is_descriptor);
std::unique_ptr<io::ZeroCopyOutputStream> output(
generator_context->Open(filename));
io::Printer printer(output.get(), '^');
@@ -955,12 +1032,12 @@ void GenerateMetadataFile(const FileDescriptor* file,
std::string fullname = FilenameToClassname(filename);
int lastindex = fullname.find_last_of("\\");
- printer.Print(
- "namespace ^name^;\n\n",
- "name", fullname.substr(0, lastindex));
-
if (lastindex != string::npos) {
printer.Print(
+ "namespace ^name^;\n\n",
+ "name", fullname.substr(0, lastindex));
+
+ printer.Print(
"class ^name^\n"
"{\n",
"name", fullname.substr(lastindex + 1));
@@ -978,9 +1055,47 @@ void GenerateMetadataFile(const FileDescriptor* file,
printer.Print("}\n\n");
}
+template <typename DescriptorType>
+void LegacyGenerateClassFile(const FileDescriptor* file, const DescriptorType* desc,
+ bool is_descriptor,
+ GeneratorContext* generator_context) {
+
+ std::string filename = LegacyGeneratedClassFileName(desc, is_descriptor);
+ std::unique_ptr<io::ZeroCopyOutputStream> output(
+ generator_context->Open(filename));
+ io::Printer printer(output.get(), '^');
+
+ GenerateHead(file, &printer);
+
+ std::string php_namespace = RootPhpNamespace(desc, is_descriptor);
+ if (php_namespace != "") {
+ printer.Print(
+ "namespace ^name^;\n\n",
+ "name", php_namespace);
+ }
+ std::string newname = FullClassName(desc, is_descriptor);
+ printer.Print("if (false) {\n");
+ Indent(&printer);
+ printer.Print("/**\n");
+ printer.Print(" * This class is deprecated. Use ^new^ instead.\n",
+ "new", newname);
+ printer.Print(" * @deprecated\n");
+ printer.Print(" */\n");
+ printer.Print("class ^old^ {}\n",
+ "old", LegacyGeneratedClassName(desc));
+ Outdent(&printer);
+ printer.Print("}\n");
+ printer.Print("class_exists(^new^::class);\n",
+ "new", GeneratedClassNameImpl(desc));
+ printer.Print("@trigger_error('^old^ is deprecated and will be removed in "
+ "the next major release. Use ^fullname^ instead', E_USER_DEPRECATED);\n\n",
+ "old", LegacyFullClassName(desc, is_descriptor),
+ "fullname", newname);
+}
+
void GenerateEnumFile(const FileDescriptor* file, const EnumDescriptor* en,
bool is_descriptor, GeneratorContext* generator_context) {
- std::string filename = GeneratedEnumFileName(en, is_descriptor);
+ std::string filename = GeneratedClassFileName(en, is_descriptor);
std::unique_ptr<io::ZeroCopyOutputStream> output(
generator_context->Open(filename));
io::Printer printer(output.get(), '^');
@@ -990,32 +1105,22 @@ void GenerateEnumFile(const FileDescriptor* file, const EnumDescriptor* en,
std::string fullname = FilenameToClassname(filename);
int lastindex = fullname.find_last_of("\\");
- if (file->options().has_php_namespace()) {
- const string& php_namespace = file->options().php_namespace();
- if (!php_namespace.empty()) {
- printer.Print(
- "namespace ^name^;\n\n",
- "name", php_namespace);
- }
- } else if (!file->package().empty()) {
+ if (lastindex != string::npos) {
printer.Print(
"namespace ^name^;\n\n",
"name", fullname.substr(0, lastindex));
}
- GenerateEnumDocComment(&printer, en, is_descriptor);
-
if (lastindex != string::npos) {
- printer.Print(
- "class ^name^\n"
- "{\n",
- "name", fullname.substr(lastindex + 1));
- } else {
- printer.Print(
- "class ^name^\n"
- "{\n",
- "name", fullname);
+ fullname = fullname.substr(lastindex + 1);
}
+
+ GenerateEnumDocComment(&printer, en, is_descriptor);
+
+ printer.Print(
+ "class ^name^\n"
+ "{\n",
+ "name", fullname);
Indent(&printer);
for (int i = 0; i < en->value_count(); i++) {
@@ -1028,6 +1133,17 @@ void GenerateEnumFile(const FileDescriptor* file, const EnumDescriptor* en,
Outdent(&printer);
printer.Print("}\n\n");
+
+ // write legacy file for backwards compatiblity with nested messages and enums
+ if (en->containing_type() != NULL) {
+ printer.Print(
+ "// Adding a class alias for backwards compatibility with the previous class name.\n");
+ printer.Print(
+ "class_alias(^new^::class, \\^old^::class);\n\n",
+ "new", fullname,
+ "old", LegacyFullClassName(en, is_descriptor));
+ LegacyGenerateClassFile(file, en, is_descriptor, generator_context);
+ }
}
void GenerateMessageFile(const FileDescriptor* file, const Descriptor* message,
@@ -1039,7 +1155,7 @@ void GenerateMessageFile(const FileDescriptor* file, const Descriptor* message,
return;
}
- std::string filename = GeneratedMessageFileName(message, is_descriptor);
+ std::string filename = GeneratedClassFileName(message, is_descriptor);
std::unique_ptr<io::ZeroCopyOutputStream> output(
generator_context->Open(filename));
io::Printer printer(output.get(), '^');
@@ -1049,14 +1165,7 @@ void GenerateMessageFile(const FileDescriptor* file, const Descriptor* message,
std::string fullname = FilenameToClassname(filename);
int lastindex = fullname.find_last_of("\\");
- if (file->options().has_php_namespace()) {
- const string& php_namespace = file->options().php_namespace();
- if (!php_namespace.empty()) {
- printer.Print(
- "namespace ^name^;\n\n",
- "name", php_namespace);
- }
- } else if (!file->package().empty()) {
+ if (lastindex != string::npos) {
printer.Print(
"namespace ^name^;\n\n",
"name", fullname.substr(0, lastindex));
@@ -1066,16 +1175,13 @@ void GenerateMessageFile(const FileDescriptor* file, const Descriptor* message,
GenerateMessageDocComment(&printer, message, is_descriptor);
if (lastindex != string::npos) {
- printer.Print(
- "class ^name^ extends \\Google\\Protobuf\\Internal\\Message\n"
- "{\n",
- "name", fullname.substr(lastindex + 1));
- } else {
- printer.Print(
- "class ^name^ extends \\Google\\Protobuf\\Internal\\Message\n"
- "{\n",
- "name", fullname);
+ fullname = fullname.substr(lastindex + 1);
}
+
+ printer.Print(
+ "class ^name^ extends \\Google\\Protobuf\\Internal\\Message\n"
+ "{\n",
+ "name", fullname);
Indent(&printer);
// Field and oneof definitions.
@@ -1089,16 +1195,17 @@ void GenerateMessageFile(const FileDescriptor* file, const Descriptor* message,
}
printer.Print("\n");
+ GenerateMessageConstructorDocComment(&printer, message, is_descriptor);
printer.Print(
- "public function __construct() {\n");
+ "public function __construct($data = NULL) {\n");
Indent(&printer);
std::string metadata_filename =
- GeneratedMetadataFileName(file->name(), is_descriptor);
+ GeneratedMetadataFileName(file, is_descriptor);
std::string metadata_fullname = FilenameToClassname(metadata_filename);
printer.Print(
"\\^fullname^::initOnce();\n"
- "parent::__construct();\n",
+ "parent::__construct($data);\n",
"fullname", metadata_fullname);
Outdent(&printer);
@@ -1126,6 +1233,17 @@ void GenerateMessageFile(const FileDescriptor* file, const Descriptor* message,
Outdent(&printer);
printer.Print("}\n\n");
+ // write legacy file for backwards compatiblity with nested messages and enums
+ if (message->containing_type() != NULL) {
+ printer.Print(
+ "// Adding a class alias for backwards compatibility with the previous class name.\n");
+ printer.Print(
+ "class_alias(^new^::class, \\^old^::class);\n\n",
+ "new", fullname,
+ "old", LegacyFullClassName(message, is_descriptor));
+ LegacyGenerateClassFile(file, message, is_descriptor, generator_context);
+ }
+
// Nested messages and enums.
for (int i = 0; i < message->nested_type_count(); i++) {
GenerateMessageFile(file, message->nested_type(i), is_descriptor,
@@ -1150,14 +1268,9 @@ void GenerateServiceFile(const FileDescriptor* file,
std::string fullname = FilenameToClassname(filename);
int lastindex = fullname.find_last_of("\\");
- if (file->options().has_php_namespace()) {
- const string& php_namespace = file->options().php_namespace();
- if (!php_namespace.empty()) {
- printer.Print(
- "namespace ^name^;\n\n",
- "name", php_namespace);
- }
- } else if (!file->package().empty()) {
+ if (!file->options().php_namespace().empty() ||
+ (!file->options().has_php_namespace() && !file->package().empty()) ||
+ lastindex != string::npos) {
printer.Print(
"namespace ^name^;\n\n",
"name", fullname.substr(0, lastindex));
@@ -1251,7 +1364,8 @@ static string EscapePhpdoc(const string& input) {
}
static void GenerateDocCommentBodyForLocation(
- io::Printer* printer, const SourceLocation& location) {
+ io::Printer* printer, const SourceLocation& location, bool trailingNewline,
+ int indentCount) {
string comments = location.leading_comments.empty() ?
location.trailing_comments : location.leading_comments;
if (!comments.empty()) {
@@ -1272,14 +1386,16 @@ static void GenerateDocCommentBodyForLocation(
// Most lines should start with a space. Watch out for lines that start
// with a /, since putting that right after the leading asterisk will
// close the comment.
- if (!lines[i].empty() && lines[i][0] == '/') {
+ if (indentCount == 0 && !lines[i].empty() && lines[i][0] == '/') {
printer->Print(" * ^line^\n", "line", lines[i]);
} else {
- printer->Print(" *^line^\n", "line", lines[i]);
+ std::string indent = std::string(indentCount, ' ');
+ printer->Print(" *^ind^^line^\n", "ind", indent, "line", lines[i]);
}
}
- printer->Print(
- " *\n");
+ if (trailingNewline) {
+ printer->Print(" *\n");
+ }
}
}
@@ -1288,7 +1404,7 @@ static void GenerateDocCommentBody(
io::Printer* printer, const DescriptorType* descriptor) {
SourceLocation location;
if (descriptor->GetSourceLocation(&location)) {
- GenerateDocCommentBodyForLocation(printer, location);
+ GenerateDocCommentBodyForLocation(printer, location, true, 0);
}
}
@@ -1310,10 +1426,41 @@ void GenerateMessageDocComment(io::Printer* printer,
printer->Print(
" * Generated from protobuf message <code>^messagename^</code>\n"
" */\n",
- "fullname", EscapePhpdoc(PhpName(message->full_name(), is_descriptor)),
+ "fullname", EscapePhpdoc(FullClassName(message, is_descriptor)),
"messagename", EscapePhpdoc(message->full_name()));
}
+void GenerateMessageConstructorDocComment(io::Printer* printer,
+ const Descriptor* message,
+ int is_descriptor) {
+ // In theory we should have slightly different comments for setters, getters,
+ // etc., but in practice everyone already knows the difference between these
+ // so it's redundant information.
+
+ // We start the comment with the main body based on the comments from the
+ // .proto file (if present). We then end with the field declaration, e.g.:
+ // optional string foo = 5;
+ // If the field is a group, the debug string might end with {.
+ printer->Print("/**\n");
+ printer->Print(" * Constructor.\n");
+ printer->Print(" *\n");
+ printer->Print(" * @param array $data {\n");
+ printer->Print(" * Optional. Data for populating the Message object.\n");
+ printer->Print(" *\n");
+ for (int i = 0; i < message->field_count(); i++) {
+ const FieldDescriptor* field = message->field(i);
+ printer->Print(" * @type ^php_type^ $^var^\n",
+ "php_type", PhpSetterTypeName(field, is_descriptor),
+ "var", field->name());
+ SourceLocation location;
+ if (field->GetSourceLocation(&location)) {
+ GenerateDocCommentBodyForLocation(printer, location, false, 10);
+ }
+ }
+ printer->Print(" * }\n");
+ printer->Print(" */\n");
+}
+
void GenerateServiceDocComment(io::Printer* printer,
const ServiceDescriptor* service) {
printer->Print("/**\n");
@@ -1355,9 +1502,9 @@ void GenerateEnumDocComment(io::Printer* printer, const EnumDescriptor* enum_,
printer->Print("/**\n");
GenerateDocCommentBody(printer, enum_);
printer->Print(
- " * Protobuf enum <code>^fullname^</code>\n"
+ " * Protobuf type <code>^fullname^</code>\n"
" */\n",
- "fullname", EscapePhpdoc(PhpName(enum_->full_name(), is_descriptor)));
+ "fullname", EscapePhpdoc(enum_->full_name()));
}
void GenerateEnumValueDocComment(io::Printer* printer,
@@ -1410,31 +1557,6 @@ bool Generator::Generate(const FileDescriptor* file, const string& parameter,
return true;
}
-std::string GeneratedClassName(const Descriptor* desc) {
- std::string classname = desc->name();
- const Descriptor* containing = desc->containing_type();
- while (containing != NULL) {
- classname = containing->name() + '_' + classname;
- containing = containing->containing_type();
- }
- return ClassNamePrefix(classname, desc) + classname;
-}
-
-std::string GeneratedClassName(const EnumDescriptor* desc) {
- std::string classname = desc->name();
- const Descriptor* containing = desc->containing_type();
- while (containing != NULL) {
- classname = containing->name() + '_' + classname;
- containing = containing->containing_type();
- }
- return ClassNamePrefix(classname, desc) + classname;
-}
-
-std::string GeneratedClassName(const ServiceDescriptor* desc) {
- std::string classname = desc->name();
- return ClassNamePrefix(classname, desc) + classname;
-}
-
} // namespace php
} // namespace compiler
} // namespace protobuf
diff --git a/src/google/protobuf/compiler/php/php_generator.h b/src/google/protobuf/compiler/php/php_generator.h
index 54a95ef5..b851d9b4 100644
--- a/src/google/protobuf/compiler/php/php_generator.h
+++ b/src/google/protobuf/compiler/php/php_generator.h
@@ -48,7 +48,6 @@ class LIBPROTOC_EXPORT Generator
const string& parameter,
GeneratorContext* generator_context,
string* error) const;
-
};
// To skip reserved keywords in php, some generated classname are prefixed.
diff --git a/src/google/protobuf/compiler/plugin.pb.cc b/src/google/protobuf/compiler/plugin.pb.cc
index ef52def3..20aa82c7 100644
--- a/src/google/protobuf/compiler/plugin.pb.cc
+++ b/src/google/protobuf/compiler/plugin.pb.cc
@@ -183,14 +183,14 @@ static ::google::protobuf::Message const * const file_default_instances[] = {
reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::compiler::_CodeGeneratorResponse_default_instance_),
};
-void protobuf_AssignDescriptors() {
+static void protobuf_AssignDescriptors() {
AddDescriptors();
AssignDescriptors(
"google/protobuf/compiler/plugin.proto", schemas, file_default_instances, TableStruct::offsets,
file_level_metadata, NULL, NULL);
}
-void protobuf_AssignDescriptorsOnce() {
+static void protobuf_AssignDescriptorsOnce() {
static ::google::protobuf::internal::once_flag once;
::google::protobuf::internal::call_once(once, protobuf_AssignDescriptors);
}
@@ -201,7 +201,7 @@ void protobuf_RegisterTypes(const ::std::string&) {
::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 4);
}
-void AddDescriptorsImpl() {
+static void AddDescriptorsImpl() {
InitDefaults();
static const char descriptor[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
"\n%google/protobuf/compiler/plugin.proto\022"
diff --git a/src/google/protobuf/compiler/plugin.pb.h b/src/google/protobuf/compiler/plugin.pb.h
index 5ad6b4d3..d5b70a88 100644
--- a/src/google/protobuf/compiler/plugin.pb.h
+++ b/src/google/protobuf/compiler/plugin.pb.h
@@ -8,12 +8,12 @@
#include <google/protobuf/stubs/common.h>
-#if GOOGLE_PROTOBUF_VERSION < 3005000
+#if GOOGLE_PROTOBUF_VERSION < 3006000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
-#if 3005001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 3006000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
diff --git a/src/google/protobuf/compiler/ruby/ruby_generator.cc b/src/google/protobuf/compiler/ruby/ruby_generator.cc
index 02aa61d1..bd737c02 100644
--- a/src/google/protobuf/compiler/ruby/ruby_generator.cc
+++ b/src/google/protobuf/compiler/ruby/ruby_generator.cc
@@ -337,9 +337,20 @@ void GenerateEnumAssignment(
}
int GeneratePackageModules(
- std::string package_name,
+ const FileDescriptor* file,
google::protobuf::io::Printer* printer) {
int levels = 0;
+ bool need_change_to_module;
+ std::string package_name;
+
+ if (file->options().has_ruby_package()) {
+ package_name = file->options().ruby_package();
+ need_change_to_module = false;
+ } else {
+ package_name = file->package();
+ need_change_to_module = true;
+ }
+
while (!package_name.empty()) {
size_t dot_index = package_name.find(".");
string component;
@@ -350,7 +361,9 @@ int GeneratePackageModules(
component = package_name.substr(0, dot_index);
package_name = package_name.substr(dot_index + 1);
}
- component = PackageToModule(component);
+ if (need_change_to_module) {
+ component = PackageToModule(component);
+ }
printer->Print(
"module $name$\n",
"name", component);
@@ -462,7 +475,7 @@ bool GenerateFile(const FileDescriptor* file, io::Printer* printer,
printer->Print(
"end\n\n");
- int levels = GeneratePackageModules(file->package(), printer);
+ int levels = GeneratePackageModules(file, printer);
for (int i = 0; i < file->message_type_count(); i++) {
GenerateMessageAssignment("", file->message_type(i), printer);
}
diff --git a/src/google/protobuf/descriptor.cc b/src/google/protobuf/descriptor.cc
index d466dd8b..58dd0ac4 100644
--- a/src/google/protobuf/descriptor.cc
+++ b/src/google/protobuf/descriptor.cc
@@ -406,9 +406,10 @@ typedef std::pair<const EnumDescriptor*, int> EnumIntPair;
template<typename PairType>
struct PointerIntegerPairHash {
size_t operator()(const PairType& p) const {
- // FIXME(kenton): What is the best way to compute this hash? I have
- // no idea! This seems a bit better than an XOR.
- return reinterpret_cast<intptr_t>(p.first) * ((1 << 16) - 1) + p.second;
+ static const size_t prime1 = 16777499;
+ static const size_t prime2 = 16777619;
+ return reinterpret_cast<size_t>(p.first) * prime1 ^
+ static_cast<size_t>(p.second) * prime2;
}
#ifdef _MSC_VER
@@ -424,11 +425,10 @@ struct PointerIntegerPairHash {
struct PointerStringPairHash {
size_t operator()(const PointerStringPair& p) const {
- // FIXME(kenton): What is the best way to compute this hash? I have
- // no idea! This seems a bit better than an XOR.
+ static const size_t prime = 16777619;
hash<const char*> cstring_hash;
- return reinterpret_cast<intptr_t>(p.first) * ((1 << 16) - 1) +
- cstring_hash(p.second);
+ return reinterpret_cast<size_t>(p.first) * prime ^
+ static_cast<size_t>(cstring_hash(p.second));
}
#ifdef _MSC_VER
@@ -775,10 +775,10 @@ class FileDescriptorTables {
SymbolsByParentMap symbols_by_parent_;
mutable FieldsByNameMap fields_by_lowercase_name_;
- mutable FieldsByNameMap* fields_by_lowercase_name_tmp_;
+ std::unique_ptr<FieldsByNameMap> fields_by_lowercase_name_tmp_;
mutable GoogleOnceDynamic fields_by_lowercase_name_once_;
mutable FieldsByNameMap fields_by_camelcase_name_;
- mutable FieldsByNameMap* fields_by_camelcase_name_tmp_;
+ std::unique_ptr<FieldsByNameMap> fields_by_camelcase_name_tmp_;
mutable GoogleOnceDynamic fields_by_camelcase_name_once_;
FieldsByNumberMap fields_by_number_; // Not including extensions.
EnumValuesByNumberMap enum_values_by_number_;
@@ -1146,10 +1146,8 @@ bool DescriptorPool::Tables::AddFile(const FileDescriptor* file) {
void FileDescriptorTables::FinalizeTables() {
// Clean up the temporary maps used by AddFieldByStylizedNames().
- delete fields_by_lowercase_name_tmp_;
- fields_by_lowercase_name_tmp_ = NULL;
- delete fields_by_camelcase_name_tmp_;
- fields_by_camelcase_name_tmp_ = NULL;
+ fields_by_lowercase_name_tmp_ = nullptr;
+ fields_by_camelcase_name_tmp_ = nullptr;
}
void FileDescriptorTables::AddFieldByStylizedNames(
@@ -1164,7 +1162,7 @@ void FileDescriptorTables::AddFieldByStylizedNames(
// entries from fields_by_number_.
PointerStringPair lowercase_key(parent, field->lowercase_name().c_str());
- if (!InsertIfNotPresent(fields_by_lowercase_name_tmp_, lowercase_key,
+ if (!InsertIfNotPresent(fields_by_lowercase_name_tmp_.get(), lowercase_key,
field)) {
InsertIfNotPresent(
&fields_by_lowercase_name_, lowercase_key,
@@ -1172,7 +1170,7 @@ void FileDescriptorTables::AddFieldByStylizedNames(
}
PointerStringPair camelcase_key(parent, field->camelcase_name().c_str());
- if (!InsertIfNotPresent(fields_by_camelcase_name_tmp_, camelcase_key,
+ if (!InsertIfNotPresent(fields_by_camelcase_name_tmp_.get(), camelcase_key,
field)) {
InsertIfNotPresent(
&fields_by_camelcase_name_, camelcase_key,
@@ -6951,7 +6949,7 @@ class DescriptorBuilder::OptionInterpreter::AggregateOptionFinder
DescriptorBuilder* builder_;
virtual const FieldDescriptor* FindExtension(
- Message* message, const string& name) const {
+ Message* message, const string& name) const override {
assert_mutex_held(builder_->pool_);
const Descriptor* descriptor = message->GetDescriptor();
Symbol result = builder_->LookupSymbolNoPlaceholder(
@@ -6989,7 +6987,7 @@ class AggregateErrorCollector : public io::ErrorCollector {
string error_;
virtual void AddError(int /* line */, int /* column */,
- const string& message) {
+ const string& message) override {
if (!error_.empty()) {
error_ += "; ";
}
@@ -6997,7 +6995,7 @@ class AggregateErrorCollector : public io::ErrorCollector {
}
virtual void AddWarning(int /* line */, int /* column */,
- const string& /* message */) {
+ const string& /* message */) override {
// Ignore warnings
}
};
diff --git a/src/google/protobuf/descriptor.pb.cc b/src/google/protobuf/descriptor.pb.cc
index 9927bc4a..f3522ec1 100644
--- a/src/google/protobuf/descriptor.pb.cc
+++ b/src/google/protobuf/descriptor.pb.cc
@@ -841,25 +841,29 @@ const ::google::protobuf::uint32 TableStruct::offsets[] GOOGLE_PROTOBUF_ATTRIBUT
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileOptions, swift_prefix_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileOptions, php_class_prefix_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileOptions, php_namespace_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileOptions, php_metadata_namespace_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileOptions, ruby_package_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileOptions, uninterpreted_option_),
0,
1,
- 9,
10,
11,
- 17,
- 2,
12,
+ 19,
+ 2,
13,
14,
15,
16,
- 8,
+ 17,
+ 18,
3,
4,
5,
6,
7,
+ 8,
+ 9,
~0u,
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::MessageOptions, _has_bits_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::MessageOptions, _internal_metadata_),
@@ -1027,20 +1031,20 @@ static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROT
{ 146, 154, sizeof(::google::protobuf::EnumValueDescriptorProto)},
{ 157, 165, sizeof(::google::protobuf::ServiceDescriptorProto)},
{ 168, 179, sizeof(::google::protobuf::MethodDescriptorProto)},
- { 185, 209, sizeof(::google::protobuf::FileOptions)},
- { 228, 238, sizeof(::google::protobuf::MessageOptions)},
- { 243, 255, sizeof(::google::protobuf::FieldOptions)},
- { 262, 268, sizeof(::google::protobuf::OneofOptions)},
- { 269, 277, sizeof(::google::protobuf::EnumOptions)},
- { 280, 287, sizeof(::google::protobuf::EnumValueOptions)},
- { 289, 296, sizeof(::google::protobuf::ServiceOptions)},
- { 298, 306, sizeof(::google::protobuf::MethodOptions)},
- { 309, 316, sizeof(::google::protobuf::UninterpretedOption_NamePart)},
- { 318, 330, sizeof(::google::protobuf::UninterpretedOption)},
- { 337, 347, sizeof(::google::protobuf::SourceCodeInfo_Location)},
- { 352, 358, sizeof(::google::protobuf::SourceCodeInfo)},
- { 359, 368, sizeof(::google::protobuf::GeneratedCodeInfo_Annotation)},
- { 372, 378, sizeof(::google::protobuf::GeneratedCodeInfo)},
+ { 185, 211, sizeof(::google::protobuf::FileOptions)},
+ { 232, 242, sizeof(::google::protobuf::MessageOptions)},
+ { 247, 259, sizeof(::google::protobuf::FieldOptions)},
+ { 266, 272, sizeof(::google::protobuf::OneofOptions)},
+ { 273, 281, sizeof(::google::protobuf::EnumOptions)},
+ { 284, 291, sizeof(::google::protobuf::EnumValueOptions)},
+ { 293, 300, sizeof(::google::protobuf::ServiceOptions)},
+ { 302, 310, sizeof(::google::protobuf::MethodOptions)},
+ { 313, 320, sizeof(::google::protobuf::UninterpretedOption_NamePart)},
+ { 322, 334, sizeof(::google::protobuf::UninterpretedOption)},
+ { 341, 351, sizeof(::google::protobuf::SourceCodeInfo_Location)},
+ { 356, 362, sizeof(::google::protobuf::SourceCodeInfo)},
+ { 363, 372, sizeof(::google::protobuf::GeneratedCodeInfo_Annotation)},
+ { 376, 382, sizeof(::google::protobuf::GeneratedCodeInfo)},
};
static ::google::protobuf::Message const * const file_default_instances[] = {
@@ -1073,14 +1077,14 @@ static ::google::protobuf::Message const * const file_default_instances[] = {
reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_GeneratedCodeInfo_default_instance_),
};
-void protobuf_AssignDescriptors() {
+static void protobuf_AssignDescriptors() {
AddDescriptors();
AssignDescriptors(
"google/protobuf/descriptor.proto", schemas, file_default_instances, TableStruct::offsets,
file_level_metadata, file_level_enum_descriptors, NULL);
}
-void protobuf_AssignDescriptorsOnce() {
+static void protobuf_AssignDescriptorsOnce() {
static ::google::protobuf::internal::once_flag once;
::google::protobuf::internal::call_once(once, protobuf_AssignDescriptors);
}
@@ -1091,7 +1095,7 @@ void protobuf_RegisterTypes(const ::std::string&) {
::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 27);
}
-void AddDescriptorsImpl() {
+static void AddDescriptorsImpl() {
InitDefaults();
static const char descriptor[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
"\n google/protobuf/descriptor.proto\022\017goog"
@@ -1167,7 +1171,7 @@ void AddDescriptorsImpl() {
"ut_type\030\003 \001(\t\022/\n\007options\030\004 \001(\0132\036.google."
"protobuf.MethodOptions\022\037\n\020client_streami"
"ng\030\005 \001(\010:\005false\022\037\n\020server_streaming\030\006 \001("
- "\010:\005false\"\360\005\n\013FileOptions\022\024\n\014java_package"
+ "\010:\005false\"\246\006\n\013FileOptions\022\024\n\014java_package"
"\030\001 \001(\t\022\034\n\024java_outer_classname\030\010 \001(\t\022\"\n\023"
"java_multiple_files\030\n \001(\010:\005false\022)\n\035java"
"_generate_equals_and_hash\030\024 \001(\010B\002\030\001\022%\n\026j"
@@ -1182,71 +1186,72 @@ void AddDescriptorsImpl() {
"\030\037 \001(\010:\005false\022\031\n\021objc_class_prefix\030$ \001(\t"
"\022\030\n\020csharp_namespace\030% \001(\t\022\024\n\014swift_pref"
"ix\030\' \001(\t\022\030\n\020php_class_prefix\030( \001(\t\022\025\n\rph"
- "p_namespace\030) \001(\t\022C\n\024uninterpreted_optio"
+ "p_namespace\030) \001(\t\022\036\n\026php_metadata_namesp"
+ "ace\030, \001(\t\022\024\n\014ruby_package\030- \001(\t\022C\n\024unint"
+ "erpreted_option\030\347\007 \003(\0132$.google.protobuf"
+ ".UninterpretedOption\":\n\014OptimizeMode\022\t\n\005"
+ "SPEED\020\001\022\r\n\tCODE_SIZE\020\002\022\020\n\014LITE_RUNTIME\020\003"
+ "*\t\010\350\007\020\200\200\200\200\002J\004\010&\020\'\"\362\001\n\016MessageOptions\022&\n\027"
+ "message_set_wire_format\030\001 \001(\010:\005false\022.\n\037"
+ "no_standard_descriptor_accessor\030\002 \001(\010:\005f"
+ "alse\022\031\n\ndeprecated\030\003 \001(\010:\005false\022\021\n\tmap_e"
+ "ntry\030\007 \001(\010\022C\n\024uninterpreted_option\030\347\007 \003("
+ "\0132$.google.protobuf.UninterpretedOption*"
+ "\t\010\350\007\020\200\200\200\200\002J\004\010\010\020\tJ\004\010\t\020\n\"\236\003\n\014FieldOptions\022"
+ ":\n\005ctype\030\001 \001(\0162#.google.protobuf.FieldOp"
+ "tions.CType:\006STRING\022\016\n\006packed\030\002 \001(\010\022\?\n\006j"
+ "stype\030\006 \001(\0162$.google.protobuf.FieldOptio"
+ "ns.JSType:\tJS_NORMAL\022\023\n\004lazy\030\005 \001(\010:\005fals"
+ "e\022\031\n\ndeprecated\030\003 \001(\010:\005false\022\023\n\004weak\030\n \001"
+ "(\010:\005false\022C\n\024uninterpreted_option\030\347\007 \003(\013"
+ "2$.google.protobuf.UninterpretedOption\"/"
+ "\n\005CType\022\n\n\006STRING\020\000\022\010\n\004CORD\020\001\022\020\n\014STRING_"
+ "PIECE\020\002\"5\n\006JSType\022\r\n\tJS_NORMAL\020\000\022\r\n\tJS_S"
+ "TRING\020\001\022\r\n\tJS_NUMBER\020\002*\t\010\350\007\020\200\200\200\200\002J\004\010\004\020\005\""
+ "^\n\014OneofOptions\022C\n\024uninterpreted_option\030"
+ "\347\007 \003(\0132$.google.protobuf.UninterpretedOp"
+ "tion*\t\010\350\007\020\200\200\200\200\002\"\223\001\n\013EnumOptions\022\023\n\013allow"
+ "_alias\030\002 \001(\010\022\031\n\ndeprecated\030\003 \001(\010:\005false\022"
+ "C\n\024uninterpreted_option\030\347\007 \003(\0132$.google."
+ "protobuf.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002J"
+ "\004\010\005\020\006\"}\n\020EnumValueOptions\022\031\n\ndeprecated\030"
+ "\001 \001(\010:\005false\022C\n\024uninterpreted_option\030\347\007 "
+ "\003(\0132$.google.protobuf.UninterpretedOptio"
+ "n*\t\010\350\007\020\200\200\200\200\002\"{\n\016ServiceOptions\022\031\n\ndeprec"
+ "ated\030! \001(\010:\005false\022C\n\024uninterpreted_optio"
"n\030\347\007 \003(\0132$.google.protobuf.Uninterpreted"
- "Option\":\n\014OptimizeMode\022\t\n\005SPEED\020\001\022\r\n\tCOD"
- "E_SIZE\020\002\022\020\n\014LITE_RUNTIME\020\003*\t\010\350\007\020\200\200\200\200\002J\004\010"
- "&\020\'\"\362\001\n\016MessageOptions\022&\n\027message_set_wi"
- "re_format\030\001 \001(\010:\005false\022.\n\037no_standard_de"
- "scriptor_accessor\030\002 \001(\010:\005false\022\031\n\ndeprec"
- "ated\030\003 \001(\010:\005false\022\021\n\tmap_entry\030\007 \001(\010\022C\n\024"
- "uninterpreted_option\030\347\007 \003(\0132$.google.pro"
- "tobuf.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002J\004\010\010"
- "\020\tJ\004\010\t\020\n\"\236\003\n\014FieldOptions\022:\n\005ctype\030\001 \001(\016"
- "2#.google.protobuf.FieldOptions.CType:\006S"
- "TRING\022\016\n\006packed\030\002 \001(\010\022\?\n\006jstype\030\006 \001(\0162$."
- "google.protobuf.FieldOptions.JSType:\tJS_"
- "NORMAL\022\023\n\004lazy\030\005 \001(\010:\005false\022\031\n\ndeprecate"
- "d\030\003 \001(\010:\005false\022\023\n\004weak\030\n \001(\010:\005false\022C\n\024u"
- "ninterpreted_option\030\347\007 \003(\0132$.google.prot"
- "obuf.UninterpretedOption\"/\n\005CType\022\n\n\006STR"
- "ING\020\000\022\010\n\004CORD\020\001\022\020\n\014STRING_PIECE\020\002\"5\n\006JST"
- "ype\022\r\n\tJS_NORMAL\020\000\022\r\n\tJS_STRING\020\001\022\r\n\tJS_"
- "NUMBER\020\002*\t\010\350\007\020\200\200\200\200\002J\004\010\004\020\005\"^\n\014OneofOption"
- "s\022C\n\024uninterpreted_option\030\347\007 \003(\0132$.googl"
- "e.protobuf.UninterpretedOption*\t\010\350\007\020\200\200\200\200"
- "\002\"\223\001\n\013EnumOptions\022\023\n\013allow_alias\030\002 \001(\010\022\031"
- "\n\ndeprecated\030\003 \001(\010:\005false\022C\n\024uninterpret"
- "ed_option\030\347\007 \003(\0132$.google.protobuf.Unint"
- "erpretedOption*\t\010\350\007\020\200\200\200\200\002J\004\010\005\020\006\"}\n\020EnumV"
- "alueOptions\022\031\n\ndeprecated\030\001 \001(\010:\005false\022C"
- "\n\024uninterpreted_option\030\347\007 \003(\0132$.google.p"
- "rotobuf.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002\"{"
- "\n\016ServiceOptions\022\031\n\ndeprecated\030! \001(\010:\005fa"
- "lse\022C\n\024uninterpreted_option\030\347\007 \003(\0132$.goo"
- "gle.protobuf.UninterpretedOption*\t\010\350\007\020\200\200"
- "\200\200\002\"\255\002\n\rMethodOptions\022\031\n\ndeprecated\030! \001("
- "\010:\005false\022_\n\021idempotency_level\030\" \001(\0162/.go"
- "ogle.protobuf.MethodOptions.IdempotencyL"
- "evel:\023IDEMPOTENCY_UNKNOWN\022C\n\024uninterpret"
- "ed_option\030\347\007 \003(\0132$.google.protobuf.Unint"
- "erpretedOption\"P\n\020IdempotencyLevel\022\027\n\023ID"
- "EMPOTENCY_UNKNOWN\020\000\022\023\n\017NO_SIDE_EFFECTS\020\001"
- "\022\016\n\nIDEMPOTENT\020\002*\t\010\350\007\020\200\200\200\200\002\"\236\002\n\023Uninterp"
- "retedOption\022;\n\004name\030\002 \003(\0132-.google.proto"
- "buf.UninterpretedOption.NamePart\022\030\n\020iden"
- "tifier_value\030\003 \001(\t\022\032\n\022positive_int_value"
- "\030\004 \001(\004\022\032\n\022negative_int_value\030\005 \001(\003\022\024\n\014do"
- "uble_value\030\006 \001(\001\022\024\n\014string_value\030\007 \001(\014\022\027"
- "\n\017aggregate_value\030\010 \001(\t\0323\n\010NamePart\022\021\n\tn"
- "ame_part\030\001 \002(\t\022\024\n\014is_extension\030\002 \002(\010\"\325\001\n"
- "\016SourceCodeInfo\022:\n\010location\030\001 \003(\0132(.goog"
- "le.protobuf.SourceCodeInfo.Location\032\206\001\n\010"
- "Location\022\020\n\004path\030\001 \003(\005B\002\020\001\022\020\n\004span\030\002 \003(\005"
- "B\002\020\001\022\030\n\020leading_comments\030\003 \001(\t\022\031\n\021traili"
- "ng_comments\030\004 \001(\t\022!\n\031leading_detached_co"
- "mments\030\006 \003(\t\"\247\001\n\021GeneratedCodeInfo\022A\n\nan"
- "notation\030\001 \003(\0132-.google.protobuf.Generat"
- "edCodeInfo.Annotation\032O\n\nAnnotation\022\020\n\004p"
- "ath\030\001 \003(\005B\002\020\001\022\023\n\013source_file\030\002 \001(\t\022\r\n\005be"
- "gin\030\003 \001(\005\022\013\n\003end\030\004 \001(\005B\217\001\n\023com.google.pr"
- "otobufB\020DescriptorProtosH\001Z>github.com/g"
- "olang/protobuf/protoc-gen-go/descriptor;"
- "descriptor\370\001\001\242\002\003GPB\252\002\032Google.Protobuf.Re"
- "flection"
+ "Option*\t\010\350\007\020\200\200\200\200\002\"\255\002\n\rMethodOptions\022\031\n\nd"
+ "eprecated\030! \001(\010:\005false\022_\n\021idempotency_le"
+ "vel\030\" \001(\0162/.google.protobuf.MethodOption"
+ "s.IdempotencyLevel:\023IDEMPOTENCY_UNKNOWN\022"
+ "C\n\024uninterpreted_option\030\347\007 \003(\0132$.google."
+ "protobuf.UninterpretedOption\"P\n\020Idempote"
+ "ncyLevel\022\027\n\023IDEMPOTENCY_UNKNOWN\020\000\022\023\n\017NO_"
+ "SIDE_EFFECTS\020\001\022\016\n\nIDEMPOTENT\020\002*\t\010\350\007\020\200\200\200\200"
+ "\002\"\236\002\n\023UninterpretedOption\022;\n\004name\030\002 \003(\0132"
+ "-.google.protobuf.UninterpretedOption.Na"
+ "mePart\022\030\n\020identifier_value\030\003 \001(\t\022\032\n\022posi"
+ "tive_int_value\030\004 \001(\004\022\032\n\022negative_int_val"
+ "ue\030\005 \001(\003\022\024\n\014double_value\030\006 \001(\001\022\024\n\014string"
+ "_value\030\007 \001(\014\022\027\n\017aggregate_value\030\010 \001(\t\0323\n"
+ "\010NamePart\022\021\n\tname_part\030\001 \002(\t\022\024\n\014is_exten"
+ "sion\030\002 \002(\010\"\325\001\n\016SourceCodeInfo\022:\n\010locatio"
+ "n\030\001 \003(\0132(.google.protobuf.SourceCodeInfo"
+ ".Location\032\206\001\n\010Location\022\020\n\004path\030\001 \003(\005B\002\020\001"
+ "\022\020\n\004span\030\002 \003(\005B\002\020\001\022\030\n\020leading_comments\030\003"
+ " \001(\t\022\031\n\021trailing_comments\030\004 \001(\t\022!\n\031leadi"
+ "ng_detached_comments\030\006 \003(\t\"\247\001\n\021Generated"
+ "CodeInfo\022A\n\nannotation\030\001 \003(\0132-.google.pr"
+ "otobuf.GeneratedCodeInfo.Annotation\032O\n\nA"
+ "nnotation\022\020\n\004path\030\001 \003(\005B\002\020\001\022\023\n\013source_fi"
+ "le\030\002 \001(\t\022\r\n\005begin\030\003 \001(\005\022\013\n\003end\030\004 \001(\005B\217\001\n"
+ "\023com.google.protobufB\020DescriptorProtosH\001"
+ "Z>github.com/golang/protobuf/protoc-gen-"
+ "go/descriptor;descriptor\370\001\001\242\002\003GPB\252\002\032Goog"
+ "le.Protobuf.Reflection"
};
::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
- descriptor, 5968);
+ descriptor, 6022);
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
"google/protobuf/descriptor.proto", &protobuf_RegisterTypes);
}
@@ -1482,7 +1487,7 @@ void FileDescriptorSet::ArenaDtor(void* object) {
FileDescriptorSet* _this = reinterpret_cast< FileDescriptorSet* >(object);
(void)_this;
}
-void FileDescriptorSet::RegisterArenaDtor(::google::protobuf::Arena* arena) {
+void FileDescriptorSet::RegisterArenaDtor(::google::protobuf::Arena*) {
}
void FileDescriptorSet::SetCachedSize(int size) const {
_cached_size_.Set(size);
@@ -1835,7 +1840,7 @@ void FileDescriptorProto::ArenaDtor(void* object) {
FileDescriptorProto* _this = reinterpret_cast< FileDescriptorProto* >(object);
(void)_this;
}
-void FileDescriptorProto::RegisterArenaDtor(::google::protobuf::Arena* arena) {
+void FileDescriptorProto::RegisterArenaDtor(::google::protobuf::Arena*) {
}
void FileDescriptorProto::SetCachedSize(int size) const {
_cached_size_.Set(size);
@@ -2637,7 +2642,7 @@ void DescriptorProto_ExtensionRange::ArenaDtor(void* object) {
DescriptorProto_ExtensionRange* _this = reinterpret_cast< DescriptorProto_ExtensionRange* >(object);
(void)_this;
}
-void DescriptorProto_ExtensionRange::RegisterArenaDtor(::google::protobuf::Arena* arena) {
+void DescriptorProto_ExtensionRange::RegisterArenaDtor(::google::protobuf::Arena*) {
}
void DescriptorProto_ExtensionRange::SetCachedSize(int size) const {
_cached_size_.Set(size);
@@ -2989,7 +2994,7 @@ void DescriptorProto_ReservedRange::ArenaDtor(void* object) {
DescriptorProto_ReservedRange* _this = reinterpret_cast< DescriptorProto_ReservedRange* >(object);
(void)_this;
}
-void DescriptorProto_ReservedRange::RegisterArenaDtor(::google::protobuf::Arena* arena) {
+void DescriptorProto_ReservedRange::RegisterArenaDtor(::google::protobuf::Arena*) {
}
void DescriptorProto_ReservedRange::SetCachedSize(int size) const {
_cached_size_.Set(size);
@@ -3345,7 +3350,7 @@ void DescriptorProto::ArenaDtor(void* object) {
DescriptorProto* _this = reinterpret_cast< DescriptorProto* >(object);
(void)_this;
}
-void DescriptorProto::RegisterArenaDtor(::google::protobuf::Arena* arena) {
+void DescriptorProto::RegisterArenaDtor(::google::protobuf::Arena*) {
}
void DescriptorProto::SetCachedSize(int size) const {
_cached_size_.Set(size);
@@ -4027,7 +4032,7 @@ void ExtensionRangeOptions::ArenaDtor(void* object) {
ExtensionRangeOptions* _this = reinterpret_cast< ExtensionRangeOptions* >(object);
(void)_this;
}
-void ExtensionRangeOptions::RegisterArenaDtor(::google::protobuf::Arena* arena) {
+void ExtensionRangeOptions::RegisterArenaDtor(::google::protobuf::Arena*) {
}
void ExtensionRangeOptions::SetCachedSize(int size) const {
_cached_size_.Set(size);
@@ -4385,7 +4390,7 @@ void FieldDescriptorProto::ArenaDtor(void* object) {
FieldDescriptorProto* _this = reinterpret_cast< FieldDescriptorProto* >(object);
(void)_this;
}
-void FieldDescriptorProto::RegisterArenaDtor(::google::protobuf::Arena* arena) {
+void FieldDescriptorProto::RegisterArenaDtor(::google::protobuf::Arena*) {
}
void FieldDescriptorProto::SetCachedSize(int size) const {
_cached_size_.Set(size);
@@ -4502,7 +4507,7 @@ bool FieldDescriptorProto::MergePartialFromCodedStream(
case 4: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(32u /* 32 & 0xFF */)) {
- int value;
+ int value = 0;
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
input, &value)));
@@ -4522,7 +4527,7 @@ bool FieldDescriptorProto::MergePartialFromCodedStream(
case 5: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(40u /* 40 & 0xFF */)) {
- int value;
+ int value = 0;
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
input, &value)));
@@ -5115,7 +5120,7 @@ void OneofDescriptorProto::ArenaDtor(void* object) {
OneofDescriptorProto* _this = reinterpret_cast< OneofDescriptorProto* >(object);
(void)_this;
}
-void OneofDescriptorProto::RegisterArenaDtor(::google::protobuf::Arena* arena) {
+void OneofDescriptorProto::RegisterArenaDtor(::google::protobuf::Arena*) {
}
void OneofDescriptorProto::SetCachedSize(int size) const {
_cached_size_.Set(size);
@@ -5445,7 +5450,7 @@ void EnumDescriptorProto_EnumReservedRange::ArenaDtor(void* object) {
EnumDescriptorProto_EnumReservedRange* _this = reinterpret_cast< EnumDescriptorProto_EnumReservedRange* >(object);
(void)_this;
}
-void EnumDescriptorProto_EnumReservedRange::RegisterArenaDtor(::google::protobuf::Arena* arena) {
+void EnumDescriptorProto_EnumReservedRange::RegisterArenaDtor(::google::protobuf::Arena*) {
}
void EnumDescriptorProto_EnumReservedRange::SetCachedSize(int size) const {
_cached_size_.Set(size);
@@ -5786,7 +5791,7 @@ void EnumDescriptorProto::ArenaDtor(void* object) {
EnumDescriptorProto* _this = reinterpret_cast< EnumDescriptorProto* >(object);
(void)_this;
}
-void EnumDescriptorProto::RegisterArenaDtor(::google::protobuf::Arena* arena) {
+void EnumDescriptorProto::RegisterArenaDtor(::google::protobuf::Arena*) {
}
void EnumDescriptorProto::SetCachedSize(int size) const {
_cached_size_.Set(size);
@@ -6278,7 +6283,7 @@ void EnumValueDescriptorProto::ArenaDtor(void* object) {
EnumValueDescriptorProto* _this = reinterpret_cast< EnumValueDescriptorProto* >(object);
(void)_this;
}
-void EnumValueDescriptorProto::RegisterArenaDtor(::google::protobuf::Arena* arena) {
+void EnumValueDescriptorProto::RegisterArenaDtor(::google::protobuf::Arena*) {
}
void EnumValueDescriptorProto::SetCachedSize(int size) const {
_cached_size_.Set(size);
@@ -6671,7 +6676,7 @@ void ServiceDescriptorProto::ArenaDtor(void* object) {
ServiceDescriptorProto* _this = reinterpret_cast< ServiceDescriptorProto* >(object);
(void)_this;
}
-void ServiceDescriptorProto::RegisterArenaDtor(::google::protobuf::Arena* arena) {
+void ServiceDescriptorProto::RegisterArenaDtor(::google::protobuf::Arena*) {
}
void ServiceDescriptorProto::SetCachedSize(int size) const {
_cached_size_.Set(size);
@@ -7091,7 +7096,7 @@ void MethodDescriptorProto::ArenaDtor(void* object) {
MethodDescriptorProto* _this = reinterpret_cast< MethodDescriptorProto* >(object);
(void)_this;
}
-void MethodDescriptorProto::RegisterArenaDtor(::google::protobuf::Arena* arena) {
+void MethodDescriptorProto::RegisterArenaDtor(::google::protobuf::Arena*) {
}
void MethodDescriptorProto::SetCachedSize(int size) const {
_cached_size_.Set(size);
@@ -7564,6 +7569,8 @@ const int FileOptions::kCsharpNamespaceFieldNumber;
const int FileOptions::kSwiftPrefixFieldNumber;
const int FileOptions::kPhpClassPrefixFieldNumber;
const int FileOptions::kPhpNamespaceFieldNumber;
+const int FileOptions::kPhpMetadataNamespaceFieldNumber;
+const int FileOptions::kRubyPackageFieldNumber;
const int FileOptions::kUninterpretedOptionFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
@@ -7631,9 +7638,19 @@ FileOptions::FileOptions(const FileOptions& from)
php_namespace_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.php_namespace(),
GetArenaNoVirtual());
}
- ::memcpy(&cc_enable_arenas_, &from.cc_enable_arenas_,
+ php_metadata_namespace_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.has_php_metadata_namespace()) {
+ php_metadata_namespace_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.php_metadata_namespace(),
+ GetArenaNoVirtual());
+ }
+ ruby_package_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.has_ruby_package()) {
+ ruby_package_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.ruby_package(),
+ GetArenaNoVirtual());
+ }
+ ::memcpy(&java_multiple_files_, &from.java_multiple_files_,
static_cast<size_t>(reinterpret_cast<char*>(&optimize_for_) -
- reinterpret_cast<char*>(&cc_enable_arenas_)) + sizeof(optimize_for_));
+ reinterpret_cast<char*>(&java_multiple_files_)) + sizeof(optimize_for_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.FileOptions)
}
@@ -7646,9 +7663,11 @@ void FileOptions::SharedCtor() {
swift_prefix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
php_class_prefix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
php_namespace_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- ::memset(&cc_enable_arenas_, 0, static_cast<size_t>(
- reinterpret_cast<char*>(&deprecated_) -
- reinterpret_cast<char*>(&cc_enable_arenas_)) + sizeof(deprecated_));
+ php_metadata_namespace_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ ruby_package_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ ::memset(&java_multiple_files_, 0, static_cast<size_t>(
+ reinterpret_cast<char*>(&cc_enable_arenas_) -
+ reinterpret_cast<char*>(&java_multiple_files_)) + sizeof(cc_enable_arenas_));
optimize_for_ = 1;
}
@@ -7667,13 +7686,15 @@ void FileOptions::SharedDtor() {
swift_prefix_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
php_class_prefix_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
php_namespace_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ php_metadata_namespace_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ ruby_package_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
void FileOptions::ArenaDtor(void* object) {
FileOptions* _this = reinterpret_cast< FileOptions* >(object);
(void)_this;
}
-void FileOptions::RegisterArenaDtor(::google::protobuf::Arena* arena) {
+void FileOptions::RegisterArenaDtor(::google::protobuf::Arena*) {
}
void FileOptions::SetCachedSize(int size) const {
_cached_size_.Set(size);
@@ -7724,13 +7745,23 @@ void FileOptions::Clear() {
php_namespace_.ClearNonDefaultToEmpty();
}
}
- if (cached_has_bits & 65280u) {
- ::memset(&cc_enable_arenas_, 0, static_cast<size_t>(
- reinterpret_cast<char*>(&php_generic_services_) -
- reinterpret_cast<char*>(&cc_enable_arenas_)) + sizeof(php_generic_services_));
+ if (cached_has_bits & 768u) {
+ if (cached_has_bits & 0x00000100u) {
+ php_metadata_namespace_.ClearNonDefaultToEmpty();
+ }
+ if (cached_has_bits & 0x00000200u) {
+ ruby_package_.ClearNonDefaultToEmpty();
+ }
+ }
+ if (cached_has_bits & 64512u) {
+ ::memset(&java_multiple_files_, 0, static_cast<size_t>(
+ reinterpret_cast<char*>(&py_generic_services_) -
+ reinterpret_cast<char*>(&java_multiple_files_)) + sizeof(py_generic_services_));
}
- if (cached_has_bits & 196608u) {
- deprecated_ = false;
+ if (cached_has_bits & 983040u) {
+ ::memset(&php_generic_services_, 0, static_cast<size_t>(
+ reinterpret_cast<char*>(&cc_enable_arenas_) -
+ reinterpret_cast<char*>(&php_generic_services_)) + sizeof(cc_enable_arenas_));
optimize_for_ = 1;
}
_has_bits_.Clear();
@@ -7783,7 +7814,7 @@ bool FileOptions::MergePartialFromCodedStream(
case 9: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(72u /* 72 & 0xFF */)) {
- int value;
+ int value = 0;
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
input, &value)));
@@ -8021,6 +8052,38 @@ bool FileOptions::MergePartialFromCodedStream(
break;
}
+ // optional string php_metadata_namespace = 44;
+ case 44: {
+ if (static_cast< ::google::protobuf::uint8>(tag) ==
+ static_cast< ::google::protobuf::uint8>(98u /* 354 & 0xFF */)) {
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_php_metadata_namespace()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->php_metadata_namespace().data(), static_cast<int>(this->php_metadata_namespace().length()),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "google.protobuf.FileOptions.php_metadata_namespace");
+ } else {
+ goto handle_unusual;
+ }
+ break;
+ }
+
+ // optional string ruby_package = 45;
+ case 45: {
+ if (static_cast< ::google::protobuf::uint8>(tag) ==
+ static_cast< ::google::protobuf::uint8>(106u /* 362 & 0xFF */)) {
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_ruby_package()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->ruby_package().data(), static_cast<int>(this->ruby_package().length()),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "google.protobuf.FileOptions.ruby_package");
+ } else {
+ goto handle_unusual;
+ }
+ break;
+ }
+
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
case 999: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
@@ -8087,13 +8150,13 @@ void FileOptions::SerializeWithCachedSizes(
}
// optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];
- if (cached_has_bits & 0x00020000u) {
+ if (cached_has_bits & 0x00080000u) {
::google::protobuf::internal::WireFormatLite::WriteEnum(
9, this->optimize_for(), output);
}
// optional bool java_multiple_files = 10 [default = false];
- if (cached_has_bits & 0x00000200u) {
+ if (cached_has_bits & 0x00000400u) {
::google::protobuf::internal::WireFormatLite::WriteBool(10, this->java_multiple_files(), output);
}
@@ -8108,37 +8171,37 @@ void FileOptions::SerializeWithCachedSizes(
}
// optional bool cc_generic_services = 16 [default = false];
- if (cached_has_bits & 0x00001000u) {
+ if (cached_has_bits & 0x00002000u) {
::google::protobuf::internal::WireFormatLite::WriteBool(16, this->cc_generic_services(), output);
}
// optional bool java_generic_services = 17 [default = false];
- if (cached_has_bits & 0x00002000u) {
+ if (cached_has_bits & 0x00004000u) {
::google::protobuf::internal::WireFormatLite::WriteBool(17, this->java_generic_services(), output);
}
// optional bool py_generic_services = 18 [default = false];
- if (cached_has_bits & 0x00004000u) {
+ if (cached_has_bits & 0x00008000u) {
::google::protobuf::internal::WireFormatLite::WriteBool(18, this->py_generic_services(), output);
}
// optional bool java_generate_equals_and_hash = 20 [deprecated = true];
- if (cached_has_bits & 0x00000400u) {
+ if (cached_has_bits & 0x00000800u) {
::google::protobuf::internal::WireFormatLite::WriteBool(20, this->java_generate_equals_and_hash(), output);
}
// optional bool deprecated = 23 [default = false];
- if (cached_has_bits & 0x00010000u) {
+ if (cached_has_bits & 0x00020000u) {
::google::protobuf::internal::WireFormatLite::WriteBool(23, this->deprecated(), output);
}
// optional bool java_string_check_utf8 = 27 [default = false];
- if (cached_has_bits & 0x00000800u) {
+ if (cached_has_bits & 0x00001000u) {
::google::protobuf::internal::WireFormatLite::WriteBool(27, this->java_string_check_utf8(), output);
}
// optional bool cc_enable_arenas = 31 [default = false];
- if (cached_has_bits & 0x00000100u) {
+ if (cached_has_bits & 0x00040000u) {
::google::protobuf::internal::WireFormatLite::WriteBool(31, this->cc_enable_arenas(), output);
}
@@ -8193,10 +8256,30 @@ void FileOptions::SerializeWithCachedSizes(
}
// optional bool php_generic_services = 42 [default = false];
- if (cached_has_bits & 0x00008000u) {
+ if (cached_has_bits & 0x00010000u) {
::google::protobuf::internal::WireFormatLite::WriteBool(42, this->php_generic_services(), output);
}
+ // optional string php_metadata_namespace = 44;
+ if (cached_has_bits & 0x00000100u) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->php_metadata_namespace().data(), static_cast<int>(this->php_metadata_namespace().length()),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "google.protobuf.FileOptions.php_metadata_namespace");
+ ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+ 44, this->php_metadata_namespace(), output);
+ }
+
+ // optional string ruby_package = 45;
+ if (cached_has_bits & 0x00000200u) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->ruby_package().data(), static_cast<int>(this->ruby_package().length()),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "google.protobuf.FileOptions.ruby_package");
+ ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+ 45, this->ruby_package(), output);
+ }
+
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->uninterpreted_option_size()); i < n; i++) {
@@ -8248,13 +8331,13 @@ void FileOptions::SerializeWithCachedSizes(
}
// optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];
- if (cached_has_bits & 0x00020000u) {
+ if (cached_has_bits & 0x00080000u) {
target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
9, this->optimize_for(), target);
}
// optional bool java_multiple_files = 10 [default = false];
- if (cached_has_bits & 0x00000200u) {
+ if (cached_has_bits & 0x00000400u) {
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(10, this->java_multiple_files(), target);
}
@@ -8270,37 +8353,37 @@ void FileOptions::SerializeWithCachedSizes(
}
// optional bool cc_generic_services = 16 [default = false];
- if (cached_has_bits & 0x00001000u) {
+ if (cached_has_bits & 0x00002000u) {
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(16, this->cc_generic_services(), target);
}
// optional bool java_generic_services = 17 [default = false];
- if (cached_has_bits & 0x00002000u) {
+ if (cached_has_bits & 0x00004000u) {
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(17, this->java_generic_services(), target);
}
// optional bool py_generic_services = 18 [default = false];
- if (cached_has_bits & 0x00004000u) {
+ if (cached_has_bits & 0x00008000u) {
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(18, this->py_generic_services(), target);
}
// optional bool java_generate_equals_and_hash = 20 [deprecated = true];
- if (cached_has_bits & 0x00000400u) {
+ if (cached_has_bits & 0x00000800u) {
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(20, this->java_generate_equals_and_hash(), target);
}
// optional bool deprecated = 23 [default = false];
- if (cached_has_bits & 0x00010000u) {
+ if (cached_has_bits & 0x00020000u) {
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(23, this->deprecated(), target);
}
// optional bool java_string_check_utf8 = 27 [default = false];
- if (cached_has_bits & 0x00000800u) {
+ if (cached_has_bits & 0x00001000u) {
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(27, this->java_string_check_utf8(), target);
}
// optional bool cc_enable_arenas = 31 [default = false];
- if (cached_has_bits & 0x00000100u) {
+ if (cached_has_bits & 0x00040000u) {
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(31, this->cc_enable_arenas(), target);
}
@@ -8360,10 +8443,32 @@ void FileOptions::SerializeWithCachedSizes(
}
// optional bool php_generic_services = 42 [default = false];
- if (cached_has_bits & 0x00008000u) {
+ if (cached_has_bits & 0x00010000u) {
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(42, this->php_generic_services(), target);
}
+ // optional string php_metadata_namespace = 44;
+ if (cached_has_bits & 0x00000100u) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->php_metadata_namespace().data(), static_cast<int>(this->php_metadata_namespace().length()),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "google.protobuf.FileOptions.php_metadata_namespace");
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 44, this->php_metadata_namespace(), target);
+ }
+
+ // optional string ruby_package = 45;
+ if (cached_has_bits & 0x00000200u) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->ruby_package().data(), static_cast<int>(this->ruby_package().length()),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "google.protobuf.FileOptions.ruby_package");
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 45, this->ruby_package(), target);
+ }
+
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->uninterpreted_option_size()); i < n; i++) {
@@ -8465,9 +8570,18 @@ size_t FileOptions::ByteSizeLong() const {
}
if (_has_bits_[8 / 32] & 65280u) {
- // optional bool cc_enable_arenas = 31 [default = false];
- if (has_cc_enable_arenas()) {
- total_size += 2 + 1;
+ // optional string php_metadata_namespace = 44;
+ if (has_php_metadata_namespace()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->php_metadata_namespace());
+ }
+
+ // optional string ruby_package = 45;
+ if (has_ruby_package()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->ruby_package());
}
// optional bool java_multiple_files = 10 [default = false];
@@ -8500,18 +8614,23 @@ size_t FileOptions::ByteSizeLong() const {
total_size += 2 + 1;
}
+ }
+ if (_has_bits_[16 / 32] & 983040u) {
// optional bool php_generic_services = 42 [default = false];
if (has_php_generic_services()) {
total_size += 2 + 1;
}
- }
- if (_has_bits_[16 / 32] & 196608u) {
// optional bool deprecated = 23 [default = false];
if (has_deprecated()) {
total_size += 2 + 1;
}
+ // optional bool cc_enable_arenas = 31 [default = false];
+ if (has_cc_enable_arenas()) {
+ total_size += 2 + 1;
+ }
+
// optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];
if (has_optimize_for()) {
total_size += 1 +
@@ -8577,36 +8696,42 @@ void FileOptions::MergeFrom(const FileOptions& from) {
}
if (cached_has_bits & 65280u) {
if (cached_has_bits & 0x00000100u) {
- cc_enable_arenas_ = from.cc_enable_arenas_;
+ set_php_metadata_namespace(from.php_metadata_namespace());
}
if (cached_has_bits & 0x00000200u) {
- java_multiple_files_ = from.java_multiple_files_;
+ set_ruby_package(from.ruby_package());
}
if (cached_has_bits & 0x00000400u) {
- java_generate_equals_and_hash_ = from.java_generate_equals_and_hash_;
+ java_multiple_files_ = from.java_multiple_files_;
}
if (cached_has_bits & 0x00000800u) {
- java_string_check_utf8_ = from.java_string_check_utf8_;
+ java_generate_equals_and_hash_ = from.java_generate_equals_and_hash_;
}
if (cached_has_bits & 0x00001000u) {
- cc_generic_services_ = from.cc_generic_services_;
+ java_string_check_utf8_ = from.java_string_check_utf8_;
}
if (cached_has_bits & 0x00002000u) {
- java_generic_services_ = from.java_generic_services_;
+ cc_generic_services_ = from.cc_generic_services_;
}
if (cached_has_bits & 0x00004000u) {
- py_generic_services_ = from.py_generic_services_;
+ java_generic_services_ = from.java_generic_services_;
}
if (cached_has_bits & 0x00008000u) {
- php_generic_services_ = from.php_generic_services_;
+ py_generic_services_ = from.py_generic_services_;
}
_has_bits_[0] |= cached_has_bits;
}
- if (cached_has_bits & 196608u) {
+ if (cached_has_bits & 983040u) {
if (cached_has_bits & 0x00010000u) {
- deprecated_ = from.deprecated_;
+ php_generic_services_ = from.php_generic_services_;
}
if (cached_has_bits & 0x00020000u) {
+ deprecated_ = from.deprecated_;
+ }
+ if (cached_has_bits & 0x00040000u) {
+ cc_enable_arenas_ = from.cc_enable_arenas_;
+ }
+ if (cached_has_bits & 0x00080000u) {
optimize_for_ = from.optimize_for_;
}
_has_bits_[0] |= cached_has_bits;
@@ -8674,7 +8799,10 @@ void FileOptions::InternalSwap(FileOptions* other) {
GetArenaNoVirtual());
php_namespace_.Swap(&other->php_namespace_, &::google::protobuf::internal::GetEmptyStringAlreadyInited(),
GetArenaNoVirtual());
- swap(cc_enable_arenas_, other->cc_enable_arenas_);
+ php_metadata_namespace_.Swap(&other->php_metadata_namespace_, &::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ GetArenaNoVirtual());
+ ruby_package_.Swap(&other->ruby_package_, &::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ GetArenaNoVirtual());
swap(java_multiple_files_, other->java_multiple_files_);
swap(java_generate_equals_and_hash_, other->java_generate_equals_and_hash_);
swap(java_string_check_utf8_, other->java_string_check_utf8_);
@@ -8683,6 +8811,7 @@ void FileOptions::InternalSwap(FileOptions* other) {
swap(py_generic_services_, other->py_generic_services_);
swap(php_generic_services_, other->php_generic_services_);
swap(deprecated_, other->deprecated_);
+ swap(cc_enable_arenas_, other->cc_enable_arenas_);
swap(optimize_for_, other->optimize_for_);
swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
@@ -8756,7 +8885,7 @@ void MessageOptions::ArenaDtor(void* object) {
MessageOptions* _this = reinterpret_cast< MessageOptions* >(object);
(void)_this;
}
-void MessageOptions::RegisterArenaDtor(::google::protobuf::Arena* arena) {
+void MessageOptions::RegisterArenaDtor(::google::protobuf::Arena*) {
}
void MessageOptions::SetCachedSize(int size) const {
_cached_size_.Set(size);
@@ -9200,7 +9329,7 @@ void FieldOptions::ArenaDtor(void* object) {
FieldOptions* _this = reinterpret_cast< FieldOptions* >(object);
(void)_this;
}
-void FieldOptions::RegisterArenaDtor(::google::protobuf::Arena* arena) {
+void FieldOptions::RegisterArenaDtor(::google::protobuf::Arena*) {
}
void FieldOptions::SetCachedSize(int size) const {
_cached_size_.Set(size);
@@ -9248,7 +9377,7 @@ bool FieldOptions::MergePartialFromCodedStream(
case 1: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(8u /* 8 & 0xFF */)) {
- int value;
+ int value = 0;
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
input, &value)));
@@ -9310,7 +9439,7 @@ bool FieldOptions::MergePartialFromCodedStream(
case 6: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(48u /* 48 & 0xFF */)) {
- int value;
+ int value = 0;
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
input, &value)));
@@ -9719,7 +9848,7 @@ void OneofOptions::ArenaDtor(void* object) {
OneofOptions* _this = reinterpret_cast< OneofOptions* >(object);
(void)_this;
}
-void OneofOptions::RegisterArenaDtor(::google::protobuf::Arena* arena) {
+void OneofOptions::RegisterArenaDtor(::google::protobuf::Arena*) {
}
void OneofOptions::SetCachedSize(int size) const {
_cached_size_.Set(size);
@@ -10016,7 +10145,7 @@ void EnumOptions::ArenaDtor(void* object) {
EnumOptions* _this = reinterpret_cast< EnumOptions* >(object);
(void)_this;
}
-void EnumOptions::RegisterArenaDtor(::google::protobuf::Arena* arena) {
+void EnumOptions::RegisterArenaDtor(::google::protobuf::Arena*) {
}
void EnumOptions::SetCachedSize(int size) const {
_cached_size_.Set(size);
@@ -10385,7 +10514,7 @@ void EnumValueOptions::ArenaDtor(void* object) {
EnumValueOptions* _this = reinterpret_cast< EnumValueOptions* >(object);
(void)_this;
}
-void EnumValueOptions::RegisterArenaDtor(::google::protobuf::Arena* arena) {
+void EnumValueOptions::RegisterArenaDtor(::google::protobuf::Arena*) {
}
void EnumValueOptions::SetCachedSize(int size) const {
_cached_size_.Set(size);
@@ -10713,7 +10842,7 @@ void ServiceOptions::ArenaDtor(void* object) {
ServiceOptions* _this = reinterpret_cast< ServiceOptions* >(object);
(void)_this;
}
-void ServiceOptions::RegisterArenaDtor(::google::protobuf::Arena* arena) {
+void ServiceOptions::RegisterArenaDtor(::google::protobuf::Arena*) {
}
void ServiceOptions::SetCachedSize(int size) const {
_cached_size_.Set(size);
@@ -11046,7 +11175,7 @@ void MethodOptions::ArenaDtor(void* object) {
MethodOptions* _this = reinterpret_cast< MethodOptions* >(object);
(void)_this;
}
-void MethodOptions::RegisterArenaDtor(::google::protobuf::Arena* arena) {
+void MethodOptions::RegisterArenaDtor(::google::protobuf::Arena*) {
}
void MethodOptions::SetCachedSize(int size) const {
_cached_size_.Set(size);
@@ -11108,7 +11237,7 @@ bool MethodOptions::MergePartialFromCodedStream(
case 34: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(16u /* 272 & 0xFF */)) {
- int value;
+ int value = 0;
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
input, &value)));
@@ -11430,7 +11559,7 @@ void UninterpretedOption_NamePart::ArenaDtor(void* object) {
UninterpretedOption_NamePart* _this = reinterpret_cast< UninterpretedOption_NamePart* >(object);
(void)_this;
}
-void UninterpretedOption_NamePart::RegisterArenaDtor(::google::protobuf::Arena* arena) {
+void UninterpretedOption_NamePart::RegisterArenaDtor(::google::protobuf::Arena*) {
}
void UninterpretedOption_NamePart::SetCachedSize(int size) const {
_cached_size_.Set(size);
@@ -11795,7 +11924,7 @@ void UninterpretedOption::ArenaDtor(void* object) {
UninterpretedOption* _this = reinterpret_cast< UninterpretedOption* >(object);
(void)_this;
}
-void UninterpretedOption::RegisterArenaDtor(::google::protobuf::Arena* arena) {
+void UninterpretedOption::RegisterArenaDtor(::google::protobuf::Arena*) {
}
void UninterpretedOption::SetCachedSize(int size) const {
_cached_size_.Set(size);
@@ -12344,7 +12473,7 @@ void SourceCodeInfo_Location::ArenaDtor(void* object) {
SourceCodeInfo_Location* _this = reinterpret_cast< SourceCodeInfo_Location* >(object);
(void)_this;
}
-void SourceCodeInfo_Location::RegisterArenaDtor(::google::protobuf::Arena* arena) {
+void SourceCodeInfo_Location::RegisterArenaDtor(::google::protobuf::Arena*) {
}
void SourceCodeInfo_Location::SetCachedSize(int size) const {
_cached_size_.Set(size);
@@ -12850,7 +12979,7 @@ void SourceCodeInfo::ArenaDtor(void* object) {
SourceCodeInfo* _this = reinterpret_cast< SourceCodeInfo* >(object);
(void)_this;
}
-void SourceCodeInfo::RegisterArenaDtor(::google::protobuf::Arena* arena) {
+void SourceCodeInfo::RegisterArenaDtor(::google::protobuf::Arena*) {
}
void SourceCodeInfo::SetCachedSize(int size) const {
_cached_size_.Set(size);
@@ -13129,7 +13258,7 @@ void GeneratedCodeInfo_Annotation::ArenaDtor(void* object) {
GeneratedCodeInfo_Annotation* _this = reinterpret_cast< GeneratedCodeInfo_Annotation* >(object);
(void)_this;
}
-void GeneratedCodeInfo_Annotation::RegisterArenaDtor(::google::protobuf::Arena* arena) {
+void GeneratedCodeInfo_Annotation::RegisterArenaDtor(::google::protobuf::Arena*) {
}
void GeneratedCodeInfo_Annotation::SetCachedSize(int size) const {
_cached_size_.Set(size);
@@ -13547,7 +13676,7 @@ void GeneratedCodeInfo::ArenaDtor(void* object) {
GeneratedCodeInfo* _this = reinterpret_cast< GeneratedCodeInfo* >(object);
(void)_this;
}
-void GeneratedCodeInfo::RegisterArenaDtor(::google::protobuf::Arena* arena) {
+void GeneratedCodeInfo::RegisterArenaDtor(::google::protobuf::Arena*) {
}
void GeneratedCodeInfo::SetCachedSize(int size) const {
_cached_size_.Set(size);
diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h
index 07a3c2f0..7a8617a2 100644
--- a/src/google/protobuf/descriptor.pb.h
+++ b/src/google/protobuf/descriptor.pb.h
@@ -8,12 +8,12 @@
#include <google/protobuf/stubs/common.h>
-#if GOOGLE_PROTOBUF_VERSION < 3005000
+#if GOOGLE_PROTOBUF_VERSION < 3006000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
-#if 3005001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 3006000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
@@ -3326,12 +3326,53 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p
void unsafe_arena_set_allocated_php_namespace(
::std::string* php_namespace);
- // optional bool cc_enable_arenas = 31 [default = false];
- bool has_cc_enable_arenas() const;
- void clear_cc_enable_arenas();
- static const int kCcEnableArenasFieldNumber = 31;
- bool cc_enable_arenas() const;
- void set_cc_enable_arenas(bool value);
+ // optional string php_metadata_namespace = 44;
+ bool has_php_metadata_namespace() const;
+ void clear_php_metadata_namespace();
+ static const int kPhpMetadataNamespaceFieldNumber = 44;
+ const ::std::string& php_metadata_namespace() const;
+ void set_php_metadata_namespace(const ::std::string& value);
+ #if LANG_CXX11
+ void set_php_metadata_namespace(::std::string&& value);
+ #endif
+ void set_php_metadata_namespace(const char* value);
+ void set_php_metadata_namespace(const char* value, size_t size);
+ ::std::string* mutable_php_metadata_namespace();
+ ::std::string* release_php_metadata_namespace();
+ void set_allocated_php_metadata_namespace(::std::string* php_metadata_namespace);
+ PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
+ " string fields are deprecated and will be removed in a"
+ " future release.")
+ ::std::string* unsafe_arena_release_php_metadata_namespace();
+ PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
+ " string fields are deprecated and will be removed in a"
+ " future release.")
+ void unsafe_arena_set_allocated_php_metadata_namespace(
+ ::std::string* php_metadata_namespace);
+
+ // optional string ruby_package = 45;
+ bool has_ruby_package() const;
+ void clear_ruby_package();
+ static const int kRubyPackageFieldNumber = 45;
+ const ::std::string& ruby_package() const;
+ void set_ruby_package(const ::std::string& value);
+ #if LANG_CXX11
+ void set_ruby_package(::std::string&& value);
+ #endif
+ void set_ruby_package(const char* value);
+ void set_ruby_package(const char* value, size_t size);
+ ::std::string* mutable_ruby_package();
+ ::std::string* release_ruby_package();
+ void set_allocated_ruby_package(::std::string* ruby_package);
+ PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
+ " string fields are deprecated and will be removed in a"
+ " future release.")
+ ::std::string* unsafe_arena_release_ruby_package();
+ PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
+ " string fields are deprecated and will be removed in a"
+ " future release.")
+ void unsafe_arena_set_allocated_ruby_package(
+ ::std::string* ruby_package);
// optional bool java_multiple_files = 10 [default = false];
bool has_java_multiple_files() const;
@@ -3389,6 +3430,13 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p
bool deprecated() const;
void set_deprecated(bool value);
+ // optional bool cc_enable_arenas = 31 [default = false];
+ bool has_cc_enable_arenas() const;
+ void clear_cc_enable_arenas();
+ static const int kCcEnableArenasFieldNumber = 31;
+ bool cc_enable_arenas() const;
+ void set_cc_enable_arenas(bool value);
+
// optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];
bool has_optimize_for() const;
void clear_optimize_for();
@@ -3435,6 +3483,10 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p
void clear_has_php_class_prefix();
void set_has_php_namespace();
void clear_has_php_namespace();
+ void set_has_php_metadata_namespace();
+ void clear_has_php_metadata_namespace();
+ void set_has_ruby_package();
+ void clear_has_ruby_package();
::google::protobuf::internal::ExtensionSet _extensions_;
@@ -3453,7 +3505,8 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p
::google::protobuf::internal::ArenaStringPtr swift_prefix_;
::google::protobuf::internal::ArenaStringPtr php_class_prefix_;
::google::protobuf::internal::ArenaStringPtr php_namespace_;
- bool cc_enable_arenas_;
+ ::google::protobuf::internal::ArenaStringPtr php_metadata_namespace_;
+ ::google::protobuf::internal::ArenaStringPtr ruby_package_;
bool java_multiple_files_;
bool java_generate_equals_and_hash_;
bool java_string_check_utf8_;
@@ -3462,6 +3515,7 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p
bool py_generic_services_;
bool php_generic_services_;
bool deprecated_;
+ bool cc_enable_arenas_;
int optimize_for_;
friend struct ::protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct;
};
@@ -9130,13 +9184,13 @@ inline void FileOptions::unsafe_arena_set_allocated_java_outer_classname(
// optional bool java_multiple_files = 10 [default = false];
inline bool FileOptions::has_java_multiple_files() const {
- return (_has_bits_[0] & 0x00000200u) != 0;
+ return (_has_bits_[0] & 0x00000400u) != 0;
}
inline void FileOptions::set_has_java_multiple_files() {
- _has_bits_[0] |= 0x00000200u;
+ _has_bits_[0] |= 0x00000400u;
}
inline void FileOptions::clear_has_java_multiple_files() {
- _has_bits_[0] &= ~0x00000200u;
+ _has_bits_[0] &= ~0x00000400u;
}
inline void FileOptions::clear_java_multiple_files() {
java_multiple_files_ = false;
@@ -9154,13 +9208,13 @@ inline void FileOptions::set_java_multiple_files(bool value) {
// optional bool java_generate_equals_and_hash = 20 [deprecated = true];
inline bool FileOptions::has_java_generate_equals_and_hash() const {
- return (_has_bits_[0] & 0x00000400u) != 0;
+ return (_has_bits_[0] & 0x00000800u) != 0;
}
inline void FileOptions::set_has_java_generate_equals_and_hash() {
- _has_bits_[0] |= 0x00000400u;
+ _has_bits_[0] |= 0x00000800u;
}
inline void FileOptions::clear_has_java_generate_equals_and_hash() {
- _has_bits_[0] &= ~0x00000400u;
+ _has_bits_[0] &= ~0x00000800u;
}
inline void FileOptions::clear_java_generate_equals_and_hash() {
java_generate_equals_and_hash_ = false;
@@ -9178,13 +9232,13 @@ inline void FileOptions::set_java_generate_equals_and_hash(bool value) {
// optional bool java_string_check_utf8 = 27 [default = false];
inline bool FileOptions::has_java_string_check_utf8() const {
- return (_has_bits_[0] & 0x00000800u) != 0;
+ return (_has_bits_[0] & 0x00001000u) != 0;
}
inline void FileOptions::set_has_java_string_check_utf8() {
- _has_bits_[0] |= 0x00000800u;
+ _has_bits_[0] |= 0x00001000u;
}
inline void FileOptions::clear_has_java_string_check_utf8() {
- _has_bits_[0] &= ~0x00000800u;
+ _has_bits_[0] &= ~0x00001000u;
}
inline void FileOptions::clear_java_string_check_utf8() {
java_string_check_utf8_ = false;
@@ -9202,13 +9256,13 @@ inline void FileOptions::set_java_string_check_utf8(bool value) {
// optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];
inline bool FileOptions::has_optimize_for() const {
- return (_has_bits_[0] & 0x00020000u) != 0;
+ return (_has_bits_[0] & 0x00080000u) != 0;
}
inline void FileOptions::set_has_optimize_for() {
- _has_bits_[0] |= 0x00020000u;
+ _has_bits_[0] |= 0x00080000u;
}
inline void FileOptions::clear_has_optimize_for() {
- _has_bits_[0] &= ~0x00020000u;
+ _has_bits_[0] &= ~0x00080000u;
}
inline void FileOptions::clear_optimize_for() {
optimize_for_ = 1;
@@ -9315,13 +9369,13 @@ inline void FileOptions::unsafe_arena_set_allocated_go_package(
// optional bool cc_generic_services = 16 [default = false];
inline bool FileOptions::has_cc_generic_services() const {
- return (_has_bits_[0] & 0x00001000u) != 0;
+ return (_has_bits_[0] & 0x00002000u) != 0;
}
inline void FileOptions::set_has_cc_generic_services() {
- _has_bits_[0] |= 0x00001000u;
+ _has_bits_[0] |= 0x00002000u;
}
inline void FileOptions::clear_has_cc_generic_services() {
- _has_bits_[0] &= ~0x00001000u;
+ _has_bits_[0] &= ~0x00002000u;
}
inline void FileOptions::clear_cc_generic_services() {
cc_generic_services_ = false;
@@ -9339,13 +9393,13 @@ inline void FileOptions::set_cc_generic_services(bool value) {
// optional bool java_generic_services = 17 [default = false];
inline bool FileOptions::has_java_generic_services() const {
- return (_has_bits_[0] & 0x00002000u) != 0;
+ return (_has_bits_[0] & 0x00004000u) != 0;
}
inline void FileOptions::set_has_java_generic_services() {
- _has_bits_[0] |= 0x00002000u;
+ _has_bits_[0] |= 0x00004000u;
}
inline void FileOptions::clear_has_java_generic_services() {
- _has_bits_[0] &= ~0x00002000u;
+ _has_bits_[0] &= ~0x00004000u;
}
inline void FileOptions::clear_java_generic_services() {
java_generic_services_ = false;
@@ -9363,13 +9417,13 @@ inline void FileOptions::set_java_generic_services(bool value) {
// optional bool py_generic_services = 18 [default = false];
inline bool FileOptions::has_py_generic_services() const {
- return (_has_bits_[0] & 0x00004000u) != 0;
+ return (_has_bits_[0] & 0x00008000u) != 0;
}
inline void FileOptions::set_has_py_generic_services() {
- _has_bits_[0] |= 0x00004000u;
+ _has_bits_[0] |= 0x00008000u;
}
inline void FileOptions::clear_has_py_generic_services() {
- _has_bits_[0] &= ~0x00004000u;
+ _has_bits_[0] &= ~0x00008000u;
}
inline void FileOptions::clear_py_generic_services() {
py_generic_services_ = false;
@@ -9387,13 +9441,13 @@ inline void FileOptions::set_py_generic_services(bool value) {
// optional bool php_generic_services = 42 [default = false];
inline bool FileOptions::has_php_generic_services() const {
- return (_has_bits_[0] & 0x00008000u) != 0;
+ return (_has_bits_[0] & 0x00010000u) != 0;
}
inline void FileOptions::set_has_php_generic_services() {
- _has_bits_[0] |= 0x00008000u;
+ _has_bits_[0] |= 0x00010000u;
}
inline void FileOptions::clear_has_php_generic_services() {
- _has_bits_[0] &= ~0x00008000u;
+ _has_bits_[0] &= ~0x00010000u;
}
inline void FileOptions::clear_php_generic_services() {
php_generic_services_ = false;
@@ -9411,13 +9465,13 @@ inline void FileOptions::set_php_generic_services(bool value) {
// optional bool deprecated = 23 [default = false];
inline bool FileOptions::has_deprecated() const {
- return (_has_bits_[0] & 0x00010000u) != 0;
+ return (_has_bits_[0] & 0x00020000u) != 0;
}
inline void FileOptions::set_has_deprecated() {
- _has_bits_[0] |= 0x00010000u;
+ _has_bits_[0] |= 0x00020000u;
}
inline void FileOptions::clear_has_deprecated() {
- _has_bits_[0] &= ~0x00010000u;
+ _has_bits_[0] &= ~0x00020000u;
}
inline void FileOptions::clear_deprecated() {
deprecated_ = false;
@@ -9435,13 +9489,13 @@ inline void FileOptions::set_deprecated(bool value) {
// optional bool cc_enable_arenas = 31 [default = false];
inline bool FileOptions::has_cc_enable_arenas() const {
- return (_has_bits_[0] & 0x00000100u) != 0;
+ return (_has_bits_[0] & 0x00040000u) != 0;
}
inline void FileOptions::set_has_cc_enable_arenas() {
- _has_bits_[0] |= 0x00000100u;
+ _has_bits_[0] |= 0x00040000u;
}
inline void FileOptions::clear_has_cc_enable_arenas() {
- _has_bits_[0] &= ~0x00000100u;
+ _has_bits_[0] &= ~0x00040000u;
}
inline void FileOptions::clear_cc_enable_arenas() {
cc_enable_arenas_ = false;
@@ -9897,6 +9951,182 @@ inline void FileOptions::unsafe_arena_set_allocated_php_namespace(
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FileOptions.php_namespace)
}
+// optional string php_metadata_namespace = 44;
+inline bool FileOptions::has_php_metadata_namespace() const {
+ return (_has_bits_[0] & 0x00000100u) != 0;
+}
+inline void FileOptions::set_has_php_metadata_namespace() {
+ _has_bits_[0] |= 0x00000100u;
+}
+inline void FileOptions::clear_has_php_metadata_namespace() {
+ _has_bits_[0] &= ~0x00000100u;
+}
+inline void FileOptions::clear_php_metadata_namespace() {
+ php_metadata_namespace_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());
+ clear_has_php_metadata_namespace();
+}
+inline const ::std::string& FileOptions::php_metadata_namespace() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.php_metadata_namespace)
+ return php_metadata_namespace_.Get();
+}
+inline void FileOptions::set_php_metadata_namespace(const ::std::string& value) {
+ set_has_php_metadata_namespace();
+ php_metadata_namespace_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual());
+ // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.php_metadata_namespace)
+}
+#if LANG_CXX11
+inline void FileOptions::set_php_metadata_namespace(::std::string&& value) {
+ set_has_php_metadata_namespace();
+ php_metadata_namespace_.Set(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual());
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.php_metadata_namespace)
+}
+#endif
+inline void FileOptions::set_php_metadata_namespace(const char* value) {
+ GOOGLE_DCHECK(value != NULL);
+ set_has_php_metadata_namespace();
+ php_metadata_namespace_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value),
+ GetArenaNoVirtual());
+ // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.php_metadata_namespace)
+}
+inline void FileOptions::set_php_metadata_namespace(const char* value,
+ size_t size) {
+ set_has_php_metadata_namespace();
+ php_metadata_namespace_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(
+ reinterpret_cast<const char*>(value), size), GetArenaNoVirtual());
+ // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.php_metadata_namespace)
+}
+inline ::std::string* FileOptions::mutable_php_metadata_namespace() {
+ set_has_php_metadata_namespace();
+ // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.php_metadata_namespace)
+ return php_metadata_namespace_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());
+}
+inline ::std::string* FileOptions::release_php_metadata_namespace() {
+ // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.php_metadata_namespace)
+ if (!has_php_metadata_namespace()) {
+ return NULL;
+ }
+ clear_has_php_metadata_namespace();
+ return php_metadata_namespace_.ReleaseNonDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());
+}
+inline void FileOptions::set_allocated_php_metadata_namespace(::std::string* php_metadata_namespace) {
+ if (php_metadata_namespace != NULL) {
+ set_has_php_metadata_namespace();
+ } else {
+ clear_has_php_metadata_namespace();
+ }
+ php_metadata_namespace_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), php_metadata_namespace,
+ GetArenaNoVirtual());
+ // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.php_metadata_namespace)
+}
+inline ::std::string* FileOptions::unsafe_arena_release_php_metadata_namespace() {
+ // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.FileOptions.php_metadata_namespace)
+ GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);
+ clear_has_php_metadata_namespace();
+ return php_metadata_namespace_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ GetArenaNoVirtual());
+}
+inline void FileOptions::unsafe_arena_set_allocated_php_metadata_namespace(
+ ::std::string* php_metadata_namespace) {
+ GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);
+ if (php_metadata_namespace != NULL) {
+ set_has_php_metadata_namespace();
+ } else {
+ clear_has_php_metadata_namespace();
+ }
+ php_metadata_namespace_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ php_metadata_namespace, GetArenaNoVirtual());
+ // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FileOptions.php_metadata_namespace)
+}
+
+// optional string ruby_package = 45;
+inline bool FileOptions::has_ruby_package() const {
+ return (_has_bits_[0] & 0x00000200u) != 0;
+}
+inline void FileOptions::set_has_ruby_package() {
+ _has_bits_[0] |= 0x00000200u;
+}
+inline void FileOptions::clear_has_ruby_package() {
+ _has_bits_[0] &= ~0x00000200u;
+}
+inline void FileOptions::clear_ruby_package() {
+ ruby_package_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());
+ clear_has_ruby_package();
+}
+inline const ::std::string& FileOptions::ruby_package() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.ruby_package)
+ return ruby_package_.Get();
+}
+inline void FileOptions::set_ruby_package(const ::std::string& value) {
+ set_has_ruby_package();
+ ruby_package_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual());
+ // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.ruby_package)
+}
+#if LANG_CXX11
+inline void FileOptions::set_ruby_package(::std::string&& value) {
+ set_has_ruby_package();
+ ruby_package_.Set(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual());
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.ruby_package)
+}
+#endif
+inline void FileOptions::set_ruby_package(const char* value) {
+ GOOGLE_DCHECK(value != NULL);
+ set_has_ruby_package();
+ ruby_package_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value),
+ GetArenaNoVirtual());
+ // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.ruby_package)
+}
+inline void FileOptions::set_ruby_package(const char* value,
+ size_t size) {
+ set_has_ruby_package();
+ ruby_package_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(
+ reinterpret_cast<const char*>(value), size), GetArenaNoVirtual());
+ // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.ruby_package)
+}
+inline ::std::string* FileOptions::mutable_ruby_package() {
+ set_has_ruby_package();
+ // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.ruby_package)
+ return ruby_package_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());
+}
+inline ::std::string* FileOptions::release_ruby_package() {
+ // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.ruby_package)
+ if (!has_ruby_package()) {
+ return NULL;
+ }
+ clear_has_ruby_package();
+ return ruby_package_.ReleaseNonDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());
+}
+inline void FileOptions::set_allocated_ruby_package(::std::string* ruby_package) {
+ if (ruby_package != NULL) {
+ set_has_ruby_package();
+ } else {
+ clear_has_ruby_package();
+ }
+ ruby_package_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ruby_package,
+ GetArenaNoVirtual());
+ // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.ruby_package)
+}
+inline ::std::string* FileOptions::unsafe_arena_release_ruby_package() {
+ // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.FileOptions.ruby_package)
+ GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);
+ clear_has_ruby_package();
+ return ruby_package_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ GetArenaNoVirtual());
+}
+inline void FileOptions::unsafe_arena_set_allocated_ruby_package(
+ ::std::string* ruby_package) {
+ GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);
+ if (ruby_package != NULL) {
+ set_has_ruby_package();
+ } else {
+ clear_has_ruby_package();
+ }
+ ruby_package_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ruby_package, GetArenaNoVirtual());
+ // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FileOptions.ruby_package)
+}
+
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
inline int FileOptions::uninterpreted_option_size() const {
return uninterpreted_option_.size();
diff --git a/src/google/protobuf/descriptor.proto b/src/google/protobuf/descriptor.proto
index 8697a50d..ed08fcbc 100644
--- a/src/google/protobuf/descriptor.proto
+++ b/src/google/protobuf/descriptor.proto
@@ -417,6 +417,17 @@ message FileOptions {
// determining the namespace.
optional string php_namespace = 41;
+
+ // Use this option to change the namespace of php generated metadata classes.
+ // Default is empty. When this option is empty, the proto file name will be used
+ // for determining the namespace.
+ optional string php_metadata_namespace = 44;
+
+ // Use this option to change the package of ruby generated classes. Default
+ // is empty. When this option is not set, the package name will be used for
+ // determining the ruby package.
+ optional string ruby_package = 45;
+
// The parser stores options it doesn't recognize here.
// See the documentation for the "Options" section above.
repeated UninterpretedOption uninterpreted_option = 999;
diff --git a/src/google/protobuf/descriptor_database.h b/src/google/protobuf/descriptor_database.h
index d61f2a6a..07523660 100644
--- a/src/google/protobuf/descriptor_database.h
+++ b/src/google/protobuf/descriptor_database.h
@@ -142,7 +142,7 @@ class LIBPROTOBUF_EXPORT DescriptorDatabase {
class LIBPROTOBUF_EXPORT SimpleDescriptorDatabase : public DescriptorDatabase {
public:
SimpleDescriptorDatabase();
- ~SimpleDescriptorDatabase();
+ ~SimpleDescriptorDatabase() override;
// Adds the FileDescriptorProto to the database, making a copy. The object
// can be deleted after Add() returns. Returns false if the file conflicted
@@ -155,14 +155,14 @@ class LIBPROTOBUF_EXPORT SimpleDescriptorDatabase : public DescriptorDatabase {
// implements DescriptorDatabase -----------------------------------
bool FindFileByName(const string& filename,
- FileDescriptorProto* output);
+ FileDescriptorProto* output) override;
bool FindFileContainingSymbol(const string& symbol_name,
- FileDescriptorProto* output);
+ FileDescriptorProto* output) override;
bool FindFileContainingExtension(const string& containing_type,
int field_number,
- FileDescriptorProto* output);
+ FileDescriptorProto* output) override;
bool FindAllExtensionNumbers(const string& extendee_type,
- std::vector<int>* output);
+ std::vector<int>* output) override;
private:
// So that it can use DescriptorIndex.
@@ -280,7 +280,7 @@ class LIBPROTOBUF_EXPORT SimpleDescriptorDatabase : public DescriptorDatabase {
class LIBPROTOBUF_EXPORT EncodedDescriptorDatabase : public DescriptorDatabase {
public:
EncodedDescriptorDatabase();
- ~EncodedDescriptorDatabase();
+ ~EncodedDescriptorDatabase() override;
// Adds the FileDescriptorProto to the database. The descriptor is provided
// in encoded form. The database does not make a copy of the bytes, nor
@@ -300,14 +300,14 @@ class LIBPROTOBUF_EXPORT EncodedDescriptorDatabase : public DescriptorDatabase {
// implements DescriptorDatabase -----------------------------------
bool FindFileByName(const string& filename,
- FileDescriptorProto* output);
+ FileDescriptorProto* output) override;
bool FindFileContainingSymbol(const string& symbol_name,
- FileDescriptorProto* output);
+ FileDescriptorProto* output) override;
bool FindFileContainingExtension(const string& containing_type,
int field_number,
- FileDescriptorProto* output);
+ FileDescriptorProto* output) override;
bool FindAllExtensionNumbers(const string& extendee_type,
- std::vector<int>* output);
+ std::vector<int>* output) override;
private:
SimpleDescriptorDatabase::DescriptorIndex<std::pair<const void*, int> >
@@ -326,18 +326,18 @@ class LIBPROTOBUF_EXPORT EncodedDescriptorDatabase : public DescriptorDatabase {
class LIBPROTOBUF_EXPORT DescriptorPoolDatabase : public DescriptorDatabase {
public:
explicit DescriptorPoolDatabase(const DescriptorPool& pool);
- ~DescriptorPoolDatabase();
+ ~DescriptorPoolDatabase() override;
// implements DescriptorDatabase -----------------------------------
bool FindFileByName(const string& filename,
- FileDescriptorProto* output);
+ FileDescriptorProto* output) override;
bool FindFileContainingSymbol(const string& symbol_name,
- FileDescriptorProto* output);
+ FileDescriptorProto* output) override;
bool FindFileContainingExtension(const string& containing_type,
int field_number,
- FileDescriptorProto* output);
+ FileDescriptorProto* output) override;
bool FindAllExtensionNumbers(const string& extendee_type,
- std::vector<int>* output);
+ std::vector<int>* output) override;
private:
const DescriptorPool& pool_;
@@ -356,20 +356,20 @@ class LIBPROTOBUF_EXPORT MergedDescriptorDatabase : public DescriptorDatabase {
// DescriptorDatabases need to stick around.
explicit MergedDescriptorDatabase(
const std::vector<DescriptorDatabase*>& sources);
- ~MergedDescriptorDatabase();
+ ~MergedDescriptorDatabase() override;
// implements DescriptorDatabase -----------------------------------
bool FindFileByName(const string& filename,
- FileDescriptorProto* output);
+ FileDescriptorProto* output) override;
bool FindFileContainingSymbol(const string& symbol_name,
- FileDescriptorProto* output);
+ FileDescriptorProto* output) override;
bool FindFileContainingExtension(const string& containing_type,
int field_number,
- FileDescriptorProto* output);
+ FileDescriptorProto* output) override;
// Merges the results of calling all databases. Returns true iff any
// of the databases returned true.
bool FindAllExtensionNumbers(const string& extendee_type,
- std::vector<int>* output);
+ std::vector<int>* output) override;
private:
diff --git a/src/google/protobuf/duration.pb.cc b/src/google/protobuf/duration.pb.cc
index ddc063db..e8417a78 100644
--- a/src/google/protobuf/duration.pb.cc
+++ b/src/google/protobuf/duration.pb.cc
@@ -66,14 +66,14 @@ static ::google::protobuf::Message const * const file_default_instances[] = {
reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_Duration_default_instance_),
};
-void protobuf_AssignDescriptors() {
+static void protobuf_AssignDescriptors() {
AddDescriptors();
AssignDescriptors(
"google/protobuf/duration.proto", schemas, file_default_instances, TableStruct::offsets,
file_level_metadata, NULL, NULL);
}
-void protobuf_AssignDescriptorsOnce() {
+static void protobuf_AssignDescriptorsOnce() {
static ::google::protobuf::internal::once_flag once;
::google::protobuf::internal::call_once(once, protobuf_AssignDescriptors);
}
@@ -84,7 +84,7 @@ void protobuf_RegisterTypes(const ::std::string&) {
::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 1);
}
-void AddDescriptorsImpl() {
+static void AddDescriptorsImpl() {
InitDefaults();
static const char descriptor[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
"\n\036google/protobuf/duration.proto\022\017google"
@@ -167,7 +167,7 @@ void Duration::ArenaDtor(void* object) {
Duration* _this = reinterpret_cast< Duration* >(object);
(void)_this;
}
-void Duration::RegisterArenaDtor(::google::protobuf::Arena* arena) {
+void Duration::RegisterArenaDtor(::google::protobuf::Arena*) {
}
void Duration::SetCachedSize(int size) const {
_cached_size_.Set(size);
diff --git a/src/google/protobuf/duration.pb.h b/src/google/protobuf/duration.pb.h
index 3d0889d1..751edbef 100644
--- a/src/google/protobuf/duration.pb.h
+++ b/src/google/protobuf/duration.pb.h
@@ -8,12 +8,12 @@
#include <google/protobuf/stubs/common.h>
-#if GOOGLE_PROTOBUF_VERSION < 3005000
+#if GOOGLE_PROTOBUF_VERSION < 3006000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
-#if 3005001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 3006000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
diff --git a/src/google/protobuf/dynamic_message.cc b/src/google/protobuf/dynamic_message.cc
index ceedf500..8ad112ce 100644
--- a/src/google/protobuf/dynamic_message.cc
+++ b/src/google/protobuf/dynamic_message.cc
@@ -258,14 +258,14 @@ class DynamicMessage : public Message {
// implements Message ----------------------------------------------
- Message* New() const;
- Message* New(::google::protobuf::Arena* arena) const;
- ::google::protobuf::Arena* GetArena() const { return arena_; }
+ Message* New() const override;
+ Message* New(::google::protobuf::Arena* arena) const override;
+ ::google::protobuf::Arena* GetArena() const override { return arena_; }
- int GetCachedSize() const;
- void SetCachedSize(int size) const;
+ int GetCachedSize() const override;
+ void SetCachedSize(int size) const override;
- Metadata GetMetadata() const;
+ Metadata GetMetadata() const override;
// We actually allocate more memory than sizeof(*this) when this
// class's memory is allocated via the global operator new. Thus, we need to
diff --git a/src/google/protobuf/dynamic_message.h b/src/google/protobuf/dynamic_message.h
index d84cc8af..940d5e15 100644
--- a/src/google/protobuf/dynamic_message.h
+++ b/src/google/protobuf/dynamic_message.h
@@ -115,7 +115,7 @@ class LIBPROTOBUF_EXPORT DynamicMessageFactory : public MessageFactory {
// outlive the DynamicMessageFactory.
//
// The method is thread-safe.
- const Message* GetPrototype(const Descriptor* type);
+ const Message* GetPrototype(const Descriptor* type) override;
private:
const DescriptorPool* pool_;
diff --git a/src/google/protobuf/empty.pb.cc b/src/google/protobuf/empty.pb.cc
index 9b53c546..163a4f6a 100644
--- a/src/google/protobuf/empty.pb.cc
+++ b/src/google/protobuf/empty.pb.cc
@@ -64,14 +64,14 @@ static ::google::protobuf::Message const * const file_default_instances[] = {
reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_Empty_default_instance_),
};
-void protobuf_AssignDescriptors() {
+static void protobuf_AssignDescriptors() {
AddDescriptors();
AssignDescriptors(
"google/protobuf/empty.proto", schemas, file_default_instances, TableStruct::offsets,
file_level_metadata, NULL, NULL);
}
-void protobuf_AssignDescriptorsOnce() {
+static void protobuf_AssignDescriptorsOnce() {
static ::google::protobuf::internal::once_flag once;
::google::protobuf::internal::call_once(once, protobuf_AssignDescriptors);
}
@@ -82,7 +82,7 @@ void protobuf_RegisterTypes(const ::std::string&) {
::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 1);
}
-void AddDescriptorsImpl() {
+static void AddDescriptorsImpl() {
InitDefaults();
static const char descriptor[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
"\n\033google/protobuf/empty.proto\022\017google.pr"
@@ -156,7 +156,7 @@ void Empty::ArenaDtor(void* object) {
Empty* _this = reinterpret_cast< Empty* >(object);
(void)_this;
}
-void Empty::RegisterArenaDtor(::google::protobuf::Arena* arena) {
+void Empty::RegisterArenaDtor(::google::protobuf::Arena*) {
}
void Empty::SetCachedSize(int size) const {
_cached_size_.Set(size);
diff --git a/src/google/protobuf/empty.pb.h b/src/google/protobuf/empty.pb.h
index 53857e5f..c3da4fa8 100644
--- a/src/google/protobuf/empty.pb.h
+++ b/src/google/protobuf/empty.pb.h
@@ -8,12 +8,12 @@
#include <google/protobuf/stubs/common.h>
-#if GOOGLE_PROTOBUF_VERSION < 3005000
+#if GOOGLE_PROTOBUF_VERSION < 3006000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
-#if 3005001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 3006000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
diff --git a/src/google/protobuf/extension_set.h b/src/google/protobuf/extension_set.h
index c4796629..e94e0b9c 100644
--- a/src/google/protobuf/extension_set.h
+++ b/src/google/protobuf/extension_set.h
@@ -134,7 +134,7 @@ class LIBPROTOBUF_EXPORT GeneratedExtensionFinder : public ExtensionFinder {
virtual ~GeneratedExtensionFinder() {}
// Returns true and fills in *output if found, otherwise returns false.
- virtual bool Find(int number, ExtensionInfo* output);
+ virtual bool Find(int number, ExtensionInfo* output) override;
private:
const MessageLite* containing_type_;
diff --git a/src/google/protobuf/extension_set_heavy.cc b/src/google/protobuf/extension_set_heavy.cc
index a3c84167..372aea57 100644
--- a/src/google/protobuf/extension_set_heavy.cc
+++ b/src/google/protobuf/extension_set_heavy.cc
@@ -85,9 +85,9 @@ class DescriptorPoolExtensionFinder : public ExtensionFinder {
MessageFactory* factory,
const Descriptor* containing_type)
: pool_(pool), factory_(factory), containing_type_(containing_type) {}
- virtual ~DescriptorPoolExtensionFinder() {}
+ virtual ~DescriptorPoolExtensionFinder() override {}
- virtual bool Find(int number, ExtensionInfo* output);
+ virtual bool Find(int number, ExtensionInfo* output) override;
private:
const DescriptorPool* pool_;
diff --git a/src/google/protobuf/field_mask.pb.cc b/src/google/protobuf/field_mask.pb.cc
index 000fa8d3..2ce061d9 100644
--- a/src/google/protobuf/field_mask.pb.cc
+++ b/src/google/protobuf/field_mask.pb.cc
@@ -65,14 +65,14 @@ static ::google::protobuf::Message const * const file_default_instances[] = {
reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_FieldMask_default_instance_),
};
-void protobuf_AssignDescriptors() {
+static void protobuf_AssignDescriptors() {
AddDescriptors();
AssignDescriptors(
"google/protobuf/field_mask.proto", schemas, file_default_instances, TableStruct::offsets,
file_level_metadata, NULL, NULL);
}
-void protobuf_AssignDescriptorsOnce() {
+static void protobuf_AssignDescriptorsOnce() {
static ::google::protobuf::internal::once_flag once;
::google::protobuf::internal::call_once(once, protobuf_AssignDescriptors);
}
@@ -83,7 +83,7 @@ void protobuf_RegisterTypes(const ::std::string&) {
::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 1);
}
-void AddDescriptorsImpl() {
+static void AddDescriptorsImpl() {
InitDefaults();
static const char descriptor[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
"\n google/protobuf/field_mask.proto\022\017goog"
diff --git a/src/google/protobuf/field_mask.pb.h b/src/google/protobuf/field_mask.pb.h
index 144b41fa..7550f7a9 100644
--- a/src/google/protobuf/field_mask.pb.h
+++ b/src/google/protobuf/field_mask.pb.h
@@ -8,12 +8,12 @@
#include <google/protobuf/stubs/common.h>
-#if GOOGLE_PROTOBUF_VERSION < 3005000
+#if GOOGLE_PROTOBUF_VERSION < 3006000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
-#if 3005001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 3006000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
diff --git a/src/google/protobuf/generated_message_reflection.h b/src/google/protobuf/generated_message_reflection.h
index 31f249b6..28a023b6 100644
--- a/src/google/protobuf/generated_message_reflection.h
+++ b/src/google/protobuf/generated_message_reflection.h
@@ -304,199 +304,208 @@ class GeneratedMessageReflection final : public Reflection {
const DescriptorPool* pool,
MessageFactory* factory);
- ~GeneratedMessageReflection();
+
+ ~GeneratedMessageReflection() override;
// implements Reflection -------------------------------------------
- const UnknownFieldSet& GetUnknownFields(const Message& message) const;
- UnknownFieldSet* MutableUnknownFields(Message* message) const;
+ const UnknownFieldSet& GetUnknownFields(
+ const Message& message) const override;
+ UnknownFieldSet* MutableUnknownFields(Message* message) const override;
- size_t SpaceUsedLong(const Message& message) const;
+ size_t SpaceUsedLong(const Message& message) const override;
- bool HasField(const Message& message, const FieldDescriptor* field) const;
- int FieldSize(const Message& message, const FieldDescriptor* field) const;
- void ClearField(Message* message, const FieldDescriptor* field) const;
+ bool HasField(const Message& message,
+ const FieldDescriptor* field) const override;
+ int FieldSize(const Message& message,
+ const FieldDescriptor* field) const override;
+ void ClearField(Message* message,
+ const FieldDescriptor* field) const override;
bool HasOneof(const Message& message,
- const OneofDescriptor* oneof_descriptor) const;
- void ClearOneof(Message* message, const OneofDescriptor* field) const;
- void RemoveLast(Message* message, const FieldDescriptor* field) const;
- Message* ReleaseLast(Message* message, const FieldDescriptor* field) const;
- void Swap(Message* message1, Message* message2) const;
+ const OneofDescriptor* oneof_descriptor) const override;
+ void ClearOneof(Message* message,
+ const OneofDescriptor* field) const override;
+ void RemoveLast(Message* message,
+ const FieldDescriptor* field) const override;
+ Message* ReleaseLast(Message* message,
+ const FieldDescriptor* field) const override;
+ void Swap(Message* message1, Message* message2) const override;
void SwapFields(Message* message1, Message* message2,
- const std::vector<const FieldDescriptor*>& fields) const;
+ const std::vector<const FieldDescriptor*>& fields) const override;
void SwapElements(Message* message, const FieldDescriptor* field,
- int index1, int index2) const;
+ int index1, int index2) const override;
void ListFields(const Message& message,
- std::vector<const FieldDescriptor*>* output) const;
-
+ std::vector<const FieldDescriptor*>* output) const override;
int32 GetInt32 (const Message& message,
- const FieldDescriptor* field) const;
+ const FieldDescriptor* field) const override;
int64 GetInt64 (const Message& message,
- const FieldDescriptor* field) const;
+ const FieldDescriptor* field) const override;
uint32 GetUInt32(const Message& message,
- const FieldDescriptor* field) const;
+ const FieldDescriptor* field) const override;
uint64 GetUInt64(const Message& message,
- const FieldDescriptor* field) const;
+ const FieldDescriptor* field) const override;
float GetFloat (const Message& message,
- const FieldDescriptor* field) const;
+ const FieldDescriptor* field) const override;
double GetDouble(const Message& message,
- const FieldDescriptor* field) const;
+ const FieldDescriptor* field) const override;
bool GetBool (const Message& message,
- const FieldDescriptor* field) const;
+ const FieldDescriptor* field) const override;
string GetString(const Message& message,
- const FieldDescriptor* field) const;
+ const FieldDescriptor* field) const override;
const string& GetStringReference(const Message& message,
const FieldDescriptor* field,
- string* scratch) const;
- const EnumValueDescriptor* GetEnum(const Message& message,
- const FieldDescriptor* field) const;
+ string* scratch) const override;
+ const EnumValueDescriptor* GetEnum(
+ const Message& message, const FieldDescriptor* field) const override;
int GetEnumValue(const Message& message,
- const FieldDescriptor* field) const;
+ const FieldDescriptor* field) const override;
const Message& GetMessage(const Message& message,
const FieldDescriptor* field,
- MessageFactory* factory = NULL) const;
+ MessageFactory* factory = NULL) const override;
const FieldDescriptor* GetOneofFieldDescriptor(
const Message& message,
- const OneofDescriptor* oneof_descriptor) const;
+ const OneofDescriptor* oneof_descriptor) const override;
private:
bool ContainsMapKey(const Message& message,
const FieldDescriptor* field,
- const MapKey& key) const;
+ const MapKey& key) const override;
bool InsertOrLookupMapValue(Message* message,
const FieldDescriptor* field,
const MapKey& key,
- MapValueRef* val) const;
+ MapValueRef* val) const override;
bool DeleteMapValue(Message* message,
const FieldDescriptor* field,
- const MapKey& key) const;
+ const MapKey& key) const override;
MapIterator MapBegin(
Message* message,
- const FieldDescriptor* field) const;
+ const FieldDescriptor* field) const override;
MapIterator MapEnd(
Message* message,
- const FieldDescriptor* field) const;
- int MapSize(const Message& message, const FieldDescriptor* field) const;
+ const FieldDescriptor* field) const override;
+ int MapSize(const Message& message,
+ const FieldDescriptor* field) const override;
public:
void SetInt32 (Message* message,
- const FieldDescriptor* field, int32 value) const;
+ const FieldDescriptor* field, int32 value) const override;
void SetInt64 (Message* message,
- const FieldDescriptor* field, int64 value) const;
+ const FieldDescriptor* field, int64 value) const override;
void SetUInt32(Message* message,
- const FieldDescriptor* field, uint32 value) const;
+ const FieldDescriptor* field, uint32 value) const override;
void SetUInt64(Message* message,
- const FieldDescriptor* field, uint64 value) const;
+ const FieldDescriptor* field, uint64 value) const override;
void SetFloat (Message* message,
- const FieldDescriptor* field, float value) const;
+ const FieldDescriptor* field, float value) const override;
void SetDouble(Message* message,
- const FieldDescriptor* field, double value) const;
+ const FieldDescriptor* field, double value) const override;
void SetBool (Message* message,
- const FieldDescriptor* field, bool value) const;
+ const FieldDescriptor* field, bool value) const override;
void SetString(Message* message,
const FieldDescriptor* field,
- const string& value) const;
+ const string& value) const override;
void SetEnum (Message* message, const FieldDescriptor* field,
- const EnumValueDescriptor* value) const;
+ const EnumValueDescriptor* value) const override;
void SetEnumValue(Message* message, const FieldDescriptor* field,
- int value) const;
+ int value) const override;
Message* MutableMessage(Message* message, const FieldDescriptor* field,
- MessageFactory* factory = NULL) const;
+ MessageFactory* factory = NULL) const override;
void SetAllocatedMessage(Message* message,
Message* sub_message,
- const FieldDescriptor* field) const;
+ const FieldDescriptor* field) const override;
Message* ReleaseMessage(Message* message, const FieldDescriptor* field,
- MessageFactory* factory = NULL) const;
-
- int32 GetRepeatedInt32 (const Message& message,
- const FieldDescriptor* field, int index) const;
- int64 GetRepeatedInt64 (const Message& message,
- const FieldDescriptor* field, int index) const;
- uint32 GetRepeatedUInt32(const Message& message,
- const FieldDescriptor* field, int index) const;
- uint64 GetRepeatedUInt64(const Message& message,
- const FieldDescriptor* field, int index) const;
- float GetRepeatedFloat (const Message& message,
- const FieldDescriptor* field, int index) const;
- double GetRepeatedDouble(const Message& message,
- const FieldDescriptor* field, int index) const;
- bool GetRepeatedBool (const Message& message,
- const FieldDescriptor* field, int index) const;
- string GetRepeatedString(const Message& message,
- const FieldDescriptor* field, int index) const;
- const string& GetRepeatedStringReference(const Message& message,
+ MessageFactory* factory = NULL) const override;
+
+ int32 GetRepeatedInt32(const Message& message, const FieldDescriptor* field,
+ int index) const override;
+ int64 GetRepeatedInt64(const Message& message, const FieldDescriptor* field,
+ int index) const override;
+ uint32 GetRepeatedUInt32(const Message& message, const FieldDescriptor* field,
+ int index) const override;
+ uint64 GetRepeatedUInt64(const Message& message, const FieldDescriptor* field,
+ int index) const override;
+ float GetRepeatedFloat(const Message& message, const FieldDescriptor* field,
+ int index) const override;
+ double GetRepeatedDouble(const Message& message, const FieldDescriptor* field,
+ int index) const override;
+ bool GetRepeatedBool(const Message& message, const FieldDescriptor* field,
+ int index) const override;
+ string GetRepeatedString(const Message& message, const FieldDescriptor* field,
+ int index) const override;
+ const string &GetRepeatedStringReference(const Message& message,
const FieldDescriptor* field,
- int index, string* scratch) const;
+ int index,
+ string* scratch) const override;
const EnumValueDescriptor* GetRepeatedEnum(const Message& message,
const FieldDescriptor* field,
- int index) const;
- int GetRepeatedEnumValue(const Message& message,
- const FieldDescriptor* field,
- int index) const;
- const Message& GetRepeatedMessage(const Message& message,
+ int index) const override;
+ int GetRepeatedEnumValue(const Message& message, const FieldDescriptor* field,
+ int index) const override;
+ const Message &GetRepeatedMessage(const Message& message,
const FieldDescriptor* field,
- int index) const;
+ int index) const override;
// Set the value of a field.
- void SetRepeatedInt32 (Message* message,
- const FieldDescriptor* field, int index, int32 value) const;
- void SetRepeatedInt64 (Message* message,
- const FieldDescriptor* field, int index, int64 value) const;
- void SetRepeatedUInt32(Message* message,
- const FieldDescriptor* field, int index, uint32 value) const;
- void SetRepeatedUInt64(Message* message,
- const FieldDescriptor* field, int index, uint64 value) const;
- void SetRepeatedFloat (Message* message,
- const FieldDescriptor* field, int index, float value) const;
- void SetRepeatedDouble(Message* message,
- const FieldDescriptor* field, int index, double value) const;
- void SetRepeatedBool (Message* message,
- const FieldDescriptor* field, int index, bool value) const;
- void SetRepeatedString(Message* message,
- const FieldDescriptor* field, int index,
- const string& value) const;
+ void SetRepeatedInt32(Message* message, const FieldDescriptor* field,
+ int index, int32 value) const override;
+ void SetRepeatedInt64(Message* message, const FieldDescriptor* field,
+ int index, int64 value) const override;
+ void SetRepeatedUInt32(Message* message, const FieldDescriptor* field,
+ int index, uint32 value) const override;
+ void SetRepeatedUInt64(Message* message, const FieldDescriptor* field,
+ int index, uint64 value) const override;
+ void SetRepeatedFloat(Message* message, const FieldDescriptor* field,
+ int index, float value) const override;
+ void SetRepeatedDouble(Message* message, const FieldDescriptor* field,
+ int index, double value) const override;
+ void SetRepeatedBool(Message* message, const FieldDescriptor* field,
+ int index, bool value) const override;
+ void SetRepeatedString(Message* message, const FieldDescriptor* field,
+ int index, const string &value) const override;
void SetRepeatedEnum(Message* message, const FieldDescriptor* field,
- int index, const EnumValueDescriptor* value) const;
+ int index,
+ const EnumValueDescriptor* value) const override;
void SetRepeatedEnumValue(Message* message, const FieldDescriptor* field,
- int index, int value) const;
+ int index, int value) const override;
// Get a mutable pointer to a field with a message type.
Message* MutableRepeatedMessage(Message* message,
const FieldDescriptor* field,
- int index) const;
+ int index) const override;
void AddInt32 (Message* message,
- const FieldDescriptor* field, int32 value) const;
+ const FieldDescriptor* field, int32 value) const override;
void AddInt64 (Message* message,
- const FieldDescriptor* field, int64 value) const;
+ const FieldDescriptor* field, int64 value) const override;
void AddUInt32(Message* message,
- const FieldDescriptor* field, uint32 value) const;
+ const FieldDescriptor* field, uint32 value) const override;
void AddUInt64(Message* message,
- const FieldDescriptor* field, uint64 value) const;
+ const FieldDescriptor* field, uint64 value) const override;
void AddFloat (Message* message,
- const FieldDescriptor* field, float value) const;
+ const FieldDescriptor* field, float value) const override;
void AddDouble(Message* message,
- const FieldDescriptor* field, double value) const;
+ const FieldDescriptor* field, double value) const override;
void AddBool (Message* message,
- const FieldDescriptor* field, bool value) const;
- void AddString(Message* message,
- const FieldDescriptor* field, const string& value) const;
+ const FieldDescriptor* field, bool value) const override;
+ void AddString(Message* message, const FieldDescriptor* field,
+ const string& value) const override;
void AddEnum(Message* message,
const FieldDescriptor* field,
- const EnumValueDescriptor* value) const;
+ const EnumValueDescriptor* value) const override;
void AddEnumValue(Message* message,
const FieldDescriptor* field,
- int value) const;
+ int value) const override;
Message* AddMessage(Message* message, const FieldDescriptor* field,
- MessageFactory* factory = NULL) const;
+ MessageFactory* factory = NULL) const override;
void AddAllocatedMessage(
Message* message, const FieldDescriptor* field,
- Message* new_entry) const;
+ Message* new_entry) const override;
- const FieldDescriptor* FindKnownExtensionByName(const string& name) const;
- const FieldDescriptor* FindKnownExtensionByNumber(int number) const;
+ const FieldDescriptor* FindKnownExtensionByName(
+ const string& name) const override;
+ const FieldDescriptor* FindKnownExtensionByNumber(int number) const override;
- bool SupportsUnknownEnumValues() const;
+ bool SupportsUnknownEnumValues() const override;
// This value for arena_offset_ indicates that there is no arena pointer in
// this message (e.g., old generated code).
@@ -514,19 +523,19 @@ class GeneratedMessageReflection final : public Reflection {
protected:
void* MutableRawRepeatedField(
Message* message, const FieldDescriptor* field, FieldDescriptor::CppType,
- int ctype, const Descriptor* desc) const;
+ int ctype, const Descriptor* desc) const override;
const void* GetRawRepeatedField(
const Message& message, const FieldDescriptor* field,
FieldDescriptor::CppType, int ctype,
- const Descriptor* desc) const;
+ const Descriptor* desc) const override;
- virtual MessageFactory* GetMessageFactory() const;
+ virtual MessageFactory* GetMessageFactory() const override;
virtual void* RepeatedFieldData(
Message* message, const FieldDescriptor* field,
FieldDescriptor::CppType cpp_type,
- const Descriptor* message_type) const;
+ const Descriptor* message_type) const override;
private:
friend class google::protobuf::flat::MetadataBuilder;
@@ -661,7 +670,7 @@ class GeneratedMessageReflection final : public Reflection {
const FieldDescriptor* field) const;
internal::MapFieldBase* MapData(
- Message* message, const FieldDescriptor* field) const;
+ Message* message, const FieldDescriptor* field) const override;
friend inline // inline so nobody can call this function.
void
diff --git a/src/google/protobuf/generated_message_util.h b/src/google/protobuf/generated_message_util.h
index c26e3e52..4da04cae 100644
--- a/src/google/protobuf/generated_message_util.h
+++ b/src/google/protobuf/generated_message_util.h
@@ -201,7 +201,7 @@ struct SerializationTable {
};
LIBPROTOBUF_EXPORT void SerializeInternal(const uint8* base, const FieldMetadata* table,
- int num_fields, ::google::protobuf::io::CodedOutputStream* output);
+ int32 num_fields, ::google::protobuf::io::CodedOutputStream* output);
inline void TableSerialize(const ::google::protobuf::MessageLite& msg,
const SerializationTable* table,
@@ -219,7 +219,7 @@ inline void TableSerialize(const ::google::protobuf::MessageLite& msg,
}
uint8* SerializeInternalToArray(const uint8* base, const FieldMetadata* table,
- int num_fields, bool is_deterministic,
+ int32 num_fields, bool is_deterministic,
uint8* buffer);
inline uint8* TableSerializeToArray(const ::google::protobuf::MessageLite& msg,
@@ -335,7 +335,16 @@ struct LIBPROTOBUF_EXPORT SCCInfoBase {
kRunning = 1,
kUninitialized = -1, // initial state
};
+#ifndef _MSC_VER
std::atomic<int> visit_status;
+#else
+ // MSVC doesnt make std::atomic constant initialized. This union trick
+ // makes it so.
+ union {
+ int visit_status_to_make_linker_init;
+ std::atomic<int> visit_status;
+ };
+#endif
int num_deps;
void (*init_func)();
// This is followed by an array of num_deps
diff --git a/src/google/protobuf/io/gzip_stream.h b/src/google/protobuf/io/gzip_stream.h
index 15b02fe3..df1a446e 100644
--- a/src/google/protobuf/io/gzip_stream.h
+++ b/src/google/protobuf/io/gzip_stream.h
@@ -118,7 +118,7 @@ class LIBPROTOBUF_EXPORT GzipOutputStream : public ZeroCopyOutputStream {
ZLIB = 2,
};
- struct Options {
+ struct LIBPROTOBUF_EXPORT Options {
// Defaults to GZIP.
Format format;
diff --git a/src/google/protobuf/io/zero_copy_stream_impl.h b/src/google/protobuf/io/zero_copy_stream_impl.h
index ea978bfb..ef9fc9d2 100644
--- a/src/google/protobuf/io/zero_copy_stream_impl.h
+++ b/src/google/protobuf/io/zero_copy_stream_impl.h
@@ -87,24 +87,24 @@ class LIBPROTOBUF_EXPORT FileInputStream : public ZeroCopyInputStream {
int GetErrno() { return copying_input_.GetErrno(); }
// implements ZeroCopyInputStream ----------------------------------
- bool Next(const void** data, int* size);
- void BackUp(int count);
- bool Skip(int count);
- int64 ByteCount() const;
+ bool Next(const void** data, int* size) override;
+ void BackUp(int count) override;
+ bool Skip(int count) override;
+ int64 ByteCount() const override;
private:
class LIBPROTOBUF_EXPORT CopyingFileInputStream : public CopyingInputStream {
public:
CopyingFileInputStream(int file_descriptor);
- ~CopyingFileInputStream();
+ ~CopyingFileInputStream() override;
bool Close();
void SetCloseOnDelete(bool value) { close_on_delete_ = value; }
int GetErrno() { return errno_; }
// implements CopyingInputStream ---------------------------------
- int Read(void* buffer, int size);
- int Skip(int count);
+ int Read(void* buffer, int size) override;
+ int Skip(int count) override;
private:
// The file descriptor.
@@ -144,7 +144,7 @@ class LIBPROTOBUF_EXPORT FileOutputStream : public ZeroCopyOutputStream {
// that should be returned by Next(). Otherwise, a reasonable default
// is used.
explicit FileOutputStream(int file_descriptor, int block_size = -1);
- ~FileOutputStream();
+ ~FileOutputStream() override;
// Flushes any buffers and closes the underlying file. Returns false if
// an error occurs during the process; use GetErrno() to examine the error.
@@ -170,22 +170,22 @@ class LIBPROTOBUF_EXPORT FileOutputStream : public ZeroCopyOutputStream {
int GetErrno() { return copying_output_.GetErrno(); }
// implements ZeroCopyOutputStream ---------------------------------
- bool Next(void** data, int* size);
- void BackUp(int count);
- int64 ByteCount() const;
+ bool Next(void** data, int* size) override;
+ void BackUp(int count) override;
+ int64 ByteCount() const override;
private:
class LIBPROTOBUF_EXPORT CopyingFileOutputStream : public CopyingOutputStream {
public:
CopyingFileOutputStream(int file_descriptor);
- ~CopyingFileOutputStream();
+ ~CopyingFileOutputStream() override;
bool Close();
void SetCloseOnDelete(bool value) { close_on_delete_ = value; }
int GetErrno() { return errno_; }
// implements CopyingOutputStream --------------------------------
- bool Write(const void* buffer, int size);
+ bool Write(const void* buffer, int size) override;
private:
// The file descriptor.
@@ -220,19 +220,19 @@ class LIBPROTOBUF_EXPORT IstreamInputStream : public ZeroCopyInputStream {
explicit IstreamInputStream(std::istream* stream, int block_size = -1);
// implements ZeroCopyInputStream ----------------------------------
- bool Next(const void** data, int* size);
- void BackUp(int count);
- bool Skip(int count);
- int64 ByteCount() const;
+ bool Next(const void** data, int* size) override;
+ void BackUp(int count) override;
+ bool Skip(int count) override;
+ int64 ByteCount() const override;
private:
class LIBPROTOBUF_EXPORT CopyingIstreamInputStream : public CopyingInputStream {
public:
CopyingIstreamInputStream(std::istream* input);
- ~CopyingIstreamInputStream();
+ ~CopyingIstreamInputStream() override;
// implements CopyingInputStream ---------------------------------
- int Read(void* buffer, int size);
+ int Read(void* buffer, int size) override;
// (We use the default implementation of Skip().)
private:
@@ -261,21 +261,21 @@ class LIBPROTOBUF_EXPORT OstreamOutputStream : public ZeroCopyOutputStream {
// that should be returned by Next(). Otherwise, a reasonable default
// is used.
explicit OstreamOutputStream(std::ostream* stream, int block_size = -1);
- ~OstreamOutputStream();
+ ~OstreamOutputStream() override;
// implements ZeroCopyOutputStream ---------------------------------
- bool Next(void** data, int* size);
- void BackUp(int count);
- int64 ByteCount() const;
+ bool Next(void** data, int* size) override;
+ void BackUp(int count) override;
+ int64 ByteCount() const override;
private:
class LIBPROTOBUF_EXPORT CopyingOstreamOutputStream : public CopyingOutputStream {
public:
CopyingOstreamOutputStream(std::ostream* output);
- ~CopyingOstreamOutputStream();
+ ~CopyingOstreamOutputStream() override;
// implements CopyingOutputStream --------------------------------
- bool Write(const void* buffer, int size);
+ bool Write(const void* buffer, int size) override;
private:
// The stream.
@@ -304,12 +304,13 @@ class LIBPROTOBUF_EXPORT ConcatenatingInputStream : public ZeroCopyInputStream {
// All streams passed in as well as the array itself must remain valid
// until the ConcatenatingInputStream is destroyed.
ConcatenatingInputStream(ZeroCopyInputStream* const streams[], int count);
+ ~ConcatenatingInputStream() override = default;
// implements ZeroCopyInputStream ----------------------------------
- bool Next(const void** data, int* size);
- void BackUp(int count);
- bool Skip(int count);
- int64 ByteCount() const;
+ bool Next(const void** data, int* size) override;
+ void BackUp(int count) override;
+ bool Skip(int count) override;
+ int64 ByteCount() const override;
private:
@@ -329,13 +330,13 @@ class LIBPROTOBUF_EXPORT ConcatenatingInputStream : public ZeroCopyInputStream {
class LIBPROTOBUF_EXPORT LimitingInputStream : public ZeroCopyInputStream {
public:
LimitingInputStream(ZeroCopyInputStream* input, int64 limit);
- ~LimitingInputStream();
+ ~LimitingInputStream() override;
// implements ZeroCopyInputStream ----------------------------------
- bool Next(const void** data, int* size);
- void BackUp(int count);
- bool Skip(int count);
- int64 ByteCount() const;
+ bool Next(const void** data, int* size) override;
+ void BackUp(int count) override;
+ bool Skip(int count) override;
+ int64 ByteCount() const override;
private:
diff --git a/src/google/protobuf/io/zero_copy_stream_impl_lite.h b/src/google/protobuf/io/zero_copy_stream_impl_lite.h
index 29f63bf0..38b6cde6 100644
--- a/src/google/protobuf/io/zero_copy_stream_impl_lite.h
+++ b/src/google/protobuf/io/zero_copy_stream_impl_lite.h
@@ -70,12 +70,13 @@ class LIBPROTOBUF_EXPORT ArrayInputStream : public ZeroCopyInputStream {
// useful for testing; in production you would probably never want to set
// it.
ArrayInputStream(const void* data, int size, int block_size = -1);
+ ~ArrayInputStream() override = default;
// implements ZeroCopyInputStream ----------------------------------
- bool Next(const void** data, int* size);
- void BackUp(int count);
- bool Skip(int count);
- int64 ByteCount() const;
+ bool Next(const void** data, int* size) override;
+ void BackUp(int count) override;
+ bool Skip(int count) override;
+ int64 ByteCount() const override;
private:
@@ -103,11 +104,12 @@ class LIBPROTOBUF_EXPORT ArrayOutputStream : public ZeroCopyOutputStream {
// useful for testing; in production you would probably never want to set
// it.
ArrayOutputStream(void* data, int size, int block_size = -1);
+ ~ArrayOutputStream() override = default;
// implements ZeroCopyOutputStream ---------------------------------
- bool Next(void** data, int* size);
- void BackUp(int count);
- int64 ByteCount() const;
+ bool Next(void** data, int* size) override;
+ void BackUp(int count) override;
+ int64 ByteCount() const override;
private:
uint8* const data_; // The byte array.
@@ -136,11 +138,12 @@ class LIBPROTOBUF_EXPORT StringOutputStream : public ZeroCopyOutputStream {
// the first call to Next() will return at least n bytes of buffer
// space.
explicit StringOutputStream(string* target);
+ ~StringOutputStream() override = default;
// implements ZeroCopyOutputStream ---------------------------------
- bool Next(void** data, int* size);
- void BackUp(int count);
- int64 ByteCount() const;
+ bool Next(void** data, int* size) override;
+ void BackUp(int count) override;
+ int64 ByteCount() const override;
protected:
void SetString(string* target);
@@ -205,17 +208,17 @@ class LIBPROTOBUF_EXPORT CopyingInputStreamAdaptor : public ZeroCopyInputStream
// copying_stream unless SetOwnsCopyingStream(true) is called.
explicit CopyingInputStreamAdaptor(CopyingInputStream* copying_stream,
int block_size = -1);
- ~CopyingInputStreamAdaptor();
+ ~CopyingInputStreamAdaptor() override;
// Call SetOwnsCopyingStream(true) to tell the CopyingInputStreamAdaptor to
// delete the underlying CopyingInputStream when it is destroyed.
void SetOwnsCopyingStream(bool value) { owns_copying_stream_ = value; }
// implements ZeroCopyInputStream ----------------------------------
- bool Next(const void** data, int* size);
- void BackUp(int count);
- bool Skip(int count);
- int64 ByteCount() const;
+ bool Next(const void** data, int* size) override;
+ void BackUp(int count) override;
+ bool Skip(int count) override;
+ int64 ByteCount() const override;
private:
// Insures that buffer_ is not NULL.
@@ -288,7 +291,7 @@ class LIBPROTOBUF_EXPORT CopyingOutputStreamAdaptor : public ZeroCopyOutputStrea
// is used.
explicit CopyingOutputStreamAdaptor(CopyingOutputStream* copying_stream,
int block_size = -1);
- ~CopyingOutputStreamAdaptor();
+ ~CopyingOutputStreamAdaptor() override;
// Writes all pending data to the underlying stream. Returns false if a
// write error occurred on the underlying stream. (The underlying
@@ -300,9 +303,9 @@ class LIBPROTOBUF_EXPORT CopyingOutputStreamAdaptor : public ZeroCopyOutputStrea
void SetOwnsCopyingStream(bool value) { owns_copying_stream_ = value; }
// implements ZeroCopyOutputStream ---------------------------------
- bool Next(void** data, int* size);
- void BackUp(int count);
- int64 ByteCount() const;
+ bool Next(void** data, int* size) override;
+ void BackUp(int count) override;
+ int64 ByteCount() const override;
private:
// Write the current buffer, if it is present.
diff --git a/src/google/protobuf/map_entry.h b/src/google/protobuf/map_entry.h
index 801def97..f25b5834 100644
--- a/src/google/protobuf/map_entry.h
+++ b/src/google/protobuf/map_entry.h
@@ -95,6 +95,19 @@ class MapEntry
typedef void InternalArenaConstructable_;
typedef void DestructorSkippable_;
+ using typename MapEntryImpl<Derived, Message, Key, Value, kKeyFieldType,
+ kValueFieldType,
+ default_enum_value>::KeyTypeHandler;
+ using typename MapEntryImpl<Derived, Message, Key, Value, kKeyFieldType,
+ kValueFieldType,
+ default_enum_value>::ValueTypeHandler;
+ size_t SpaceUsedLong() const override {
+ size_t size = sizeof(Derived);
+ size += KeyTypeHandler::SpaceUsedInMapEntryLong(this->key_);
+ size += ValueTypeHandler::SpaceUsedInMapEntryLong(this->value_);
+ return size;
+ }
+
InternalMetadataWithArena _internal_metadata_;
private:
diff --git a/src/google/protobuf/map_entry_lite.h b/src/google/protobuf/map_entry_lite.h
index 85a0bed7..01c734bc 100644
--- a/src/google/protobuf/map_entry_lite.h
+++ b/src/google/protobuf/map_entry_lite.h
@@ -177,13 +177,13 @@ class MapEntryImpl : public Base {
// MapEntryImpl is for implementation only and this function isn't called
// anywhere. Just provide a fake implementation here for MessageLite.
- string GetTypeName() const { return ""; }
+ string GetTypeName() const override { return ""; }
- void CheckTypeAndMergeFrom(const MessageLite& other) {
+ void CheckTypeAndMergeFrom(const MessageLite& other) override {
MergeFromInternal(*::google::protobuf::down_cast<const Derived*>(&other));
}
- bool MergePartialFromCodedStream(::google::protobuf::io::CodedInputStream* input) {
+ bool MergePartialFromCodedStream(::google::protobuf::io::CodedInputStream* input) override {
uint32 tag;
for (;;) {
@@ -224,7 +224,7 @@ class MapEntryImpl : public Base {
}
}
- size_t ByteSizeLong() const {
+ size_t ByteSizeLong() const override {
size_t size = 0;
size += has_key() ?
kTagSize + static_cast<size_t>(KeyTypeHandler::ByteSize(key())) : 0;
@@ -233,13 +233,13 @@ class MapEntryImpl : public Base {
return size;
}
- void SerializeWithCachedSizes(::google::protobuf::io::CodedOutputStream* output) const {
+ void SerializeWithCachedSizes(::google::protobuf::io::CodedOutputStream* output) const override {
KeyTypeHandler::Write(kKeyFieldNumber, key(), output);
ValueTypeHandler::Write(kValueFieldNumber, value(), output);
}
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(bool deterministic,
- ::google::protobuf::uint8* output) const {
+ ::google::protobuf::uint8* output) const override {
output = KeyTypeHandler::InternalWriteToArray(kKeyFieldNumber, key(),
deterministic, output);
output = ValueTypeHandler::InternalWriteToArray(kValueFieldNumber, value(),
@@ -249,7 +249,7 @@ class MapEntryImpl : public Base {
// Don't override SerializeWithCachedSizesToArray. Use MessageLite's.
- int GetCachedSize() const {
+ int GetCachedSize() const override {
int size = 0;
size += has_key()
? static_cast<int>(kTagSize) + KeyTypeHandler::GetCachedSize(key())
@@ -260,25 +260,18 @@ class MapEntryImpl : public Base {
return size;
}
- bool IsInitialized() const { return ValueTypeHandler::IsInitialized(value_); }
+ bool IsInitialized() const override { return ValueTypeHandler::IsInitialized(value_); }
- Base* New() const {
+ Base* New() const override {
Derived* entry = new Derived;
return entry;
}
- Base* New(Arena* arena) const {
+ Base* New(Arena* arena) const override {
Derived* entry = Arena::CreateMessage<Derived>(arena);
return entry;
}
- size_t SpaceUsedLong() const {
- size_t size = sizeof(Derived);
- size += KeyTypeHandler::SpaceUsedInMapEntryLong(key_);
- size += ValueTypeHandler::SpaceUsedInMapEntryLong(value_);
- return size;
- }
-
protected:
// We can't declare this function directly here as it would hide the other
// overload (const Message&).
@@ -298,7 +291,7 @@ class MapEntryImpl : public Base {
}
public:
- void Clear() {
+ void Clear() override {
KeyTypeHandler::Clear(&key_, GetArenaNoVirtual());
ValueTypeHandler::ClearMaybeByDefaultEnum(
&value_, GetArenaNoVirtual(), default_enum_value);
@@ -312,7 +305,7 @@ class MapEntryImpl : public Base {
ValueTypeHandler::AssignDefaultValue(&d->value_);
}
- Arena* GetArena() const {
+ Arena* GetArena() const override {
return GetArenaNoVirtual();
}
@@ -466,8 +459,8 @@ class MapEntryImpl : public Base {
BaseClass::set_has_key();
BaseClass::set_has_value();
}
- inline const KeyMapEntryAccessorType& key() const { return key_; }
- inline const ValueMapEntryAccessorType& value() const { return value_; }
+ inline const KeyMapEntryAccessorType &key() const override { return key_; }
+ inline const ValueMapEntryAccessorType& value() const override { return value_; }
private:
const Key& key_;
diff --git a/src/google/protobuf/map_field.h b/src/google/protobuf/map_field.h
index 494401e1..44ca29b3 100644
--- a/src/google/protobuf/map_field.h
+++ b/src/google/protobuf/map_field.h
@@ -181,10 +181,10 @@ class TypeDefinedMapFieldBase : public MapFieldBase {
public:
TypeDefinedMapFieldBase() {}
explicit TypeDefinedMapFieldBase(Arena* arena) : MapFieldBase(arena) {}
- ~TypeDefinedMapFieldBase() {}
- void MapBegin(MapIterator* map_iter) const;
- void MapEnd(MapIterator* map_iter) const;
- bool EqualIterator(const MapIterator& a, const MapIterator& b) const;
+ ~TypeDefinedMapFieldBase() override {}
+ void MapBegin(MapIterator* map_iter) const override;
+ void MapEnd(MapIterator* map_iter) const override;
+ bool EqualIterator(const MapIterator& a, const MapIterator& b) const override;
virtual const Map<Key, T>& GetMap() const = 0;
virtual Map<Key, T>* MutableMap() = 0;
@@ -194,11 +194,11 @@ class TypeDefinedMapFieldBase : public MapFieldBase {
const MapIterator* map_iter) const;
private:
- void InitializeIterator(MapIterator* map_iter) const;
- void DeleteIterator(MapIterator* map_iter) const;
+ void InitializeIterator(MapIterator* map_iter) const override;
+ void DeleteIterator(MapIterator* map_iter) const override;
void CopyIterator(MapIterator* this_iteratorm,
- const MapIterator& that_iterator) const;
- void IncreaseIterator(MapIterator* map_iter) const;
+ const MapIterator& that_iterator) const override;
+ void IncreaseIterator(MapIterator* map_iter) const override;
virtual void SetMapIteratorValue(MapIterator* map_iter) const = 0;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TypeDefinedMapFieldBase);
@@ -243,16 +243,16 @@ class MapField : public TypeDefinedMapFieldBase<Key, T> {
: TypeDefinedMapFieldBase<Key, T>(arena), impl_(arena) {}
// Implement MapFieldBase
- bool ContainsMapKey(const MapKey& map_key) const;
- bool InsertOrLookupMapValue(const MapKey& map_key, MapValueRef* val);
- bool DeleteMapValue(const MapKey& map_key);
+ bool ContainsMapKey(const MapKey& map_key) const override;
+ bool InsertOrLookupMapValue(const MapKey& map_key, MapValueRef* val) override;
+ bool DeleteMapValue(const MapKey& map_key) override;
- const Map<Key, T>& GetMap() const {
+ const Map<Key, T>& GetMap() const override {
MapFieldBase::SyncMapWithRepeatedField();
return impl_.GetMap();
}
- Map<Key, T>* MutableMap() {
+ Map<Key, T>* MutableMap() override {
MapFieldBase::SyncMapWithRepeatedField();
Map<Key, T>* result = impl_.MutableMap();
MapFieldBase::SetMapDirty();
@@ -260,7 +260,7 @@ class MapField : public TypeDefinedMapFieldBase<Key, T> {
}
// Convenient methods for generated message implementation.
- int size() const;
+ int size() const override;
void Clear();
void MergeFrom(const MapField& other);
void Swap(MapField* other);
@@ -285,12 +285,13 @@ class MapField : public TypeDefinedMapFieldBase<Key, T> {
typedef void InternalArenaConstructable_;
typedef void DestructorSkippable_;
+
// Implements MapFieldBase
- void SyncRepeatedFieldWithMapNoLock() const;
- void SyncMapWithRepeatedFieldNoLock() const;
- size_t SpaceUsedExcludingSelfNoLock() const;
+ void SyncRepeatedFieldWithMapNoLock() const override;
+ void SyncMapWithRepeatedFieldNoLock() const override;
+ size_t SpaceUsedExcludingSelfNoLock() const override;
- void SetMapIteratorValue(MapIterator* map_iter) const;
+ void SetMapIteratorValue(MapIterator* map_iter) const override;
friend class ::google::protobuf::Arena;
friend class MapFieldStateTest; // For testing, it needs raw access to impl_
@@ -311,27 +312,27 @@ class LIBPROTOBUF_EXPORT DynamicMapField: public TypeDefinedMapFieldBase<MapKey,
public:
explicit DynamicMapField(const Message* default_entry);
DynamicMapField(const Message* default_entry, Arena* arena);
- ~DynamicMapField();
+ ~DynamicMapField() override;
// Implement MapFieldBase
- bool ContainsMapKey(const MapKey& map_key) const;
- bool InsertOrLookupMapValue(const MapKey& map_key, MapValueRef* val);
- bool DeleteMapValue(const MapKey& map_key);
+ bool ContainsMapKey(const MapKey& map_key) const override;
+ bool InsertOrLookupMapValue(const MapKey& map_key, MapValueRef* val) override;
+ bool DeleteMapValue(const MapKey& map_key) override;
- const Map<MapKey, MapValueRef>& GetMap() const;
- Map<MapKey, MapValueRef>* MutableMap();
+ const Map<MapKey, MapValueRef>& GetMap() const override;
+ Map<MapKey, MapValueRef>* MutableMap() override;
- int size() const;
+ int size() const override;
private:
Map<MapKey, MapValueRef> map_;
const Message* default_entry_;
// Implements MapFieldBase
- void SyncRepeatedFieldWithMapNoLock() const;
- void SyncMapWithRepeatedFieldNoLock() const;
- size_t SpaceUsedExcludingSelfNoLock() const;
- void SetMapIteratorValue(MapIterator* map_iter) const;
+ void SyncRepeatedFieldWithMapNoLock() const override;
+ void SyncMapWithRepeatedFieldNoLock() const override;
+ size_t SpaceUsedExcludingSelfNoLock() const override;
+ void SetMapIteratorValue(MapIterator* map_iter) const override;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DynamicMapField);
};
diff --git a/src/google/protobuf/message.cc b/src/google/protobuf/message.cc
index 810db233..7fda0c79 100644
--- a/src/google/protobuf/message.cc
+++ b/src/google/protobuf/message.cc
@@ -272,7 +272,7 @@ class GeneratedMessageFactory : public MessageFactory {
void RegisterType(const Descriptor* descriptor, const Message* prototype);
// implements MessageFactory ---------------------------------------
- const Message* GetPrototype(const Descriptor* type);
+ const Message* GetPrototype(const Descriptor* type) override;
private:
// Only written at static init time, so does not require locking.
diff --git a/src/google/protobuf/message.h b/src/google/protobuf/message.h
index f3d1a58a..4bdda3ad 100644
--- a/src/google/protobuf/message.h
+++ b/src/google/protobuf/message.h
@@ -196,12 +196,12 @@ class LIBPROTOBUF_EXPORT Message : public MessageLite {
// Construct a new instance of the same type. Ownership is passed to the
// caller. (This is also defined in MessageLite, but is defined again here
// for return-type covariance.)
- virtual Message* New() const = 0;
+ virtual Message* New() const override = 0;
// Construct a new instance on the arena. Ownership is passed to the caller
// if arena is a NULL. Default implementation allows for API compatibility
// during the Arena transition.
- virtual Message* New(::google::protobuf::Arena* arena) const {
+ virtual Message* New(::google::protobuf::Arena* arena) const override {
Message* message = New();
if (arena != NULL) {
arena->Own(message);
@@ -233,7 +233,7 @@ class LIBPROTOBUF_EXPORT Message : public MessageLite {
// Like FindInitializationErrors, but joins all the strings, delimited by
// commas, and returns them.
- string InitializationErrorString() const;
+ string InitializationErrorString() const override;
// Clears all unknown fields from this message and all embedded messages.
// Normally, if unknown tag numbers are encountered when parsing a message,
@@ -305,13 +305,13 @@ class LIBPROTOBUF_EXPORT Message : public MessageLite {
// These methods are pure-virtual in MessageLite, but Message provides
// reflection-based default implementations.
- virtual string GetTypeName() const;
- virtual void Clear();
- virtual bool IsInitialized() const;
- virtual void CheckTypeAndMergeFrom(const MessageLite& other);
- virtual bool MergePartialFromCodedStream(io::CodedInputStream* input);
- virtual size_t ByteSizeLong() const;
- virtual void SerializeWithCachedSizes(io::CodedOutputStream* output) const;
+ virtual string GetTypeName() const override;
+ virtual void Clear() override;
+ virtual bool IsInitialized() const override;
+ virtual void CheckTypeAndMergeFrom(const MessageLite& other) override;
+ virtual bool MergePartialFromCodedStream(io::CodedInputStream* input) override;
+ virtual size_t ByteSizeLong() const override;
+ virtual void SerializeWithCachedSizes(io::CodedOutputStream* output) const override;
private:
// This is called only by the default implementation of ByteSize(), to
diff --git a/src/google/protobuf/message_lite.cc b/src/google/protobuf/message_lite.cc
index 123b142d..65af7cea 100644
--- a/src/google/protobuf/message_lite.cc
+++ b/src/google/protobuf/message_lite.cc
@@ -316,7 +316,11 @@ bool MessageLite::SerializeToArray(void* data, int size) const {
}
bool MessageLite::SerializePartialToArray(void* data, int size) const {
- int byte_size = ByteSizeLong();
+ size_t byte_size = ByteSizeLong();
+ if (byte_size > INT_MAX) {
+ GOOGLE_LOG(ERROR) << "Exceeded maximum protobuf size of 2GB: " << size;
+ return false;
+ }
if (size < byte_size) return false;
uint8* start = reinterpret_cast<uint8*>(data);
uint8* end = SerializeWithCachedSizesToArray(start);
diff --git a/src/google/protobuf/reflection.h b/src/google/protobuf/reflection.h
index 5d0fc42b..5d0fc42b 100755..100644
--- a/src/google/protobuf/reflection.h
+++ b/src/google/protobuf/reflection.h
diff --git a/src/google/protobuf/reflection_internal.h b/src/google/protobuf/reflection_internal.h
index fcb42471..840d611f 100644
--- a/src/google/protobuf/reflection_internal.h
+++ b/src/google/protobuf/reflection_internal.h
@@ -43,32 +43,32 @@ namespace internal {
// corresponding random-access methods.
class RandomAccessRepeatedFieldAccessor : public RepeatedFieldAccessor {
public:
- virtual ~RandomAccessRepeatedFieldAccessor() {}
+ virtual ~RandomAccessRepeatedFieldAccessor() override {}
- virtual Iterator* BeginIterator(const Field* data) const {
+ virtual Iterator* BeginIterator(const Field* data) const override {
return PositionToIterator(0);
}
- virtual Iterator* EndIterator(const Field* data) const {
+ virtual Iterator* EndIterator(const Field* data) const override {
return PositionToIterator(this->Size(data));
}
virtual Iterator* CopyIterator(const Field* data,
- const Iterator* iterator) const {
+ const Iterator* iterator) const override {
return const_cast<Iterator*>(iterator);
}
virtual Iterator* AdvanceIterator(const Field* data,
- Iterator* iterator) const {
+ Iterator* iterator) const override {
return PositionToIterator(IteratorToPosition(iterator) + 1);
}
virtual bool EqualsIterator(const Field* data,
- const Iterator* a,
- const Iterator* b) const {
+ const Iterator* a,
+ const Iterator* b) const override {
return a == b;
}
- virtual void DeleteIterator(const Field* data, Iterator* iterator) const {
+ virtual void DeleteIterator(const Field* data, Iterator* iterator) const override {
}
virtual const Value* GetIteratorValue(const Field* data,
- const Iterator* iterator,
- Value* scratch_space) const {
+ const Iterator* iterator,
+ Value* scratch_space) const override {
return Get(data, static_cast<int>(IteratorToPosition(iterator)),
scratch_space);
}
@@ -88,30 +88,30 @@ template<typename T>
class RepeatedFieldWrapper : public RandomAccessRepeatedFieldAccessor {
public:
RepeatedFieldWrapper() {}
- virtual ~RepeatedFieldWrapper() {}
- virtual bool IsEmpty(const Field* data) const {
+ virtual ~RepeatedFieldWrapper() override {}
+ virtual bool IsEmpty(const Field* data) const override {
return GetRepeatedField(data)->empty();
}
- virtual int Size(const Field* data) const {
+ virtual int Size(const Field* data) const override {
return GetRepeatedField(data)->size();
}
virtual const Value* Get(const Field* data, int index,
- Value* scratch_space) const {
+ Value* scratch_space) const override {
return ConvertFromT(GetRepeatedField(data)->Get(index), scratch_space);
}
- virtual void Clear(Field* data) const {
+ virtual void Clear(Field* data) const override {
MutableRepeatedField(data)->Clear();
}
- virtual void Set(Field* data, int index, const Value* value) const {
+ virtual void Set(Field* data, int index, const Value* value) const override {
MutableRepeatedField(data)->Set(index, ConvertToT(value));
}
- virtual void Add(Field* data, const Value* value) const {
+ virtual void Add(Field* data, const Value* value) const override {
MutableRepeatedField(data)->Add(ConvertToT(value));
}
- virtual void RemoveLast(Field* data) const {
+ virtual void RemoveLast(Field* data) const override {
MutableRepeatedField(data)->RemoveLast();
}
- virtual void SwapElements(Field* data, int index1, int index2) const {
+ virtual void SwapElements(Field* data, int index1, int index2) const override {
MutableRepeatedField(data)->SwapElements(index1, index2);
}
@@ -144,31 +144,31 @@ class RepeatedPtrFieldWrapper : public RandomAccessRepeatedFieldAccessor {
public:
RepeatedPtrFieldWrapper() {}
virtual ~RepeatedPtrFieldWrapper() {}
- virtual bool IsEmpty(const Field* data) const {
+ virtual bool IsEmpty(const Field* data) const override {
return GetRepeatedField(data)->empty();
}
- virtual int Size(const Field* data) const {
+ virtual int Size(const Field* data) const override {
return GetRepeatedField(data)->size();
}
virtual const Value* Get(const Field* data, int index,
- Value* scratch_space) const {
+ Value* scratch_space) const override {
return ConvertFromT(GetRepeatedField(data)->Get(index), scratch_space);
}
- virtual void Clear(Field* data) const {
+ virtual void Clear(Field* data) const override {
MutableRepeatedField(data)->Clear();
}
- virtual void Set(Field* data, int index, const Value* value) const {
+ virtual void Set(Field* data, int index, const Value* value) const override {
ConvertToT(value, MutableRepeatedField(data)->Mutable(index));
}
- virtual void Add(Field* data, const Value* value) const {
+ virtual void Add(Field* data, const Value* value) const override {
T* allocated = New(value);
ConvertToT(value, allocated);
MutableRepeatedField(data)->AddAllocated(allocated);
}
- virtual void RemoveLast(Field* data) const {
+ virtual void RemoveLast(Field* data) const override {
MutableRepeatedField(data)->RemoveLast();
}
- virtual void SwapElements(Field* data, int index1, int index2) const {
+ virtual void SwapElements(Field* data, int index1, int index2) const override {
MutableRepeatedField(data)->SwapElements(index1, index2);
}
@@ -205,38 +205,38 @@ class RepeatedPtrFieldWrapper : public RandomAccessRepeatedFieldAccessor {
class MapFieldAccessor : public RandomAccessRepeatedFieldAccessor {
public:
MapFieldAccessor() {}
- virtual ~MapFieldAccessor() {}
- virtual bool IsEmpty(const Field* data) const {
+ virtual ~MapFieldAccessor() override {}
+ virtual bool IsEmpty(const Field* data) const override {
return GetRepeatedField(data)->empty();
}
- virtual int Size(const Field* data) const {
+ virtual int Size(const Field* data) const override {
return GetRepeatedField(data)->size();
}
virtual const Value* Get(const Field* data, int index,
- Value* scratch_space) const {
+ Value* scratch_space) const override {
return ConvertFromEntry(GetRepeatedField(data)->Get(index), scratch_space);
}
- virtual void Clear(Field* data) const {
+ virtual void Clear(Field* data) const override {
MutableRepeatedField(data)->Clear();
}
- virtual void Set(Field* data, int index, const Value* value) const {
+ virtual void Set(Field* data, int index, const Value* value) const override {
ConvertToEntry(value, MutableRepeatedField(data)->Mutable(index));
}
- virtual void Add(Field* data, const Value* value) const {
+ virtual void Add(Field* data, const Value* value) const override {
Message* allocated = New(value);
ConvertToEntry(value, allocated);
MutableRepeatedField(data)->AddAllocated(allocated);
}
- virtual void RemoveLast(Field* data) const {
+ virtual void RemoveLast(Field* data) const override {
MutableRepeatedField(data)->RemoveLast();
}
- virtual void SwapElements(Field* data, int index1, int index2) const {
+ virtual void SwapElements(Field* data, int index1, int index2) const override {
MutableRepeatedField(data)->SwapElements(index1, index2);
}
virtual void Swap(
Field* data,
const internal::RepeatedFieldAccessor* other_mutator,
- Field* other_data) const {
+ Field* other_data) const override {
GOOGLE_CHECK(this == other_mutator);
MutableRepeatedField(data)->Swap(MutableRepeatedField(other_data));
}
@@ -276,11 +276,11 @@ class RepeatedFieldPrimitiveAccessor : public RepeatedFieldWrapper<T> {
public:
RepeatedFieldPrimitiveAccessor() {}
- virtual ~RepeatedFieldPrimitiveAccessor() {}
+ virtual ~RepeatedFieldPrimitiveAccessor() override {}
virtual void Swap(
Field* data,
const internal::RepeatedFieldAccessor* other_mutator,
- Field* other_data) const {
+ Field* other_data) const override {
// Currently RepeatedFieldPrimitiveAccessor is the only implementation of
// RepeatedFieldAccessor for primitive types. As we are using singletons
// for these accessors, here "other_mutator" must be "this".
@@ -289,11 +289,11 @@ class RepeatedFieldPrimitiveAccessor : public RepeatedFieldWrapper<T> {
}
protected:
- virtual T ConvertToT(const Value* value) const {
+ virtual T ConvertToT(const Value* value) const override {
return *static_cast<const T*>(value);
}
virtual const Value* ConvertFromT(const T& value,
- Value* scratch_space) const {
+ Value* scratch_space) const override {
return static_cast<const Value*>(&value);
}
};
@@ -307,11 +307,11 @@ class RepeatedPtrFieldStringAccessor : public RepeatedPtrFieldWrapper<string> {
public:
RepeatedPtrFieldStringAccessor() {}
- virtual ~RepeatedPtrFieldStringAccessor() {}
+ virtual ~RepeatedPtrFieldStringAccessor() override {}
virtual void Swap(
Field* data,
const internal::RepeatedFieldAccessor* other_mutator,
- Field* other_data) const {
+ Field* other_data) const override {
if (this == other_mutator) {
MutableRepeatedField(data)->Swap(MutableRepeatedField(other_data));
} else {
@@ -330,14 +330,14 @@ class RepeatedPtrFieldStringAccessor : public RepeatedPtrFieldWrapper<string> {
}
protected:
- virtual string* New(const Value*) const {
+ virtual string* New(const Value*) const override {
return new string();
}
- virtual void ConvertToT(const Value* value, string* result) const {
+ virtual void ConvertToT(const Value* value, string* result) const override {
*result = *static_cast<const string*>(value);
}
virtual const Value* ConvertFromT(const string& value,
- Value* scratch_space) const {
+ Value* scratch_space) const override {
return static_cast<const Value*>(&value);
}
};
@@ -350,24 +350,24 @@ class RepeatedPtrFieldMessageAccessor
public:
RepeatedPtrFieldMessageAccessor() {}
- virtual ~RepeatedPtrFieldMessageAccessor() {}
+ virtual ~RepeatedPtrFieldMessageAccessor() override {}
virtual void Swap(
Field* data,
const internal::RepeatedFieldAccessor* other_mutator,
- Field* other_data) const {
+ Field* other_data) const override {
GOOGLE_CHECK(this == other_mutator);
MutableRepeatedField(data)->Swap(MutableRepeatedField(other_data));
}
protected:
- virtual Message* New(const Value* value) const {
+ virtual Message* New(const Value* value) const override {
return static_cast<const Message*>(value)->New();
}
- virtual void ConvertToT(const Value* value, Message* result) const {
+ virtual void ConvertToT(const Value* value, Message* result) const override {
result->CopyFrom(*static_cast<const Message*>(value));
}
virtual const Value* ConvertFromT(const Message& value,
- Value* scratch_space) const {
+ Value* scratch_space) const override {
return static_cast<const Value*>(&value);
}
};
diff --git a/src/google/protobuf/repeated_field.h b/src/google/protobuf/repeated_field.h
index b47ea994..fbfbf942 100644
--- a/src/google/protobuf/repeated_field.h
+++ b/src/google/protobuf/repeated_field.h
@@ -705,13 +705,13 @@ void GenericTypeHandler<string>::Merge(const string& from,
// Declarations of the specialization as we cannot define them here, as the
// header that defines ProtocolMessage depends on types defined in this header.
#define DECLARE_SPECIALIZATIONS_FOR_BASE_PROTO_TYPES(TypeName) \
- template<> \
+ template<> LIBPROTOBUF_EXPORT \
TypeName* GenericTypeHandler<TypeName>::NewFromPrototype( \
const TypeName* prototype, google::protobuf::Arena* arena); \
- template<> \
+ template<> LIBPROTOBUF_EXPORT \
google::protobuf::Arena* GenericTypeHandler<TypeName>::GetArena( \
TypeName* value); \
- template<> \
+ template<> LIBPROTOBUF_EXPORT \
void* GenericTypeHandler<TypeName>::GetMaybeArenaPointer( \
TypeName* value);
diff --git a/src/google/protobuf/source_context.pb.cc b/src/google/protobuf/source_context.pb.cc
index 739172f8..af93e6b2 100644
--- a/src/google/protobuf/source_context.pb.cc
+++ b/src/google/protobuf/source_context.pb.cc
@@ -65,14 +65,14 @@ static ::google::protobuf::Message const * const file_default_instances[] = {
reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_SourceContext_default_instance_),
};
-void protobuf_AssignDescriptors() {
+static void protobuf_AssignDescriptors() {
AddDescriptors();
AssignDescriptors(
"google/protobuf/source_context.proto", schemas, file_default_instances, TableStruct::offsets,
file_level_metadata, NULL, NULL);
}
-void protobuf_AssignDescriptorsOnce() {
+static void protobuf_AssignDescriptorsOnce() {
static ::google::protobuf::internal::once_flag once;
::google::protobuf::internal::call_once(once, protobuf_AssignDescriptors);
}
@@ -83,7 +83,7 @@ void protobuf_RegisterTypes(const ::std::string&) {
::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 1);
}
-void AddDescriptorsImpl() {
+static void AddDescriptorsImpl() {
InitDefaults();
static const char descriptor[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
"\n$google/protobuf/source_context.proto\022\017"
diff --git a/src/google/protobuf/source_context.pb.h b/src/google/protobuf/source_context.pb.h
index 16ed21ca..eee1b73f 100644
--- a/src/google/protobuf/source_context.pb.h
+++ b/src/google/protobuf/source_context.pb.h
@@ -8,12 +8,12 @@
#include <google/protobuf/stubs/common.h>
-#if GOOGLE_PROTOBUF_VERSION < 3005000
+#if GOOGLE_PROTOBUF_VERSION < 3006000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
-#if 3005001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 3006000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
diff --git a/src/google/protobuf/struct.pb.cc b/src/google/protobuf/struct.pb.cc
index 8f2d4848..ead81689 100644
--- a/src/google/protobuf/struct.pb.cc
+++ b/src/google/protobuf/struct.pb.cc
@@ -140,14 +140,14 @@ static ::google::protobuf::Message const * const file_default_instances[] = {
reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_ListValue_default_instance_),
};
-void protobuf_AssignDescriptors() {
+static void protobuf_AssignDescriptors() {
AddDescriptors();
AssignDescriptors(
"google/protobuf/struct.proto", schemas, file_default_instances, TableStruct::offsets,
file_level_metadata, file_level_enum_descriptors, NULL);
}
-void protobuf_AssignDescriptorsOnce() {
+static void protobuf_AssignDescriptorsOnce() {
static ::google::protobuf::internal::once_flag once;
::google::protobuf::internal::call_once(once, protobuf_AssignDescriptors);
}
@@ -158,7 +158,7 @@ void protobuf_RegisterTypes(const ::std::string&) {
::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 4);
}
-void AddDescriptorsImpl() {
+static void AddDescriptorsImpl() {
InitDefaults();
static const char descriptor[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
"\n\034google/protobuf/struct.proto\022\017google.p"
@@ -277,7 +277,7 @@ void Struct::ArenaDtor(void* object) {
Struct* _this = reinterpret_cast< Struct* >(object);
(void)_this;
}
-void Struct::RegisterArenaDtor(::google::protobuf::Arena* arena) {
+void Struct::RegisterArenaDtor(::google::protobuf::Arena*) {
}
void Struct::SetCachedSize(int size) const {
_cached_size_.Set(size);
@@ -730,7 +730,7 @@ void Value::ArenaDtor(void* object) {
Value* _this = reinterpret_cast< Value* >(object);
(void)_this;
}
-void Value::RegisterArenaDtor(::google::protobuf::Arena* arena) {
+void Value::RegisterArenaDtor(::google::protobuf::Arena*) {
}
void Value::SetCachedSize(int size) const {
_cached_size_.Set(size);
@@ -810,7 +810,7 @@ bool Value::MergePartialFromCodedStream(
case 1: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(8u /* 8 & 0xFF */)) {
- int value;
+ int value = 0;
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
input, &value)));
@@ -1225,7 +1225,7 @@ void ListValue::ArenaDtor(void* object) {
ListValue* _this = reinterpret_cast< ListValue* >(object);
(void)_this;
}
-void ListValue::RegisterArenaDtor(::google::protobuf::Arena* arena) {
+void ListValue::RegisterArenaDtor(::google::protobuf::Arena*) {
}
void ListValue::SetCachedSize(int size) const {
_cached_size_.Set(size);
diff --git a/src/google/protobuf/struct.pb.h b/src/google/protobuf/struct.pb.h
index 75665ff2..b2263435 100644
--- a/src/google/protobuf/struct.pb.h
+++ b/src/google/protobuf/struct.pb.h
@@ -8,12 +8,12 @@
#include <google/protobuf/stubs/common.h>
-#if GOOGLE_PROTOBUF_VERSION < 3005000
+#if GOOGLE_PROTOBUF_VERSION < 3006000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
-#if 3005001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 3006000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
diff --git a/src/google/protobuf/stubs/bytestream.h b/src/google/protobuf/stubs/bytestream.h
index 86510d14..cfa19f29 100644
--- a/src/google/protobuf/stubs/bytestream.h
+++ b/src/google/protobuf/stubs/bytestream.h
@@ -57,7 +57,6 @@
#include <google/protobuf/stubs/stringpiece.h>
class CordByteSink;
-class MemBlock;
namespace google {
namespace protobuf {
@@ -162,7 +161,7 @@ class LIBPROTOBUF_EXPORT ByteSource {
class LIBPROTOBUF_EXPORT UncheckedArrayByteSink : public ByteSink {
public:
explicit UncheckedArrayByteSink(char* dest) : dest_(dest) {}
- virtual void Append(const char* data, size_t n);
+ virtual void Append(const char* data, size_t n) override;
// Returns the current output pointer so that a caller can see how many bytes
// were produced.
@@ -190,7 +189,7 @@ class LIBPROTOBUF_EXPORT UncheckedArrayByteSink : public ByteSink {
class LIBPROTOBUF_EXPORT CheckedArrayByteSink : public ByteSink {
public:
CheckedArrayByteSink(char* outbuf, size_t capacity);
- virtual void Append(const char* bytes, size_t n);
+ virtual void Append(const char* bytes, size_t n) override;
// Returns the number of bytes actually written to the sink.
size_t NumberOfBytesWritten() const { return size_; }
@@ -227,7 +226,7 @@ class LIBPROTOBUF_EXPORT GrowingArrayByteSink : public strings::ByteSink {
public:
explicit GrowingArrayByteSink(size_t estimated_size);
virtual ~GrowingArrayByteSink();
- virtual void Append(const char* bytes, size_t n);
+ virtual void Append(const char* bytes, size_t n) override;
// Returns the allocated buffer, and sets nbytes to its size. The caller takes
// ownership of the buffer and must delete it with delete[].
@@ -256,7 +255,7 @@ class LIBPROTOBUF_EXPORT GrowingArrayByteSink : public strings::ByteSink {
class LIBPROTOBUF_EXPORT StringByteSink : public ByteSink {
public:
explicit StringByteSink(string* dest) : dest_(dest) {}
- virtual void Append(const char* data, size_t n);
+ virtual void Append(const char* data, size_t n) override;
private:
string* dest_;
@@ -273,7 +272,7 @@ class LIBPROTOBUF_EXPORT StringByteSink : public ByteSink {
class LIBPROTOBUF_EXPORT NullByteSink : public ByteSink {
public:
NullByteSink() {}
- virtual void Append(const char *data, size_t n) {}
+ virtual void Append(const char *data, size_t n) override {}
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(NullByteSink);
@@ -296,9 +295,9 @@ class LIBPROTOBUF_EXPORT ArrayByteSource : public ByteSource {
public:
explicit ArrayByteSource(StringPiece s) : input_(s) {}
- virtual size_t Available() const;
- virtual StringPiece Peek();
- virtual void Skip(size_t n);
+ virtual size_t Available() const override;
+ virtual StringPiece Peek() override;
+ virtual void Skip(size_t n) override;
private:
StringPiece input_;
@@ -328,13 +327,13 @@ class LIBPROTOBUF_EXPORT LimitByteSource : public ByteSource {
// Returns at most "limit" bytes from "source".
LimitByteSource(ByteSource* source, size_t limit);
- virtual size_t Available() const;
- virtual StringPiece Peek();
- virtual void Skip(size_t n);
+ virtual size_t Available() const override;
+ virtual StringPiece Peek() override;
+ virtual void Skip(size_t n) override;
// We override CopyTo so that we can forward to the underlying source, in
// case it has an efficient implementation of CopyTo.
- virtual void CopyTo(ByteSink* sink, size_t n);
+ virtual void CopyTo(ByteSink* sink, size_t n) override;
private:
ByteSource* source_;
diff --git a/src/google/protobuf/stubs/callback.h b/src/google/protobuf/stubs/callback.h
index 6888f136..dae972f2 100644
--- a/src/google/protobuf/stubs/callback.h
+++ b/src/google/protobuf/stubs/callback.h
@@ -125,7 +125,7 @@ class LIBPROTOBUF_EXPORT FunctionClosure0 : public Closure {
: function_(function), self_deleting_(self_deleting) {}
~FunctionClosure0();
- void Run() {
+ void Run() override {
bool needs_delete = self_deleting_; // read in case callback deletes
function_();
if (needs_delete) delete this;
@@ -145,7 +145,7 @@ class MethodClosure0 : public Closure {
: object_(object), method_(method), self_deleting_(self_deleting) {}
~MethodClosure0() {}
- void Run() {
+ void Run() override {
bool needs_delete = self_deleting_; // read in case callback deletes
(object_->*method_)();
if (needs_delete) delete this;
@@ -168,7 +168,7 @@ class FunctionClosure1 : public Closure {
arg1_(arg1) {}
~FunctionClosure1() {}
- void Run() {
+ void Run() override {
bool needs_delete = self_deleting_; // read in case callback deletes
function_(arg1_);
if (needs_delete) delete this;
@@ -191,7 +191,7 @@ class MethodClosure1 : public Closure {
arg1_(arg1) {}
~MethodClosure1() {}
- void Run() {
+ void Run() override {
bool needs_delete = self_deleting_; // read in case callback deletes
(object_->*method_)(arg1_);
if (needs_delete) delete this;
@@ -215,7 +215,7 @@ class FunctionClosure2 : public Closure {
arg1_(arg1), arg2_(arg2) {}
~FunctionClosure2() {}
- void Run() {
+ void Run() override {
bool needs_delete = self_deleting_; // read in case callback deletes
function_(arg1_, arg2_);
if (needs_delete) delete this;
@@ -239,7 +239,7 @@ class MethodClosure2 : public Closure {
arg1_(arg1), arg2_(arg2) {}
~MethodClosure2() {}
- void Run() {
+ void Run() override {
bool needs_delete = self_deleting_; // read in case callback deletes
(object_->*method_)(arg1_, arg2_);
if (needs_delete) delete this;
@@ -262,7 +262,7 @@ class FunctionResultCallback_0_0 : public ResultCallback<R> {
: function_(function), self_deleting_(self_deleting) {}
~FunctionResultCallback_0_0() {}
- R Run() {
+ R Run() override {
bool needs_delete = self_deleting_; // read in case callback deletes
R result = function_();
if (needs_delete) delete this;
@@ -284,7 +284,7 @@ class FunctionResultCallback_1_0 : public ResultCallback<R> {
: function_(function), self_deleting_(self_deleting), p1_(p1) {}
~FunctionResultCallback_1_0() {}
- R Run() {
+ R Run() override {
bool needs_delete = self_deleting_; // read in case callback deletes
R result = function_(p1_);
if (needs_delete) delete this;
@@ -306,7 +306,7 @@ class FunctionResultCallback_0_1 : public ResultCallback1<R, Arg1> {
: function_(function), self_deleting_(self_deleting) {}
~FunctionResultCallback_0_1() {}
- R Run(Arg1 a1) {
+ R Run(Arg1 a1) override {
bool needs_delete = self_deleting_; // read in case callback deletes
R result = function_(a1);
if (needs_delete) delete this;
@@ -328,7 +328,7 @@ class FunctionResultCallback_1_1 : public ResultCallback1<R, A1> {
: function_(function), self_deleting_(self_deleting), p1_(p1) {}
~FunctionResultCallback_1_1() {}
- R Run(A1 a1) {
+ R Run(A1 a1) override {
bool needs_delete = self_deleting_; // read in case callback deletes
R result = function_(p1_, a1);
if (needs_delete) delete this;
@@ -387,7 +387,7 @@ class MethodResultCallback_5_2 : public ResultCallback2<R, A1, A2> {
p5_(p5) {}
~MethodResultCallback_5_2() {}
- R Run(A1 a1, A2 a2) {
+ R Run(A1 a1, A2 a2) override {
bool needs_delete = self_deleting_;
R result = (object_->*method_)(p1_, p2_, p3_, p4_, p5_, a1, a2);
if (needs_delete) delete this;
diff --git a/src/google/protobuf/stubs/common.cc b/src/google/protobuf/stubs/common.cc
index 33d24c57..33d24c57 100755..100644
--- a/src/google/protobuf/stubs/common.cc
+++ b/src/google/protobuf/stubs/common.cc
diff --git a/src/google/protobuf/stubs/common.h b/src/google/protobuf/stubs/common.h
index c336383d..5d320764 100644
--- a/src/google/protobuf/stubs/common.h
+++ b/src/google/protobuf/stubs/common.h
@@ -101,27 +101,27 @@ namespace internal {
// The current version, represented as a single integer to make comparison
// easier: major * 10^6 + minor * 10^3 + micro
-#define GOOGLE_PROTOBUF_VERSION 3005001
+#define GOOGLE_PROTOBUF_VERSION 3006000
// A suffix string for alpha, beta or rc releases. Empty for stable releases.
#define GOOGLE_PROTOBUF_VERSION_SUFFIX ""
// The minimum library version which works with the current version of the
// headers.
-#define GOOGLE_PROTOBUF_MIN_LIBRARY_VERSION 3005000
+#define GOOGLE_PROTOBUF_MIN_LIBRARY_VERSION 3006000
// The minimum header version which works with the current version of
// the library. This constant should only be used by protoc's C++ code
// generator.
-static const int kMinHeaderVersionForLibrary = 3005000;
+static const int kMinHeaderVersionForLibrary = 3006000;
// The minimum protoc version which works with the current version of the
// headers.
-#define GOOGLE_PROTOBUF_MIN_PROTOC_VERSION 3005000
+#define GOOGLE_PROTOBUF_MIN_PROTOC_VERSION 3006000
// The minimum header version which works with the current version of
// protoc. This constant should only be used in VerifyVersion().
-static const int kMinHeaderVersionForProtoc = 3005000;
+static const int kMinHeaderVersionForProtoc = 3006000;
// Verifies that the headers and libraries are compatible. Use the macro
// below to call this.
diff --git a/src/google/protobuf/stubs/int128.cc b/src/google/protobuf/stubs/int128.cc
index a5090801..7b993e8f 100644
--- a/src/google/protobuf/stubs/int128.cc
+++ b/src/google/protobuf/stubs/int128.cc
@@ -76,52 +76,36 @@ static inline int Fls128(uint128 n) {
return Fls64(Uint128Low64(n));
}
-// Long division/modulo for uint128 implemented using the shift-subtract
-// division algorithm adapted from:
-// http://stackoverflow.com/questions/5386377/division-without-using
void uint128::DivModImpl(uint128 dividend, uint128 divisor,
uint128* quotient_ret, uint128* remainder_ret) {
if (divisor == 0) {
GOOGLE_LOG(FATAL) << "Division or mod by zero: dividend.hi=" << dividend.hi_
<< ", lo=" << dividend.lo_;
- }
-
- if (divisor > dividend) {
+ } else if (dividend < divisor) {
*quotient_ret = 0;
*remainder_ret = dividend;
return;
- }
-
- if (divisor == dividend) {
- *quotient_ret = 1;
- *remainder_ret = 0;
- return;
- }
-
- uint128 denominator = divisor;
- uint128 position = 1;
- uint128 quotient = 0;
-
- // Left aligns the MSB of the denominator and the dividend.
- int shift = Fls128(dividend) - Fls128(denominator);
- denominator <<= shift;
- position <<= shift;
-
- // Uses shift-subtract algorithm to divide dividend by denominator. The
- // remainder will be left in dividend.
- while (position > 0) {
- if (dividend >= denominator) {
- dividend -= denominator;
- quotient |= position;
+ } else {
+ int dividend_bit_length = Fls128(dividend);
+ int divisor_bit_length = Fls128(divisor);
+ int difference = dividend_bit_length - divisor_bit_length;
+ uint128 quotient = 0;
+ while (difference >= 0) {
+ quotient <<= 1;
+ uint128 shifted_divisor = divisor << difference;
+ if (shifted_divisor <= dividend) {
+ dividend -= shifted_divisor;
+ quotient += 1;
+ }
+ difference -= 1;
}
- position >>= 1;
- denominator >>= 1;
+ //record the final quotient and remainder
+ *quotient_ret = quotient;
+ *remainder_ret = dividend;
}
-
- *quotient_ret = quotient;
- *remainder_ret = dividend;
}
+
uint128& uint128::operator/=(const uint128& divisor) {
uint128 quotient = 0;
uint128 remainder = 0;
diff --git a/src/google/protobuf/stubs/mutex.h b/src/google/protobuf/stubs/mutex.h
index b9b7d2e1..47edb7a3 100644
--- a/src/google/protobuf/stubs/mutex.h
+++ b/src/google/protobuf/stubs/mutex.h
@@ -34,6 +34,18 @@
#include <google/protobuf/stubs/macros.h>
+// Define thread-safety annotations for use below, if we are building with
+// Clang.
+#if defined(__clang__) && !defined(SWIG)
+#define GOOGLE_PROTOBUF_ACQUIRE(...) \
+ __attribute__((acquire_capability(__VA_ARGS__)))
+#define GOOGLE_PROTOBUF_RELEASE(...) \
+ __attribute__((release_capability(__VA_ARGS__)))
+#else
+#define GOOGLE_PROTOBUF_ACQUIRE(...)
+#define GOOGLE_PROTOBUF_RELEASE(...)
+#endif
+
// ===================================================================
// emulates google3/base/mutex.h
namespace google {
@@ -48,8 +60,8 @@ namespace internal {
class LIBPROTOBUF_EXPORT WrappedMutex {
public:
WrappedMutex() = default;
- void Lock() { mu_.lock(); }
- void Unlock() { mu_.unlock(); }
+ void Lock() GOOGLE_PROTOBUF_ACQUIRE() { mu_.lock(); }
+ void Unlock() GOOGLE_PROTOBUF_RELEASE() { mu_.unlock(); }
// Crash if this Mutex is not held exclusively by this thread.
// May fail to crash when it should; will never crash when it should not.
void AssertHeld() const {}
@@ -123,8 +135,10 @@ using internal::ReaderMutexLock;
using internal::WriterMutexLock;
using internal::MutexLockMaybe;
-
} // namespace protobuf
} // namespace google
+#undef GOOGLE_PROTOBUF_ACQUIRE
+#undef GOOGLE_PROTOBUF_RELEASE
+
#endif // GOOGLE_PROTOBUF_STUBS_MUTEX_H_
diff --git a/src/google/protobuf/stubs/platform_macros.h b/src/google/protobuf/stubs/platform_macros.h
index c3a64dd2..ce1b1e36 100644
--- a/src/google/protobuf/stubs/platform_macros.h
+++ b/src/google/protobuf/stubs/platform_macros.h
@@ -56,7 +56,7 @@
#elif defined(__aarch64__)
#define GOOGLE_PROTOBUF_ARCH_AARCH64 1
#define GOOGLE_PROTOBUF_ARCH_64_BIT 1
-#elif defined(__MIPSEL__)
+#elif defined(__mips__)
#if defined(__LP64__)
#define GOOGLE_PROTOBUF_ARCH_MIPS64 1
#define GOOGLE_PROTOBUF_ARCH_64_BIT 1
@@ -99,6 +99,7 @@ GOOGLE_PROTOBUF_PLATFORM_ERROR
#if defined(__APPLE__)
#define GOOGLE_PROTOBUF_OS_APPLE
+#include <Availability.h>
#include <TargetConditionals.h>
#if TARGET_OS_IPHONE
#define GOOGLE_PROTOBUF_OS_IPHONE
@@ -125,4 +126,9 @@ GOOGLE_PROTOBUF_PLATFORM_ERROR
#define GOOGLE_PROTOBUF_NO_THREADLOCAL
#endif
+#if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 1070
+// __thread keyword requires at least 10.7
+#define GOOGLE_PROTOBUF_NO_THREADLOCAL
+#endif
+
#endif // GOOGLE_PROTOBUF_PLATFORM_MACROS_H_
diff --git a/src/google/protobuf/stubs/port.h b/src/google/protobuf/stubs/port.h
index 6b52305f..3aa6403b 100644
--- a/src/google/protobuf/stubs/port.h
+++ b/src/google/protobuf/stubs/port.h
@@ -382,10 +382,14 @@ inline void GOOGLE_UNALIGNED_STORE64(void *p, uint64 v) {
#elif !defined(__GLIBC__) && !defined(__BIONIC__) && !defined(__CYGWIN__)
+#ifndef bswap_16
static inline uint16 bswap_16(uint16 x) {
return static_cast<uint16>(((x & 0xFF) << 8) | ((x & 0xFF00) >> 8));
}
#define bswap_16(x) bswap_16(x)
+#endif
+
+#ifndef bswap_32
static inline uint32 bswap_32(uint32 x) {
return (((x & 0xFF) << 24) |
((x & 0xFF00) << 8) |
@@ -393,6 +397,9 @@ static inline uint32 bswap_32(uint32 x) {
((x & 0xFF000000) >> 24));
}
#define bswap_32(x) bswap_32(x)
+#endif
+
+#ifndef bswap_64
static inline uint64 bswap_64(uint64 x) {
return (((x & GOOGLE_ULONGLONG(0xFF)) << 56) |
((x & GOOGLE_ULONGLONG(0xFF00)) << 40) |
@@ -404,6 +411,7 @@ static inline uint64 bswap_64(uint64 x) {
((x & GOOGLE_ULONGLONG(0xFF00000000000000)) >> 56));
}
#define bswap_64(x) bswap_64(x)
+#endif
#endif
diff --git a/src/google/protobuf/text_format.cc b/src/google/protobuf/text_format.cc
index 0965fd7a..a9c062eb 100644
--- a/src/google/protobuf/text_format.cc
+++ b/src/google/protobuf/text_format.cc
@@ -1138,13 +1138,13 @@ label_skip_parsing:
explicit ParserErrorCollector(TextFormat::Parser::ParserImpl* parser) :
parser_(parser) { }
- virtual ~ParserErrorCollector() { }
+ ~ParserErrorCollector() override { }
- virtual void AddError(int line, int column, const string& message) {
+ void AddError(int line, int column, const string& message) override {
parser_->ReportError(line, column, message);
}
- virtual void AddWarning(int line, int column, const string& message) {
+ void AddWarning(int line, int column, const string& message) override {
parser_->ReportWarning(line, column, message);
}
@@ -1444,7 +1444,7 @@ namespace {
// A BaseTextGenerator that writes to a string.
class StringBaseTextGenerator : public TextFormat::BaseTextGenerator {
public:
- void Print(const char* text, size_t size) { output_.append(text, size); }
+ void Print(const char* text, size_t size) override { output_.append(text, size); }
// Some compilers do not support ref-qualifiers even in C++11 mode.
// Disable the optimization for now and revisit it later.
@@ -1642,37 +1642,37 @@ class FieldValuePrinterWrapper : public TextFormat::FastFieldValuePrinter {
delegate_.reset(delegate);
}
- void PrintBool(bool val, TextFormat::BaseTextGenerator* generator) const {
+ void PrintBool(bool val, TextFormat::BaseTextGenerator* generator) const override {
generator->PrintString(delegate_->PrintBool(val));
}
- void PrintInt32(int32 val, TextFormat::BaseTextGenerator* generator) const {
+ void PrintInt32(int32 val, TextFormat::BaseTextGenerator* generator) const override {
generator->PrintString(delegate_->PrintInt32(val));
}
- void PrintUInt32(uint32 val, TextFormat::BaseTextGenerator* generator) const {
+ void PrintUInt32(uint32 val, TextFormat::BaseTextGenerator* generator) const override {
generator->PrintString(delegate_->PrintUInt32(val));
}
- void PrintInt64(int64 val, TextFormat::BaseTextGenerator* generator) const {
+ void PrintInt64(int64 val, TextFormat::BaseTextGenerator* generator) const override {
generator->PrintString(delegate_->PrintInt64(val));
}
- void PrintUInt64(uint64 val, TextFormat::BaseTextGenerator* generator) const {
+ void PrintUInt64(uint64 val, TextFormat::BaseTextGenerator* generator) const override {
generator->PrintString(delegate_->PrintUInt64(val));
}
- void PrintFloat(float val, TextFormat::BaseTextGenerator* generator) const {
+ void PrintFloat(float val, TextFormat::BaseTextGenerator* generator) const override {
generator->PrintString(delegate_->PrintFloat(val));
}
- void PrintDouble(double val, TextFormat::BaseTextGenerator* generator) const {
+ void PrintDouble(double val, TextFormat::BaseTextGenerator* generator) const override {
generator->PrintString(delegate_->PrintDouble(val));
}
void PrintString(const string& val,
- TextFormat::BaseTextGenerator* generator) const {
+ TextFormat::BaseTextGenerator* generator) const override {
generator->PrintString(delegate_->PrintString(val));
}
void PrintBytes(const string& val,
- TextFormat::BaseTextGenerator* generator) const {
+ TextFormat::BaseTextGenerator* generator) const override {
generator->PrintString(delegate_->PrintBytes(val));
}
void PrintEnum(int32 val, const string& name,
- TextFormat::BaseTextGenerator* generator) const {
+ TextFormat::BaseTextGenerator* generator) const override {
generator->PrintString(delegate_->PrintEnum(val, name));
}
void PrintFieldName(const Message& message, int field_index, int field_count,
@@ -1684,19 +1684,19 @@ class FieldValuePrinterWrapper : public TextFormat::FastFieldValuePrinter {
}
void PrintFieldName(const Message& message, const Reflection* reflection,
const FieldDescriptor* field,
- TextFormat::BaseTextGenerator* generator) const {
+ TextFormat::BaseTextGenerator* generator) const override {
generator->PrintString(
delegate_->PrintFieldName(message, reflection, field));
}
void PrintMessageStart(const Message& message, int field_index,
int field_count, bool single_line_mode,
- TextFormat::BaseTextGenerator* generator) const {
+ TextFormat::BaseTextGenerator* generator) const override {
generator->PrintString(delegate_->PrintMessageStart(
message, field_index, field_count, single_line_mode));
}
void PrintMessageEnd(const Message& message, int field_index, int field_count,
bool single_line_mode,
- TextFormat::BaseTextGenerator* generator) const {
+ TextFormat::BaseTextGenerator* generator) const override {
generator->PrintString(delegate_->PrintMessageEnd(
message, field_index, field_count, single_line_mode));
}
@@ -1710,13 +1710,13 @@ class FastFieldValuePrinterUtf8Escaping
: public TextFormat::FastFieldValuePrinter {
public:
void PrintString(const string& val,
- TextFormat::BaseTextGenerator* generator) const {
+ TextFormat::BaseTextGenerator* generator) const override {
generator->PrintLiteral("\"");
generator->PrintString(strings::Utf8SafeCEscape(val));
generator->PrintLiteral("\"");
}
void PrintBytes(const string& val,
- TextFormat::BaseTextGenerator* generator) const {
+ TextFormat::BaseTextGenerator* generator) const override {
return FastFieldValuePrinter::PrintString(val, generator);
}
};
diff --git a/src/google/protobuf/text_format_unittest.cc b/src/google/protobuf/text_format_unittest.cc
index 544c37e2..53184130 100644
--- a/src/google/protobuf/text_format_unittest.cc
+++ b/src/google/protobuf/text_format_unittest.cc
@@ -574,6 +574,11 @@ class CompactRepeatedFieldPrinter : public TextFormat::FastFieldValuePrinter {
generator->PrintString(field->name());
}
}
+ // To prevent compiler complaining about Woverloaded-virtual
+ void PrintFieldName(const Message& message,
+ const Reflection* reflection,
+ const FieldDescriptor* field,
+ TextFormat::BaseTextGenerator* generator) const override {}
void PrintMessageStart(
const Message& message, int field_index, int field_count,
bool single_line_mode,
diff --git a/src/google/protobuf/timestamp.pb.cc b/src/google/protobuf/timestamp.pb.cc
index 8e6b5f23..4269031f 100644
--- a/src/google/protobuf/timestamp.pb.cc
+++ b/src/google/protobuf/timestamp.pb.cc
@@ -66,14 +66,14 @@ static ::google::protobuf::Message const * const file_default_instances[] = {
reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_Timestamp_default_instance_),
};
-void protobuf_AssignDescriptors() {
+static void protobuf_AssignDescriptors() {
AddDescriptors();
AssignDescriptors(
"google/protobuf/timestamp.proto", schemas, file_default_instances, TableStruct::offsets,
file_level_metadata, NULL, NULL);
}
-void protobuf_AssignDescriptorsOnce() {
+static void protobuf_AssignDescriptorsOnce() {
static ::google::protobuf::internal::once_flag once;
::google::protobuf::internal::call_once(once, protobuf_AssignDescriptors);
}
@@ -84,7 +84,7 @@ void protobuf_RegisterTypes(const ::std::string&) {
::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 1);
}
-void AddDescriptorsImpl() {
+static void AddDescriptorsImpl() {
InitDefaults();
static const char descriptor[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
"\n\037google/protobuf/timestamp.proto\022\017googl"
@@ -167,7 +167,7 @@ void Timestamp::ArenaDtor(void* object) {
Timestamp* _this = reinterpret_cast< Timestamp* >(object);
(void)_this;
}
-void Timestamp::RegisterArenaDtor(::google::protobuf::Arena* arena) {
+void Timestamp::RegisterArenaDtor(::google::protobuf::Arena*) {
}
void Timestamp::SetCachedSize(int size) const {
_cached_size_.Set(size);
diff --git a/src/google/protobuf/timestamp.pb.h b/src/google/protobuf/timestamp.pb.h
index f73e75b3..daea80f6 100644
--- a/src/google/protobuf/timestamp.pb.h
+++ b/src/google/protobuf/timestamp.pb.h
@@ -8,12 +8,12 @@
#include <google/protobuf/stubs/common.h>
-#if GOOGLE_PROTOBUF_VERSION < 3005000
+#if GOOGLE_PROTOBUF_VERSION < 3006000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
-#if 3005001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 3006000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
diff --git a/src/google/protobuf/type.pb.cc b/src/google/protobuf/type.pb.cc
index 130af52a..72679df8 100644
--- a/src/google/protobuf/type.pb.cc
+++ b/src/google/protobuf/type.pb.cc
@@ -219,14 +219,14 @@ static ::google::protobuf::Message const * const file_default_instances[] = {
reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_Option_default_instance_),
};
-void protobuf_AssignDescriptors() {
+static void protobuf_AssignDescriptors() {
AddDescriptors();
AssignDescriptors(
"google/protobuf/type.proto", schemas, file_default_instances, TableStruct::offsets,
file_level_metadata, file_level_enum_descriptors, NULL);
}
-void protobuf_AssignDescriptorsOnce() {
+static void protobuf_AssignDescriptorsOnce() {
static ::google::protobuf::internal::once_flag once;
::google::protobuf::internal::call_once(once, protobuf_AssignDescriptors);
}
@@ -237,7 +237,7 @@ void protobuf_RegisterTypes(const ::std::string&) {
::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 5);
}
-void AddDescriptorsImpl() {
+static void AddDescriptorsImpl() {
InitDefaults();
static const char descriptor[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
"\n\032google/protobuf/type.proto\022\017google.pro"
@@ -492,7 +492,7 @@ void Type::ArenaDtor(void* object) {
Type* _this = reinterpret_cast< Type* >(object);
(void)_this;
}
-void Type::RegisterArenaDtor(::google::protobuf::Arena* arena) {
+void Type::RegisterArenaDtor(::google::protobuf::Arena*) {
}
void Type::SetCachedSize(int size) const {
_cached_size_.Set(size);
@@ -609,7 +609,7 @@ bool Type::MergePartialFromCodedStream(
case 6: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(48u /* 48 & 0xFF */)) {
- int value;
+ int value = 0;
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
input, &value)));
@@ -1014,7 +1014,7 @@ void Field::ArenaDtor(void* object) {
Field* _this = reinterpret_cast< Field* >(object);
(void)_this;
}
-void Field::RegisterArenaDtor(::google::protobuf::Arena* arena) {
+void Field::RegisterArenaDtor(::google::protobuf::Arena*) {
}
void Field::SetCachedSize(int size) const {
_cached_size_.Set(size);
@@ -1061,7 +1061,7 @@ bool Field::MergePartialFromCodedStream(
case 1: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(8u /* 8 & 0xFF */)) {
- int value;
+ int value = 0;
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
input, &value)));
@@ -1076,7 +1076,7 @@ bool Field::MergePartialFromCodedStream(
case 2: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(16u /* 16 & 0xFF */)) {
- int value;
+ int value = 0;
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
input, &value)));
@@ -1698,7 +1698,7 @@ void Enum::ArenaDtor(void* object) {
Enum* _this = reinterpret_cast< Enum* >(object);
(void)_this;
}
-void Enum::RegisterArenaDtor(::google::protobuf::Arena* arena) {
+void Enum::RegisterArenaDtor(::google::protobuf::Arena*) {
}
void Enum::SetCachedSize(int size) const {
_cached_size_.Set(size);
@@ -1797,7 +1797,7 @@ bool Enum::MergePartialFromCodedStream(
case 5: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(40u /* 40 & 0xFF */)) {
- int value;
+ int value = 0;
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
input, &value)));
@@ -2140,7 +2140,7 @@ void EnumValue::ArenaDtor(void* object) {
EnumValue* _this = reinterpret_cast< EnumValue* >(object);
(void)_this;
}
-void EnumValue::RegisterArenaDtor(::google::protobuf::Arena* arena) {
+void EnumValue::RegisterArenaDtor(::google::protobuf::Arena*) {
}
void EnumValue::SetCachedSize(int size) const {
_cached_size_.Set(size);
@@ -2520,7 +2520,7 @@ void Option::ArenaDtor(void* object) {
Option* _this = reinterpret_cast< Option* >(object);
(void)_this;
}
-void Option::RegisterArenaDtor(::google::protobuf::Arena* arena) {
+void Option::RegisterArenaDtor(::google::protobuf::Arena*) {
}
void Option::SetCachedSize(int size) const {
_cached_size_.Set(size);
diff --git a/src/google/protobuf/type.pb.h b/src/google/protobuf/type.pb.h
index 69af6c2e..cbd0cdcc 100644
--- a/src/google/protobuf/type.pb.h
+++ b/src/google/protobuf/type.pb.h
@@ -8,12 +8,12 @@
#include <google/protobuf/stubs/common.h>
-#if GOOGLE_PROTOBUF_VERSION < 3005000
+#if GOOGLE_PROTOBUF_VERSION < 3006000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
-#if 3005001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 3006000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
diff --git a/src/google/protobuf/util/field_comparator.h b/src/google/protobuf/util/field_comparator.h
index 27ef4c77..63e89fb7 100644
--- a/src/google/protobuf/util/field_comparator.h
+++ b/src/google/protobuf/util/field_comparator.h
@@ -110,14 +110,14 @@ class LIBPROTOBUF_EXPORT DefaultFieldComparator : public FieldComparator {
// Creates new comparator with float comparison set to EXACT.
DefaultFieldComparator();
- virtual ~DefaultFieldComparator();
+ ~DefaultFieldComparator() override;
- virtual ComparisonResult Compare(
+ ComparisonResult Compare(
const google::protobuf::Message& message_1,
const google::protobuf::Message& message_2,
const google::protobuf::FieldDescriptor* field,
int index_1, int index_2,
- const google::protobuf::util::FieldContext* field_context);
+ const google::protobuf::util::FieldContext* field_context) override;
void set_float_comparison(FloatComparison float_comparison) {
float_comparison_ = float_comparison;
diff --git a/src/google/protobuf/util/internal/default_value_objectwriter.h b/src/google/protobuf/util/internal/default_value_objectwriter.h
index 6e71f9c8..7d245c9c 100644
--- a/src/google/protobuf/util/internal/default_value_objectwriter.h
+++ b/src/google/protobuf/util/internal/default_value_objectwriter.h
@@ -83,37 +83,37 @@ class LIBPROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter {
virtual ~DefaultValueObjectWriter();
// ObjectWriter methods.
- virtual DefaultValueObjectWriter* StartObject(StringPiece name);
+ virtual DefaultValueObjectWriter* StartObject(StringPiece name) override;
- virtual DefaultValueObjectWriter* EndObject();
+ virtual DefaultValueObjectWriter* EndObject() override;
- virtual DefaultValueObjectWriter* StartList(StringPiece name);
+ virtual DefaultValueObjectWriter* StartList(StringPiece name) override;
- virtual DefaultValueObjectWriter* EndList();
+ virtual DefaultValueObjectWriter* EndList() override;
- virtual DefaultValueObjectWriter* RenderBool(StringPiece name, bool value);
+ virtual DefaultValueObjectWriter* RenderBool(StringPiece name, bool value) override;
- virtual DefaultValueObjectWriter* RenderInt32(StringPiece name, int32 value);
+ virtual DefaultValueObjectWriter* RenderInt32(StringPiece name, int32 value) override;
virtual DefaultValueObjectWriter* RenderUint32(StringPiece name,
- uint32 value);
+ uint32 value) override;
- virtual DefaultValueObjectWriter* RenderInt64(StringPiece name, int64 value);
+ virtual DefaultValueObjectWriter* RenderInt64(StringPiece name, int64 value) override;
virtual DefaultValueObjectWriter* RenderUint64(StringPiece name,
- uint64 value);
+ uint64 value) override;
virtual DefaultValueObjectWriter* RenderDouble(StringPiece name,
- double value);
+ double value) override;
- virtual DefaultValueObjectWriter* RenderFloat(StringPiece name, float value);
+ virtual DefaultValueObjectWriter* RenderFloat(StringPiece name, float value) override;
virtual DefaultValueObjectWriter* RenderString(StringPiece name,
- StringPiece value);
+ StringPiece value) override;
virtual DefaultValueObjectWriter* RenderBytes(StringPiece name,
- StringPiece value);
+ StringPiece value) override;
- virtual DefaultValueObjectWriter* RenderNull(StringPiece name);
+ virtual DefaultValueObjectWriter* RenderNull(StringPiece name) override;
// Register the callback for scrubbing of fields. Owership of
// field_scrub_callback pointer is also transferred to this class
diff --git a/src/google/protobuf/util/internal/error_listener.h b/src/google/protobuf/util/internal/error_listener.h
index a19bd3f7..e3baa224 100644
--- a/src/google/protobuf/util/internal/error_listener.h
+++ b/src/google/protobuf/util/internal/error_listener.h
@@ -76,16 +76,16 @@ class LIBPROTOBUF_EXPORT ErrorListener {
class LIBPROTOBUF_EXPORT NoopErrorListener : public ErrorListener {
public:
NoopErrorListener() {}
- virtual ~NoopErrorListener() {}
+ virtual ~NoopErrorListener() override {}
virtual void InvalidName(const LocationTrackerInterface& loc,
- StringPiece invalid_name, StringPiece message) {}
+ StringPiece invalid_name, StringPiece message) override {}
- virtual void InvalidValue(const LocationTrackerInterface& loc,
- StringPiece type_name, StringPiece value) {}
+ virtual void InvalidValue(const LocationTrackerInterface &loc, StringPiece type_name,
+ StringPiece value) override {}
- virtual void MissingField(const LocationTrackerInterface& loc,
- StringPiece missing_name) {}
+ virtual void MissingField(const LocationTrackerInterface &loc,
+ StringPiece missing_name) override {}
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(NoopErrorListener);
diff --git a/src/google/protobuf/util/internal/json_objectwriter.h b/src/google/protobuf/util/internal/json_objectwriter.h
index 81644dab..4c25b465 100644
--- a/src/google/protobuf/util/internal/json_objectwriter.h
+++ b/src/google/protobuf/util/internal/json_objectwriter.h
@@ -94,20 +94,20 @@ class LIBPROTOBUF_EXPORT JsonObjectWriter : public StructuredObjectWriter {
virtual ~JsonObjectWriter();
// ObjectWriter methods.
- virtual JsonObjectWriter* StartObject(StringPiece name);
- virtual JsonObjectWriter* EndObject();
- virtual JsonObjectWriter* StartList(StringPiece name);
- virtual JsonObjectWriter* EndList();
- virtual JsonObjectWriter* RenderBool(StringPiece name, bool value);
- virtual JsonObjectWriter* RenderInt32(StringPiece name, int32 value);
- virtual JsonObjectWriter* RenderUint32(StringPiece name, uint32 value);
- virtual JsonObjectWriter* RenderInt64(StringPiece name, int64 value);
- virtual JsonObjectWriter* RenderUint64(StringPiece name, uint64 value);
- virtual JsonObjectWriter* RenderDouble(StringPiece name, double value);
- virtual JsonObjectWriter* RenderFloat(StringPiece name, float value);
- virtual JsonObjectWriter* RenderString(StringPiece name, StringPiece value);
- virtual JsonObjectWriter* RenderBytes(StringPiece name, StringPiece value);
- virtual JsonObjectWriter* RenderNull(StringPiece name);
+ virtual JsonObjectWriter* StartObject(StringPiece name) override;
+ virtual JsonObjectWriter* EndObject() override;
+ virtual JsonObjectWriter* StartList(StringPiece name) override;
+ virtual JsonObjectWriter* EndList() override;
+ virtual JsonObjectWriter* RenderBool(StringPiece name, bool value) override;
+ virtual JsonObjectWriter* RenderInt32(StringPiece name, int32 value) override;
+ virtual JsonObjectWriter* RenderUint32(StringPiece name, uint32 value) override;
+ virtual JsonObjectWriter* RenderInt64(StringPiece name, int64 value) override;
+ virtual JsonObjectWriter* RenderUint64(StringPiece name, uint64 value) override;
+ virtual JsonObjectWriter* RenderDouble(StringPiece name, double value) override;
+ virtual JsonObjectWriter* RenderFloat(StringPiece name, float value) override;
+ virtual JsonObjectWriter* RenderString(StringPiece name, StringPiece value) override;
+ virtual JsonObjectWriter* RenderBytes(StringPiece name, StringPiece value) override;
+ virtual JsonObjectWriter* RenderNull(StringPiece name) override;
virtual JsonObjectWriter* RenderNullAsEmpty(StringPiece name);
void set_use_websafe_base64_for_bytes(bool value) {
@@ -143,17 +143,17 @@ class LIBPROTOBUF_EXPORT JsonObjectWriter : public StructuredObjectWriter {
GOOGLE_DISALLOW_IMPLICIT_CONSTRUCTORS(Element);
};
- virtual Element* element() { return element_.get(); }
+ Element* element() override { return element_.get(); }
private:
class LIBPROTOBUF_EXPORT ByteSinkWrapper : public strings::ByteSink {
public:
explicit ByteSinkWrapper(google::protobuf::io::CodedOutputStream* stream)
: stream_(stream) {}
- virtual ~ByteSinkWrapper() {}
+ ~ByteSinkWrapper() override {}
// ByteSink methods.
- virtual void Append(const char* bytes, size_t n) {
+ void Append(const char* bytes, size_t n) override {
stream_->WriteRaw(bytes, n);
}
diff --git a/src/google/protobuf/util/internal/object_location_tracker.h b/src/google/protobuf/util/internal/object_location_tracker.h
index 8586cecc..f9b90bc4 100644
--- a/src/google/protobuf/util/internal/object_location_tracker.h
+++ b/src/google/protobuf/util/internal/object_location_tracker.h
@@ -47,10 +47,10 @@ class ObjectLocationTracker : public LocationTrackerInterface {
// Creates an empty location tracker.
ObjectLocationTracker() {}
- virtual ~ObjectLocationTracker() {}
+ ~ObjectLocationTracker() override {}
// Returns empty because nothing is tracked.
- virtual string ToString() const { return ""; }
+ string ToString() const override { return ""; }
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ObjectLocationTracker);
diff --git a/src/google/protobuf/util/internal/proto_writer.h b/src/google/protobuf/util/internal/proto_writer.h
index 28496963..5bdafcc9 100644
--- a/src/google/protobuf/util/internal/proto_writer.h
+++ b/src/google/protobuf/util/internal/proto_writer.h
@@ -78,7 +78,7 @@ class LIBPROTOBUF_EXPORT ProtoWriter : public StructuredObjectWriter {
// Constructor. Does not take ownership of any parameter passed in.
ProtoWriter(TypeResolver* type_resolver, const google::protobuf::Type& type,
strings::ByteSink* output, ErrorListener* listener);
- virtual ~ProtoWriter();
+ virtual ~ProtoWriter() override;
// ObjectWriter methods.
ProtoWriter* StartObject(StringPiece name) override;
@@ -110,7 +110,7 @@ class LIBPROTOBUF_EXPORT ProtoWriter : public StructuredObjectWriter {
return RenderDataPiece(name,
DataPiece(value, use_strict_base64_decoding()));
}
- virtual ProtoWriter* RenderBytes(StringPiece name, StringPiece value) {
+ ProtoWriter* RenderBytes(StringPiece name, StringPiece value) override {
return RenderDataPiece(
name, DataPiece(value, false, use_strict_base64_decoding()));
}
@@ -163,7 +163,7 @@ class LIBPROTOBUF_EXPORT ProtoWriter : public StructuredObjectWriter {
ProtoElement(ProtoElement* parent, const google::protobuf::Field* field,
const google::protobuf::Type& type, bool is_list);
- virtual ~ProtoElement() {}
+ virtual ~ProtoElement() override {}
// Called just before the destructor for clean up:
// - reports any missing required fields
@@ -183,9 +183,9 @@ class LIBPROTOBUF_EXPORT ProtoWriter : public StructuredObjectWriter {
void RegisterField(const google::protobuf::Field* field);
// To report location on error messages.
- virtual string ToString() const;
+ virtual string ToString() const override;
- virtual ProtoElement* parent() const {
+ virtual ProtoElement* parent() const override {
return static_cast<ProtoElement*>(BaseElement::parent());
}
diff --git a/src/google/protobuf/util/internal/protostream_objectsource.cc b/src/google/protobuf/util/internal/protostream_objectsource.cc
index 56e6db12..b0d86c17 100644
--- a/src/google/protobuf/util/internal/protostream_objectsource.cc
+++ b/src/google/protobuf/util/internal/protostream_objectsource.cc
@@ -648,6 +648,13 @@ Status ProtoStreamObjectSource::RenderAny(const ProtoStreamObjectSource* os,
// using a nested ProtoStreamObjectSource using our nested type information.
ProtoStreamObjectSource nested_os(&in_stream, os->typeinfo_, *nested_type);
+ // TODO(htuch): This is somewhat fragile, since new options may be omitted.
+ // We should probably do this via the constructor or some object grouping
+ // options.
+ nested_os.set_use_lower_camel_for_enums(os->use_lower_camel_for_enums_);
+ nested_os.set_use_ints_for_enums(os->use_ints_for_enums_);
+ nested_os.set_preserve_proto_field_names(os->preserve_proto_field_names_);
+
// We manually call start and end object here so we can inject the @type.
ow->StartObject(field_name);
ow->RenderString("@type", type_url);
diff --git a/src/google/protobuf/util/internal/protostream_objectsource.h b/src/google/protobuf/util/internal/protostream_objectsource.h
index b56efdf4..acd081d9 100644
--- a/src/google/protobuf/util/internal/protostream_objectsource.h
+++ b/src/google/protobuf/util/internal/protostream_objectsource.h
@@ -78,9 +78,9 @@ class LIBPROTOBUF_EXPORT ProtoStreamObjectSource : public ObjectSource {
TypeResolver* type_resolver,
const google::protobuf::Type& type);
- virtual ~ProtoStreamObjectSource();
+ virtual ~ProtoStreamObjectSource() override;
- virtual util::Status NamedWriteTo(StringPiece name, ObjectWriter* ow) const;
+ virtual util::Status NamedWriteTo(StringPiece name, ObjectWriter* ow) const override;
// Sets whether or not to use lowerCamelCase casing for enum values. If set to
// false, enum values are output without any case conversions.
diff --git a/src/google/protobuf/util/internal/protostream_objectsource_test.cc b/src/google/protobuf/util/internal/protostream_objectsource_test.cc
index df790728..4d86b856 100644
--- a/src/google/protobuf/util/internal/protostream_objectsource_test.cc
+++ b/src/google/protobuf/util/internal/protostream_objectsource_test.cc
@@ -100,6 +100,7 @@ class ProtostreamObjectSourceTest
ow_(&mock_),
use_lower_camel_for_enums_(false),
use_ints_for_enums_(false),
+ use_preserve_proto_field_names_(false),
add_trailing_zeros_(false),
render_unknown_enum_values_(true) {
helper_.ResetTypeInfo(Book::descriptor(), Proto3Message::descriptor());
@@ -123,6 +124,7 @@ class ProtostreamObjectSourceTest
helper_.NewProtoSource(&in_stream, GetTypeUrl(descriptor)));
if (use_lower_camel_for_enums_) os->set_use_lower_camel_for_enums(true);
if (use_ints_for_enums_) os->set_use_ints_for_enums(true);
+ if (use_preserve_proto_field_names_) os->set_preserve_proto_field_names(true);
os->set_max_recursion_depth(64);
return os->WriteTo(&mock_);
}
@@ -272,6 +274,8 @@ class ProtostreamObjectSourceTest
void UseIntsForEnums() { use_ints_for_enums_ = true; }
+ void UsePreserveProtoFieldNames() { use_preserve_proto_field_names_ = true; }
+
void AddTrailingZeros() { add_trailing_zeros_ = true; }
void SetRenderUnknownEnumValues(bool value) {
@@ -284,6 +288,7 @@ class ProtostreamObjectSourceTest
ExpectingObjectWriter ow_;
bool use_lower_camel_for_enums_;
bool use_ints_for_enums_;
+ bool use_preserve_proto_field_names_;
bool add_trailing_zeros_;
bool render_unknown_enum_values_;
};
@@ -536,6 +541,16 @@ TEST_P(ProtostreamObjectSourceTest, UseIntsForEnumsTest) {
DoTest(book, Book::descriptor());
}
+TEST_P(ProtostreamObjectSourceTest, UsePreserveProtoFieldNames) {
+ Book book;
+ book.set_snake_field("foo");
+
+ UsePreserveProtoFieldNames();
+
+ ow_.StartObject("")->RenderString("snake_field", "foo")->EndObject();
+ DoTest(book, Book::descriptor());
+}
+
TEST_P(ProtostreamObjectSourceTest,
UnknownEnumAreDroppedWhenRenderUnknownEnumValuesIsUnset) {
Proto3Message message;
@@ -769,6 +784,69 @@ TEST_P(ProtostreamObjectSourceAnysTest, BasicAny) {
DoTest(out, AnyOut::descriptor());
}
+TEST_P(ProtostreamObjectSourceAnysTest, LowerCamelEnumOutputSnakeCase) {
+ AnyOut out;
+ ::google::protobuf::Any* any = out.mutable_any();
+
+ Book book;
+ book.set_type(Book::arts_and_photography);
+ any->PackFrom(book);
+
+ UseLowerCamelForEnums();
+
+ ow_.StartObject("")
+ ->StartObject("any")
+ ->RenderString("@type",
+ "type.googleapis.com/google.protobuf.testing.Book")
+ ->RenderString("type", "artsAndPhotography")
+ ->EndObject()
+ ->EndObject();
+
+ DoTest(out, AnyOut::descriptor());
+}
+
+TEST_P(ProtostreamObjectSourceAnysTest, UseIntsForEnumsTest) {
+ AnyOut out;
+ ::google::protobuf::Any* any = out.mutable_any();
+
+ Book book;
+ book.set_type(Book::ACTION_AND_ADVENTURE);
+ any->PackFrom(book);
+
+ UseIntsForEnums();
+
+ ow_.StartObject("")
+ ->StartObject("any")
+ ->RenderString("@type",
+ "type.googleapis.com/google.protobuf.testing.Book")
+ ->RenderInt32("type", 3)
+ ->EndObject()
+ ->EndObject();
+
+ DoTest(out, AnyOut::descriptor());
+}
+
+TEST_P(ProtostreamObjectSourceAnysTest, UsePreserveProtoFieldNames) {
+ AnyOut out;
+ ::google::protobuf::Any* any = out.mutable_any();
+
+ Book book;
+ book.set_snake_field("foo");
+ any->PackFrom(book);
+
+ UsePreserveProtoFieldNames();
+
+ ow_.StartObject("")
+ ->StartObject("any")
+ ->RenderString("@type",
+ "type.googleapis.com/google.protobuf.testing.Book")
+ ->RenderString("snake_field", "foo")
+ ->EndObject()
+ ->EndObject();
+
+ DoTest(out, AnyOut::descriptor());
+}
+
TEST_P(ProtostreamObjectSourceAnysTest, RecursiveAny) {
AnyOut out;
::google::protobuf::Any* any = out.mutable_any();
diff --git a/src/google/protobuf/util/internal/protostream_objectwriter.cc b/src/google/protobuf/util/internal/protostream_objectwriter.cc
index 2edfd075..a1a7030a 100644
--- a/src/google/protobuf/util/internal/protostream_objectwriter.cc
+++ b/src/google/protobuf/util/internal/protostream_objectwriter.cc
@@ -534,7 +534,7 @@ ProtoStreamObjectWriter* ProtoStreamObjectWriter::StartObject(
Push("", Item::MESSAGE, false, false);
ProtoWriter::RenderDataPiece("key",
DataPiece(name, use_strict_base64_decoding()));
- Push("value", Item::MESSAGE, true, false);
+ Push("value", IsAny(*Lookup("value")) ? Item::ANY : Item::MESSAGE, true, false);
// Make sure we are valid so far after starting map fields.
if (invalid_depth() > 0) return this;
diff --git a/src/google/protobuf/util/internal/protostream_objectwriter.h b/src/google/protobuf/util/internal/protostream_objectwriter.h
index c33a4639..d9bb432e 100644
--- a/src/google/protobuf/util/internal/protostream_objectwriter.h
+++ b/src/google/protobuf/util/internal/protostream_objectwriter.h
@@ -112,18 +112,18 @@ class LIBPROTOBUF_EXPORT ProtoStreamObjectWriter : public ProtoWriter {
strings::ByteSink* output, ErrorListener* listener,
const ProtoStreamObjectWriter::Options& options =
ProtoStreamObjectWriter::Options::Defaults());
- virtual ~ProtoStreamObjectWriter();
+ virtual ~ProtoStreamObjectWriter() override;
// ObjectWriter methods.
- virtual ProtoStreamObjectWriter* StartObject(StringPiece name);
- virtual ProtoStreamObjectWriter* EndObject();
- virtual ProtoStreamObjectWriter* StartList(StringPiece name);
- virtual ProtoStreamObjectWriter* EndList();
+ virtual ProtoStreamObjectWriter* StartObject(StringPiece name) override;
+ virtual ProtoStreamObjectWriter* EndObject() override;
+ virtual ProtoStreamObjectWriter* StartList(StringPiece name) override;
+ virtual ProtoStreamObjectWriter* EndList() override;
// Renders a DataPiece 'value' into a field whose wire type is determined
// from the given field 'name'.
virtual ProtoStreamObjectWriter* RenderDataPiece(StringPiece name,
- const DataPiece& value);
+ const DataPiece& value) override;
protected:
// Function that renders a well known type with modified behavior.
@@ -263,7 +263,7 @@ class LIBPROTOBUF_EXPORT ProtoStreamObjectWriter : public ProtoWriter {
// Constructor for a field of a message.
Item(Item* parent, ItemType item_type, bool is_placeholder, bool is_list);
- virtual ~Item() {}
+ virtual ~Item() override {}
// These functions return true if the element type is corresponding to the
// type in function name.
@@ -272,7 +272,7 @@ class LIBPROTOBUF_EXPORT ProtoStreamObjectWriter : public ProtoWriter {
AnyWriter* any() const { return any_.get(); }
- virtual Item* parent() const {
+ virtual Item* parent() const override {
return static_cast<Item*>(BaseElement::parent());
}
diff --git a/src/google/protobuf/util/internal/protostream_objectwriter_test.cc b/src/google/protobuf/util/internal/protostream_objectwriter_test.cc
index 7f0df567..9c50e7dd 100644
--- a/src/google/protobuf/util/internal/protostream_objectwriter_test.cc
+++ b/src/google/protobuf/util/internal/protostream_objectwriter_test.cc
@@ -1679,6 +1679,22 @@ TEST_P(ProtoStreamObjectWriterMapTest, RepeatedMapKeyTest) {
->EndObject();
}
+TEST_P(ProtoStreamObjectWriterMapTest, AnyInMap) {
+ MapIn mm;
+ google::protobuf::DoubleValue d;
+ d.set_value(40.2);
+ (*mm.mutable_map_any())["foo"].PackFrom(d);
+ ow_->StartObject("")
+ ->StartObject("map_any")
+ ->StartObject("foo")
+ ->RenderString("@type", "type.googleapis.com/google.protobuf.DoubleValue")
+ ->RenderDouble("value", 40.2)
+ ->EndObject()
+ ->EndObject()
+ ->EndObject();
+ CheckOutput(mm);
+}
+
class ProtoStreamObjectWriterAnyTest : public BaseProtoStreamObjectWriterTest {
protected:
ProtoStreamObjectWriterAnyTest() {
diff --git a/src/google/protobuf/util/internal/testdata/books.proto b/src/google/protobuf/util/internal/testdata/books.proto
index 5630cc78..5e08a291 100644
--- a/src/google/protobuf/util/internal/testdata/books.proto
+++ b/src/google/protobuf/util/internal/testdata/books.proto
@@ -69,6 +69,9 @@ message Book {
}
optional Type type = 11;
+ // Useful for testing JSON snake/camel-case conversions.
+ optional string snake_field = 12;
+
extensions 200 to 499;
}
diff --git a/src/google/protobuf/util/internal/testdata/maps.proto b/src/google/protobuf/util/internal/testdata/maps.proto
index 0f381b32..765254ea 100644
--- a/src/google/protobuf/util/internal/testdata/maps.proto
+++ b/src/google/protobuf/util/internal/testdata/maps.proto
@@ -32,6 +32,8 @@ syntax = "proto3";
package google.protobuf.testing;
+import "google/protobuf/any.proto";
+
// Top-level test cases proto used by MarshallingTest. See description
// at the top of the class MarshallingTest for details on how to write
// test cases.
@@ -103,6 +105,7 @@ message MapIn {
string other = 1;
repeated string things = 2;
map<string, string> map_input = 3;
+ map<string, google.protobuf.Any> map_any = 4;
}
message MapOut {
diff --git a/src/google/protobuf/util/internal/type_info.cc b/src/google/protobuf/util/internal/type_info.cc
index 3847b179..e32e71d0 100644
--- a/src/google/protobuf/util/internal/type_info.cc
+++ b/src/google/protobuf/util/internal/type_info.cc
@@ -59,7 +59,7 @@ class TypeInfoForTypeResolver : public TypeInfo {
}
virtual util::StatusOr<const google::protobuf::Type*> ResolveTypeUrl(
- StringPiece type_url) const {
+ StringPiece type_url) const override {
std::map<StringPiece, StatusOrType>::iterator it =
cached_types_.find(type_url);
if (it != cached_types_.end()) {
@@ -79,13 +79,13 @@ class TypeInfoForTypeResolver : public TypeInfo {
}
virtual const google::protobuf::Type* GetTypeByTypeUrl(
- StringPiece type_url) const {
+ StringPiece type_url) const override {
StatusOrType result = ResolveTypeUrl(type_url);
return result.ok() ? result.ValueOrDie() : NULL;
}
virtual const google::protobuf::Enum* GetEnumByTypeUrl(
- StringPiece type_url) const {
+ StringPiece type_url) const override {
std::map<StringPiece, StatusOrEnum>::iterator it =
cached_enums_.find(type_url);
if (it != cached_enums_.end()) {
@@ -105,8 +105,10 @@ class TypeInfoForTypeResolver : public TypeInfo {
return result.ok() ? result.ValueOrDie() : NULL;
}
+
virtual const google::protobuf::Field* FindField(
- const google::protobuf::Type* type, StringPiece camel_case_name) const {
+ const google::protobuf::Type* type,
+ StringPiece camel_case_name) const override {
std::map<const google::protobuf::Type*, CamelCaseNameTable>::const_iterator
it = indexed_types_.find(type);
const CamelCaseNameTable& camel_case_name_table =
diff --git a/src/google/protobuf/util/json_util.cc b/src/google/protobuf/util/json_util.cc
index f81a7a30..7a7f299f 100644
--- a/src/google/protobuf/util/json_util.cc
+++ b/src/google/protobuf/util/json_util.cc
@@ -119,19 +119,21 @@ util::Status BinaryToJsonString(TypeResolver* resolver,
namespace {
class StatusErrorListener : public converter::ErrorListener {
public:
+
StatusErrorListener() {}
- virtual ~StatusErrorListener() {}
+ virtual ~StatusErrorListener() override {}
util::Status GetStatus() { return status_; }
virtual void InvalidName(const converter::LocationTrackerInterface& loc,
- StringPiece unknown_name, StringPiece message) {
+ StringPiece unknown_name, StringPiece message) override {
status_ = util::Status(util::error::INVALID_ARGUMENT,
- loc.ToString() + ": " + string(message));
+ loc.ToString() + ": invalid name " +
+ string(unknown_name) + ": " + string(message));
}
virtual void InvalidValue(const converter::LocationTrackerInterface& loc,
- StringPiece type_name, StringPiece value) {
+ StringPiece type_name, StringPiece value) override {
status_ =
util::Status(util::error::INVALID_ARGUMENT,
loc.ToString() + ": invalid value " + string(value) +
@@ -139,7 +141,7 @@ class StatusErrorListener : public converter::ErrorListener {
}
virtual void MissingField(const converter::LocationTrackerInterface& loc,
- StringPiece missing_name) {
+ StringPiece missing_name) override {
status_ = util::Status(
util::error::INVALID_ARGUMENT,
loc.ToString() + ": missing field " + string(missing_name));
diff --git a/src/google/protobuf/util/json_util.h b/src/google/protobuf/util/json_util.h
index b1c69813..e7868307 100644
--- a/src/google/protobuf/util/json_util.h
+++ b/src/google/protobuf/util/json_util.h
@@ -182,7 +182,7 @@ class LIBPROTOBUF_EXPORT ZeroCopyStreamByteSink : public strings::ByteSink {
: stream_(stream), buffer_(NULL), buffer_size_(0) {}
~ZeroCopyStreamByteSink();
- virtual void Append(const char* bytes, size_t len);
+ virtual void Append(const char* bytes, size_t len) override;
private:
io::ZeroCopyOutputStream* stream_;
diff --git a/src/google/protobuf/util/json_util_test.cc b/src/google/protobuf/util/json_util_test.cc
index ed9092df..a2a84b57 100644
--- a/src/google/protobuf/util/json_util_test.cc
+++ b/src/google/protobuf/util/json_util_test.cc
@@ -284,7 +284,7 @@ TEST_F(JsonUtilTest, ParsePrimitiveMapIn) {
JsonPrintOptions print_options;
print_options.always_print_primitive_fields = true;
JsonParseOptions parse_options;
- EXPECT_EQ("{\"other\":\"\",\"things\":[],\"mapInput\":{}}",
+ EXPECT_EQ("{\"other\":\"\",\"things\":[],\"mapInput\":{},\"mapAny\":{}}",
ToJson(message, print_options));
MapIn other;
ASSERT_TRUE(FromJson(ToJson(message, print_options), &other, parse_options));
diff --git a/src/google/protobuf/util/message_differencer.cc b/src/google/protobuf/util/message_differencer.cc
index 9842f64c..7d3976f8 100644
--- a/src/google/protobuf/util/message_differencer.cc
+++ b/src/google/protobuf/util/message_differencer.cc
@@ -90,7 +90,7 @@ class MessageDifferencer::MultipleFieldsMapKeyComparator
virtual bool IsMatch(
const Message& message1,
const Message& message2,
- const std::vector<SpecificField>& parent_fields) const {
+ const std::vector<SpecificField>& parent_fields) const override {
for (int i = 0; i < key_field_paths_.size(); ++i) {
if (!IsMatchInternal(message1, message2, parent_fields,
key_field_paths_[i], 0)) {
diff --git a/src/google/protobuf/util/message_differencer.h b/src/google/protobuf/util/message_differencer.h
index bbcf8498..b3e65515 100644
--- a/src/google/protobuf/util/message_differencer.h
+++ b/src/google/protobuf/util/message_differencer.h
@@ -597,7 +597,7 @@ class LIBPROTOBUF_EXPORT MessageDifferencer {
public:
explicit StreamReporter(io::ZeroCopyOutputStream* output);
explicit StreamReporter(io::Printer* printer); // delimiter '$'
- virtual ~StreamReporter();
+ virtual ~StreamReporter() override;
// When set to true, the stream reporter will also output aggregates nodes
// (i.e. messages and groups) whose subfields have been modified. When
@@ -607,32 +607,33 @@ class LIBPROTOBUF_EXPORT MessageDifferencer {
}
// The following are implementations of the methods described above.
+
virtual void ReportAdded(const Message& message1, const Message& message2,
- const std::vector<SpecificField>& field_path);
+ const std::vector<SpecificField>& field_path) override;
virtual void ReportDeleted(const Message& message1,
const Message& message2,
- const std::vector<SpecificField>& field_path);
+ const std::vector<SpecificField>& field_path) override;
virtual void ReportModified(const Message& message1,
const Message& message2,
- const std::vector<SpecificField>& field_path);
+ const std::vector<SpecificField>& field_path) override;
virtual void ReportMoved(const Message& message1,
const Message& message2,
- const std::vector<SpecificField>& field_path);
+ const std::vector<SpecificField>& field_path) override;
virtual void ReportMatched(const Message& message1,
const Message& message2,
- const std::vector<SpecificField>& field_path);
+ const std::vector<SpecificField>& field_path) override;
virtual void ReportIgnored(const Message& message1,
const Message& message2,
- const std::vector<SpecificField>& field_path);
+ const std::vector<SpecificField>& field_path) override;
- virtual void ReportUnknownFieldIgnored(
+ void ReportUnknownFieldIgnored(
const Message& message1, const Message& message2,
- const std::vector<SpecificField>& field_path);
+ const std::vector<SpecificField>& field_path) override;
protected:
// Prints the specified path of fields to the buffer. message is used to
@@ -681,7 +682,7 @@ class LIBPROTOBUF_EXPORT MessageDifferencer {
public:
explicit MapEntryKeyComparator(MessageDifferencer* message_differencer);
virtual bool IsMatch(const Message& message1, const Message& message2,
- const std::vector<SpecificField>& parent_fields) const;
+ const std::vector<SpecificField>& parent_fields) const override;
private:
MessageDifferencer* message_differencer_;
diff --git a/src/google/protobuf/util/message_differencer_unittest.cc b/src/google/protobuf/util/message_differencer_unittest.cc
index a263d983..a263d983 100755..100644
--- a/src/google/protobuf/util/message_differencer_unittest.cc
+++ b/src/google/protobuf/util/message_differencer_unittest.cc
diff --git a/src/google/protobuf/util/type_resolver_util.cc b/src/google/protobuf/util/type_resolver_util.cc
index a69ed58c..aa48ef60 100644
--- a/src/google/protobuf/util/type_resolver_util.cc
+++ b/src/google/protobuf/util/type_resolver_util.cc
@@ -60,7 +60,7 @@ class DescriptorPoolTypeResolver : public TypeResolver {
const DescriptorPool* pool)
: url_prefix_(url_prefix), pool_(pool) {}
- Status ResolveMessageType(const string& type_url, Type* type) {
+ Status ResolveMessageType(const string& type_url, Type* type) override {
string type_name;
Status status = ParseTypeUrl(type_url, &type_name);
if (!status.ok()) {
@@ -75,7 +75,7 @@ class DescriptorPoolTypeResolver : public TypeResolver {
return Status();
}
- Status ResolveEnumType(const string& type_url, Enum* enum_type) {
+ Status ResolveEnumType(const string& type_url, Enum* enum_type) override {
string type_name;
Status status = ParseTypeUrl(type_url, &type_name);
if (!status.ok()) {
diff --git a/src/google/protobuf/wire_format.h b/src/google/protobuf/wire_format.h
index d602d214..36f4a0bb 100644
--- a/src/google/protobuf/wire_format.h
+++ b/src/google/protobuf/wire_format.h
@@ -260,12 +260,12 @@ class LIBPROTOBUF_EXPORT UnknownFieldSetFieldSkipper : public FieldSkipper {
public:
UnknownFieldSetFieldSkipper(UnknownFieldSet* unknown_fields)
: unknown_fields_(unknown_fields) {}
- virtual ~UnknownFieldSetFieldSkipper() {}
+ virtual ~UnknownFieldSetFieldSkipper() override {}
// implements FieldSkipper -----------------------------------------
- virtual bool SkipField(io::CodedInputStream* input, uint32 tag);
- virtual bool SkipMessage(io::CodedInputStream* input);
- virtual void SkipUnknownEnum(int field_number, int value);
+ virtual bool SkipField(io::CodedInputStream* input, uint32 tag) override;
+ virtual bool SkipMessage(io::CodedInputStream* input) override;
+ virtual void SkipUnknownEnum(int field_number, int value) override;
protected:
UnknownFieldSet* unknown_fields_;
diff --git a/src/google/protobuf/wire_format_lite.h b/src/google/protobuf/wire_format_lite.h
index 77eaa9a6..2244b35d 100644
--- a/src/google/protobuf/wire_format_lite.h
+++ b/src/google/protobuf/wire_format_lite.h
@@ -763,9 +763,9 @@ class LIBPROTOBUF_EXPORT CodedOutputStreamFieldSkipper : public FieldSkipper {
virtual ~CodedOutputStreamFieldSkipper() {}
// implements FieldSkipper -----------------------------------------
- virtual bool SkipField(io::CodedInputStream* input, uint32 tag);
- virtual bool SkipMessage(io::CodedInputStream* input);
- virtual void SkipUnknownEnum(int field_number, int value);
+ virtual bool SkipField(io::CodedInputStream* input, uint32 tag) override;
+ virtual bool SkipMessage(io::CodedInputStream* input) override;
+ virtual void SkipUnknownEnum(int field_number, int value) override;
protected:
io::CodedOutputStream* unknown_fields_;
diff --git a/src/google/protobuf/wrappers.pb.cc b/src/google/protobuf/wrappers.pb.cc
index ffd905f5..8f254b82 100644
--- a/src/google/protobuf/wrappers.pb.cc
+++ b/src/google/protobuf/wrappers.pb.cc
@@ -289,14 +289,14 @@ static ::google::protobuf::Message const * const file_default_instances[] = {
reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_BytesValue_default_instance_),
};
-void protobuf_AssignDescriptors() {
+static void protobuf_AssignDescriptors() {
AddDescriptors();
AssignDescriptors(
"google/protobuf/wrappers.proto", schemas, file_default_instances, TableStruct::offsets,
file_level_metadata, NULL, NULL);
}
-void protobuf_AssignDescriptorsOnce() {
+static void protobuf_AssignDescriptorsOnce() {
static ::google::protobuf::internal::once_flag once;
::google::protobuf::internal::call_once(once, protobuf_AssignDescriptors);
}
@@ -307,7 +307,7 @@ void protobuf_RegisterTypes(const ::std::string&) {
::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 9);
}
-void AddDescriptorsImpl() {
+static void AddDescriptorsImpl() {
InitDefaults();
static const char descriptor[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
"\n\036google/protobuf/wrappers.proto\022\017google"
@@ -391,7 +391,7 @@ void DoubleValue::ArenaDtor(void* object) {
DoubleValue* _this = reinterpret_cast< DoubleValue* >(object);
(void)_this;
}
-void DoubleValue::RegisterArenaDtor(::google::protobuf::Arena* arena) {
+void DoubleValue::RegisterArenaDtor(::google::protobuf::Arena*) {
}
void DoubleValue::SetCachedSize(int size) const {
_cached_size_.Set(size);
@@ -642,7 +642,7 @@ void FloatValue::ArenaDtor(void* object) {
FloatValue* _this = reinterpret_cast< FloatValue* >(object);
(void)_this;
}
-void FloatValue::RegisterArenaDtor(::google::protobuf::Arena* arena) {
+void FloatValue::RegisterArenaDtor(::google::protobuf::Arena*) {
}
void FloatValue::SetCachedSize(int size) const {
_cached_size_.Set(size);
@@ -893,7 +893,7 @@ void Int64Value::ArenaDtor(void* object) {
Int64Value* _this = reinterpret_cast< Int64Value* >(object);
(void)_this;
}
-void Int64Value::RegisterArenaDtor(::google::protobuf::Arena* arena) {
+void Int64Value::RegisterArenaDtor(::google::protobuf::Arena*) {
}
void Int64Value::SetCachedSize(int size) const {
_cached_size_.Set(size);
@@ -1146,7 +1146,7 @@ void UInt64Value::ArenaDtor(void* object) {
UInt64Value* _this = reinterpret_cast< UInt64Value* >(object);
(void)_this;
}
-void UInt64Value::RegisterArenaDtor(::google::protobuf::Arena* arena) {
+void UInt64Value::RegisterArenaDtor(::google::protobuf::Arena*) {
}
void UInt64Value::SetCachedSize(int size) const {
_cached_size_.Set(size);
@@ -1399,7 +1399,7 @@ void Int32Value::ArenaDtor(void* object) {
Int32Value* _this = reinterpret_cast< Int32Value* >(object);
(void)_this;
}
-void Int32Value::RegisterArenaDtor(::google::protobuf::Arena* arena) {
+void Int32Value::RegisterArenaDtor(::google::protobuf::Arena*) {
}
void Int32Value::SetCachedSize(int size) const {
_cached_size_.Set(size);
@@ -1652,7 +1652,7 @@ void UInt32Value::ArenaDtor(void* object) {
UInt32Value* _this = reinterpret_cast< UInt32Value* >(object);
(void)_this;
}
-void UInt32Value::RegisterArenaDtor(::google::protobuf::Arena* arena) {
+void UInt32Value::RegisterArenaDtor(::google::protobuf::Arena*) {
}
void UInt32Value::SetCachedSize(int size) const {
_cached_size_.Set(size);
@@ -1905,7 +1905,7 @@ void BoolValue::ArenaDtor(void* object) {
BoolValue* _this = reinterpret_cast< BoolValue* >(object);
(void)_this;
}
-void BoolValue::RegisterArenaDtor(::google::protobuf::Arena* arena) {
+void BoolValue::RegisterArenaDtor(::google::protobuf::Arena*) {
}
void BoolValue::SetCachedSize(int size) const {
_cached_size_.Set(size);
@@ -2161,7 +2161,7 @@ void StringValue::ArenaDtor(void* object) {
StringValue* _this = reinterpret_cast< StringValue* >(object);
(void)_this;
}
-void StringValue::RegisterArenaDtor(::google::protobuf::Arena* arena) {
+void StringValue::RegisterArenaDtor(::google::protobuf::Arena*) {
}
void StringValue::SetCachedSize(int size) const {
_cached_size_.Set(size);
@@ -2433,7 +2433,7 @@ void BytesValue::ArenaDtor(void* object) {
BytesValue* _this = reinterpret_cast< BytesValue* >(object);
(void)_this;
}
-void BytesValue::RegisterArenaDtor(::google::protobuf::Arena* arena) {
+void BytesValue::RegisterArenaDtor(::google::protobuf::Arena*) {
}
void BytesValue::SetCachedSize(int size) const {
_cached_size_.Set(size);
diff --git a/src/google/protobuf/wrappers.pb.h b/src/google/protobuf/wrappers.pb.h
index 9f51a062..b00d4ea9 100644
--- a/src/google/protobuf/wrappers.pb.h
+++ b/src/google/protobuf/wrappers.pb.h
@@ -8,12 +8,12 @@
#include <google/protobuf/stubs/common.h>
-#if GOOGLE_PROTOBUF_VERSION < 3005000
+#if GOOGLE_PROTOBUF_VERSION < 3006000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
-#if 3005001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 3006000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.