aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoshua Haberman <jhaberman@gmail.com>2018-09-07 16:15:38 -0700
committerGitHub <noreply@github.com>2018-09-07 16:15:38 -0700
commitf9d8138376765d229a32635c9209061e4e4aed8c (patch)
tree50719686fd7262f405c9bda8694d6c72e7c038b8 /src
parent2e7563f40ec7f901ae8ae1cc749d701fa07e211d (diff)
parente53be9bce4556cf0d13e24f1a25a7d75f663144f (diff)
downloadprotobuf-f9d8138376765d229a32635c9209061e4e4aed8c.tar.gz
protobuf-f9d8138376765d229a32635c9209061e4e4aed8c.tar.bz2
protobuf-f9d8138376765d229a32635c9209061e4e4aed8c.zip
Merge pull request #5109 from haberman/integrate
Down-integrate from google3.
Diffstat (limited to 'src')
-rw-r--r--src/google/protobuf/any.h14
-rw-r--r--src/google/protobuf/any.pb.cc44
-rw-r--r--src/google/protobuf/any.pb.h25
-rw-r--r--src/google/protobuf/any.proto3
-rw-r--r--src/google/protobuf/api.pb.cc183
-rw-r--r--src/google/protobuf/api.pb.h37
-rw-r--r--src/google/protobuf/arena.cc30
-rw-r--r--src/google/protobuf/arena.h90
-rw-r--r--src/google/protobuf/arena_impl.h10
-rw-r--r--src/google/protobuf/arena_test_util.h12
-rw-r--r--src/google/protobuf/arena_unittest.cc12
-rw-r--r--src/google/protobuf/arenastring.h19
-rw-r--r--src/google/protobuf/compiler/annotation_test_util.h26
-rw-r--r--src/google/protobuf/compiler/code_generator.h26
-rw-r--r--src/google/protobuf/compiler/command_line_interface.cc15
-rw-r--r--src/google/protobuf/compiler/command_line_interface.h78
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc12
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_enum.h6
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_extension.cc10
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_extension.h4
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_field.h6
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_file.cc46
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_file.h20
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_generator.cc53
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_generator.h12
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_helpers.cc359
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_helpers.h151
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_map_field.cc56
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_message.cc155
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_message.h6
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_options.h7
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_service.h4
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_unittest.inc8
-rw-r--r--src/google/protobuf/compiler/csharp/csharp_generator.h8
-rw-r--r--src/google/protobuf/compiler/csharp/csharp_helpers.h8
-rw-r--r--src/google/protobuf/compiler/csharp/csharp_names.h20
-rw-r--r--src/google/protobuf/compiler/importer.h77
-rw-r--r--src/google/protobuf/compiler/java/java_doc_comment.h6
-rw-r--r--src/google/protobuf/compiler/java/java_enum_field.h8
-rw-r--r--src/google/protobuf/compiler/java/java_enum_field_lite.h8
-rw-r--r--src/google/protobuf/compiler/java/java_extension.h6
-rw-r--r--src/google/protobuf/compiler/java/java_extension_lite.h2
-rw-r--r--src/google/protobuf/compiler/java/java_field.h20
-rw-r--r--src/google/protobuf/compiler/java/java_file.cc4
-rw-r--r--src/google/protobuf/compiler/java/java_file.h16
-rw-r--r--src/google/protobuf/compiler/java/java_generator.h10
-rw-r--r--src/google/protobuf/compiler/java/java_helpers.h78
-rw-r--r--src/google/protobuf/compiler/java/java_map_field.h4
-rw-r--r--src/google/protobuf/compiler/java/java_map_field_lite.h4
-rw-r--r--src/google/protobuf/compiler/java/java_message_field.h8
-rw-r--r--src/google/protobuf/compiler/java/java_message_field_lite.h8
-rw-r--r--src/google/protobuf/compiler/java/java_message_lite.cc16
-rw-r--r--src/google/protobuf/compiler/java/java_name_resolver.h36
-rw-r--r--src/google/protobuf/compiler/java/java_names.h12
-rw-r--r--src/google/protobuf/compiler/java/java_primitive_field.h8
-rw-r--r--src/google/protobuf/compiler/java/java_primitive_field_lite.h8
-rw-r--r--src/google/protobuf/compiler/java/java_service.h2
-rw-r--r--src/google/protobuf/compiler/java/java_shared_code_generator.h4
-rw-r--r--src/google/protobuf/compiler/java/java_string_field.h8
-rw-r--r--src/google/protobuf/compiler/java/java_string_field_lite.h8
-rw-r--r--src/google/protobuf/compiler/js/js_generator.h64
-rw-r--r--src/google/protobuf/compiler/mock_code_generator.h48
-rw-r--r--src/google/protobuf/compiler/objectivec/objectivec_generator.h7
-rw-r--r--src/google/protobuf/compiler/objectivec/objectivec_helpers.h99
-rw-r--r--src/google/protobuf/compiler/parser.h42
-rw-r--r--src/google/protobuf/compiler/php/php_generator.h12
-rw-r--r--src/google/protobuf/compiler/plugin.h10
-rw-r--r--src/google/protobuf/compiler/plugin.pb.cc187
-rw-r--r--src/google/protobuf/compiler/plugin.pb.h43
-rw-r--r--src/google/protobuf/compiler/python/python_generator.h38
-rw-r--r--src/google/protobuf/compiler/ruby/ruby_generator.h6
-rw-r--r--src/google/protobuf/compiler/scc.h6
-rw-r--r--src/google/protobuf/compiler/subprocess.h12
-rw-r--r--src/google/protobuf/compiler/zip_writer.h4
-rw-r--r--src/google/protobuf/descriptor.cc4
-rw-r--r--src/google/protobuf/descriptor.h290
-rw-r--r--src/google/protobuf/descriptor.pb.cc1460
-rw-r--r--src/google/protobuf/descriptor.pb.h219
-rw-r--r--src/google/protobuf/descriptor_database.h92
-rw-r--r--src/google/protobuf/descriptor_unittest.cc18
-rw-r--r--src/google/protobuf/duration.pb.cc35
-rw-r--r--src/google/protobuf/duration.pb.h27
-rw-r--r--src/google/protobuf/dynamic_message.h14
-rw-r--r--src/google/protobuf/empty.pb.cc27
-rw-r--r--src/google/protobuf/empty.pb.h25
-rw-r--r--src/google/protobuf/extension_set.cc124
-rw-r--r--src/google/protobuf/extension_set.h202
-rw-r--r--src/google/protobuf/extension_set_heavy.cc162
-rw-r--r--src/google/protobuf/extension_set_unittest.cc14
-rw-r--r--src/google/protobuf/field_mask.pb.cc37
-rw-r--r--src/google/protobuf/field_mask.pb.h25
-rw-r--r--src/google/protobuf/generated_enum_reflection.h14
-rw-r--r--src/google/protobuf/generated_message_reflection.cc7
-rw-r--r--src/google/protobuf/generated_message_reflection.h37
-rw-r--r--src/google/protobuf/generated_message_table_driven_lite.h87
-rw-r--r--src/google/protobuf/generated_message_util.h73
-rw-r--r--src/google/protobuf/has_bits.h9
-rw-r--r--src/google/protobuf/implicit_weak_message.cc6
-rw-r--r--src/google/protobuf/implicit_weak_message.h32
-rw-r--r--src/google/protobuf/inlined_string_field.h54
-rw-r--r--src/google/protobuf/io/coded_stream.cc86
-rw-r--r--src/google/protobuf/io/coded_stream.h72
-rw-r--r--src/google/protobuf/io/coded_stream_inl.h2
-rw-r--r--src/google/protobuf/io/coded_stream_unittest.cc4
-rw-r--r--src/google/protobuf/io/gzip_stream.h11
-rw-r--r--src/google/protobuf/io/printer.h44
-rw-r--r--src/google/protobuf/io/tokenizer.h42
-rw-r--r--src/google/protobuf/io/zero_copy_stream.h8
-rw-r--r--src/google/protobuf/io/zero_copy_stream_impl.h25
-rw-r--r--src/google/protobuf/io/zero_copy_stream_impl_lite.h28
-rw-r--r--src/google/protobuf/lite_unittest.cc181
-rw-r--r--src/google/protobuf/map.h14
-rw-r--r--src/google/protobuf/map_entry.h2
-rw-r--r--src/google/protobuf/map_entry_lite.h77
-rw-r--r--src/google/protobuf/map_field.h69
-rw-r--r--src/google/protobuf/map_field_inl.h4
-rw-r--r--src/google/protobuf/map_field_lite.h4
-rw-r--r--src/google/protobuf/map_test.cc115
-rw-r--r--src/google/protobuf/map_test_util.h10
-rw-r--r--src/google/protobuf/map_type_handler.h4
-rw-r--r--src/google/protobuf/message.cc181
-rw-r--r--src/google/protobuf/message.h89
-rw-r--r--src/google/protobuf/message_lite.cc411
-rw-r--r--src/google/protobuf/message_lite.h34
-rw-r--r--src/google/protobuf/message_unittest.inc62
-rw-r--r--src/google/protobuf/metadata_lite.h53
-rw-r--r--src/google/protobuf/port_def.inc313
-rw-r--r--src/google/protobuf/port_undef.inc71
-rw-r--r--src/google/protobuf/reflection.h14
-rw-r--r--src/google/protobuf/reflection_internal.h16
-rw-r--r--src/google/protobuf/reflection_ops.h10
-rw-r--r--src/google/protobuf/repeated_field.cc18
-rw-r--r--src/google/protobuf/repeated_field.h81
-rw-r--r--src/google/protobuf/service.h14
-rw-r--r--src/google/protobuf/source_context.pb.cc35
-rw-r--r--src/google/protobuf/source_context.pb.h25
-rw-r--r--src/google/protobuf/struct.pb.cc137
-rw-r--r--src/google/protobuf/struct.pb.h47
-rw-r--r--src/google/protobuf/stubs/bytestream.h22
-rw-r--r--src/google/protobuf/stubs/callback.h19
-rw-r--r--src/google/protobuf/stubs/common.cc6
-rw-r--r--src/google/protobuf/stubs/common.h40
-rw-r--r--src/google/protobuf/stubs/fastmem.h6
-rw-r--r--src/google/protobuf/stubs/int128.cc17
-rw-r--r--src/google/protobuf/stubs/int128.h16
-rw-r--r--src/google/protobuf/stubs/int128_unittest.cc130
-rw-r--r--src/google/protobuf/stubs/io_win32.h41
-rw-r--r--src/google/protobuf/stubs/logging.h12
-rw-r--r--src/google/protobuf/stubs/mathlimits.h122
-rw-r--r--src/google/protobuf/stubs/mutex.h10
-rw-r--r--src/google/protobuf/stubs/port.h176
-rw-r--r--src/google/protobuf/stubs/status.h9
-rw-r--r--src/google/protobuf/stubs/status_macros.h10
-rw-r--r--src/google/protobuf/stubs/statusor.h6
-rw-r--r--src/google/protobuf/stubs/stringpiece.h6
-rw-r--r--src/google/protobuf/stubs/stringprintf.h19
-rw-r--r--src/google/protobuf/stubs/strutil.h240
-rw-r--r--src/google/protobuf/stubs/substitute.h54
-rw-r--r--src/google/protobuf/stubs/time.h15
-rw-r--r--src/google/protobuf/test_util.h25
-rw-r--r--src/google/protobuf/test_util2.h2
-rw-r--r--src/google/protobuf/text_format.cc216
-rw-r--r--src/google/protobuf/text_format.h90
-rw-r--r--src/google/protobuf/text_format_unittest.cc16
-rw-r--r--src/google/protobuf/timestamp.pb.cc35
-rw-r--r--src/google/protobuf/timestamp.pb.h27
-rw-r--r--src/google/protobuf/timestamp.proto2
-rw-r--r--src/google/protobuf/type.pb.cc289
-rw-r--r--src/google/protobuf/type.pb.h61
-rw-r--r--src/google/protobuf/unknown_field_set.cc31
-rw-r--r--src/google/protobuf/unknown_field_set.h64
-rw-r--r--src/google/protobuf/util/delimited_message_util.h23
-rw-r--r--src/google/protobuf/util/field_comparator.h12
-rw-r--r--src/google/protobuf/util/field_mask_util.cc8
-rw-r--r--src/google/protobuf/util/field_mask_util.h39
-rw-r--r--src/google/protobuf/util/internal/datapiece.h16
-rw-r--r--src/google/protobuf/util/internal/default_value_objectwriter.h28
-rw-r--r--src/google/protobuf/util/internal/error_listener.h8
-rw-r--r--src/google/protobuf/util/internal/expecting_objectwriter.h26
-rw-r--r--src/google/protobuf/util/internal/field_mask_utility.cc2
-rw-r--r--src/google/protobuf/util/internal/field_mask_utility.h4
-rw-r--r--src/google/protobuf/util/internal/json_objectwriter.h14
-rw-r--r--src/google/protobuf/util/internal/json_stream_parser.h16
-rw-r--r--src/google/protobuf/util/internal/location_tracker.h8
-rw-r--r--src/google/protobuf/util/internal/object_location_tracker.h2
-rw-r--r--src/google/protobuf/util/internal/object_source.h6
-rw-r--r--src/google/protobuf/util/internal/object_writer.h6
-rw-r--r--src/google/protobuf/util/internal/proto_writer.cc11
-rw-r--r--src/google/protobuf/util/internal/proto_writer.h22
-rw-r--r--src/google/protobuf/util/internal/protostream_objectsource.cc10
-rw-r--r--src/google/protobuf/util/internal/protostream_objectsource.h12
-rw-r--r--src/google/protobuf/util/internal/protostream_objectwriter.cc9
-rw-r--r--src/google/protobuf/util/internal/protostream_objectwriter.h33
-rw-r--r--src/google/protobuf/util/internal/protostream_objectwriter_test.cc16
-rw-r--r--src/google/protobuf/util/internal/structured_objectwriter.h8
-rw-r--r--src/google/protobuf/util/internal/type_info.h6
-rw-r--r--src/google/protobuf/util/internal/type_info_test_helper.h6
-rw-r--r--src/google/protobuf/util/internal/utility.cc6
-rw-r--r--src/google/protobuf/util/internal/utility.h61
-rw-r--r--src/google/protobuf/util/json_util.cc9
-rw-r--r--src/google/protobuf/util/json_util.h66
-rw-r--r--src/google/protobuf/util/message_differencer.h24
-rw-r--r--src/google/protobuf/util/message_differencer_unittest.cc6
-rw-r--r--src/google/protobuf/util/time_util.cc4
-rw-r--r--src/google/protobuf/util/time_util.h41
-rw-r--r--src/google/protobuf/util/type_resolver.h10
-rw-r--r--src/google/protobuf/util/type_resolver_util.h9
-rw-r--r--src/google/protobuf/wire_format.h14
-rw-r--r--src/google/protobuf/wire_format_lite.cc25
-rw-r--r--src/google/protobuf/wire_format_lite.h58
-rw-r--r--src/google/protobuf/wire_format_lite_inl.h14
-rw-r--r--src/google/protobuf/wire_format_unittest.cc6
-rw-r--r--src/google/protobuf/wrappers.pb.cc220
-rw-r--r--src/google/protobuf/wrappers.pb.h77
-rw-r--r--src/google/protobuf/wrappers.proto4
215 files changed, 6048 insertions, 4812 deletions
diff --git a/src/google/protobuf/any.h b/src/google/protobuf/any.h
index 61dc7176..db7d76a8 100644
--- a/src/google/protobuf/any.h
+++ b/src/google/protobuf/any.h
@@ -38,12 +38,14 @@
#include <google/protobuf/message.h>
#include <google/protobuf/arenastring.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace internal {
// Helper class used to implement google::protobuf::Any.
-class LIBPROTOBUF_EXPORT AnyMetadata {
+class PROTOBUF_EXPORT AnyMetadata {
typedef ArenaStringPtr UrlType;
typedef ArenaStringPtr ValueType;
public:
@@ -59,7 +61,7 @@ class LIBPROTOBUF_EXPORT AnyMetadata {
// For example, both PackFrom(message, "type.googleapis.com") and
// PackFrom(message, "type.googleapis.com/") yield the same result type
// URL: "type.googleapis.com/<message_full_name>".
- void PackFrom(const Message& message, const string& type_url_prefix);
+ void PackFrom(const Message& message, const std::string& type_url_prefix);
// Unpacks the payload into the given message. Returns false if the message's
// type doesn't match the type specified in the type URL (i.e., the full
@@ -95,15 +97,15 @@ extern const char kTypeGoogleProdComPrefix[]; // "type.googleprod.com/".
//
// NOTE: this function is available publicly as:
// google::protobuf::Any() // static method on the generated message type.
-bool ParseAnyTypeUrl(const string& type_url, string* full_type_name);
+bool ParseAnyTypeUrl(const std::string& type_url, std::string* full_type_name);
// Get the proto type name and prefix from Any::type_url value. For example,
// passing "type.googleapis.com/rpc.QueryOrigin" will return
// "type.googleapis.com/" in *url_prefix and "rpc.QueryOrigin" in
// *full_type_name. Returns false if the type_url does not have a "/" in the
// type url separating the full type name.
-bool ParseAnyTypeUrl(const string& type_url, string* url_prefix,
- string* full_type_name);
+bool ParseAnyTypeUrl(const std::string& type_url, std::string* url_prefix,
+ std::string* full_type_name);
// See if message is of type google.protobuf.Any, if so, return the descriptors
// for "type_url" and "value" fields.
@@ -115,4 +117,6 @@ bool GetAnyFieldDescriptors(const Message& message,
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_ANY_H__
diff --git a/src/google/protobuf/any.pb.cc b/src/google/protobuf/any.pb.cc
index 7b10893c..a45f6580 100644
--- a/src/google/protobuf/any.pb.cc
+++ b/src/google/protobuf/any.pb.cc
@@ -13,10 +13,6 @@
#include <google/protobuf/generated_message_reflection.h>
#include <google/protobuf/reflection_ops.h>
#include <google/protobuf/wire_format.h>
-// This is a temporary google only hack
-#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
-#include "third_party/protobuf/version.h"
-#endif
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>
@@ -39,7 +35,7 @@ static void InitDefaultsAny_google_2fprotobuf_2fany_2eproto() {
::google::protobuf::Any::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_Any_google_2fprotobuf_2fany_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_Any_google_2fprotobuf_2fany_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsAny_google_2fprotobuf_2fany_2eproto}, {}};
void InitDefaults_google_2fprotobuf_2fany_2eproto() {
@@ -50,16 +46,16 @@ void InitDefaults_google_2fprotobuf_2fany_2eproto() {
constexpr ::google::protobuf::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2fany_2eproto = nullptr;
constexpr ::google::protobuf::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fany_2eproto = nullptr;
-const ::google::protobuf::uint32 TableStruct_google_2fprotobuf_2fany_2eproto::offsets[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
+const ::google::protobuf::uint32 TableStruct_google_2fprotobuf_2fany_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
~0u, // no _has_bits_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Any, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Any, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Any, type_url_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Any, value_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Any, type_url_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Any, value_),
};
-static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
+static const ::google::protobuf::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
{ 0, -1, sizeof(::google::protobuf::Any)},
};
@@ -204,14 +200,13 @@ const char* Any::_InternalParse(const char* begin, const char* end, void* object
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// string type_url = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 10) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.Any.type_url");
parser_till_end = ::google::protobuf::internal::StringParserUTF8;
::std::string* str = msg->mutable_type_url();
@@ -219,29 +214,29 @@ const char* Any::_InternalParse(const char* begin, const char* end, void* object
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// bytes value = 2;
case 2: {
if (static_cast<::google::protobuf::uint8>(tag) != 18) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::internal::StringParser;
::std::string* str = msg->mutable_value();
str->clear();
object = str;
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ str->append(ptr, size);
+ ptr += size;
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
@@ -252,8 +247,6 @@ const char* Any::_InternalParse(const char* begin, const char* end, void* object
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -265,7 +258,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool Any::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.Any)
for (;;) {
@@ -488,10 +481,11 @@ void Any::InternalSwap(Any* other) {
} // namespace google
namespace google {
namespace protobuf {
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Any* Arena::CreateMaybeMessage< ::google::protobuf::Any >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::Any* Arena::CreateMaybeMessage< ::google::protobuf::Any >(Arena* arena) {
return Arena::CreateInternal< ::google::protobuf::Any >(arena);
}
} // namespace protobuf
} // namespace google
// @@protoc_insertion_point(global_scope)
+#include <google/protobuf/port_undef.inc>
diff --git a/src/google/protobuf/any.pb.h b/src/google/protobuf/any.pb.h
index a5ad5827..c931d500 100644
--- a/src/google/protobuf/any.pb.h
+++ b/src/google/protobuf/any.pb.h
@@ -7,18 +7,19 @@
#include <limits>
#include <string>
-#include <google/protobuf/stubs/common.h>
-#if GOOGLE_PROTOBUF_VERSION < 3006000
+#include <google/protobuf/port_def.inc>
+#if PROTOBUF_VERSION < 3006001
#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 3006001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 3006001 < 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.
#endif
+#include <google/protobuf/port_undef.inc>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
@@ -33,27 +34,27 @@
#include <google/protobuf/any.h>
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>
-#define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fany_2eproto LIBPROTOBUF_EXPORT
+#define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fany_2eproto PROTOBUF_EXPORT
// Internal implementation detail -- do not use these members.
-struct LIBPROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fany_2eproto {
+struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fany_2eproto {
static const ::google::protobuf::internal::ParseTableField entries[]
- GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold);
+ PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::google::protobuf::internal::AuxillaryParseTableField aux[]
- GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold);
+ PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::google::protobuf::internal::ParseTable schema[1]
- GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold);
+ PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::google::protobuf::internal::FieldMetadata field_metadata[];
static const ::google::protobuf::internal::SerializationTable serialization_table[];
static const ::google::protobuf::uint32 offsets[];
};
-void LIBPROTOBUF_EXPORT AddDescriptors_google_2fprotobuf_2fany_2eproto();
+void PROTOBUF_EXPORT AddDescriptors_google_2fprotobuf_2fany_2eproto();
namespace google {
namespace protobuf {
class Any;
class AnyDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern AnyDefaultTypeInternal _Any_default_instance_;
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::Any* Arena::CreateMaybeMessage<::google::protobuf::Any>(Arena*);
+PROTOBUF_EXPORT extern AnyDefaultTypeInternal _Any_default_instance_;
+template<> PROTOBUF_EXPORT ::google::protobuf::Any* Arena::CreateMaybeMessage<::google::protobuf::Any>(Arena*);
} // namespace protobuf
} // namespace google
namespace google {
@@ -61,7 +62,7 @@ namespace protobuf {
// ===================================================================
-class LIBPROTOBUF_EXPORT Any : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Any) */ {
+class PROTOBUF_EXPORT Any : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Any) */ {
public:
Any();
virtual ~Any();
diff --git a/src/google/protobuf/any.proto b/src/google/protobuf/any.proto
index 49329425..c9be8541 100644
--- a/src/google/protobuf/any.proto
+++ b/src/google/protobuf/any.proto
@@ -121,7 +121,8 @@ option objc_class_prefix = "GPB";
//
message Any {
// A URL/resource name that uniquely identifies the type of the serialized
- // protocol buffer message. The last segment of the URL's path must represent
+ // protocol buffer message. This string must contain at least
+ // one "/" character. The last segment of the URL's path must represent
// the fully qualified name of the type (as in
// `path/google.protobuf.Duration`). The name should be in a canonical form
// (e.g., leading "." is not accepted).
diff --git a/src/google/protobuf/api.pb.cc b/src/google/protobuf/api.pb.cc
index ac2a0e89..1734dfdf 100644
--- a/src/google/protobuf/api.pb.cc
+++ b/src/google/protobuf/api.pb.cc
@@ -13,10 +13,6 @@
#include <google/protobuf/generated_message_reflection.h>
#include <google/protobuf/reflection_ops.h>
#include <google/protobuf/wire_format.h>
-// This is a temporary google only hack
-#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
-#include "third_party/protobuf/version.h"
-#endif
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>
@@ -51,7 +47,7 @@ static void InitDefaultsApi_google_2fprotobuf_2fapi_2eproto() {
::google::protobuf::Api::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<4> scc_info_Api_google_2fprotobuf_2fapi_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<4> scc_info_Api_google_2fprotobuf_2fapi_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 4, InitDefaultsApi_google_2fprotobuf_2fapi_2eproto}, {
&scc_info_Method_google_2fprotobuf_2fapi_2eproto.base,
&scc_info_Option_google_2fprotobuf_2ftype_2eproto.base,
@@ -69,7 +65,7 @@ static void InitDefaultsMethod_google_2fprotobuf_2fapi_2eproto() {
::google::protobuf::Method::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<1> scc_info_Method_google_2fprotobuf_2fapi_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<1> scc_info_Method_google_2fprotobuf_2fapi_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsMethod_google_2fprotobuf_2fapi_2eproto}, {
&scc_info_Option_google_2fprotobuf_2ftype_2eproto.base,}};
@@ -84,7 +80,7 @@ static void InitDefaultsMixin_google_2fprotobuf_2fapi_2eproto() {
::google::protobuf::Mixin::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_Mixin_google_2fprotobuf_2fapi_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_Mixin_google_2fprotobuf_2fapi_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsMixin_google_2fprotobuf_2fapi_2eproto}, {}};
void InitDefaults_google_2fprotobuf_2fapi_2eproto() {
@@ -97,40 +93,40 @@ void InitDefaults_google_2fprotobuf_2fapi_2eproto() {
constexpr ::google::protobuf::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2fapi_2eproto = nullptr;
constexpr ::google::protobuf::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fapi_2eproto = nullptr;
-const ::google::protobuf::uint32 TableStruct_google_2fprotobuf_2fapi_2eproto::offsets[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
+const ::google::protobuf::uint32 TableStruct_google_2fprotobuf_2fapi_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
~0u, // no _has_bits_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Api, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Api, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Api, name_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Api, methods_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Api, options_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Api, version_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Api, source_context_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Api, mixins_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Api, syntax_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Api, name_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Api, methods_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Api, options_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Api, version_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Api, source_context_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Api, mixins_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Api, syntax_),
~0u, // no _has_bits_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Method, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Method, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Method, name_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Method, request_type_url_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Method, request_streaming_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Method, response_type_url_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Method, response_streaming_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Method, options_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Method, syntax_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Method, name_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Method, request_type_url_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Method, request_streaming_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Method, response_type_url_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Method, response_streaming_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Method, options_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Method, syntax_),
~0u, // no _has_bits_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Mixin, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Mixin, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Mixin, name_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Mixin, root_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Mixin, name_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Mixin, root_),
};
-static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
+static const ::google::protobuf::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
{ 0, -1, sizeof(::google::protobuf::Api)},
{ 12, -1, sizeof(::google::protobuf::Method)},
{ 24, -1, sizeof(::google::protobuf::Mixin)},
@@ -310,14 +306,13 @@ const char* Api::_InternalParse(const char* begin, const char* end, void* object
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// string name = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 10) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.Api.name");
parser_till_end = ::google::protobuf::internal::StringParserUTF8;
::std::string* str = msg->mutable_name();
@@ -325,8 +320,8 @@ const char* Api::_InternalParse(const char* begin, const char* end, void* object
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// repeated .google.protobuf.Method methods = 2;
@@ -334,15 +329,17 @@ const char* Api::_InternalParse(const char* begin, const char* end, void* object
if (static_cast<::google::protobuf::uint8>(tag) != 18) goto handle_unusual;
do {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::Method::_InternalParse;
object = msg->add_methods();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 255) == 18 && (ptr += 1));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 18 && (ptr += 1));
break;
}
// repeated .google.protobuf.Option options = 3;
@@ -350,22 +347,24 @@ const char* Api::_InternalParse(const char* begin, const char* end, void* object
if (static_cast<::google::protobuf::uint8>(tag) != 26) goto handle_unusual;
do {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::Option::_InternalParse;
object = msg->add_options();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 255) == 26 && (ptr += 1));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 26 && (ptr += 1));
break;
}
// string version = 4;
case 4: {
if (static_cast<::google::protobuf::uint8>(tag) != 34) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.Api.version");
parser_till_end = ::google::protobuf::internal::StringParserUTF8;
::std::string* str = msg->mutable_version();
@@ -373,20 +372,22 @@ const char* Api::_InternalParse(const char* begin, const char* end, void* object
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// .google.protobuf.SourceContext source_context = 5;
case 5: {
if (static_cast<::google::protobuf::uint8>(tag) != 42) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::SourceContext::_InternalParse;
object = msg->mutable_source_context();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
break;
}
@@ -395,15 +396,17 @@ const char* Api::_InternalParse(const char* begin, const char* end, void* object
if (static_cast<::google::protobuf::uint8>(tag) != 50) goto handle_unusual;
do {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::Mixin::_InternalParse;
object = msg->add_mixins();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 255) == 50 && (ptr += 1));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 50 && (ptr += 1));
break;
}
// .google.protobuf.Syntax syntax = 7;
@@ -411,15 +414,16 @@ const char* Api::_InternalParse(const char* begin, const char* end, void* object
if (static_cast<::google::protobuf::uint8>(tag) != 56) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
::google::protobuf::Syntax value = static_cast<::google::protobuf::Syntax>(val);
msg->set_syntax(value);
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
@@ -430,8 +434,6 @@ const char* Api::_InternalParse(const char* begin, const char* end, void* object
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -443,7 +445,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool Api::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.Api)
for (;;) {
@@ -974,14 +976,13 @@ const char* Method::_InternalParse(const char* begin, const char* end, void* obj
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// string name = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 10) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.Method.name");
parser_till_end = ::google::protobuf::internal::StringParserUTF8;
::std::string* str = msg->mutable_name();
@@ -989,15 +990,15 @@ const char* Method::_InternalParse(const char* begin, const char* end, void* obj
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// string request_type_url = 2;
case 2: {
if (static_cast<::google::protobuf::uint8>(tag) != 18) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.Method.request_type_url");
parser_till_end = ::google::protobuf::internal::StringParserUTF8;
::std::string* str = msg->mutable_request_type_url();
@@ -1005,8 +1006,8 @@ const char* Method::_InternalParse(const char* begin, const char* end, void* obj
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// bool request_streaming = 3;
@@ -1014,7 +1015,7 @@ const char* Method::_InternalParse(const char* begin, const char* end, void* obj
if (static_cast<::google::protobuf::uint8>(tag) != 24) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
bool value = val;
msg->set_request_streaming(value);
break;
@@ -1023,7 +1024,7 @@ const char* Method::_InternalParse(const char* begin, const char* end, void* obj
case 4: {
if (static_cast<::google::protobuf::uint8>(tag) != 34) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.Method.response_type_url");
parser_till_end = ::google::protobuf::internal::StringParserUTF8;
::std::string* str = msg->mutable_response_type_url();
@@ -1031,8 +1032,8 @@ const char* Method::_InternalParse(const char* begin, const char* end, void* obj
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// bool response_streaming = 5;
@@ -1040,7 +1041,7 @@ const char* Method::_InternalParse(const char* begin, const char* end, void* obj
if (static_cast<::google::protobuf::uint8>(tag) != 40) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
bool value = val;
msg->set_response_streaming(value);
break;
@@ -1050,15 +1051,17 @@ const char* Method::_InternalParse(const char* begin, const char* end, void* obj
if (static_cast<::google::protobuf::uint8>(tag) != 50) goto handle_unusual;
do {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::Option::_InternalParse;
object = msg->add_options();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 255) == 50 && (ptr += 1));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 50 && (ptr += 1));
break;
}
// .google.protobuf.Syntax syntax = 7;
@@ -1066,15 +1069,16 @@ const char* Method::_InternalParse(const char* begin, const char* end, void* obj
if (static_cast<::google::protobuf::uint8>(tag) != 56) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
::google::protobuf::Syntax value = static_cast<::google::protobuf::Syntax>(val);
msg->set_syntax(value);
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
@@ -1085,8 +1089,6 @@ const char* Method::_InternalParse(const char* begin, const char* end, void* obj
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -1098,7 +1100,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool Method::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.Method)
for (;;) {
@@ -1599,14 +1601,13 @@ const char* Mixin::_InternalParse(const char* begin, const char* end, void* obje
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// string name = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 10) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.Mixin.name");
parser_till_end = ::google::protobuf::internal::StringParserUTF8;
::std::string* str = msg->mutable_name();
@@ -1614,15 +1615,15 @@ const char* Mixin::_InternalParse(const char* begin, const char* end, void* obje
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// string root = 2;
case 2: {
if (static_cast<::google::protobuf::uint8>(tag) != 18) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.Mixin.root");
parser_till_end = ::google::protobuf::internal::StringParserUTF8;
::std::string* str = msg->mutable_root();
@@ -1630,14 +1631,15 @@ const char* Mixin::_InternalParse(const char* begin, const char* end, void* obje
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
@@ -1648,8 +1650,6 @@ const char* Mixin::_InternalParse(const char* begin, const char* end, void* obje
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -1661,7 +1661,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool Mixin::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.Mixin)
for (;;) {
@@ -1896,16 +1896,17 @@ void Mixin::InternalSwap(Mixin* other) {
} // namespace google
namespace google {
namespace protobuf {
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Api* Arena::CreateMaybeMessage< ::google::protobuf::Api >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::Api* Arena::CreateMaybeMessage< ::google::protobuf::Api >(Arena* arena) {
return Arena::CreateInternal< ::google::protobuf::Api >(arena);
}
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Method* Arena::CreateMaybeMessage< ::google::protobuf::Method >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::Method* Arena::CreateMaybeMessage< ::google::protobuf::Method >(Arena* arena) {
return Arena::CreateInternal< ::google::protobuf::Method >(arena);
}
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Mixin* Arena::CreateMaybeMessage< ::google::protobuf::Mixin >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::Mixin* Arena::CreateMaybeMessage< ::google::protobuf::Mixin >(Arena* arena) {
return Arena::CreateInternal< ::google::protobuf::Mixin >(arena);
}
} // namespace protobuf
} // namespace google
// @@protoc_insertion_point(global_scope)
+#include <google/protobuf/port_undef.inc>
diff --git a/src/google/protobuf/api.pb.h b/src/google/protobuf/api.pb.h
index 5af8aaf2..40a609b7 100644
--- a/src/google/protobuf/api.pb.h
+++ b/src/google/protobuf/api.pb.h
@@ -7,18 +7,19 @@
#include <limits>
#include <string>
-#include <google/protobuf/stubs/common.h>
-#if GOOGLE_PROTOBUF_VERSION < 3006000
+#include <google/protobuf/port_def.inc>
+#if PROTOBUF_VERSION < 3006001
#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 3006001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 3006001 < 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.
#endif
+#include <google/protobuf/port_undef.inc>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
@@ -34,35 +35,35 @@
#include <google/protobuf/type.pb.h>
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>
-#define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fapi_2eproto LIBPROTOBUF_EXPORT
+#define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fapi_2eproto PROTOBUF_EXPORT
// Internal implementation detail -- do not use these members.
-struct LIBPROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fapi_2eproto {
+struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fapi_2eproto {
static const ::google::protobuf::internal::ParseTableField entries[]
- GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold);
+ PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::google::protobuf::internal::AuxillaryParseTableField aux[]
- GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold);
+ PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::google::protobuf::internal::ParseTable schema[3]
- GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold);
+ PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::google::protobuf::internal::FieldMetadata field_metadata[];
static const ::google::protobuf::internal::SerializationTable serialization_table[];
static const ::google::protobuf::uint32 offsets[];
};
-void LIBPROTOBUF_EXPORT AddDescriptors_google_2fprotobuf_2fapi_2eproto();
+void PROTOBUF_EXPORT AddDescriptors_google_2fprotobuf_2fapi_2eproto();
namespace google {
namespace protobuf {
class Api;
class ApiDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern ApiDefaultTypeInternal _Api_default_instance_;
+PROTOBUF_EXPORT extern ApiDefaultTypeInternal _Api_default_instance_;
class Method;
class MethodDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern MethodDefaultTypeInternal _Method_default_instance_;
+PROTOBUF_EXPORT extern MethodDefaultTypeInternal _Method_default_instance_;
class Mixin;
class MixinDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern MixinDefaultTypeInternal _Mixin_default_instance_;
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::Api* Arena::CreateMaybeMessage<::google::protobuf::Api>(Arena*);
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::Method* Arena::CreateMaybeMessage<::google::protobuf::Method>(Arena*);
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::Mixin* Arena::CreateMaybeMessage<::google::protobuf::Mixin>(Arena*);
+PROTOBUF_EXPORT extern MixinDefaultTypeInternal _Mixin_default_instance_;
+template<> PROTOBUF_EXPORT ::google::protobuf::Api* Arena::CreateMaybeMessage<::google::protobuf::Api>(Arena*);
+template<> PROTOBUF_EXPORT ::google::protobuf::Method* Arena::CreateMaybeMessage<::google::protobuf::Method>(Arena*);
+template<> PROTOBUF_EXPORT ::google::protobuf::Mixin* Arena::CreateMaybeMessage<::google::protobuf::Mixin>(Arena*);
} // namespace protobuf
} // namespace google
namespace google {
@@ -70,7 +71,7 @@ namespace protobuf {
// ===================================================================
-class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Api) */ {
+class PROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Api) */ {
public:
Api();
virtual ~Api();
@@ -260,7 +261,7 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in
};
// -------------------------------------------------------------------
-class LIBPROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Method) */ {
+class PROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Method) */ {
public:
Method();
virtual ~Method();
@@ -443,7 +444,7 @@ class LIBPROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc
};
// -------------------------------------------------------------------
-class LIBPROTOBUF_EXPORT Mixin : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Mixin) */ {
+class PROTOBUF_EXPORT Mixin : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Mixin) */ {
public:
Mixin();
virtual ~Mixin();
diff --git a/src/google/protobuf/arena.cc b/src/google/protobuf/arena.cc
index 1d81c322..26c291cf 100644
--- a/src/google/protobuf/arena.cc
+++ b/src/google/protobuf/arena.cc
@@ -125,7 +125,7 @@ ArenaImpl::Block* ArenaImpl::NewBlock(Block* last_block, size_t min_bytes) {
ArenaImpl::Block::Block(size_t size, Block* next)
: next_(next), pos_(kBlockHeaderSize), size_(size) {}
-GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE
+PROTOBUF_NOINLINE
void ArenaImpl::SerialArena::AddCleanupFallback(void* elem,
void (*cleanup)(void*)) {
size_t size = cleanup_ ? cleanup_->size * 2 : kMinCleanupListElements;
@@ -142,10 +142,10 @@ void ArenaImpl::SerialArena::AddCleanupFallback(void* elem,
AddCleanup(elem, cleanup);
}
-GOOGLE_PROTOBUF_ATTRIBUTE_FUNC_ALIGN(32)
+PROTOBUF_FUNC_ALIGN(32)
void* ArenaImpl::AllocateAligned(size_t n) {
SerialArena* arena;
- if (GOOGLE_PREDICT_TRUE(GetSerialArenaFast(&arena))) {
+ if (PROTOBUF_PREDICT_TRUE(GetSerialArenaFast(&arena))) {
return arena->AllocateAligned(n);
} else {
return AllocateAlignedFallback(n);
@@ -155,7 +155,7 @@ void* ArenaImpl::AllocateAligned(size_t n) {
void* ArenaImpl::AllocateAlignedAndAddCleanup(size_t n,
void (*cleanup)(void*)) {
SerialArena* arena;
- if (GOOGLE_PREDICT_TRUE(GetSerialArenaFast(&arena))) {
+ if (PROTOBUF_PREDICT_TRUE(GetSerialArenaFast(&arena))) {
return arena->AllocateAlignedAndAddCleanup(n, cleanup);
} else {
return AllocateAlignedAndAddCleanupFallback(n, cleanup);
@@ -164,36 +164,36 @@ void* ArenaImpl::AllocateAlignedAndAddCleanup(size_t n,
void ArenaImpl::AddCleanup(void* elem, void (*cleanup)(void*)) {
SerialArena* arena;
- if (GOOGLE_PREDICT_TRUE(GetSerialArenaFast(&arena))) {
+ if (PROTOBUF_PREDICT_TRUE(GetSerialArenaFast(&arena))) {
arena->AddCleanup(elem, cleanup);
} else {
return AddCleanupFallback(elem, cleanup);
}
}
-GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE
+PROTOBUF_NOINLINE
void* ArenaImpl::AllocateAlignedFallback(size_t n) {
return GetSerialArena()->AllocateAligned(n);
}
-GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE
+PROTOBUF_NOINLINE
void* ArenaImpl::AllocateAlignedAndAddCleanupFallback(size_t n,
void (*cleanup)(void*)) {
return GetSerialArena()->AllocateAlignedAndAddCleanup(n, cleanup);
}
-GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE
+PROTOBUF_NOINLINE
void ArenaImpl::AddCleanupFallback(void* elem, void (*cleanup)(void*)) {
GetSerialArena()->AddCleanup(elem, cleanup);
}
-inline GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE bool
-ArenaImpl::GetSerialArenaFast(ArenaImpl::SerialArena** arena) {
+inline PROTOBUF_ALWAYS_INLINE bool ArenaImpl::GetSerialArenaFast(
+ ArenaImpl::SerialArena** arena) {
// If this thread already owns a block in this arena then try to use that.
// This fast path optimizes the case where multiple threads allocate from the
// same arena.
ThreadCache* tc = &thread_cache();
- if (GOOGLE_PREDICT_TRUE(tc->last_lifecycle_id_seen == lifecycle_id_)) {
+ if (PROTOBUF_PREDICT_TRUE(tc->last_lifecycle_id_seen == lifecycle_id_)) {
*arena = tc->last_serial_arena;
return true;
}
@@ -201,7 +201,7 @@ ArenaImpl::GetSerialArenaFast(ArenaImpl::SerialArena** arena) {
// Check whether we own the last accessed SerialArena on this arena. This
// fast path optimizes the case where a single thread uses multiple arenas.
SerialArena* serial = hint_.load(std::memory_order_acquire);
- if (GOOGLE_PREDICT_TRUE(serial != NULL && serial->owner() == tc)) {
+ if (PROTOBUF_PREDICT_TRUE(serial != NULL && serial->owner() == tc)) {
*arena = serial;
return true;
}
@@ -211,14 +211,14 @@ ArenaImpl::GetSerialArenaFast(ArenaImpl::SerialArena** arena) {
ArenaImpl::SerialArena* ArenaImpl::GetSerialArena() {
SerialArena* arena;
- if (GOOGLE_PREDICT_TRUE(GetSerialArenaFast(&arena))) {
+ if (PROTOBUF_PREDICT_TRUE(GetSerialArenaFast(&arena))) {
return arena;
} else {
return GetSerialArenaFallback(&thread_cache());
}
}
-GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE
+PROTOBUF_NOINLINE
void* ArenaImpl::SerialArena::AllocateAlignedFallback(size_t n) {
// Sync back to current's pos.
head_->set_pos(head_->size() - (limit_ - ptr_));
@@ -362,7 +362,7 @@ ArenaImpl::SerialArena* ArenaImpl::SerialArena::New(Block* b, void* owner,
return serial;
}
-GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE
+PROTOBUF_NOINLINE
ArenaImpl::SerialArena* ArenaImpl::GetSerialArenaFallback(void* me) {
// Look for this SerialArena in our linked list.
SerialArena* serial = threads_.load(std::memory_order_acquire);
diff --git a/src/google/protobuf/arena.h b/src/google/protobuf/arena.h
index 53099ff6..a38a8021 100644
--- a/src/google/protobuf/arena.h
+++ b/src/google/protobuf/arena.h
@@ -187,7 +187,7 @@ struct ArenaOptions {
// Support for non-RTTI environments. (The metrics hooks API uses type
// information.)
-#if GOOGLE_PROTOBUF_RTTI
+#if PROTOBUF_RTTI
#define RTTI_TYPE_ID(type) (&typeid(type))
#else
#define RTTI_TYPE_ID(type) (NULL)
@@ -245,7 +245,7 @@ struct ArenaOptions {
//
// Do NOT subclass Arena. This class will be marked as final when C++11 is
// enabled.
-class LIBPROTOBUF_EXPORT Arena {
+class PROTOBUF_EXPORT Arena {
public:
// Arena constructor taking custom options. See ArenaOptions below for
// descriptions of the options available.
@@ -295,8 +295,7 @@ class LIBPROTOBUF_EXPORT Arena {
// This function also accepts any type T that satisfies the arena message
// allocation protocol, documented above.
template <typename T, typename... Args>
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE static T* CreateMessage(
- Arena* arena, Args&&... args) {
+ PROTOBUF_ALWAYS_INLINE static T* CreateMessage(Arena* arena, Args&&... args) {
static_assert(
InternalHelper<T>::is_arena_constructable::value,
"CreateMessage can only construct types that are ArenaConstructable");
@@ -322,8 +321,7 @@ class LIBPROTOBUF_EXPORT Arena {
// if the object were allocated on the heap (except that the underlying memory
// is obtained from the arena).
template <typename T, typename... Args>
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE static T* Create(Arena* arena,
- Args&&... args) {
+ PROTOBUF_ALWAYS_INLINE static T* Create(Arena* arena, Args&&... args) {
return CreateNoMessage<T>(arena, is_arena_constructable<T>(),
std::forward<Args>(args)...);
}
@@ -335,8 +333,8 @@ class LIBPROTOBUF_EXPORT Arena {
// (when compiled as C++11) that T is trivially default-constructible and
// trivially destructible.
template <typename T>
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE static T* CreateArray(
- Arena* arena, size_t num_elements) {
+ PROTOBUF_ALWAYS_INLINE static T* CreateArray(Arena* arena,
+ size_t num_elements) {
static_assert(std::is_pod<T>::value,
"CreateArray requires a trivially constructible type");
static_assert(std::is_trivially_destructible<T>::value,
@@ -363,8 +361,7 @@ class LIBPROTOBUF_EXPORT Arena {
//
// Combines SpaceAllocated and SpaceUsed. Returns a pair of
// <space_allocated, space_used>.
- GOOGLE_PROTOBUF_DEPRECATED_MSG(
- "Please use SpaceAllocated() and SpaceUsed()")
+ PROTOBUF_DEPRECATED_MSG("Please use SpaceAllocated() and SpaceUsed()")
std::pair<uint64, uint64> SpaceAllocatedAndUsed() const {
return std::make_pair(SpaceAllocated(), SpaceUsed());
}
@@ -374,7 +371,7 @@ class LIBPROTOBUF_EXPORT Arena {
// Any objects allocated on this arena are unusable after this call. It also
// returns the total space used by the arena which is the sums of the sizes
// of the allocated blocks. This method is not thread-safe.
- GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE uint64 Reset() {
+ PROTOBUF_NOINLINE uint64 Reset() {
// Call the reset hook
if (on_arena_reset_ != NULL) {
on_arena_reset_(this, hooks_cookie_, impl_.SpaceAllocated());
@@ -385,7 +382,7 @@ class LIBPROTOBUF_EXPORT Arena {
// Adds |object| to a list of heap-allocated objects to be freed with |delete|
// when the arena is destroyed or reset.
template <typename T>
- GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE void Own(T* object) {
+ PROTOBUF_NOINLINE void Own(T* object) {
OwnInternal(object, std::is_convertible<T*, Message*>());
}
@@ -395,7 +392,7 @@ class LIBPROTOBUF_EXPORT Arena {
// normally only used for objects that are placement-newed into
// arena-allocated memory.
template <typename T>
- GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE void OwnDestructor(T* object) {
+ PROTOBUF_NOINLINE void OwnDestructor(T* object) {
if (object != NULL) {
impl_.AddCleanup(object, &internal::arena_destruct_object<T>);
}
@@ -405,7 +402,7 @@ class LIBPROTOBUF_EXPORT Arena {
// will be manually called when the arena is destroyed or reset. This differs
// from OwnDestructor() in that any member function may be specified, not only
// the class destructor.
- GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE void OwnCustomDestructor(
+ PROTOBUF_NOINLINE void OwnCustomDestructor(
void* object, void (*destruct)(void*)) {
impl_.AddCleanup(object, destruct);
}
@@ -415,8 +412,7 @@ class LIBPROTOBUF_EXPORT Arena {
// latter is a virtual call, while this method is a templated call that
// resolves at compile-time.
template <typename T>
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE static Arena* GetArena(
- const T* value) {
+ PROTOBUF_ALWAYS_INLINE static Arena* GetArena(const T* value) {
return GetArenaInternal(value, is_arena_constructable<T>());
}
@@ -474,8 +470,8 @@ class LIBPROTOBUF_EXPORT Arena {
private:
template <typename T, typename... Args>
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE static T* CreateMessageInternal(
- Arena* arena, Args&&... args) {
+ PROTOBUF_ALWAYS_INLINE static T* CreateMessageInternal(Arena* arena,
+ Args&&... args) {
static_assert(
InternalHelper<T>::is_arena_constructable::value,
"CreateMessage can only construct types that are ArenaConstructable");
@@ -490,8 +486,7 @@ class LIBPROTOBUF_EXPORT Arena {
// slightly different. When the arena pointer is nullptr, it calls T()
// instead of T(nullptr).
template <typename T>
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE static T* CreateMessageInternal(
- Arena* arena) {
+ PROTOBUF_ALWAYS_INLINE static T* CreateMessageInternal(Arena* arena) {
static_assert(
InternalHelper<T>::is_arena_constructable::value,
"CreateMessage can only construct types that are ArenaConstructable");
@@ -503,8 +498,8 @@ class LIBPROTOBUF_EXPORT Arena {
}
template <typename T, typename... Args>
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE static T* CreateInternal(
- Arena* arena, Args&&... args) {
+ PROTOBUF_ALWAYS_INLINE static T* CreateInternal(Arena* arena,
+ Args&&... args) {
if (arena == NULL) {
return new T(std::forward<Args>(args)...);
} else {
@@ -516,7 +511,7 @@ class LIBPROTOBUF_EXPORT Arena {
void CallDestructorHooks();
void OnArenaAllocation(const std::type_info* allocated_type, size_t n) const;
inline void AllocHook(const std::type_info* allocated_type, size_t n) const {
- if (GOOGLE_PREDICT_FALSE(hooks_cookie_ != NULL)) {
+ if (PROTOBUF_PREDICT_FALSE(hooks_cookie_ != NULL)) {
OnArenaAllocation(allocated_type, n);
}
}
@@ -525,8 +520,7 @@ class LIBPROTOBUF_EXPORT Arena {
// allocated type info when the hooks are in place in ArenaOptions and
// the cookie is not null.
template <typename T>
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE void* AllocateInternal(
- bool skip_explicit_ownership) {
+ PROTOBUF_ALWAYS_INLINE void* AllocateInternal(bool skip_explicit_ownership) {
const size_t n = internal::AlignUpTo8(sizeof(T));
AllocHook(RTTI_TYPE_ID(T), n);
// Monitor allocation if needed.
@@ -544,27 +538,29 @@ class LIBPROTOBUF_EXPORT Arena {
// user code. These are used only internally from LazyField and Repeated
// fields, since they are designed to work in all mode combinations.
template <typename Msg, typename... Args>
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE static Msg* DoCreateMaybeMessage(
- Arena* arena, std::true_type, Args&&... args) {
+ PROTOBUF_ALWAYS_INLINE static Msg* DoCreateMaybeMessage(Arena* arena,
+ std::true_type,
+ Args&&... args) {
return CreateMessageInternal<Msg>(arena, std::forward<Args>(args)...);
}
template <typename T, typename... Args>
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE static T* DoCreateMaybeMessage(
- Arena* arena, std::false_type, Args&&... args) {
+ PROTOBUF_ALWAYS_INLINE static T* DoCreateMaybeMessage(Arena* arena,
+ std::false_type,
+ Args&&... args) {
return CreateInternal<T>(arena, std::forward<Args>(args)...);
}
template <typename T, typename... Args>
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE static T* CreateMaybeMessage(
- Arena* arena, Args&&... args) {
+ PROTOBUF_ALWAYS_INLINE static T* CreateMaybeMessage(Arena* arena,
+ Args&&... args) {
return DoCreateMaybeMessage<T>(arena, is_arena_constructable<T>(),
std::forward<Args>(args)...);
}
template <typename T, typename... Args>
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE static T* CreateNoMessage(
- Arena* arena, std::true_type, Args&&... args) {
+ PROTOBUF_ALWAYS_INLINE static T* CreateNoMessage(Arena* arena, std::true_type,
+ Args&&... args) {
// User is constructing with Create() despite the fact that T supports arena
// construction. In this case we have to delegate to CreateInternal(), and
// we can't use any CreateMaybeMessage() specialization that may be defined.
@@ -572,8 +568,9 @@ class LIBPROTOBUF_EXPORT Arena {
}
template <typename T, typename... Args>
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE static T* CreateNoMessage(
- Arena* arena, std::false_type, Args&&... args) {
+ PROTOBUF_ALWAYS_INLINE static T* CreateNoMessage(Arena* arena,
+ std::false_type,
+ Args&&... args) {
// User is constructing with Create() and the type does not support arena
// construction. In this case we can delegate to CreateMaybeMessage() and
// use any specialization that may be available for that.
@@ -583,8 +580,7 @@ class LIBPROTOBUF_EXPORT Arena {
// Just allocate the required size for the given type assuming the
// type has a trivial constructor.
template <typename T>
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE T* CreateInternalRawArray(
- size_t num_elements) {
+ PROTOBUF_ALWAYS_INLINE T* CreateInternalRawArray(size_t num_elements) {
GOOGLE_CHECK_LE(num_elements, std::numeric_limits<size_t>::max() / sizeof(T))
<< "Requested size is too large to fit into size_t.";
const size_t n = internal::AlignUpTo8(sizeof(T) * num_elements);
@@ -594,13 +590,13 @@ class LIBPROTOBUF_EXPORT Arena {
}
template <typename T, typename... Args>
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE T* DoCreate(
- bool skip_explicit_ownership, Args&&... args) {
+ PROTOBUF_ALWAYS_INLINE T* DoCreate(bool skip_explicit_ownership,
+ Args&&... args) {
return new (AllocateInternal<T>(skip_explicit_ownership))
T(std::forward<Args>(args)...);
}
template <typename T, typename... Args>
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE T* DoCreateMessage(Args&&... args) {
+ PROTOBUF_ALWAYS_INLINE T* DoCreateMessage(Args&&... args) {
return InternalHelper<T>::Construct(
AllocateInternal<T>(InternalHelper<T>::is_destructor_skippable::value),
this, std::forward<Args>(args)...);
@@ -644,15 +640,13 @@ class LIBPROTOBUF_EXPORT Arena {
// all template instantiations to one for generic Message reduces code size,
// using the virtual destructor instead.
template <typename T>
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE void OwnInternal(T* object,
- std::true_type) {
+ PROTOBUF_ALWAYS_INLINE void OwnInternal(T* object, std::true_type) {
if (object != NULL) {
impl_.AddCleanup(object, &internal::arena_delete_object<Message>);
}
}
template <typename T>
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE void OwnInternal(T* object,
- std::false_type) {
+ PROTOBUF_ALWAYS_INLINE void OwnInternal(T* object, std::false_type) {
if (object != NULL) {
impl_.AddCleanup(object, &internal::arena_delete_object<T>);
}
@@ -662,14 +656,14 @@ class LIBPROTOBUF_EXPORT Arena {
// InternalArenaConstructable_ tags can be associated with an arena, and such
// objects must implement a GetArenaNoVirtual() method.
template <typename T>
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE static Arena* GetArenaInternal(
- const T* value, std::true_type) {
+ PROTOBUF_ALWAYS_INLINE static Arena* GetArenaInternal(const T* value,
+ std::true_type) {
return InternalHelper<T>::GetArena(value);
}
template <typename T>
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE static Arena* GetArenaInternal(
- const T* /* value */, std::false_type) {
+ PROTOBUF_ALWAYS_INLINE static Arena* GetArenaInternal(const T* /* value */,
+ std::false_type) {
return NULL;
}
diff --git a/src/google/protobuf/arena_impl.h b/src/google/protobuf/arena_impl.h
index 0b71819d..a0fb1069 100644
--- a/src/google/protobuf/arena_impl.h
+++ b/src/google/protobuf/arena_impl.h
@@ -61,7 +61,7 @@ inline size_t AlignUpTo8(size_t n) {
// in turn would be templates, which will/cannot happen. However separating
// the memory allocation part from the cruft of the API users expect we can
// use #ifdef the select the best implementation based on hardware / OS.
-class LIBPROTOBUF_EXPORT ArenaImpl {
+class PROTOBUF_EXPORT ArenaImpl {
public:
struct Options {
size_t start_block_size;
@@ -137,7 +137,7 @@ class LIBPROTOBUF_EXPORT ArenaImpl {
class Block;
// A thread-unsafe Arena that can only be used within its owning thread.
- class LIBPROTOBUF_EXPORT SerialArena {
+ class PROTOBUF_EXPORT SerialArena {
public:
// The allocate/free methods here are a little strange, since SerialArena is
// allocated inside a Block which it also manages. This is to avoid doing
@@ -157,7 +157,7 @@ class LIBPROTOBUF_EXPORT ArenaImpl {
void* AllocateAligned(size_t n) {
GOOGLE_DCHECK_EQ(internal::AlignUpTo8(n), n); // Must be already aligned.
GOOGLE_DCHECK_GE(limit_, ptr_);
- if (GOOGLE_PREDICT_FALSE(static_cast<size_t>(limit_ - ptr_) < n)) {
+ if (PROTOBUF_PREDICT_FALSE(static_cast<size_t>(limit_ - ptr_) < n)) {
return AllocateAlignedFallback(n);
}
void* ret = ptr_;
@@ -169,7 +169,7 @@ class LIBPROTOBUF_EXPORT ArenaImpl {
}
void AddCleanup(void* elem, void (*cleanup)(void*)) {
- if (GOOGLE_PREDICT_FALSE(cleanup_ptr_ == cleanup_limit_)) {
+ if (PROTOBUF_PREDICT_FALSE(cleanup_ptr_ == cleanup_limit_)) {
AddCleanupFallback(elem, cleanup);
return;
}
@@ -212,7 +212,7 @@ class LIBPROTOBUF_EXPORT ArenaImpl {
// Blocks are variable length malloc-ed objects. The following structure
// describes the common header for all blocks.
- class LIBPROTOBUF_EXPORT Block {
+ class PROTOBUF_EXPORT Block {
public:
Block(size_t size, Block* next);
diff --git a/src/google/protobuf/arena_test_util.h b/src/google/protobuf/arena_test_util.h
index 9c821b90..fdbaca06 100644
--- a/src/google/protobuf/arena_test_util.h
+++ b/src/google/protobuf/arena_test_util.h
@@ -33,6 +33,8 @@
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/io/coded_stream.h>
+#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
#include <google/protobuf/arena.h>
namespace google {
@@ -41,7 +43,15 @@ namespace protobuf {
template <typename T, bool use_arena>
void TestParseCorruptedString(const T& message) {
int success_count = 0;
- string s = message.SerializeAsString();
+ std::string s;
+ {
+ // Map order is not deterministic. To make the test deterministic we want
+ // to serialize the proto deterministically.
+ io::StringOutputStream output(&s);
+ io::CodedOutputStream out(&output);
+ out.SetSerializationDeterministic(true);
+ message.SerializePartialToCodedStream(&out);
+ }
const int kMaxIters = 900;
const int stride = s.size() <= kMaxIters ? 1 : s.size() / kMaxIters;
const int start = stride == 1 || use_arena ? 0 : (stride + 1) / 2;
diff --git a/src/google/protobuf/arena_unittest.cc b/src/google/protobuf/arena_unittest.cc
index 92e5c84d..361b83ef 100644
--- a/src/google/protobuf/arena_unittest.cc
+++ b/src/google/protobuf/arena_unittest.cc
@@ -586,7 +586,7 @@ TEST(ArenaTest, ReleaseFromArenaMessageMakesCopy) {
delete nested_string;
}
-#if GOOGLE_PROTOBUF_RTTI
+#if PROTOBUF_RTTI
TEST(ArenaTest, ReleaseFromArenaMessageUsingReflectionMakesCopy) {
TestAllTypes::NestedMessage* nested_msg = NULL;
// Note: no string: reflection API only supports releasing submessages.
@@ -603,7 +603,7 @@ TEST(ArenaTest, ReleaseFromArenaMessageUsingReflectionMakesCopy) {
EXPECT_EQ(42, nested_msg->bb());
delete nested_msg;
}
-#endif // GOOGLE_PROTOBUF_RTTI
+#endif // PROTOBUF_RTTI
TEST(ArenaTest, SetAllocatedAcrossArenas) {
Arena arena1;
@@ -1129,7 +1129,7 @@ TEST(ArenaTest, RepeatedFieldOnArena) {
}
-#if GOOGLE_PROTOBUF_RTTI
+#if PROTOBUF_RTTI
TEST(ArenaTest, MutableMessageReflection) {
Arena arena;
TestAllTypes* message = Arena::CreateMessage<TestAllTypes>(&arena);
@@ -1153,7 +1153,7 @@ TEST(ArenaTest, MutableMessageReflection) {
EXPECT_EQ(submessage_expected, submessage);
EXPECT_EQ(&arena, submessage->GetArena());
}
-#endif // GOOGLE_PROTOBUF_RTTI
+#endif // PROTOBUF_RTTI
void FillArenaAwareFields(TestAllTypes* message) {
@@ -1199,7 +1199,7 @@ TEST(ArenaTest, ParseCorruptedString) {
TestParseCorruptedString<TestAllTypes, false>(message);
}
-#if GOOGLE_PROTOBUF_RTTI
+#if PROTOBUF_RTTI
// Test construction on an arena via generic MessageLite interface. We should be
// able to successfully deserialize on the arena without incurring heap
// allocations, i.e., everything should still be arena-allocation-aware.
@@ -1228,7 +1228,7 @@ TEST(ArenaTest, MessageLiteOnArena) {
arena.Reset();
}
-#endif // GOOGLE_PROTOBUF_RTTI
+#endif // PROTOBUF_RTTI
// RepeatedField should support non-POD types, and invoke constructors and
diff --git a/src/google/protobuf/arenastring.h b/src/google/protobuf/arenastring.h
index 168fc972..cb4dc8b3 100644
--- a/src/google/protobuf/arenastring.h
+++ b/src/google/protobuf/arenastring.h
@@ -39,6 +39,8 @@
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/port.h>
+#include <google/protobuf/port_def.inc>
+
// This is the implementation of arena string fields written for the open-source
// release. The ArenaStringPtr struct below is an internal implementation class
// and *should not be used* by user code. It is used to collect string
@@ -63,7 +65,7 @@ class TaggedPtr {
uintptr_t ptr_;
};
-struct LIBPROTOBUF_EXPORT ArenaStringPtr {
+struct PROTOBUF_EXPORT ArenaStringPtr {
inline void Set(const ::std::string* default_value,
const ::std::string& value, ::google::protobuf::Arena* arena) {
if (ptr_ == default_value) {
@@ -168,11 +170,12 @@ struct LIBPROTOBUF_EXPORT ArenaStringPtr {
// Swaps internal pointers. Arena-safety semantics: this is guarded by the
// logic in Swap()/UnsafeArenaSwap() at the message level, so this method is
// 'unsafe' if called directly.
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE void Swap(ArenaStringPtr* other) {
+ PROTOBUF_ALWAYS_INLINE void Swap(ArenaStringPtr* other) {
std::swap(ptr_, other->ptr_);
}
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE void Swap(
- ArenaStringPtr* other, const ::std::string* default_value, Arena* arena) {
+ PROTOBUF_ALWAYS_INLINE void Swap(ArenaStringPtr* other,
+ const ::std::string* default_value,
+ Arena* arena) {
#ifndef NDEBUG
// For debug builds, we swap the contents of the string, rather than the
// string instances themselves. This invalidates previously taken const
@@ -364,14 +367,14 @@ struct LIBPROTOBUF_EXPORT ArenaStringPtr {
private:
::std::string* ptr_;
- GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE
+ PROTOBUF_NOINLINE
void CreateInstance(::google::protobuf::Arena* arena,
const ::std::string* initial_value) {
GOOGLE_DCHECK(initial_value != NULL);
// uses "new ::std::string" when arena is nullptr
ptr_ = Arena::Create< ::std::string >(arena, *initial_value);
}
- GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE
+ PROTOBUF_NOINLINE
void CreateInstanceNoArena(const ::std::string* initial_value) {
GOOGLE_DCHECK(initial_value != NULL);
ptr_ = new ::std::string(*initial_value);
@@ -398,6 +401,8 @@ inline void ArenaStringPtr::AssignWithDefault(const ::std::string* default_value
} // namespace internal
} // namespace protobuf
-
} // namespace google
+
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_ARENASTRING_H__
diff --git a/src/google/protobuf/compiler/annotation_test_util.h b/src/google/protobuf/compiler/annotation_test_util.h
index 34c3f6a9..fbd3dec5 100644
--- a/src/google/protobuf/compiler/annotation_test_util.h
+++ b/src/google/protobuf/compiler/annotation_test_util.h
@@ -49,15 +49,15 @@ namespace annotation_test_util {
// file_content = content of Foo.java
// file_info = parsed content of Foo.java.pb.meta
struct ExpectedOutput {
- string file_path;
- string file_content;
+ std::string file_path;
+ std::string file_content;
GeneratedCodeInfo file_info;
- explicit ExpectedOutput(const string& file_path) : file_path(file_path) {}
+ explicit ExpectedOutput(const std::string& file_path) : file_path(file_path) {}
};
// Creates a file with name `filename` and content `data` in temp test
// directory.
-void AddFile(const string& filename, const string& data);
+void AddFile(const std::string& filename, const std::string& data);
// Runs proto compiler. Captures proto file structrue in FileDescriptorProto.
// Files will be generated in TestTempDir() folder. Callers of this
@@ -70,17 +70,17 @@ void AddFile(const string& filename, const string& data);
// annotation_unittest.cc for an example of how to initialize it.
// file: output parameter, will be set to the descriptor of the proto file
// specified in filename.
-bool RunProtoCompiler(const string& filename,
- const string& plugin_specific_args,
+bool RunProtoCompiler(const std::string& filename,
+ const std::string& plugin_specific_args,
CommandLineInterface* cli, FileDescriptorProto* file);
-bool DecodeMetadata(const string& path, GeneratedCodeInfo* info);
+bool DecodeMetadata(const std::string& path, GeneratedCodeInfo* info);
// Finds all of the Annotations for a given source file and path.
// See Location.path in http://google3/net/proto2/proto/descriptor.proto for
// explanation of what path vector is.
void FindAnnotationsOnPath(
- const GeneratedCodeInfo& info, const string& source_file,
+ const GeneratedCodeInfo& info, const std::string& source_file,
const std::vector<int>& path,
std::vector<const GeneratedCodeInfo::Annotation*>* annotations);
@@ -90,21 +90,21 @@ void FindAnnotationsOnPath(
// http://google3/net/proto2/proto/descriptor.proto for explanation of what path
// vector is.
const GeneratedCodeInfo::Annotation* FindAnnotationOnPath(
- const GeneratedCodeInfo& info, const string& source_file,
+ const GeneratedCodeInfo& info, const std::string& source_file,
const std::vector<int>& path);
// Returns true if at least one of the provided annotations covers a given
// substring in file_content.
bool AtLeastOneAnnotationMatchesSubstring(
- const string& file_content,
+ const std::string& file_content,
const std::vector<const GeneratedCodeInfo::Annotation*>& annotations,
- const string& expected_text);
+ const std::string& expected_text);
// Returns true if the provided annotation covers a given substring in
// file_content.
-bool AnnotationMatchesSubstring(const string& file_content,
+bool AnnotationMatchesSubstring(const std::string& file_content,
const GeneratedCodeInfo::Annotation* annotation,
- const string& expected_text);
+ const std::string& expected_text);
} // namespace annotation_test_util
} // namespace compiler
diff --git a/src/google/protobuf/compiler/code_generator.h b/src/google/protobuf/compiler/code_generator.h
index a1cd6113..b1eb61ac 100644
--- a/src/google/protobuf/compiler/code_generator.h
+++ b/src/google/protobuf/compiler/code_generator.h
@@ -43,6 +43,8 @@
#include <vector>
#include <utility>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
@@ -61,7 +63,7 @@ class GeneratorContext;
// The abstract interface to a class which generates code implementing a
// particular proto file in a particular language. A number of these may
// be registered with CommandLineInterface to support various languages.
-class LIBPROTOC_EXPORT CodeGenerator {
+class PROTOC_EXPORT CodeGenerator {
public:
inline CodeGenerator() {}
virtual ~CodeGenerator();
@@ -78,9 +80,9 @@ class LIBPROTOC_EXPORT CodeGenerator {
// Returns true if successful. Otherwise, sets *error to a description of
// the problem (e.g. "invalid parameter") and returns false.
virtual bool Generate(const FileDescriptor* file,
- const string& parameter,
+ const std::string& parameter,
GeneratorContext* generator_context,
- string* error) const = 0;
+ std::string* error) const = 0;
// Generates code for all given proto files.
//
@@ -94,9 +96,9 @@ class LIBPROTOC_EXPORT CodeGenerator {
// Returns true if successful. Otherwise, sets *error to a description of
// the problem (e.g. "invalid parameter") and returns false.
virtual bool GenerateAll(const std::vector<const FileDescriptor*>& files,
- const string& parameter,
+ const std::string& parameter,
GeneratorContext* generator_context,
- string* error) const;
+ std::string* error) const;
// This is no longer used, but this class is part of the opensource protobuf
// library, so it has to remain to keep vtables the same for the current
@@ -112,7 +114,7 @@ class LIBPROTOC_EXPORT CodeGenerator {
// abstract interface represents the directory to which the CodeGenerator is
// to write and other information about the context in which the Generator
// runs.
-class LIBPROTOC_EXPORT GeneratorContext {
+class PROTOC_EXPORT GeneratorContext {
public:
inline GeneratorContext() {
}
@@ -128,10 +130,10 @@ class LIBPROTOC_EXPORT GeneratorContext {
// generate the files "foo/bar.pb.h" and "foo/bar.pb.cc"; note that
// "foo/" is included in these filenames. The filename is not allowed to
// contain "." or ".." components.
- virtual io::ZeroCopyOutputStream* Open(const string& filename) = 0;
+ virtual io::ZeroCopyOutputStream* Open(const std::string& filename) = 0;
// Similar to Open() but the output will be appended to the file if exists
- virtual io::ZeroCopyOutputStream* OpenForAppend(const string& filename);
+ virtual io::ZeroCopyOutputStream* OpenForAppend(const std::string& filename);
// Creates a ZeroCopyOutputStream which will insert code into the given file
// at the given insertion point. See plugin.proto (plugin.pb.h) for more
@@ -140,7 +142,7 @@ class LIBPROTOC_EXPORT GeneratorContext {
//
// WARNING: This feature is currently EXPERIMENTAL and is subject to change.
virtual io::ZeroCopyOutputStream* OpenForInsert(
- const string& filename, const string& insertion_point);
+ const std::string& filename, const std::string& insertion_point);
// Returns a vector of FileDescriptors for all the files being compiled
// in this run. Useful for languages, such as Go, that treat files
@@ -166,11 +168,13 @@ typedef GeneratorContext OutputDirectory;
// "foo=bar,baz,qux=corge"
// parses to the pairs:
// ("foo", "bar"), ("baz", ""), ("qux", "corge")
-LIBPROTOC_EXPORT void ParseGeneratorParameter(
- const string&, std::vector<std::pair<string, string> >*);
+PROTOC_EXPORT void ParseGeneratorParameter(
+ const std::string&, std::vector<std::pair<std::string, std::string> >*);
} // namespace compiler
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_COMPILER_CODE_GENERATOR_H__
diff --git a/src/google/protobuf/compiler/command_line_interface.cc b/src/google/protobuf/compiler/command_line_interface.cc
index 80056774..4d1ef09b 100644
--- a/src/google/protobuf/compiler/command_line_interface.cc
+++ b/src/google/protobuf/compiler/command_line_interface.cc
@@ -84,6 +84,8 @@
#include <google/protobuf/stubs/io_win32.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace compiler {
@@ -169,7 +171,8 @@ bool VerifyDirectoryExists(const string& path) {
bool TryCreateParentDirectory(const string& prefix, const string& filename) {
// Recursively create parent directories to the output file.
// On Windows, both '/' and '\' are valid path separators.
- std::vector<string> parts = Split(filename, "/\\", true);
+ std::vector<string> parts =
+ Split(filename, "/\\", true);
string path_so_far = prefix;
for (int i = 0; i < parts.size() - 1; i++) {
path_so_far += parts[i];
@@ -1546,7 +1549,7 @@ CommandLineInterface::InterpretArgument(const string& name,
std::cout << version_info_ << std::endl;
}
std::cout << "libprotoc "
- << protobuf::internal::VersionString(GOOGLE_PROTOBUF_VERSION)
+ << protobuf::internal::VersionString(PROTOBUF_VERSION)
<< std::endl;
return PARSE_ARGUMENT_DONE_AND_EXIT; // Exit without running compiler.
@@ -1932,10 +1935,10 @@ bool CommandLineInterface::GeneratePluginOutput(
google::protobuf::compiler::Version* version =
request.mutable_compiler_version();
- version->set_major(GOOGLE_PROTOBUF_VERSION / 1000000);
- version->set_minor(GOOGLE_PROTOBUF_VERSION / 1000 % 1000);
- version->set_patch(GOOGLE_PROTOBUF_VERSION % 1000);
- version->set_suffix(GOOGLE_PROTOBUF_VERSION_SUFFIX);
+ version->set_major(PROTOBUF_VERSION / 1000000);
+ version->set_minor(PROTOBUF_VERSION / 1000 % 1000);
+ version->set_patch(PROTOBUF_VERSION % 1000);
+ version->set_suffix(PROTOBUF_VERSION_SUFFIX);
// Invoke the plugin.
Subprocess subprocess;
diff --git a/src/google/protobuf/compiler/command_line_interface.h b/src/google/protobuf/compiler/command_line_interface.h
index 8dba9949..cef29ffe 100644
--- a/src/google/protobuf/compiler/command_line_interface.h
+++ b/src/google/protobuf/compiler/command_line_interface.h
@@ -47,6 +47,8 @@
#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
@@ -102,7 +104,7 @@ class DiskSourceTree; // importer.h
// relative virtual path, the physical file path takes precendence.
//
// For a full description of the command-line syntax, invoke it with --help.
-class LIBPROTOC_EXPORT CommandLineInterface {
+class PROTOC_EXPORT CommandLineInterface {
public:
static const char* const kPathSeparator;
@@ -125,9 +127,9 @@ class LIBPROTOC_EXPORT CommandLineInterface {
// protoc --foo_out=enable_bar:outdir
// The text before the colon is passed to CodeGenerator::Generate() as the
// "parameter".
- void RegisterGenerator(const string& flag_name,
+ void RegisterGenerator(const std::string& flag_name,
CodeGenerator* generator,
- const string& help_text);
+ const std::string& help_text);
// Register a code generator for a language.
// Besides flag_name you can specify another option_flag_name that could be
@@ -137,10 +139,10 @@ class LIBPROTOC_EXPORT CommandLineInterface {
// Then you could invoke the compiler with a command like:
// protoc --foo_out=enable_bar:outdir --foo_opt=enable_baz
// This will pass "enable_bar,enable_baz" as the parameter to the generator.
- void RegisterGenerator(const string& flag_name,
- const string& option_flag_name,
+ void RegisterGenerator(const std::string& flag_name,
+ const std::string& option_flag_name,
CodeGenerator* generator,
- const string& help_text);
+ const std::string& help_text);
// Enables "plugins". In this mode, if a command-line flag ends with "_out"
// but does not match any registered generator, the compiler will attempt to
@@ -178,7 +180,7 @@ class LIBPROTOC_EXPORT CommandLineInterface {
// protoc --plug_out=enable_bar:outdir --plug_opt=enable_baz
// This will pass "enable_bar,enable_baz" as the parameter to the plugin.
//
- void AllowPlugins(const string& exe_name_prefix);
+ void AllowPlugins(const std::string& exe_name_prefix);
// Run the Protocol Compiler with the given command-line parameters.
// Returns the error code which should be returned by main().
@@ -196,7 +198,7 @@ class LIBPROTOC_EXPORT CommandLineInterface {
// Provides some text which will be printed when the --version flag is
// used. The version of libprotoc will also be printed on the next line
// after this text.
- void SetVersionInfo(const string& text) {
+ void SetVersionInfo(const std::string& text) {
version_info_ = text;
}
@@ -207,14 +209,14 @@ class LIBPROTOC_EXPORT CommandLineInterface {
class ErrorPrinter;
class GeneratorContextImpl;
class MemoryOutputStream;
- typedef std::unordered_map<string, GeneratorContextImpl*> GeneratorContextMap;
+ typedef std::unordered_map<std::string, GeneratorContextImpl*> GeneratorContextMap;
// Clear state from previous Run().
void Clear();
// Remaps the proto file so that it is relative to one of the ddirectories
// in proto_path_. Returns false if an error occurred.
- bool MakeProtoProtoPathRelative(DiskSourceTree* source_tree, string* proto);
+ bool MakeProtoProtoPathRelative(DiskSourceTree* source_tree, std::string* proto);
// Remaps each file in input_files_ so that it is relative to one of the
// directories in proto_path_. Returns false if an error occurred.
@@ -234,7 +236,7 @@ class LIBPROTOC_EXPORT CommandLineInterface {
// Read an argument file and append the file's content to the list of
// arguments. Return false if the file cannot be read.
- bool ExpandArgumentFile(const string& file, std::vector<string>* arguments);
+ bool ExpandArgumentFile(const std::string& file, std::vector<std::string>* arguments);
// Parses a command-line argument into a name/value pair. Returns
// true if the next argument in the argv should be used as the value,
@@ -247,11 +249,11 @@ class LIBPROTOC_EXPORT CommandLineInterface {
// name = "--cpp_out", value = "src/foo.pb2.cc"
// "foo.proto" ->
// name = "", value = "foo.proto"
- bool ParseArgument(const char* arg, string* name, string* value);
+ bool ParseArgument(const char* arg, std::string* name, std::string* value);
// Interprets arguments parsed with ParseArgument.
- ParseArgumentStatus InterpretArgument(const string& name,
- const string& value);
+ ParseArgumentStatus InterpretArgument(const std::string& name,
+ const std::string& value);
// Print the --help text to stderr.
void PrintHelpText();
@@ -273,8 +275,8 @@ class LIBPROTOC_EXPORT CommandLineInterface {
GeneratorContext* generator_context);
bool GeneratePluginOutput(
const std::vector<const FileDescriptor*>& parsed_files,
- const string& plugin_name, const string& parameter,
- GeneratorContext* generator_context, string* error);
+ const std::string& plugin_name, const std::string& parameter,
+ GeneratorContext* generator_context, std::string* error);
// Implements --encode and --decode.
bool EncodeOrDecode(const DescriptorPool* pool);
@@ -324,36 +326,36 @@ class LIBPROTOC_EXPORT CommandLineInterface {
// -----------------------------------------------------------------
// The name of the executable as invoked (i.e. argv[0]).
- string executable_name_;
+ std::string executable_name_;
// Version info set with SetVersionInfo().
- string version_info_;
+ std::string version_info_;
// Registered generators.
struct GeneratorInfo {
- string flag_name;
- string option_flag_name;
+ std::string flag_name;
+ std::string option_flag_name;
CodeGenerator* generator;
- string help_text;
+ std::string help_text;
};
- typedef std::map<string, GeneratorInfo> GeneratorMap;
+ typedef std::map<std::string, GeneratorInfo> GeneratorMap;
GeneratorMap generators_by_flag_name_;
GeneratorMap generators_by_option_name_;
// A map from generator names to the parameters specified using the option
// flag. For example, if the user invokes the compiler with:
// protoc --foo_out=outputdir --foo_opt=enable_bar ...
// Then there will be an entry ("--foo_out", "enable_bar") in this map.
- std::map<string, string> generator_parameters_;
+ std::map<std::string, std::string> generator_parameters_;
// Similar to generator_parameters_, but stores the parameters for plugins.
- std::map<string, string> plugin_parameters_;
+ std::map<std::string, std::string> plugin_parameters_;
// See AllowPlugins(). If this is empty, plugins aren't allowed.
- string plugin_prefix_;
+ std::string plugin_prefix_;
// Maps specific plugin names to files. When executing a plugin, this map
// is searched first to find the plugin executable. If not found here, the
// PATH (or other OS-specific search strategy) is searched.
- std::map<string, string> plugins_;
+ std::map<std::string, std::string> plugins_;
// Stuff parsed from command line.
enum Mode {
@@ -379,44 +381,44 @@ class LIBPROTOC_EXPORT CommandLineInterface {
ErrorFormat error_format_;
- std::vector<std::pair<string, string> >
+ std::vector<std::pair<std::string, std::string> >
proto_path_; // Search path for proto files.
- std::vector<string> input_files_; // Names of the input proto files.
+ std::vector<std::string> input_files_; // Names of the input proto files.
// Names of proto files which are allowed to be imported. Used by build
// systems to enforce depend-on-what-you-import.
- std::set<string> direct_dependencies_;
+ std::set<std::string> direct_dependencies_;
bool direct_dependencies_explicitly_set_;
// If there's a violation of depend-on-what-you-import, this string will be
// presented to the user. "%s" will be replaced with the violating import.
- string direct_dependencies_violation_msg_;
+ std::string direct_dependencies_violation_msg_;
// output_directives_ lists all the files we are supposed to output and what
// generator to use for each.
struct OutputDirective {
- string name; // E.g. "--foo_out"
+ std::string name; // E.g. "--foo_out"
CodeGenerator* generator; // NULL for plugins
- string parameter;
- string output_location;
+ std::string parameter;
+ std::string output_location;
};
std::vector<OutputDirective> output_directives_;
// When using --encode or --decode, this names the type we are encoding or
// decoding. (Empty string indicates --decode_raw.)
- string codec_type_;
+ std::string codec_type_;
// If --descriptor_set_in was given, these are filenames containing
// parsed FileDescriptorSets to be used for loading protos. Otherwise, empty.
- std::vector<string> descriptor_set_in_names_;
+ std::vector<std::string> descriptor_set_in_names_;
// If --descriptor_set_out was given, this is the filename to which the
// FileDescriptorSet should be written. Otherwise, empty.
- string descriptor_set_out_name_;
+ std::string descriptor_set_out_name_;
// If --dependency_out was given, this is the path to the file where the
// dependency file will be written. Otherwise, empty.
- string dependency_out_name_;
+ std::string dependency_out_name_;
// True if --include_imports was given, meaning that we should
// write all transitive dependencies to the DescriptorSet. Otherwise, only
@@ -437,4 +439,6 @@ class LIBPROTOC_EXPORT CommandLineInterface {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_COMPILER_COMMAND_LINE_INTERFACE_H__
diff --git a/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc b/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc
index 4c135649..a19ad595 100644
--- a/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc
@@ -50,6 +50,7 @@
#include <google/protobuf/test_util2.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
#include <google/protobuf/descriptor.h>
+#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/substitute.h>
#include <google/protobuf/stubs/map_util.h>
#include <google/protobuf/stubs/stl_util.h>
@@ -98,6 +99,13 @@ class MockGeneratorContext : public GeneratorContext {
&actual_contents, true))
<< physical_filename;
CleanStringLineEndings(&actual_contents, false);
+
+#ifdef WRITE_FILES // Define to debug mismatched files.
+ GOOGLE_CHECK_OK(
+ File::SetContents("/tmp/1.cc", *expected_contents, true));
+ GOOGLE_CHECK_OK(File::SetContents("/tmp/2.cc", actual_contents, true));
+#endif
+
EXPECT_EQ(*expected_contents, actual_contents)
<< physical_filename
<< " needs to be regenerated. Please run "
@@ -119,8 +127,8 @@ class MockGeneratorContext : public GeneratorContext {
std::map<string, string*> files_;
};
-const char kDescriptorParameter[] = "dllexport_decl=LIBPROTOBUF_EXPORT";
-const char kPluginParameter[] = "dllexport_decl=LIBPROTOC_EXPORT";
+const char kDescriptorParameter[] = "dllexport_decl=PROTOBUF_EXPORT";
+const char kPluginParameter[] = "dllexport_decl=PROTOC_EXPORT";
const char kNormalParameter[] = "";
const char* test_protos[][2] = {
diff --git a/src/google/protobuf/compiler/cpp/cpp_enum.h b/src/google/protobuf/compiler/cpp/cpp_enum.h
index 55e6b835..6b9700ae 100644
--- a/src/google/protobuf/compiler/cpp/cpp_enum.h
+++ b/src/google/protobuf/compiler/cpp/cpp_enum.h
@@ -58,7 +58,7 @@ class EnumGenerator {
public:
// See generator.cc for the meaning of dllexport_decl.
EnumGenerator(const EnumDescriptor* descriptor,
- const std::map<string, string>& vars, const Options& options);
+ const std::map<std::string, std::string>& vars, const Options& options);
~EnumGenerator();
// Generate header code defining the enum. This code should be placed
@@ -85,12 +85,12 @@ class EnumGenerator {
private:
const EnumDescriptor* descriptor_;
- const string classname_;
+ const std::string classname_;
const Options& options_;
// whether to generate the *_ARRAYSIZE constant.
const bool generate_array_size_;
- std::map<string, string> variables_;
+ std::map<std::string, std::string> variables_;
friend class FileGenerator;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumGenerator);
diff --git a/src/google/protobuf/compiler/cpp/cpp_extension.cc b/src/google/protobuf/compiler/cpp/cpp_extension.cc
index 25bcc333..f866eb6e 100644
--- a/src/google/protobuf/compiler/cpp/cpp_extension.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_extension.cc
@@ -137,6 +137,16 @@ void ExtensionGenerator::GenerateDeclaration(io::Printer* printer) const {
}
void ExtensionGenerator::GenerateDefinition(io::Printer* printer) {
+ // If we are building for lite with implicit weak fields, we want to skip over
+ // any custom options (i.e. extensions of messages from descriptor.proto).
+ // This prevents the creation of any unnecessary linker references to the
+ // descriptor messages.
+ if (options_.lite_implicit_weak_fields &&
+ descriptor_->containing_type()->file()->name() ==
+ "net/proto2/proto/descriptor.proto") {
+ return;
+ }
+
Formatter format(printer, variables_);
string default_str;
// If this is a class member, it needs to be declared in its class scope.
diff --git a/src/google/protobuf/compiler/cpp/cpp_extension.h b/src/google/protobuf/compiler/cpp/cpp_extension.h
index c316f5da..72413f6b 100644
--- a/src/google/protobuf/compiler/cpp/cpp_extension.h
+++ b/src/google/protobuf/compiler/cpp/cpp_extension.h
@@ -75,10 +75,10 @@ class ExtensionGenerator {
private:
const FieldDescriptor* descriptor_;
- string type_traits_;
+ std::string type_traits_;
Options options_;
- std::map<string, string> variables_;
+ std::map<std::string, std::string> variables_;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ExtensionGenerator);
};
diff --git a/src/google/protobuf/compiler/cpp/cpp_field.h b/src/google/protobuf/compiler/cpp/cpp_field.h
index 4561b33e..43a3e367 100644
--- a/src/google/protobuf/compiler/cpp/cpp_field.h
+++ b/src/google/protobuf/compiler/cpp/cpp_field.h
@@ -61,11 +61,11 @@ namespace cpp {
// ['name', 'index', 'number', 'classname', 'declared_type', 'tag_size',
// 'deprecation'].
void SetCommonFieldVariables(const FieldDescriptor* descriptor,
- std::map<string, string>* variables,
+ std::map<std::string, std::string>* variables,
const Options& options);
void SetCommonOneofFieldVariables(const FieldDescriptor* descriptor,
- std::map<string, string>* variables);
+ std::map<std::string, std::string>* variables);
class FieldGenerator {
public:
@@ -203,7 +203,7 @@ class FieldGenerator {
protected:
const FieldDescriptor* descriptor_;
const Options& options_;
- std::map<string, string> variables_;
+ std::map<std::string, std::string> variables_;
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldGenerator);
diff --git a/src/google/protobuf/compiler/cpp/cpp_file.cc b/src/google/protobuf/compiler/cpp/cpp_file.cc
index 414da2f8..1e80715d 100644
--- a/src/google/protobuf/compiler/cpp/cpp_file.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_file.cc
@@ -256,6 +256,8 @@ void FileGenerator::GenerateProtoHeader(io::Printer* printer,
GenerateHeader(printer);
+ IncludeFile("net/proto2/public/port_undef.inc", printer);
+
GenerateBottomHeaderGuard(printer, filename_identifier);
}
@@ -425,20 +427,6 @@ void FileGenerator::GenerateSourceIncludes(io::Printer* printer) {
}
}
- // TODO(gerbens) Remove this when all code in google is using the same
- // proto library. This is a temporary hack to force build errors if
- // the proto library is compiled with GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
- // and is also linking internal proto2. This is to prevent regressions while
- // we work cleaning up the code base. After this is completed and we have
- // one proto lib all code uses this should be removed.
- if (options_.opensource_runtime) {
- format(
- "// This is a temporary google only hack\n"
- "#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS\n"
- "#include \"third_party/protobuf/version.h\"\n"
- "#endif\n");
- }
-
format("// @@protoc_insertion_point(includes)\n");
IncludeFile("net/proto2/public/port_def.inc", printer);
}
@@ -702,6 +690,8 @@ void FileGenerator::GenerateSource(io::Printer* printer) {
format(
"\n"
"// @@protoc_insertion_point(global_scope)\n");
+
+ IncludeFile("net/proto2/public/port_undef.inc", printer);
}
void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) {
@@ -751,7 +741,7 @@ void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) {
format(
"\n"
"const $uint32$ $tablename$::offsets[] "
- "$GOOGLE_PROTOBUF$_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {\n");
+ "PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {\n");
format.Indent();
std::vector<std::pair<size_t, size_t> > pairs;
pairs.reserve(message_generators_.size());
@@ -762,7 +752,7 @@ void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) {
format(
"};\n"
"static const ::$proto_ns$::internal::MigrationSchema schemas[] "
- "$GOOGLE_PROTOBUF$_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {\n");
+ "PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {\n");
format.Indent();
{
int offset = 0;
@@ -958,7 +948,7 @@ void FileGenerator::GenerateTables(io::Printer* printer) {
format(
"PROTOBUF_CONSTEXPR_VAR ::$proto_ns$::internal::ParseTableField\n"
" const $tablename$::entries[] "
- "$GOOGLE_PROTOBUF$_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {\n");
+ "PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {\n");
format.Indent();
std::vector<size_t> entries;
@@ -981,7 +971,7 @@ void FileGenerator::GenerateTables(io::Printer* printer) {
"PROTOBUF_CONSTEXPR_VAR "
"::$proto_ns$::internal::AuxillaryParseTableField\n"
" const $tablename$::aux[] "
- "$GOOGLE_PROTOBUF$_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {\n");
+ "PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {\n");
format.Indent();
std::vector<size_t> aux_entries;
@@ -1001,7 +991,7 @@ void FileGenerator::GenerateTables(io::Printer* printer) {
"};\n"
"PROTOBUF_CONSTEXPR_VAR ::$proto_ns$::internal::ParseTable const\n"
" $tablename$::schema[] "
- "$GOOGLE_PROTOBUF$_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {\n");
+ "PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {\n");
format.Indent();
size_t offset = 0;
@@ -1199,25 +1189,25 @@ void FileGenerator::GenerateLibraryIncludes(io::Printer* printer) {
}
if (options_.opensource_runtime) {
- DoIncludeFile("net/proto2/public/stubs/common.h", false, printer);
-
// Verify the protobuf library header version is compatible with the protoc
// version before going any further.
+ IncludeFile("net/proto2/public/port_def.inc", printer);
format(
- "#if GOOGLE_PROTOBUF_VERSION < $1$\n"
+ "#if PROTOBUF_VERSION < $1$\n"
"#error This file was generated by a newer version of protoc which is\n"
"#error incompatible with your Protocol Buffer headers. Please update\n"
"#error your headers.\n"
"#endif\n"
- "#if $2$ < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION\n"
+ "#if $2$ < PROTOBUF_MIN_PROTOC_VERSION\n"
"#error This file was generated by an older version of protoc which "
"is\n"
"#error incompatible with your Protocol Buffer headers. Please\n"
"#error regenerate this file with a newer version of protoc.\n"
"#endif\n"
"\n",
- GOOGLE_PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC, // 1
- GOOGLE_PROTOBUF_VERSION); // 2
+ PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC, // 1
+ PROTOBUF_VERSION); // 2
+ IncludeFile("net/proto2/public/port_undef.inc", printer);
}
// OK, it's now safe to #include other files.
@@ -1341,11 +1331,11 @@ void FileGenerator::GenerateGlobalStateFunctionDeclarations(
// These tables describe how to serialize and parse messages. Used
// for table driven code.
" static const ::$proto_ns$::internal::ParseTableField entries[]\n"
- " $GOOGLE_PROTOBUF$_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold);\n"
+ " PROTOBUF_SECTION_VARIABLE(protodesc_cold);\n"
" static const ::$proto_ns$::internal::AuxillaryParseTableField aux[]\n"
- " $GOOGLE_PROTOBUF$_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold);\n"
+ " PROTOBUF_SECTION_VARIABLE(protodesc_cold);\n"
" static const ::$proto_ns$::internal::ParseTable schema[$1$]\n"
- " $GOOGLE_PROTOBUF$_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold);\n"
+ " PROTOBUF_SECTION_VARIABLE(protodesc_cold);\n"
" static const ::$proto_ns$::internal::FieldMetadata field_metadata[];\n"
" static const ::$proto_ns$::internal::SerializationTable "
"serialization_table[];\n"
diff --git a/src/google/protobuf/compiler/cpp/cpp_file.h b/src/google/protobuf/compiler/cpp/cpp_file.h
index 9dfdf50f..315cf139 100644
--- a/src/google/protobuf/compiler/cpp/cpp_file.h
+++ b/src/google/protobuf/compiler/cpp/cpp_file.h
@@ -76,10 +76,10 @@ class FileGenerator {
// info_path, if non-empty, should be the path (relative to printer's
// output) to the metadata file describing this proto header.
- void GenerateProtoHeader(io::Printer* printer, const string& info_path);
+ void GenerateProtoHeader(io::Printer* printer, const std::string& info_path);
// info_path, if non-empty, should be the path (relative to printer's
// output) to the metadata file describing this PB header.
- void GeneratePBHeader(io::Printer* printer, const string& info_path);
+ void GeneratePBHeader(io::Printer* printer, const std::string& info_path);
void GenerateSource(io::Printer* printer);
int NumMessages() const { return message_generators_.size(); }
@@ -91,16 +91,16 @@ class FileGenerator {
// Internal type used by GenerateForwardDeclarations (defined in file.cc).
class ForwardDeclarations;
- void IncludeFile(const string& google3_name, io::Printer* printer) {
+ void IncludeFile(const std::string& google3_name, io::Printer* printer) {
DoIncludeFile(google3_name, false, printer);
}
- void IncludeFileAndExport(const string& google3_name, io::Printer* printer) {
+ void IncludeFileAndExport(const std::string& google3_name, io::Printer* printer) {
DoIncludeFile(google3_name, true, printer);
}
- void DoIncludeFile(const string& google3_name, bool do_export,
+ void DoIncludeFile(const std::string& google3_name, bool do_export,
io::Printer* printer);
- string CreateHeaderInclude(const string& basename,
+ std::string CreateHeaderInclude(const std::string& basename,
const FileDescriptor* file);
void GenerateInternalForwardDeclarations(
const std::vector<const FieldDescriptor*>& fields, const Options& options,
@@ -117,9 +117,9 @@ class FileGenerator {
// Generates top or bottom of a header file.
void GenerateTopHeaderGuard(io::Printer* printer,
- const string& filename_identifier);
+ const std::string& filename_identifier);
void GenerateBottomHeaderGuard(io::Printer* printer,
- const string& filename_identifier);
+ const std::string& filename_identifier);
// Generates #include directives.
void GenerateLibraryIncludes(io::Printer* printer);
@@ -127,7 +127,7 @@ class FileGenerator {
// Generate a pragma to pull in metadata using the given info_path (if
// non-empty). info_path should be relative to printer's output.
- void GenerateMetadataPragma(io::Printer* printer, const string& info_path);
+ void GenerateMetadataPragma(io::Printer* printer, const std::string& info_path);
// Generates a couple of different pieces before definitions:
void GenerateGlobalStateFunctionDeclarations(io::Printer* printer);
@@ -182,7 +182,7 @@ class FileGenerator {
MessageSCCAnalyzer scc_analyzer_;
- std::map<string, string> variables_;
+ std::map<std::string, std::string> variables_;
// Contains the post-order walk of all the messages (and child messages) in
// this file. If you need a pre-order walk just reverse iterate.
diff --git a/src/google/protobuf/compiler/cpp/cpp_generator.cc b/src/google/protobuf/compiler/cpp/cpp_generator.cc
index 79f773ee..0e7e4dfd 100644
--- a/src/google/protobuf/compiler/cpp/cpp_generator.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_generator.cc
@@ -182,32 +182,41 @@ bool CppGenerator::Generate(const FileDescriptor* file,
// Generate cc file(s).
if (UsingImplicitWeakFields(file, file_options)) {
- {
- // This is the global .cc file, containing enum/services/tables/reflection
+ if (file->name() == "net/proto2/proto/descriptor.proto") {
+ // If we are building with implicit weak fields then we do not want to
+ // produce any symbols for descriptor.proto, so we just create an empty
+ // pb.cc file.
std::unique_ptr<io::ZeroCopyOutputStream> output(
generator_context->Open(basename + ".pb.cc"));
- io::Printer printer(output.get(), '$');
- file_generator.GenerateGlobalSource(&printer);
- }
+ } else {
+ {
+ // This is the global .cc file, containing
+ // enum/services/tables/reflection
+ std::unique_ptr<io::ZeroCopyOutputStream> output(
+ generator_context->Open(basename + ".pb.cc"));
+ io::Printer printer(output.get(), '$');
+ file_generator.GenerateGlobalSource(&printer);
+ }
- int num_cc_files = file_generator.NumMessages();
+ int num_cc_files = file_generator.NumMessages();
- // If we're using implicit weak fields then we allow the user to optionally
- // specify how many files to generate, not counting the global pb.cc file.
- // If we have more files than messages, then some files will be generated as
- // empty placeholders.
- if (file_options.num_cc_files > 0) {
- GOOGLE_CHECK_LE(file_generator.NumMessages(), file_options.num_cc_files)
- << "There must be at least as many numbered .cc files as messages.";
- num_cc_files = file_options.num_cc_files;
- }
- for (int i = 0; i < num_cc_files; i++) {
- // TODO(gerbens) Agree on naming scheme.
- std::unique_ptr<io::ZeroCopyOutputStream> output(generator_context->Open(
- basename + ".out/" + SimpleItoa(i) + ".cc"));
- io::Printer printer(output.get(), '$');
- if (i < file_generator.NumMessages()) {
- file_generator.GenerateSourceForMessage(i, &printer);
+ // If we're using implicit weak fields then we allow the user to
+ // optionally specify how many files to generate, not counting the global
+ // pb.cc file. If we have more files than messages, then some files will
+ // be generated as empty placeholders.
+ if (file_options.num_cc_files > 0) {
+ GOOGLE_CHECK_LE(file_generator.NumMessages(), file_options.num_cc_files)
+ << "There must be at least as many numbered .cc files as messages.";
+ num_cc_files = file_options.num_cc_files;
+ }
+ for (int i = 0; i < num_cc_files; i++) {
+ std::unique_ptr<io::ZeroCopyOutputStream> output(
+ generator_context->Open(basename + ".out/" +
+ SimpleItoa(i) + ".cc"));
+ io::Printer printer(output.get(), '$');
+ if (i < file_generator.NumMessages()) {
+ file_generator.GenerateSourceForMessage(i, &printer);
+ }
}
}
} else {
diff --git a/src/google/protobuf/compiler/cpp/cpp_generator.h b/src/google/protobuf/compiler/cpp/cpp_generator.h
index 06d3c36f..30363e73 100644
--- a/src/google/protobuf/compiler/cpp/cpp_generator.h
+++ b/src/google/protobuf/compiler/cpp/cpp_generator.h
@@ -40,6 +40,8 @@
#include <string>
#include <google/protobuf/compiler/code_generator.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace compiler {
@@ -49,12 +51,12 @@ namespace cpp {
// header. If you create your own protocol compiler binary and you want
// it to support C++ output, you can do so by registering an instance of this
// CodeGenerator with the CommandLineInterface in your main() function.
-class LIBPROTOC_EXPORT CppGenerator : public CodeGenerator {
+class PROTOC_EXPORT CppGenerator : public CodeGenerator {
public:
CppGenerator();
~CppGenerator();
- enum class LIBPROTOC_EXPORT Runtime {
+ enum class Runtime {
kGoogle3, // Use the internal google3 runtime.
kOpensource, // Use the open-source runtime.
@@ -70,9 +72,9 @@ class LIBPROTOC_EXPORT CppGenerator : public CodeGenerator {
// implements CodeGenerator ----------------------------------------
bool Generate(const FileDescriptor* file,
- const string& parameter,
+ const std::string& parameter,
GeneratorContext* generator_context,
- string* error) const;
+ std::string* error) const;
private:
Runtime runtime_ = Runtime::kOpensource;
@@ -84,4 +86,6 @@ class LIBPROTOC_EXPORT CppGenerator : public CodeGenerator {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_COMPILER_CPP_GENERATOR_H__
diff --git a/src/google/protobuf/compiler/cpp/cpp_helpers.cc b/src/google/protobuf/compiler/cpp/cpp_helpers.cc
index bc0a9264..472c55f4 100644
--- a/src/google/protobuf/compiler/cpp/cpp_helpers.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_helpers.cc
@@ -53,6 +53,8 @@
#include <google/protobuf/stubs/hash.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace compiler {
@@ -487,10 +489,9 @@ string DefaultValue(const Options& options, const FieldDescriptor* field) {
case FieldDescriptor::CPPTYPE_UINT32:
return SimpleItoa(field->default_value_uint32()) + "u";
case FieldDescriptor::CPPTYPE_INT64:
- return Int64ToString(MacroPrefix(options), field->default_value_int64());
+ return Int64ToString("PROTOBUF", field->default_value_int64());
case FieldDescriptor::CPPTYPE_UINT64:
- return UInt64ToString(MacroPrefix(options),
- field->default_value_uint64());
+ return UInt64ToString("PROTOBUF", field->default_value_uint64());
case FieldDescriptor::CPPTYPE_DOUBLE: {
double value = field->default_value_double();
if (value == std::numeric_limits<double>::infinity()) {
@@ -1058,7 +1059,7 @@ void ListAllTypesForServices(const FileDescriptor* fd,
bool GetBootstrapBasename(const Options& options, const string& basename,
string* bootstrap_basename) {
- if (options.opensource_runtime) {
+ if (options.opensource_runtime || options.lite_implicit_weak_fields) {
return false;
}
@@ -1169,6 +1170,193 @@ bool ShouldRepeat(const FieldDescriptor* descriptor,
wiretype != internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED);
}
+void GenerateLengthDelim(
+ const FieldDescriptor* field, const Options& options,
+ MessageSCCAnalyzer* scc_analyzer,
+ const Formatter& format) {
+ format(
+ "ptr = Varint::Parse32Inline(ptr, &size);\n"
+ "$GOOGLE_PROTOBUF$_PARSER_ASSERT(ptr);\n");
+ if (!IsProto1(field->file(), options) && field->is_packable()) {
+ if (!HasPreservingUnknownEnumSemantics(field->file()) &&
+ field->type() == FieldDescriptor::TYPE_ENUM) {
+ format(
+ "ctx->extra_parse_data().SetEnumValidator($1$_IsValid, "
+ "msg->mutable_unknown_fields(), $2$);\n"
+ "parser_till_end = "
+ "::$proto_ns$::internal::PackedValidEnumParser$3$;\n"
+ "object = msg->mutable_$4$();\n",
+ QualifiedClassName(field->enum_type()), field->number(),
+ UseUnknownFieldSet(field->file(), options) ? "" : "Lite",
+ FieldName(field));
+ } else {
+ format(
+ "parser_till_end = ::$proto_ns$::internal::Packed$1$Parser;\n"
+ "object = msg->mutable_$2$();\n",
+ DeclaredTypeMethodName(field->type()), FieldName(field));
+ }
+ format(
+ "if (size > end - ptr) goto len_delim_till_end;\n"
+ "auto newend = ptr + size;\n"
+ "if (size) ptr = parser_till_end(ptr, newend, object, ctx);\n"
+ "$GOOGLE_PROTOBUF$_PARSER_ASSERT(ptr == newend);\n");
+ } else {
+ auto field_type = field->type();
+ if (IsProto1(field->file(), options)) {
+ if (field->is_packable()) {
+ // Sigh ... packed fields endup as a string in proto1
+ field_type = FieldDescriptor::TYPE_BYTES;
+ }
+ if (field_type == FieldDescriptor::TYPE_STRING) {
+ // In proto1 strings are treated as bytes
+ field_type = FieldDescriptor::TYPE_BYTES;
+ }
+ }
+ string utf8 = "";
+ switch (field_type) {
+ case FieldDescriptor::TYPE_STRING:
+ utf8 = GetUtf8Suffix(field, options);
+ if (!utf8.empty()) {
+ string name = "nullptr";
+ if (HasDescriptorMethods(field->file(), options)) {
+ name = "\"" + field->full_name() + "\"";
+ }
+ format("ctx->extra_parse_data().SetFieldName($1$);\n", name);
+ }
+ PROTOBUF_FALLTHROUGH_INTENDED;
+ case FieldDescriptor::TYPE_BYTES: {
+ if (field->options().ctype() == FieldOptions::STRING ||
+ (IsProto1(field->file(), options) &&
+ field->options().ctype() == FieldOptions::STRING_PIECE)) {
+ format(
+ "parser_till_end = ::$proto_ns$::internal::StringParser$1$;\n"
+ "$string$* str = msg->$2$_$3$();\n"
+ "str->clear();\n",
+ utf8,
+ field->is_repeated() && !field->is_map() &&
+ !field->is_packable()
+ ? "add"
+ : "mutable",
+ FieldName(field));
+ if (utf8.empty()) {
+ // special case if there is no utf8 verification.
+ format(
+ "object = str;\n"
+ "if (size > end - ptr) goto len_delim_till_end;\n"
+ "str->append(ptr, size);\n"
+ "ptr += size;\n");
+ return;
+ }
+ } else if (field->options().ctype() == FieldOptions::CORD) {
+ string cord_parser = "CordParser" + utf8;
+ format(
+ "parser_till_end = ::$proto_ns$::internal::$1$;\n"
+ "auto* str = msg->$2$_$3$();\n"
+ "str->Clear();\n",
+ cord_parser,
+ field->is_repeated() && !field->is_map() ? "add" : "mutable",
+ FieldName(field));
+ } else if (field->options().ctype() == FieldOptions::STRING_PIECE) {
+ format(
+ "parser_till_end = "
+ "::$proto_ns$::internal::StringPieceParser$1$;\n"
+ "::$proto_ns$::internal::StringPieceField* str = "
+ "msg->$2$_$3$();\n"
+ "str->Clear();\n",
+ utf8,
+ field->is_repeated() && !field->is_map() ? "add" : "mutable",
+ FieldName(field));
+ }
+ format(
+ "object = str;\n"
+ "if (size > end - ptr) goto len_delim_till_end;\n"
+ "auto newend = ptr + size;\n"
+ "if (size) ptr = parser_till_end(ptr, newend, object, ctx);\n");
+ if (!utf8.empty()) {
+ // If utf8 verification is on this can fail.
+ format("$GOOGLE_PROTOBUF$_PARSER_ASSERT(ptr == newend);\n");
+ }
+ break;
+ }
+ case FieldDescriptor::TYPE_MESSAGE: {
+ GOOGLE_CHECK(field->message_type());
+ if (!IsProto1(field->file(), options) && field->is_map()) {
+ const FieldDescriptor* val =
+ field->message_type()->FindFieldByName("value");
+ GOOGLE_CHECK(val);
+ if (HasFieldPresence(field->file()) &&
+ val->type() == FieldDescriptor::TYPE_ENUM) {
+ format(
+ "ctx->extra_parse_data().field_number = $1$;\n"
+ "ctx->extra_parse_data().unknown_fields = "
+ "&msg->_internal_metadata_;\n",
+ field->number());
+ }
+ format(
+ "parser_till_end = ::$proto_ns$::internal::SlowMapEntryParser;\n"
+ "auto parse_map = $1$::_ParseMap;\n"
+ "ctx->extra_parse_data().payload.clear();\n"
+ "ctx->extra_parse_data().parse_map = parse_map;\n"
+ "object = &msg->$2$_;\n"
+ "if (size > end - ptr) goto len_delim_till_end;\n"
+ "auto newend = ptr + size;\n"
+ "GOOGLE_PROTOBUF_PARSER_ASSERT(parse_map(ptr, newend, "
+ "object, ctx));\n"
+ "ptr = newend;\n",
+ QualifiedClassName(field->message_type()), FieldName(field));
+ break;
+ }
+ if (IsImplicitWeakField(field, options, scc_analyzer)) {
+ if (!field->is_repeated()) {
+ format("object = HasBitSetters::mutable_$1$(msg);\n",
+ FieldName(field));
+ } else {
+ format(
+ "object = "
+ "CastToBase(&msg->$1$_)->AddWeak(reinterpret_cast<const "
+ "::google::protobuf::MessageLite*>(&$2$::_$3$_default_instance_));\n",
+ FieldName(field), Namespace(field->message_type()),
+ ClassName(field->message_type()));
+ }
+ format(
+ "parser_till_end = static_cast<::$proto_ns$::MessageLite*>("
+ "object)->_ParseFunc();\n");
+ } else if (IsWeak(field, options)) {
+ if (IsProto1(field->file(), options)) {
+ format("object = msg->internal_mutable_$1$();\n",
+ FieldName(field));
+ } else {
+ format(
+ "object = msg->_weak_field_map_.MutableMessage($1$, "
+ "_$classname$_default_instance_.$2$_);\n",
+ field->number(), FieldName(field));
+ }
+ format(
+ "parser_till_end = static_cast<::$proto_ns$::MessageLite*>("
+ "object)->_ParseFunc();\n");
+ } else {
+ format(
+ "parser_till_end = $1$::_InternalParse;\n"
+ "object = msg->$2$_$3$();\n",
+ QualifiedClassName(field->message_type()),
+ field->is_repeated() ? "add" : "mutable", FieldName(field));
+ }
+ format(
+ "if (size > end - ptr) goto len_delim_till_end;\n"
+ "auto newend = ptr + size;\n"
+ "bool ok = ctx->ParseExactRange({parser_till_end, object},\n"
+ " ptr, newend);\n"
+ "$GOOGLE_PROTOBUF$_PARSER_ASSERT(ok);\n"
+ "ptr = newend;\n");
+ break;
+ }
+ default:
+ GOOGLE_LOG(FATAL) << "Illegal combination for length delimited wiretype "
+ << " filed type is " << field->type();
+ }
+ }
+}
+
void GenerateCaseBody(internal::WireFormatLite::WireType wiretype,
const FieldDescriptor* field, const Options& options,
MessageSCCAnalyzer* scc_analyzer,
@@ -1185,10 +1373,11 @@ void GenerateCaseBody(internal::WireFormatLite::WireType wiretype,
format(
"$uint64$ val;\n"
"ptr = Varint::Parse64(ptr, &val);\n"
- "if (!ptr) goto error;\n");
+ "$GOOGLE_PROTOBUF$_PARSER_ASSERT(ptr);\n");
string type = PrimitiveTypeName(options, field->cpp_type());
- if (field->type() == FieldDescriptor::TYPE_SINT32 ||
- field->type() == FieldDescriptor::TYPE_SINT64) {
+ if ((field->type() == FieldDescriptor::TYPE_SINT32 ||
+ field->type() == FieldDescriptor::TYPE_SINT64) &&
+ !IsProto1(field->file(), options)) {
int size = EstimateAlignmentSize(field) * 8;
format(
"$1$ value = "
@@ -1232,149 +1421,17 @@ void GenerateCaseBody(internal::WireFormatLite::WireType wiretype,
break;
}
case WireFormatLite::WIRETYPE_LENGTH_DELIMITED: {
- format(
- "ptr = Varint::Parse32Inline(ptr, &size);\n"
- "if (!ptr) goto error;\n");
- if (!IsProto1(field->file(), options) && field->is_packable()) {
- if (!HasPreservingUnknownEnumSemantics(field->file()) &&
- field->type() == FieldDescriptor::TYPE_ENUM) {
- format(
- "ctx->extra_parse_data().SetEnumValidator($1$_IsValid, "
- "msg->mutable_unknown_fields(), $2$);\n"
- "parser_till_end = "
- "::$proto_ns$::internal::PackedValidEnumParser$3$;\n"
- "object = msg->mutable_$4$();\n",
- QualifiedClassName(field->enum_type()), field->number(),
- UseUnknownFieldSet(field->file(), options) ? "" : "Lite",
- FieldName(field));
- } else {
- format(
- "parser_till_end = ::$proto_ns$::internal::Packed$1$Parser;\n"
- "object = msg->mutable_$2$();\n",
- DeclaredTypeMethodName(field->type()), FieldName(field));
- }
- } else {
- auto field_type = field->type();
- if (IsProto1(field->file(), options)) {
- if (field->is_packable()) {
- // Sigh ... packed fields endup as a string in proto1
- field_type = FieldDescriptor::TYPE_BYTES;
- }
- if (field_type == FieldDescriptor::TYPE_STRING) {
- // In proto1 strings are treated as bytes
- field_type = FieldDescriptor::TYPE_BYTES;
- }
- }
- string utf8 = "";
- switch (field_type) {
- case FieldDescriptor::TYPE_STRING:
- utf8 = GetUtf8Suffix(field, options);
- if (!utf8.empty()) {
- string name = "nullptr";
- if (HasDescriptorMethods(field->file(), options)) {
- name = field->full_name();
- }
- format("ctx->extra_parse_data().SetFieldName(\"$1$\");\n", name);
- }
- [[clang::fallthrough]];
- case FieldDescriptor::TYPE_BYTES: {
- if (field->options().ctype() == FieldOptions::STRING ||
- (IsProto1(field->file(), options) &&
- field->options().ctype() == FieldOptions::STRING_PIECE)) {
- format(
- "parser_till_end = ::$proto_ns$::internal::StringParser$1$;\n"
- "$string$* str = msg->$2$_$3$();\n"
- "str->clear();\n",
- utf8,
- field->is_repeated() && !field->is_map() &&
- !field->is_packable()
- ? "add"
- : "mutable",
- FieldName(field));
- } else if (field->options().ctype() == FieldOptions::CORD) {
- string cord_parser = "CordParser" + utf8;
- format(
- "parser_till_end = ::$proto_ns$::internal::$1$;\n"
- "auto* str = msg->$2$_$3$();\n"
- "str->Clear();\n",
- cord_parser,
- field->is_repeated() && !field->is_map() ? "add" : "mutable",
- FieldName(field));
- } else if (field->options().ctype() == FieldOptions::STRING_PIECE) {
- format(
- "parser_till_end = "
- "::$proto_ns$::internal::StringPieceParser$1$;\n"
- "::$proto_ns$::internal::StringPieceField* str = "
- "msg->$2$_$3$();\n"
- "str->Clear();\n",
- utf8,
- field->is_repeated() && !field->is_map() ? "add" : "mutable",
- FieldName(field));
- }
- format("object = str;\n");
- break;
- }
- case FieldDescriptor::TYPE_MESSAGE: {
- GOOGLE_CHECK(field->message_type());
- if (IsImplicitWeakField(field, options, scc_analyzer)) {
- if (!field->is_repeated()) {
- format("object = HasBitSetters::mutable_$1$(msg);\n",
- FieldName(field));
- } else {
- format(
- "object = "
- "CastToBase(&msg->$1$_)->AddWeak(reinterpret_cast<const "
- "::google::protobuf::MessageLite*>(&$2$::_$3$_default_instance_));\n",
- FieldName(field), Namespace(field->message_type()),
- ClassName(field->message_type()));
- }
- format(
- "parser_till_end = static_cast<::$proto_ns$::MessageLite*>("
- "object)->_ParseFunc();\n");
- break;
- } else if (IsWeak(field, options)) {
- if (IsProto1(field->file(), options)) {
- format("object = msg->internal_mutable_$1$();\n",
- FieldName(field));
- } else {
- format(
- "object = msg->_weak_field_map_.MutableMessage($1$, "
- "_$classname$_default_instance_.$2$_);\n",
- field->number(), FieldName(field));
- }
- format(
- "parser_till_end = static_cast<::$proto_ns$::MessageLite*>("
- "object)->_ParseFunc();\n");
- break;
- }
- format(
- "parser_till_end = $1$::_InternalParse;\n"
- "object = msg->$2$_$3$();\n",
- QualifiedClassName(field->message_type()),
- field->is_repeated() && !field->is_map() ? "add" : "mutable",
- FieldName(field));
- break;
- }
- default:
- GOOGLE_LOG(FATAL) << "Illegal combination for length delimited wiretype "
- << " filed type is " << field->type();
- }
- }
- format(
- "if (size > end - ptr) goto len_delim_till_end;\n"
- "auto newend = ptr + size;\n"
- "if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) "
- "goto error;\n"
- "ptr = newend;\n");
+ GenerateLengthDelim(field, options, scc_analyzer, format);
break;
}
case WireFormatLite::WIRETYPE_START_GROUP: {
format(
"parser_till_end = $1$::_InternalParse;\n"
"object = msg->$2$_$3$();\n"
- "if (!ctx->PrepareGroup(tag, &depth)) goto error;\n"
+ "bool ok = ctx->PrepareGroup(tag, &depth);\n"
+ "$GOOGLE_PROTOBUF$_PARSER_ASSERT(ok);\n"
"ptr = parser_till_end(ptr, end, object, ctx);\n"
- "if (!ptr) goto error;\n"
+ "$GOOGLE_PROTOBUF$_PARSER_ASSERT(ptr);\n"
"if (ctx->GroupContinues(depth)) goto group_continues;\n",
QualifiedClassName(field->message_type()),
field->is_repeated() ? "add" : "mutable", FieldName(field));
@@ -1413,8 +1470,8 @@ void GenerateCaseBody(internal::WireFormatLite::WireType wiretype,
uint64 mask = (1ull << (cnt * 8)) - 1;
format.Outdent();
format(
- "} while((*reinterpret_cast<const $uint64$*>(ptr) & $1$) == $2$ && "
- "(ptr += $3$));\n",
+ "} while ((::$proto_ns$::io::UnalignedLoad<$uint64$>(ptr) & $1$) == "
+ "$2$ && (ptr += $3$));\n",
mask, y, cnt);
}
format("break;\n");
@@ -1491,9 +1548,8 @@ void GenerateParserLoop(const Descriptor* descriptor, const Options& options,
" while (ptr < end) {\n"
" $uint32$ tag;\n"
" ptr = Varint::Parse32Inline(ptr, &tag);\n"
- " if (!ptr) goto error;\n"
- " switch (tag >> 3) {\n"
- " case 0: goto error;\n");
+ " $GOOGLE_PROTOBUF$_PARSER_ASSERT(ptr);\n"
+ " switch (tag >> 3) {\n");
format.Indent();
format.Indent();
@@ -1526,8 +1582,9 @@ void GenerateParserLoop(const Descriptor* descriptor, const Options& options,
format(
"default: {\n"
"handle_unusual: (void)&&handle_unusual;\n"
- " if ((tag & 7) == 4) {\n"
- " if (!ctx->ValidEndGroup(tag)) goto error;\n"
+ " if ((tag & 7) == 4 || tag == 0) {\n"
+ " bool ok = ctx->ValidEndGroup(tag);\n"
+ " $GOOGLE_PROTOBUF$_PARSER_ASSERT(ok);\n"
" return ptr;\n"
" }\n");
if (IsMapEntryMessage(descriptor)) {
@@ -1579,8 +1636,6 @@ void GenerateParserLoop(const Descriptor* descriptor, const Options& options,
" } // switch\n"
" } // while\n"
" return ptr;\n"
- "error:\n"
- " return nullptr;\n"
"len_delim_till_end: (void)&&len_delim_till_end;\n"
" return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},\n"
" {parser_till_end, object}, size);\n"
diff --git a/src/google/protobuf/compiler/cpp/cpp_helpers.h b/src/google/protobuf/compiler/cpp/cpp_helpers.h
index c01329fa..b8431aed 100644
--- a/src/google/protobuf/compiler/cpp/cpp_helpers.h
+++ b/src/google/protobuf/compiler/cpp/cpp_helpers.h
@@ -55,19 +55,16 @@ namespace protobuf {
namespace compiler {
namespace cpp {
-inline string ProtobufNamespace(const Options& options) {
+inline std::string ProtobufNamespace(const Options& options) {
return options.opensource_runtime ? "google::protobuf" : "proto2";
}
-inline string MacroPrefix(const Options& options) {
+inline std::string MacroPrefix(const Options& options) {
return options.opensource_runtime ? "GOOGLE_PROTOBUF" : "GOOGLE_PROTOBUF";
}
-inline string DeprecatedAttribute(const Options& options, bool deprecated) {
- if (!deprecated) {
- return "";
- }
- return MacroPrefix(options) + "_DEPRECATED ";
+inline std::string DeprecatedAttribute(const Options& options, bool deprecated) {
+ return deprecated ? "PROTOBUF_DEPRECATED " : "";
}
// Commonly-used separator comments. Thick is a line of '=', thin is a line
@@ -79,35 +76,35 @@ inline bool IsProto1(const FileDescriptor* file, const Options& options) {
return false;
}
-void SetCommonVars(const Options& options, std::map<string, string>* variables);
+void SetCommonVars(const Options& options, std::map<std::string, std::string>* variables);
-bool GetBootstrapBasename(const Options& options, const string& basename,
- string* bootstrap_basename);
+bool GetBootstrapBasename(const Options& options, const std::string& basename,
+ std::string* bootstrap_basename);
bool MaybeBootstrap(const Options& options, GeneratorContext* generator_context,
- bool bootstrap_flag, string* basename);
+ bool bootstrap_flag, std::string* basename);
bool IsBootstrapProto(const Options& options, const FileDescriptor* file);
// Name space of the proto file. This namespace is such that the string
// "<namespace>::some_name" is the correct fully qualified namespace.
// This means if the package is empty the namespace is "", and otherwise
// the namespace is "::foo::bar::...::baz" without trailing semi-colons.
-string Namespace(const string& package);
-inline string Namespace(const FileDescriptor* d) {
+std::string Namespace(const std::string& package);
+inline std::string Namespace(const FileDescriptor* d) {
return Namespace(d->package());
}
-string Namespace(const Descriptor* d);
-string Namespace(const FieldDescriptor* d);
-string Namespace(const EnumDescriptor* d);
+std::string Namespace(const Descriptor* d);
+std::string Namespace(const FieldDescriptor* d);
+std::string Namespace(const EnumDescriptor* d);
// Returns true if it's safe to reset "field" to zero.
bool CanInitializeByZeroing(const FieldDescriptor* field);
-string ClassName(const Descriptor* descriptor);
-string ClassName(const EnumDescriptor* enum_descriptor);
+std::string ClassName(const Descriptor* descriptor);
+std::string ClassName(const EnumDescriptor* enum_descriptor);
-string QualifiedClassName(const Descriptor* d);
-string QualifiedClassName(const EnumDescriptor* d);
+std::string QualifiedClassName(const Descriptor* d);
+std::string QualifiedClassName(const EnumDescriptor* d);
// DEPRECATED just use ClassName or QualifiedClassName, a boolean is very
// unreadable at the callsite.
@@ -119,33 +116,33 @@ string QualifiedClassName(const EnumDescriptor* d);
// ::foo::bar::Baz_Qux
// While the non-qualified version would be:
// Baz_Qux
-inline string ClassName(const Descriptor* descriptor, bool qualified) {
+inline std::string ClassName(const Descriptor* descriptor, bool qualified) {
return qualified ? QualifiedClassName(descriptor) : ClassName(descriptor);
}
-inline string ClassName(const EnumDescriptor* descriptor, bool qualified) {
+inline std::string ClassName(const EnumDescriptor* descriptor, bool qualified) {
return qualified ? QualifiedClassName(descriptor) : ClassName(descriptor);
}
// Fully qualified name of the default_instance of this message.
-string DefaultInstanceName(const Descriptor* descriptor);
+std::string DefaultInstanceName(const Descriptor* descriptor);
// Returns the name of a no-op function that we can call to introduce a linker
// dependency on the given message type. This is used to implement implicit weak
// fields.
-string ReferenceFunctionName(const Descriptor* descriptor);
+std::string ReferenceFunctionName(const Descriptor* descriptor);
// Name of the base class: google::protobuf::Message or google::protobuf::MessageLite.
-string SuperClassName(const Descriptor* descriptor, const Options& options);
+std::string SuperClassName(const Descriptor* descriptor, const Options& options);
// Get the (unqualified) name that should be used for this field in C++ code.
// The name is coerced to lower-case to emulate proto1 behavior. People
// should be using lowercase-with-underscores style for proto field names
// anyway, so normally this just returns field->name().
-string FieldName(const FieldDescriptor* field);
+std::string FieldName(const FieldDescriptor* field);
// Get the sanitized name that should be used for the given enum in C++ code.
-string EnumValueName(const EnumValueDescriptor* enum_value);
+std::string EnumValueName(const EnumValueDescriptor* enum_value);
// Returns an estimate of the compiler's alignment for the field. This
// can't guarantee to be correct because the generated code could be compiled on
@@ -155,7 +152,7 @@ int EstimateAlignmentSize(const FieldDescriptor* field);
// Get the unqualified name that should be used for a field's field
// number constant.
-string FieldConstantName(const FieldDescriptor *field);
+std::string FieldConstantName(const FieldDescriptor *field);
// Returns the scope where the field was defined (for extensions, this is
// different from the message type to which the field applies).
@@ -166,51 +163,51 @@ inline const Descriptor* FieldScope(const FieldDescriptor* field) {
// Returns the fully-qualified type name field->message_type(). Usually this
// is just ClassName(field->message_type(), true);
-string FieldMessageTypeName(const FieldDescriptor* field);
+std::string FieldMessageTypeName(const FieldDescriptor* field);
// Strips ".proto" or ".protodevel" from the end of a filename.
-LIBPROTOC_EXPORT string StripProto(const string& filename);
+PROTOC_EXPORT std::string StripProto(const std::string& filename);
// Get the C++ type name for a primitive type (e.g. "double", "::google::protobuf::int32", etc.).
const char* PrimitiveTypeName(FieldDescriptor::CppType type);
-string PrimitiveTypeName(const Options& options, FieldDescriptor::CppType type);
+std::string PrimitiveTypeName(const Options& options, FieldDescriptor::CppType type);
// Get the declared type name in CamelCase format, as is used e.g. for the
// methods of WireFormat. For example, TYPE_INT32 becomes "Int32".
const char* DeclaredTypeMethodName(FieldDescriptor::Type type);
// Return the code that evaluates to the number when compiled.
-string Int32ToString(int number);
+std::string Int32ToString(int number);
// Return the code that evaluates to the number when compiled.
-string Int64ToString(const Options& options, int64 number);
+std::string Int64ToString(const Options& options, int64 number);
// Get code that evaluates to the field's default value.
-string DefaultValue(const Options& options, const FieldDescriptor* field);
+std::string DefaultValue(const Options& options, const FieldDescriptor* field);
// Compatibility function for callers outside proto2.
-string DefaultValue(const FieldDescriptor* field);
+std::string DefaultValue(const FieldDescriptor* field);
// Convert a file name into a valid identifier.
-string FilenameIdentifier(const string& filename);
+std::string FilenameIdentifier(const std::string& filename);
// For each .proto file generates a unique name. To prevent collisions of
// symbols in the global namespace
-string UniqueName(const string& name, const string& filename,
+std::string UniqueName(const std::string& name, const std::string& filename,
const Options& options);
-inline string UniqueName(const string& name, const FileDescriptor* d,
+inline std::string UniqueName(const std::string& name, const FileDescriptor* d,
const Options& options) {
return UniqueName(name, d->name(), options);
}
-inline string UniqueName(const string& name, const Descriptor* d,
+inline std::string UniqueName(const std::string& name, const Descriptor* d,
const Options& options) {
return UniqueName(name, d->file(), options);
}
-inline string UniqueName(const string& name, const EnumDescriptor* d,
+inline std::string UniqueName(const std::string& name, const EnumDescriptor* d,
const Options& options) {
return UniqueName(name, d->file(), options);
}
-inline string UniqueName(const string& name, const ServiceDescriptor* d,
+inline std::string UniqueName(const std::string& name, const ServiceDescriptor* d,
const Options& options) {
return UniqueName(name, d->file(), options);
}
@@ -222,32 +219,32 @@ inline Options InternalRuntimeOptions() {
options.opensource_runtime = false;
return options;
}
-inline string UniqueName(const string& name, const string& filename) {
+inline std::string UniqueName(const std::string& name, const std::string& filename) {
return UniqueName(name, filename, InternalRuntimeOptions());
}
-inline string UniqueName(const string& name, const FileDescriptor* d) {
+inline std::string UniqueName(const std::string& name, const FileDescriptor* d) {
return UniqueName(name, d->name(), InternalRuntimeOptions());
}
-inline string UniqueName(const string& name, const Descriptor* d) {
+inline std::string UniqueName(const std::string& name, const Descriptor* d) {
return UniqueName(name, d->file(), InternalRuntimeOptions());
}
-inline string UniqueName(const string& name, const EnumDescriptor* d) {
+inline std::string UniqueName(const std::string& name, const EnumDescriptor* d) {
return UniqueName(name, d->file(), InternalRuntimeOptions());
}
-inline string UniqueName(const string& name, const ServiceDescriptor* d) {
+inline std::string UniqueName(const std::string& name, const ServiceDescriptor* d) {
return UniqueName(name, d->file(), InternalRuntimeOptions());
}
// Return the qualified C++ name for a file level symbol.
-string QualifiedFileLevelSymbol(const string& package, const string& name);
+std::string QualifiedFileLevelSymbol(const std::string& package, const std::string& name);
// Escape C++ trigraphs by escaping question marks to \?
-string EscapeTrigraphs(const string& to_escape);
+std::string EscapeTrigraphs(const std::string& to_escape);
// Escaped function name to eliminate naming conflict.
-string SafeFunctionName(const Descriptor* descriptor,
+std::string SafeFunctionName(const Descriptor* descriptor,
const FieldDescriptor* field,
- const string& prefix);
+ const std::string& prefix);
// Returns true if generated messages have public unknown fields accessors
inline bool PublicUnknownFieldsAccessors(const Descriptor* message) {
@@ -355,6 +352,8 @@ inline bool HasFastArraySerialization(const FileDescriptor* file,
inline bool IsProto2MessageSet(const Descriptor* descriptor,
const Options& options) {
return !options.opensource_runtime &&
+ !options.enforce_lite &&
+ !options.lite_implicit_weak_fields &&
descriptor->options().message_set_wire_format() &&
descriptor->full_name() == "google.protobuf.bridge.MessageSet";
}
@@ -362,6 +361,8 @@ inline bool IsProto2MessageSet(const Descriptor* descriptor,
inline bool IsProto2MessageSetFile(const FileDescriptor* file,
const Options& options) {
return !options.opensource_runtime &&
+ !options.enforce_lite &&
+ !options.lite_implicit_weak_fields &&
file->name() == "net/proto2/bridge/proto/message_set.proto";
}
@@ -372,7 +373,7 @@ inline bool IsMapEntryMessage(const Descriptor* descriptor) {
// Returns true if the field's CPPTYPE is string or message.
bool IsStringOrMessage(const FieldDescriptor* field);
-string UnderscoresToCamelCase(const string& input, bool cap_next_letter);
+std::string UnderscoresToCamelCase(const std::string& input, bool cap_next_letter);
inline bool HasFieldPresence(const FileDescriptor* file) {
return file->syntax() != FileDescriptor::SYNTAX_PROTO3;
@@ -401,11 +402,11 @@ inline bool IsCrossFileMessage(const FieldDescriptor* field) {
field->message_type()->file() != field->file();
}
-inline string MessageCreateFunction(const Descriptor* d) {
+inline std::string MessageCreateFunction(const Descriptor* d) {
return SupportsArenas(d) ? "CreateMessage" : "Create";
}
-inline string MakeDefaultName(const FieldDescriptor* field) {
+inline std::string MakeDefaultName(const FieldDescriptor* field) {
return "_i_give_permission_to_break_this_code_default_" + FieldName(field) +
"_";
}
@@ -455,7 +456,7 @@ struct MessageAnalysis {
// quadratic performance, if we do this per message we would get O(V*(V+E)).
// Logically this is just only used in message.cc, but in the header for
// FileGenerator to help share it.
-class LIBPROTOC_EXPORT MessageSCCAnalyzer {
+class PROTOC_EXPORT MessageSCCAnalyzer {
public:
explicit MessageSCCAnalyzer(const Options& options) : options_(options) {}
@@ -528,18 +529,18 @@ bool IsImplicitWeakField(const FieldDescriptor* field, const Options& options,
// "__declspec(export) void fun();"
//
// which is convenient to prevent double, leading or trailing spaces.
-class LIBPROTOC_EXPORT Formatter {
+class PROTOC_EXPORT Formatter {
public:
explicit Formatter(io::Printer* printer) : printer_(printer) {}
- Formatter(io::Printer* printer, const std::map<string, string>& vars)
+ Formatter(io::Printer* printer, const std::map<std::string, std::string>& vars)
: printer_(printer), vars_(vars) {}
template <typename T>
- void Set(const string& key, const T& value) {
+ void Set(const std::string& key, const T& value) {
vars_[key] = ToString(value);
}
- void AddMap(const std::map<string, string>& vars) {
+ void AddMap(const std::map<std::string, std::string>& vars) {
for (const auto& keyval : vars) vars_[keyval.first] = keyval.second;
}
@@ -552,7 +553,7 @@ class LIBPROTOC_EXPORT Formatter {
void Outdent() const { printer_->Outdent(); }
io::Printer* printer() const { return printer_; }
- class LIBPROTOC_EXPORT SaveState {
+ class PROTOC_EXPORT SaveState {
public:
explicit SaveState(Formatter* format)
: format_(format), vars_(format->vars_) {}
@@ -560,28 +561,28 @@ class LIBPROTOC_EXPORT Formatter {
private:
Formatter* format_;
- std::map<string, string> vars_;
+ std::map<std::string, std::string> vars_;
};
private:
io::Printer* printer_;
- std::map<string, string> vars_;
+ std::map<std::string, std::string> vars_;
// Convenience overloads to accept different types as arguments.
- static string ToString(const string& s) { return s; }
+ static std::string ToString(const std::string& s) { return s; }
template <typename I, typename = typename std::enable_if<
std::is_integral<I>::value>::type>
- static string ToString(I x) {
+ static std::string ToString(I x) {
return SimpleItoa(x);
}
- static string ToString(strings::Hex x) { return StrCat(x); }
- static string ToString(const FieldDescriptor* d) { return Payload(d); }
- static string ToString(const Descriptor* d) { return Payload(d); }
- static string ToString(const EnumDescriptor* d) { return Payload(d); }
- static string ToString(const EnumValueDescriptor* d) { return Payload(d); }
+ static std::string ToString(strings::Hex x) { return StrCat(x); }
+ static std::string ToString(const FieldDescriptor* d) { return Payload(d); }
+ static std::string ToString(const Descriptor* d) { return Payload(d); }
+ static std::string ToString(const EnumDescriptor* d) { return Payload(d); }
+ static std::string ToString(const EnumValueDescriptor* d) { return Payload(d); }
template <typename Descriptor>
- static string Payload(const Descriptor* descriptor) {
+ static std::string Payload(const Descriptor* descriptor) {
std::vector<int> path;
descriptor->GetLocationPath(&path);
GeneratedCodeInfo::Annotation annotation;
@@ -593,18 +594,18 @@ class LIBPROTOC_EXPORT Formatter {
}
};
-class LIBPROTOC_EXPORT NamespaceOpener {
+class PROTOC_EXPORT NamespaceOpener {
public:
explicit NamespaceOpener(const Formatter& format)
: printer_(format.printer()) {}
- NamespaceOpener(const string& name, const Formatter& format)
+ NamespaceOpener(const std::string& name, const Formatter& format)
: NamespaceOpener(format) {
ChangeTo(name);
}
~NamespaceOpener() { ChangeTo(""); }
- void ChangeTo(const string& name) {
- std::vector<string> new_stack_ =
+ void ChangeTo(const std::string& name) {
+ std::vector<std::string> new_stack_ =
Split(name, "::", true);
int len = std::min(name_stack_.size(), new_stack_.size());
int common_idx = 0;
@@ -623,10 +624,10 @@ class LIBPROTOC_EXPORT NamespaceOpener {
private:
io::Printer* printer_;
- std::vector<string> name_stack_;
+ std::vector<std::string> name_stack_;
};
-string GetUtf8Suffix(const FieldDescriptor* field, const Options& options);
+std::string GetUtf8Suffix(const FieldDescriptor* field, const Options& options);
void GenerateUtf8CheckCodeForString(const FieldDescriptor* field,
const Options& options, bool for_parse,
const char* parameters,
diff --git a/src/google/protobuf/compiler/cpp/cpp_map_field.cc b/src/google/protobuf/compiler/cpp/cpp_map_field.cc
index 4ab407d2..3114bbf7 100644
--- a/src/google/protobuf/compiler/cpp/cpp_map_field.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_map_field.cc
@@ -177,54 +177,49 @@ GenerateMergeFromCodedStream(io::Printer* printer) const {
descriptor_->message_type()->FindFieldByName("key");
const FieldDescriptor* value_field =
descriptor_->message_type()->FindFieldByName("value");
- bool using_entry = false;
string key;
string value;
+ format(
+ "$map_classname$::Parser< ::$proto_ns$::internal::MapField$lite$<\n"
+ " $map_classname$,\n"
+ " $key_cpp$, $val_cpp$,\n"
+ " ::$proto_ns$::internal::WireFormatLite::$key_wire_type$,\n"
+ " ::$proto_ns$::internal::WireFormatLite::$val_wire_type$,\n"
+ " $default_enum_value$ >,\n"
+ " ::$proto_ns$::Map< $key_cpp$, $val_cpp$ > >"
+ " parser(&$name$_);\n");
if (IsProto3Field(descriptor_) ||
value_field->type() != FieldDescriptor::TYPE_ENUM) {
format(
- "$map_classname$::Parser< ::$proto_ns$::internal::MapField$lite$<\n"
- " $map_classname$,\n"
- " $key_cpp$, $val_cpp$,\n"
- " ::$proto_ns$::internal::WireFormatLite::$key_wire_type$,\n"
- " ::$proto_ns$::internal::WireFormatLite::$val_wire_type$,\n"
- " $default_enum_value$ >,\n"
- " ::$proto_ns$::Map< $key_cpp$, $val_cpp$ > >"
- " parser(&$name$_);\n"
"DO_(::$proto_ns$::internal::WireFormatLite::ReadMessageNoVirtual(\n"
" input, &parser));\n");
key = "parser.key()";
value = "parser.value()";
} else {
- using_entry = true;
key = "entry->key()";
value = "entry->value()";
- format("::std::unique_ptr<$map_classname$> entry($name$_.NewEntry());\n");
+ format("auto entry = parser.NewEntry();\n");
format(
- "{\n"
- " ::std::string data;\n"
- " DO_(::$proto_ns$::internal::WireFormatLite::ReadString(input, "
+ "::std::string data;\n"
+ "DO_(::$proto_ns$::internal::WireFormatLite::ReadString(input, "
"&data));\n"
- " DO_(entry->ParseFromString(data));\n"
- " if ($val_cpp$_IsValid(*entry->mutable_value())) {\n"
- " (*mutable_$name$())[entry->key()] =\n"
- " static_cast< $val_cpp$ >(*entry->mutable_value());\n"
- " } else {\n");
+ "DO_(entry->ParseFromString(data));\n"
+ "if ($val_cpp$_IsValid(*entry->mutable_value())) {\n"
+ " (*mutable_$name$())[entry->key()] =\n"
+ " static_cast< $val_cpp$ >(*entry->mutable_value());\n"
+ "} else {\n");
if (HasDescriptorMethods(descriptor_->file(), options_)) {
format(
- " mutable_unknown_fields()"
+ " mutable_unknown_fields()"
"->AddLengthDelimited($number$, data);\n");
} else {
format(
- " unknown_fields_stream.WriteVarint32($tag$u);\n"
- " unknown_fields_stream.WriteVarint32(\n"
- " static_cast< ::google::protobuf::uint32>(data.size()));\n"
- " unknown_fields_stream.WriteString(data);\n");
+ " unknown_fields_stream.WriteVarint32($tag$u);\n"
+ " unknown_fields_stream.WriteVarint32(\n"
+ " static_cast< ::google::protobuf::uint32>(data.size()));\n"
+ " unknown_fields_stream.WriteString(data);\n");
}
-
- format(
- " }\n"
- "}\n");
+ format("}\n");
}
if (key_field->type() == FieldDescriptor::TYPE_STRING) {
@@ -242,11 +237,6 @@ GenerateMergeFromCodedStream(io::Printer* printer) const {
.data(),
format);
}
-
- // If entry is allocated by arena, its desctructor should be avoided.
- if (using_entry && SupportsArenas(descriptor_)) {
- format("if (entry->GetArena() != NULL) entry.release();\n");
- }
}
static void GenerateSerializationLoop(const Formatter& format,
diff --git a/src/google/protobuf/compiler/cpp/cpp_message.cc b/src/google/protobuf/compiler/cpp/cpp_message.cc
index e219d784..4af54032 100644
--- a/src/google/protobuf/compiler/cpp/cpp_message.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_message.cc
@@ -554,7 +554,7 @@ void ColdChunkSkipper::OnStartChunk(int chunk, int cached_has_bit_index,
}
// Emit has_bit check for each has_bit_dword index.
- format("if ($GOOGLE_PROTOBUF$_PREDICT_FALSE(");
+ format("if (PROTOBUF_PREDICT_FALSE(");
int first_word = HasbitWord(chunk, 0);
while (chunk < limit_chunk_) {
uint32 mask = 0;
@@ -940,8 +940,8 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
" $default_enum_value$ > {\n"
"public:\n"
"#if $GOOGLE_PROTOBUF$_ENABLE_EXPERIMENTAL_PARSER\n"
- " static const char* _InternalParse(const char* begin, const char* "
- "end, void* object, ::$proto_ns$::internal::ParseContext* ctx);\n"
+ "static bool _ParseMap(const char* begin, const "
+ "char* end, void* object, ::google::protobuf::internal::ParseContext* ctx);\n"
"#endif // $GOOGLE_PROTOBUF$_ENABLE_EXPERIMENTAL_PARSER\n"
" typedef ::$proto_ns$::internal::MapEntry$lite$<$classname$, \n"
" $key_cpp$, $val_cpp$,\n"
@@ -1514,23 +1514,17 @@ bool MessageGenerator::GenerateParseTable(io::Printer* printer, size_t offset,
// If we don't have field presence, then _has_bits_ does not exist.
format("-1,\n");
} else {
- format(
- "$GOOGLE_PROTOBUF$_GENERATED_MESSAGE_FIELD_OFFSET(\n"
- " $classtype$, _has_bits_),\n");
+ format("PROTOBUF_FIELD_OFFSET($classtype$, _has_bits_),\n");
}
if (descriptor_->oneof_decl_count() > 0) {
- format(
- "$GOOGLE_PROTOBUF$_GENERATED_MESSAGE_FIELD_OFFSET(\n"
- " $classtype$, _oneof_case_),\n");
+ format("PROTOBUF_FIELD_OFFSET($classtype$, _oneof_case_),\n");
} else {
format("-1, // no _oneof_case_\n");
}
if (descriptor_->extension_range_count() > 0) {
- format(
- "$GOOGLE_PROTOBUF$_GENERATED_MESSAGE_FIELD_OFFSET($classtype$, "
- "_extensions_),\n");
+ format("PROTOBUF_FIELD_OFFSET($classtype$, _extensions_),\n");
} else {
format("-1, // no _extensions_\n");
}
@@ -1538,8 +1532,7 @@ bool MessageGenerator::GenerateParseTable(io::Printer* printer, size_t offset,
// TODO(ckennelly): Consolidate this with the calculation for
// AuxillaryParseTableField.
format(
- "$GOOGLE_PROTOBUF$_GENERATED_MESSAGE_FIELD_OFFSET(\n"
- " $classtype$, _internal_metadata_),\n"
+ "PROTOBUF_FIELD_OFFSET($classtype$, _internal_metadata_),\n"
"&$package_ns$::_$classname$_default_instance_,\n");
if (UseUnknownFieldSet(descriptor_->file(), options_)) {
@@ -1650,10 +1643,10 @@ int MessageGenerator::GenerateFieldMetadata(io::Printer* printer) {
Formatter::SaveState saver(&format);
format.AddMap(vars);
format(
- "{$GOOGLE_PROTOBUF$_GENERATED_MESSAGE_FIELD_OFFSET("
+ "{PROTOBUF_FIELD_OFFSET("
"::$proto_ns$::internal::MapEntryHelper<$classtype$::"
"SuperType>, $field_name$_), $tag$,"
- "$GOOGLE_PROTOBUF$_GENERATED_MESSAGE_FIELD_OFFSET("
+ "PROTOBUF_FIELD_OFFSET("
"::$proto_ns$::internal::MapEntryHelper<$classtype$::"
"SuperType>, _has_bits_) * 8 + $hasbit$, $type$, "
"$ptr$},\n");
@@ -1661,8 +1654,7 @@ int MessageGenerator::GenerateFieldMetadata(io::Printer* printer) {
return 2;
}
format(
- "{$GOOGLE_PROTOBUF$_GENERATED_MESSAGE_FIELD_OFFSET($classtype$, "
- "_cached_size_), 0, 0, 0, NULL},\n");
+ "{PROTOBUF_FIELD_OFFSET($classtype$, _cached_size_), 0, 0, 0, NULL},\n");
std::vector<const Descriptor::ExtensionRange*> sorted_extensions;
for (int i = 0; i < descriptor_->extension_range_count(); ++i) {
sorted_extensions.push_back(descriptor_->extension_range(i));
@@ -1677,8 +1669,7 @@ int MessageGenerator::GenerateFieldMetadata(io::Printer* printer) {
const Descriptor::ExtensionRange* range =
sorted_extensions[extension_idx];
format(
- "{$GOOGLE_PROTOBUF$_GENERATED_MESSAGE_FIELD_OFFSET($classtype$, "
- "_extensions_), "
+ "{PROTOBUF_FIELD_OFFSET($classtype$, _extensions_), "
"$1$, $2$, ::$proto_ns$::internal::FieldMetadata::kSpecial, "
"reinterpret_cast<const "
"void*>(::$proto_ns$::internal::ExtensionSerializer)},\n",
@@ -1703,8 +1694,7 @@ int MessageGenerator::GenerateFieldMetadata(io::Printer* printer) {
if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
if (IsMapEntryMessage(field->message_type())) {
format(
- "{$GOOGLE_PROTOBUF$_GENERATED_MESSAGE_FIELD_OFFSET($"
- "classtype$, $field_name$_), $1$, $2$, "
+ "{PROTOBUF_FIELD_OFFSET($classtype$, $field_name$_), $1$, $2$, "
"::$proto_ns$::internal::FieldMetadata::kSpecial, "
"reinterpret_cast<const void*>(static_cast< "
"::$proto_ns$::internal::SpecialSerializer>("
@@ -1745,7 +1735,7 @@ int MessageGenerator::GenerateFieldMetadata(io::Printer* printer) {
if (field->options().weak()) {
// TODO(gerbens) merge weak fields into ranges
format(
- "{$GOOGLE_PROTOBUF$_GENERATED_MESSAGE_FIELD_OFFSET("
+ "{PROTOBUF_FIELD_OFFSET("
"$classtype$, _weak_field_map_), $1$, $1$, "
"::$proto_ns$::internal::FieldMetadata::kSpecial, "
"reinterpret_cast<const "
@@ -1755,24 +1745,21 @@ int MessageGenerator::GenerateFieldMetadata(io::Printer* printer) {
format.Set("oneofoffset",
sizeof(uint32) * field->containing_oneof()->index());
format(
- "{$GOOGLE_PROTOBUF$_GENERATED_MESSAGE_FIELD_OFFSET($classtype$, "
- "$field_name$_), "
- "$1$, $GOOGLE_PROTOBUF$_GENERATED_MESSAGE_FIELD_OFFSET($classtype$, "
- "_oneof_case_) + $oneofoffset$, $2$, $3$},\n",
+ "{PROTOBUF_FIELD_OFFSET($classtype$, $field_name$_), $1$,"
+ " PROTOBUF_FIELD_OFFSET($classtype$, _oneof_case_) + "
+ "$oneofoffset$, $2$, $3$},\n",
tag, type, ptr);
} else if (HasFieldPresence(descriptor_->file()) &&
has_bit_indices_[field->index()] != -1) {
format.Set("hasbitsoffset", has_bit_indices_[field->index()]);
format(
- "{$GOOGLE_PROTOBUF$_GENERATED_MESSAGE_FIELD_OFFSET($classtype$, "
- "$field_name$_), "
- "$1$, $GOOGLE_PROTOBUF$_GENERATED_MESSAGE_FIELD_OFFSET($classtype$, "
- "_has_bits_) * 8 + $hasbitsoffset$, $2$, $3$},\n",
+ "{PROTOBUF_FIELD_OFFSET($classtype$, $field_name$_), "
+ "$1$, PROTOBUF_FIELD_OFFSET($classtype$, _has_bits_) * 8 + "
+ "$hasbitsoffset$, $2$, $3$},\n",
tag, type, ptr);
} else {
format(
- "{$GOOGLE_PROTOBUF$_GENERATED_MESSAGE_FIELD_OFFSET($classtype$, "
- "$field_name$_), "
+ "{PROTOBUF_FIELD_OFFSET($classtype$, $field_name$_), "
"$1$, ~0u, $2$, $3$},\n",
tag, type, ptr);
}
@@ -1783,8 +1770,7 @@ int MessageGenerator::GenerateFieldMetadata(io::Printer* printer) {
? "UnknownFieldSetSerializer"
: "UnknownFieldSerializerLite";
format(
- "{$GOOGLE_PROTOBUF$_GENERATED_MESSAGE_FIELD_OFFSET($classtype$, "
- "_internal_metadata_), 0, ~0u, "
+ "{PROTOBUF_FIELD_OFFSET($classtype$, _internal_metadata_), 0, ~0u, "
"::$proto_ns$::internal::FieldMetadata::kSpecial, reinterpret_cast<const "
"void*>(::$proto_ns$::internal::$1$)},\n",
serializer);
@@ -1876,12 +1862,62 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) {
"}\n"
"\n");
}
- // TODO(gerbens) make maps parse :(
format(
"#if $GOOGLE_PROTOBUF$_ENABLE_EXPERIMENTAL_PARSER\n"
- "const char* $classname$::_InternalParse(const char* begin, const "
- "char* end, void* object, ::$proto_ns$::internal::ParseContext* ctx) { "
- "return end; }\n"
+ "bool $classname$::_ParseMap(const char* begin, const "
+ "char* end, void* object, ::google::protobuf::internal::ParseContext* ctx) {\n"
+ " using MF = ::$proto_ns$::internal::MapField$1$<\n"
+ " $classname$, EntryKeyType, EntryValueType,\n"
+ " kEntryKeyFieldType, kEntryValueFieldType,\n"
+ " kEntryDefaultEnumValue>;\n"
+ " auto mf = static_cast<MF*>(object);\n"
+ " Parser<MF, ::$proto_ns$::Map<EntryKeyType, EntryValueType>> "
+ "parser(mf);\n"
+ "#define DO_(x) if (!(x)) return false\n",
+ HasDescriptorMethods(descriptor_->file(), options_) ? "" : "Lite");
+ const FieldDescriptor* key = descriptor_->FindFieldByName("key");
+ const FieldDescriptor* val = descriptor_->FindFieldByName("value");
+ GOOGLE_CHECK(val);
+ string key_string;
+ string value_string;
+ if (HasFieldPresence(descriptor_->file()) &&
+ val->type() == FieldDescriptor::TYPE_ENUM) {
+ format(
+ " DO_(parser.ParseMapEnumValidation(\n"
+ " begin, end, ctx->extra_parse_data().field_number,\n"
+ " static_cast<::google::protobuf::internal::InternalMetadataWithArena$1$*>("
+ "ctx->extra_parse_data().unknown_fields), $2$_IsValid));\n",
+ HasDescriptorMethods(descriptor_->file(), options_) ? "" : "Lite",
+ QualifiedClassName(val->enum_type()));
+ key_string = "parser.entry_key()";
+ value_string = "parser.entry_value()";
+ } else {
+ format(" DO_(parser.ParseMap(begin, end));\n");
+ key_string = "parser.key()";
+ value_string = "parser.value()";
+ }
+ format.Indent();
+ if (key->type() == FieldDescriptor::TYPE_STRING) {
+ GenerateUtf8CheckCodeForString(
+ key, options_, true,
+ StrCat(key_string, ".data(), static_cast<int>(", key_string,
+ ".length()),\n")
+ .data(),
+ format);
+ }
+ if (val->type() == FieldDescriptor::TYPE_STRING) {
+ GenerateUtf8CheckCodeForString(
+ val, options_, true,
+ StrCat(value_string, ".data(), static_cast<int>(", value_string,
+ ".length()),\n")
+ .data(),
+ format);
+ }
+ format.Outdent();
+ format(
+ "#undef DO_\n"
+ " return true;\n"
+ "}\n"
"#endif // $GOOGLE_PROTOBUF$_ENABLE_EXPERIMENTAL_PARSER\n");
format("\n");
return;
@@ -2138,8 +2174,7 @@ size_t MessageGenerator::GenerateParseOffsets(io::Printer* printer) {
format(
"{\n"
- " $GOOGLE_PROTOBUF$_GENERATED_MESSAGE_FIELD_OFFSET(\n"
- " $classtype$, $name$_),\n"
+ " PROTOBUF_FIELD_OFFSET($classtype$, $name$_),\n"
" static_cast<$uint32$>($presence$),\n"
" $nwtype$, $pwtype$, $ptype$, $tag_size$\n"
"},\n");
@@ -2236,33 +2271,23 @@ std::pair<size_t, size_t> MessageGenerator::GenerateOffsets(
Formatter format(printer, variables_);
if (HasFieldPresence(descriptor_->file()) || IsMapEntryMessage(descriptor_)) {
- format(
- "$GOOGLE_PROTOBUF$_GENERATED_MESSAGE_FIELD_OFFSET($classtype$, "
- "_has_bits_),\n");
+ format("PROTOBUF_FIELD_OFFSET($classtype$, _has_bits_),\n");
} else {
format("~0u, // no _has_bits_\n");
}
- format(
- "$GOOGLE_PROTOBUF$_GENERATED_MESSAGE_FIELD_OFFSET($classtype$, "
- "_internal_metadata_),\n");
+ format("PROTOBUF_FIELD_OFFSET($classtype$, _internal_metadata_),\n");
if (descriptor_->extension_range_count() > 0) {
- format(
- "$GOOGLE_PROTOBUF$_GENERATED_MESSAGE_FIELD_OFFSET($classtype$, "
- "_extensions_),\n");
+ format("PROTOBUF_FIELD_OFFSET($classtype$, _extensions_),\n");
} else {
format("~0u, // no _extensions_\n");
}
if (descriptor_->oneof_decl_count() > 0) {
- format(
- "$GOOGLE_PROTOBUF$_GENERATED_MESSAGE_FIELD_OFFSET("
- "$classtype$, _oneof_case_[0]),\n");
+ format("PROTOBUF_FIELD_OFFSET($classtype$, _oneof_case_[0]),\n");
} else {
format("~0u, // no _oneof_case_\n");
}
if (num_weak_fields_ > 0) {
- format(
- "$GOOGLE_PROTOBUF$_GENERATED_MESSAGE_FIELD_OFFSET($classtype$,"
- " _weak_field_map_),\n");
+ format("PROTOBUF_FIELD_OFFSET($classtype$, _weak_field_map_),\n");
} else {
format("~0u, // no _weak_field_map_\n");
}
@@ -2275,9 +2300,7 @@ std::pair<size_t, size_t> MessageGenerator::GenerateOffsets(
format("offsetof($classtype$DefaultTypeInternal, $1$_)",
FieldName(field));
} else {
- format(
- "$GOOGLE_PROTOBUF$_GENERATED_MESSAGE_FIELD_OFFSET($classtype$, $1$_)",
- FieldName(field));
+ format("PROTOBUF_FIELD_OFFSET($classtype$, $1$_)", FieldName(field));
}
uint32 tag = field_generators_.get(field).CalculateFieldTag();
@@ -2289,9 +2312,7 @@ std::pair<size_t, size_t> MessageGenerator::GenerateOffsets(
}
for (auto oneof : OneOfRange(descriptor_)) {
- format(
- "$GOOGLE_PROTOBUF$_GENERATED_MESSAGE_FIELD_OFFSET($classtype$, $1$_),\n",
- oneof->name());
+ format("PROTOBUF_FIELD_OFFSET($classtype$, $1$_),\n", oneof->name());
}
if (IsMapEntryMessage(descriptor_)) {
@@ -2687,7 +2708,7 @@ void MessageGenerator::GenerateSourceInProto2Namespace(io::Printer* printer) {
Formatter format(printer, variables_);
format(
"template<> "
- "$GOOGLE_PROTOBUF$_ATTRIBUTE_NOINLINE "
+ "PROTOBUF_NOINLINE "
"$classtype$* Arena::CreateMaybeMessage< $classtype$ >(Arena* arena) {\n"
" return Arena::$1$Internal< $classtype$ >(arena);\n"
"}\n",
@@ -3334,8 +3355,9 @@ void MessageGenerator::GenerateMergeFromCodedStream(io::Printer* printer) {
"const char* $classname$::_InternalParse(const char* begin, const "
"char* end, void* object,\n"
" ::$proto_ns$::internal::ParseContext* ctx) {\n"
+ " auto msg = static_cast<$classname$*>(object);\n"
" return ::$proto_ns$::internal::ParseMessageSet(begin, end, "
- "static_cast<$classname$*>(object), ctx);\n"
+ "msg, &msg->_extensions_, &msg->_internal_metadata_, ctx);\n"
"}\n"
"const char* $classname$::InternalParseMessageSetItem(const char* "
"begin, const char* end, void* object,\n"
@@ -3396,7 +3418,7 @@ void MessageGenerator::GenerateMergeFromCodedStream(io::Printer* printer) {
format(
"#define DO_(EXPRESSION) if "
- "(!$GOOGLE_PROTOBUF$_PREDICT_TRUE(EXPRESSION)) goto failure\n"
+ "(!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure\n"
" $uint32$ tag;\n");
if (!UseUnknownFieldSet(descriptor_->file(), options_)) {
@@ -3801,11 +3823,12 @@ void MessageGenerator::GenerateSerializeWithCachedSizesToArray(
" target = _extensions_."
"InternalSerializeMessageSetWithCachedSizesToArray(\n"
" deterministic, target);\n");
+ GOOGLE_CHECK(UseUnknownFieldSet(descriptor_->file(), options_));
std::map<string, string> vars;
SetUnknkownFieldsVariable(descriptor_, options_, &vars);
format.AddMap(vars);
format(
- " target = ::$proto_ns$::internal::\n"
+ " target = ::$proto_ns$::internal::WireFormat::\n"
" SerializeUnknownMessageSetItemsToArray(\n"
" $unknown_fields$, target);\n");
format(
diff --git a/src/google/protobuf/compiler/cpp/cpp_message.h b/src/google/protobuf/compiler/cpp/cpp_message.h
index 170a70cd..6bef8d56 100644
--- a/src/google/protobuf/compiler/cpp/cpp_message.h
+++ b/src/google/protobuf/compiler/cpp/cpp_message.h
@@ -63,7 +63,7 @@ class MessageGenerator {
public:
// See generator.cc for the meaning of dllexport_decl.
MessageGenerator(const Descriptor* descriptor,
- const std::map<string, string>& vars,
+ const std::map<std::string, std::string>& vars,
int index_in_file_messages, const Options& options,
MessageSCCAnalyzer* scc_analyzer);
~MessageGenerator();
@@ -194,7 +194,7 @@ class MessageGenerator {
const Descriptor* descriptor_;
int index_in_file_messages_;
- string classname_;
+ std::string classname_;
Options options_;
FieldGeneratorMap field_generators_;
// optimized_order_ is the order we layout the message's fields in the
@@ -216,7 +216,7 @@ class MessageGenerator {
MessageSCCAnalyzer* scc_analyzer_;
- std::map<string, string> variables_;
+ std::map<std::string, std::string> variables_;
friend class FileGenerator;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageGenerator);
diff --git a/src/google/protobuf/compiler/cpp/cpp_options.h b/src/google/protobuf/compiler/cpp/cpp_options.h
index 6a364deb..84c18622 100644
--- a/src/google/protobuf/compiler/cpp/cpp_options.h
+++ b/src/google/protobuf/compiler/cpp/cpp_options.h
@@ -35,7 +35,6 @@
#include <string>
-#include <google/protobuf/stubs/common.h>
namespace google {
namespace protobuf {
namespace compiler {
@@ -45,7 +44,7 @@ namespace cpp {
// Generator options (see generator.cc for a description of each):
struct Options {
- string dllexport_decl;
+ std::string dllexport_decl;
bool safe_boundary_check = false;
bool proto_h = false;
bool transitive_pb_h = true;
@@ -58,8 +57,8 @@ struct Options {
bool opensource_runtime = false;
bool opensource_include_paths = false;
int num_cc_files = 0;
- string annotation_pragma_name;
- string annotation_guard_name;
+ std::string annotation_pragma_name;
+ std::string annotation_guard_name;
const AccessInfoMap* access_info_map = nullptr;
};
diff --git a/src/google/protobuf/compiler/cpp/cpp_service.h b/src/google/protobuf/compiler/cpp/cpp_service.h
index 3acbe637..2952e413 100644
--- a/src/google/protobuf/compiler/cpp/cpp_service.h
+++ b/src/google/protobuf/compiler/cpp/cpp_service.h
@@ -57,7 +57,7 @@ class ServiceGenerator {
public:
// See generator.cc for the meaning of dllexport_decl.
explicit ServiceGenerator(const ServiceDescriptor* descriptor,
- const std::map<string, string>& vars,
+ const std::map<std::string, std::string>& vars,
const Options& options);
~ServiceGenerator();
@@ -109,7 +109,7 @@ class ServiceGenerator {
void GenerateStubMethods(io::Printer* printer);
const ServiceDescriptor* descriptor_;
- std::map<string, string> vars_;
+ std::map<std::string, std::string> vars_;
int index_in_metadata_;
diff --git a/src/google/protobuf/compiler/cpp/cpp_unittest.inc b/src/google/protobuf/compiler/cpp/cpp_unittest.inc
index 0604731f..898b1fbb 100644
--- a/src/google/protobuf/compiler/cpp/cpp_unittest.inc
+++ b/src/google/protobuf/compiler/cpp/cpp_unittest.inc
@@ -78,6 +78,8 @@
#include <google/protobuf/stubs/casts.h>
#include <google/protobuf/stubs/stl_util.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace compiler {
@@ -203,7 +205,7 @@ TEST(GENERATED_MESSAGE_TEST_NAME, ExtremeSmallIntegerDefault) {
const UNITTEST::TestExtremeDefaultValues& extreme_default =
UNITTEST::TestExtremeDefaultValues::default_instance();
EXPECT_EQ(~0x7fffffff, kint32min);
- EXPECT_EQ(GOOGLE_LONGLONG(~0x7fffffffffffffff), kint64min);
+ EXPECT_EQ(PROTOBUF_LONGLONG(~0x7fffffffffffffff), kint64min);
EXPECT_EQ(kint32min, extreme_default.really_small_int32());
EXPECT_EQ(kint64min, extreme_default.really_small_int64());
}
@@ -656,7 +658,7 @@ TEST(GENERATED_MESSAGE_TEST_NAME, CopyAssignmentOperator) {
TestUtil::ExpectAllFieldsSet(message2);
}
-#if !defined(PROTOBUF_TEST_NO_DESCRIPTORS) || GOOGLE_PROTOBUF_RTTI
+#if !defined(PROTOBUF_TEST_NO_DESCRIPTORS) || PROTOBUF_RTTI
TEST(GENERATED_MESSAGE_TEST_NAME, UpcastCopyFrom) {
// Test the CopyFrom method that takes in the generic const Message&
// parameter.
@@ -2267,3 +2269,5 @@ TEST(DESCRIPTOR_INIT_TEST_NAME, Initialized) {
} // namespace compiler
} // namespace protobuf
} // namespace google
+
+#include <google/protobuf/port_undef.inc>
diff --git a/src/google/protobuf/compiler/csharp/csharp_generator.h b/src/google/protobuf/compiler/csharp/csharp_generator.h
index c8b19529..dc7319b1 100644
--- a/src/google/protobuf/compiler/csharp/csharp_generator.h
+++ b/src/google/protobuf/compiler/csharp/csharp_generator.h
@@ -37,6 +37,8 @@
#include <google/protobuf/compiler/code_generator.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace compiler {
@@ -46,9 +48,9 @@ namespace csharp {
// header. If you create your own protocol compiler binary and you want
// it to support C# output, you can do so by registering an instance of this
// CodeGenerator with the CommandLineInterface in your main() function.
-class LIBPROTOC_EXPORT Generator
+class PROTOC_EXPORT Generator
: public google::protobuf::compiler::CodeGenerator {
-public:
+ public:
virtual bool Generate(
const FileDescriptor* file,
const string& parameter,
@@ -61,4 +63,6 @@ public:
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_COMPILER_CSHARP_GENERATOR_H__
diff --git a/src/google/protobuf/compiler/csharp/csharp_helpers.h b/src/google/protobuf/compiler/csharp/csharp_helpers.h
index 8dd265bc..ec0b1c77 100644
--- a/src/google/protobuf/compiler/csharp/csharp_helpers.h
+++ b/src/google/protobuf/compiler/csharp/csharp_helpers.h
@@ -42,6 +42,8 @@
#include <google/protobuf/compiler/code_generator.h>
#include <google/protobuf/io/printer.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace compiler {
@@ -96,7 +98,8 @@ std::string UnderscoresToPascalCase(const std::string& input);
// Note that we wouldn't normally want to export this (we're not expecting
// it to be used outside libprotoc itself) but this exposes it for testing.
-std::string LIBPROTOC_EXPORT GetEnumValueName(const std::string& enum_name, const std::string& enum_value_name);
+std::string PROTOC_EXPORT GetEnumValueName(const std::string& enum_name,
+ const std::string& enum_value_name);
// TODO(jtattermusch): perhaps we could move this to strutil
std::string StringToBase64(const std::string& input);
@@ -145,4 +148,7 @@ inline bool IsWrapperType(const FieldDescriptor* descriptor) {
} // namespace compiler
} // namespace protobuf
} // namespace google
+
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_COMPILER_CSHARP_HELPERS_H__
diff --git a/src/google/protobuf/compiler/csharp/csharp_names.h b/src/google/protobuf/compiler/csharp/csharp_names.h
index 21758f28..87a16515 100644
--- a/src/google/protobuf/compiler/csharp/csharp_names.h
+++ b/src/google/protobuf/compiler/csharp/csharp_names.h
@@ -41,6 +41,8 @@
#include <string>
#include <google/protobuf/stubs/port.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
@@ -57,14 +59,14 @@ namespace csharp {
//
// Returns:
// The namespace to use for given file descriptor.
-string LIBPROTOC_EXPORT GetFileNamespace(const FileDescriptor* descriptor);
+string PROTOC_EXPORT GetFileNamespace(const FileDescriptor* descriptor);
// Requires:
// descriptor != NULL
//
// Returns:
// The fully-qualified C# class name.
-string LIBPROTOC_EXPORT GetClassName(const Descriptor* descriptor);
+string PROTOC_EXPORT GetClassName(const Descriptor* descriptor);
// Requires:
// descriptor != NULL
@@ -73,7 +75,7 @@ string LIBPROTOC_EXPORT GetClassName(const Descriptor* descriptor);
// The fully-qualified name of the C# class that provides
// access to the file descriptor. Proto compiler generates
// such class for each .proto file processed.
-string LIBPROTOC_EXPORT GetReflectionClassName(const FileDescriptor* descriptor);
+string PROTOC_EXPORT GetReflectionClassName(const FileDescriptor* descriptor);
// Generates output file name for given file descriptor. If generate_directories
// is true, the output file will be put under directory corresponding to file's
@@ -89,16 +91,16 @@ string LIBPROTOC_EXPORT GetReflectionClassName(const FileDescriptor* descriptor)
// The file name to use as output file for given file descriptor. In case
// of failure, this function will return empty string and error parameter
// will contain the error message.
-string LIBPROTOC_EXPORT GetOutputFile(
- const google::protobuf::FileDescriptor* descriptor,
- const string file_extension,
- const bool generate_directories,
- const string base_namespace,
- string* error);
+string PROTOC_EXPORT
+GetOutputFile(const google::protobuf::FileDescriptor* descriptor,
+ const string file_extension, const bool generate_directories,
+ const string base_namespace, string* error);
} // namespace csharp
} // namespace compiler
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_COMPILER_CSHARP_NAMES_H__
diff --git a/src/google/protobuf/compiler/importer.h b/src/google/protobuf/compiler/importer.h
index 5f279078..cf6b0123 100644
--- a/src/google/protobuf/compiler/importer.h
+++ b/src/google/protobuf/compiler/importer.h
@@ -45,6 +45,8 @@
#include <google/protobuf/descriptor_database.h>
#include <google/protobuf/compiler/parser.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
@@ -73,7 +75,7 @@ class DiskSourceTree;
//
// Note: This class does not implement FindFileContainingSymbol() or
// FindFileContainingExtension(); these will always return false.
-class LIBPROTOBUF_EXPORT SourceTreeDescriptorDatabase : public DescriptorDatabase {
+class PROTOBUF_EXPORT SourceTreeDescriptorDatabase : public DescriptorDatabase {
public:
SourceTreeDescriptorDatabase(SourceTree* source_tree);
~SourceTreeDescriptorDatabase();
@@ -96,11 +98,11 @@ class LIBPROTOBUF_EXPORT SourceTreeDescriptorDatabase : public DescriptorDatabas
}
// implements DescriptorDatabase -----------------------------------
- bool FindFileByName(const string& filename,
+ bool FindFileByName(const std::string& filename,
FileDescriptorProto* output) override;
- bool FindFileContainingSymbol(const string& symbol_name,
+ bool FindFileContainingSymbol(const std::string& symbol_name,
FileDescriptorProto* output) override;
- bool FindFileContainingExtension(const string& containing_type,
+ bool FindFileContainingExtension(const std::string& containing_type,
int field_number,
FileDescriptorProto* output) override;
@@ -110,19 +112,20 @@ class LIBPROTOBUF_EXPORT SourceTreeDescriptorDatabase : public DescriptorDatabas
SourceTree* source_tree_;
MultiFileErrorCollector* error_collector_;
- class LIBPROTOBUF_EXPORT ValidationErrorCollector : public DescriptorPool::ErrorCollector {
+ class PROTOBUF_EXPORT ValidationErrorCollector
+ : public DescriptorPool::ErrorCollector {
public:
ValidationErrorCollector(SourceTreeDescriptorDatabase* owner);
~ValidationErrorCollector();
// implements ErrorCollector ---------------------------------------
- void AddError(const string& filename, const string& element_name,
+ void AddError(const std::string& filename, const std::string& element_name,
const Message* descriptor, ErrorLocation location,
- const string& message) override;
+ const std::string& message) override;
- void AddWarning(const string& filename, const string& element_name,
+ void AddWarning(const std::string& filename, const std::string& element_name,
const Message* descriptor, ErrorLocation location,
- const string& message) override;
+ const std::string& message) override;
private:
SourceTreeDescriptorDatabase* owner_;
@@ -142,7 +145,7 @@ class LIBPROTOBUF_EXPORT SourceTreeDescriptorDatabase : public DescriptorDatabas
// You may find that SourceTreeDescriptorDatabase is more flexible.
//
// TODO(kenton): I feel like this class is not well-named.
-class LIBPROTOBUF_EXPORT Importer {
+class PROTOBUF_EXPORT Importer {
public:
Importer(SourceTree* source_tree,
MultiFileErrorCollector* error_collector);
@@ -161,7 +164,7 @@ class LIBPROTOBUF_EXPORT Importer {
// you want to see errors for the same files repeatedly, you can use a
// separate Importer object to import each one (but use the same
// DescriptorPool so that they can be cross-linked).
- const FileDescriptor* Import(const string& filename);
+ const FileDescriptor* Import(const std::string& filename);
// The DescriptorPool in which all imported FileDescriptors and their
// contents are stored.
@@ -169,7 +172,7 @@ class LIBPROTOBUF_EXPORT Importer {
return &pool_;
}
- void AddUnusedImportTrackFile(const string& file_name);
+ void AddUnusedImportTrackFile(const std::string& file_name);
void ClearUnusedImportTrackFiles();
@@ -182,18 +185,18 @@ class LIBPROTOBUF_EXPORT Importer {
// If the importer encounters problems while trying to import the proto files,
// it reports them to a MultiFileErrorCollector.
-class LIBPROTOBUF_EXPORT MultiFileErrorCollector {
+class PROTOBUF_EXPORT MultiFileErrorCollector {
public:
inline MultiFileErrorCollector() {}
virtual ~MultiFileErrorCollector();
// Line and column numbers are zero-based. A line number of -1 indicates
// an error with the entire file (e.g. "not found").
- virtual void AddError(const string& filename, int line, int column,
- const string& message) = 0;
+ virtual void AddError(const std::string& filename, int line, int column,
+ const std::string& message) = 0;
- virtual void AddWarning(const string& filename, int line, int column,
- const string& message) {}
+ virtual void AddWarning(const std::string& filename, int line, int column,
+ const std::string& message) {}
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MultiFileErrorCollector);
@@ -203,7 +206,7 @@ class LIBPROTOBUF_EXPORT MultiFileErrorCollector {
// Used by the default implementation of Importer to resolve import statements
// Most users will probably want to use the DiskSourceTree implementation,
// below.
-class LIBPROTOBUF_EXPORT SourceTree {
+class PROTOBUF_EXPORT SourceTree {
public:
inline SourceTree() {}
virtual ~SourceTree();
@@ -212,14 +215,14 @@ class LIBPROTOBUF_EXPORT SourceTree {
// found. The caller takes ownership of the returned object. The filename
// must be a path relative to the root of the source tree and must not
// contain "." or ".." components.
- virtual io::ZeroCopyInputStream* Open(const string& filename) = 0;
+ virtual io::ZeroCopyInputStream* Open(const std::string& filename) = 0;
// If Open() returns NULL, calling this method immediately will return an
// description of the error.
// Subclasses should implement this method and return a meaningful value for
// better error reporting.
// TODO(xiaofeng): change this to a pure virtual function.
- virtual string GetLastErrorMessage();
+ virtual std::string GetLastErrorMessage();
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(SourceTree);
@@ -228,7 +231,7 @@ class LIBPROTOBUF_EXPORT SourceTree {
// An implementation of SourceTree which loads files from locations on disk.
// Multiple mappings can be set up to map locations in the DiskSourceTree to
// locations in the physical filesystem.
-class LIBPROTOBUF_EXPORT DiskSourceTree : public SourceTree {
+class PROTOBUF_EXPORT DiskSourceTree : public SourceTree {
public:
DiskSourceTree();
~DiskSourceTree();
@@ -249,7 +252,7 @@ class LIBPROTOBUF_EXPORT DiskSourceTree : public SourceTree {
//
// disk_path may be an absolute path or relative to the current directory,
// just like a path you'd pass to open().
- void MapPath(const string& virtual_path, const string& disk_path);
+ void MapPath(const std::string& virtual_path, const std::string& disk_path);
// Return type for DiskFileToVirtualFile().
enum DiskFileToVirtualFileResult {
@@ -280,39 +283,39 @@ class LIBPROTOBUF_EXPORT DiskSourceTree : public SourceTree {
// * NO_MAPPING: Indicates that no mapping was found which contains this
// file.
DiskFileToVirtualFileResult
- DiskFileToVirtualFile(const string& disk_file,
- string* virtual_file,
- string* shadowing_disk_file);
+ DiskFileToVirtualFile(const std::string& disk_file,
+ std::string* virtual_file,
+ std::string* shadowing_disk_file);
// Given a virtual path, find the path to the file on disk.
// Return true and update disk_file with the on-disk path if the file exists.
// Return false and leave disk_file untouched if the file doesn't exist.
- bool VirtualFileToDiskFile(const string& virtual_file, string* disk_file);
+ bool VirtualFileToDiskFile(const std::string& virtual_file, std::string* disk_file);
// implements SourceTree -------------------------------------------
- io::ZeroCopyInputStream* Open(const string& filename) override;
+ io::ZeroCopyInputStream* Open(const std::string& filename) override;
- string GetLastErrorMessage() override;
+ std::string GetLastErrorMessage() override;
private:
struct Mapping {
- string virtual_path;
- string disk_path;
+ std::string virtual_path;
+ std::string disk_path;
- inline Mapping(const string& virtual_path_param,
- const string& disk_path_param)
+ inline Mapping(const std::string& virtual_path_param,
+ const std::string& disk_path_param)
: virtual_path(virtual_path_param), disk_path(disk_path_param) {}
};
std::vector<Mapping> mappings_;
- string last_error_message_;
+ std::string last_error_message_;
// Like Open(), but returns the on-disk path in disk_file if disk_file is
// non-NULL and the file could be successfully opened.
- io::ZeroCopyInputStream* OpenVirtualFile(const string& virtual_file,
- string* disk_file);
+ io::ZeroCopyInputStream* OpenVirtualFile(const std::string& virtual_file,
+ std::string* disk_file);
// Like Open() but given the actual on-disk path.
- io::ZeroCopyInputStream* OpenDiskFile(const string& filename);
+ io::ZeroCopyInputStream* OpenDiskFile(const std::string& filename);
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DiskSourceTree);
};
@@ -321,4 +324,6 @@ class LIBPROTOBUF_EXPORT DiskSourceTree : public SourceTree {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_COMPILER_IMPORTER_H__
diff --git a/src/google/protobuf/compiler/java/java_doc_comment.h b/src/google/protobuf/compiler/java/java_doc_comment.h
index 112c3bc3..ef9b3a90 100644
--- a/src/google/protobuf/compiler/java/java_doc_comment.h
+++ b/src/google/protobuf/compiler/java/java_doc_comment.h
@@ -37,6 +37,8 @@
#include <google/protobuf/descriptor.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace io {
@@ -61,11 +63,13 @@ void WriteMethodDocComment(io::Printer* printer,
const MethodDescriptor* method);
// Exposed for testing only.
-LIBPROTOC_EXPORT string EscapeJavadoc(const string& input);
+PROTOC_EXPORT std::string EscapeJavadoc(const std::string& input);
} // namespace java
} // namespace compiler
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_DOC_COMMENT_H__
diff --git a/src/google/protobuf/compiler/java/java_enum_field.h b/src/google/protobuf/compiler/java/java_enum_field.h
index 842da592..723102d8 100644
--- a/src/google/protobuf/compiler/java/java_enum_field.h
+++ b/src/google/protobuf/compiler/java/java_enum_field.h
@@ -81,11 +81,11 @@ class ImmutableEnumFieldGenerator : public ImmutableFieldGenerator {
void GenerateEqualsCode(io::Printer* printer) const;
void GenerateHashCode(io::Printer* printer) const;
- string GetBoxedType() const;
+ std::string GetBoxedType() const;
protected:
const FieldDescriptor* descriptor_;
- std::map<string, string> variables_;
+ std::map<std::string, std::string> variables_;
const int messageBitIndex_;
const int builderBitIndex_;
Context* context_;
@@ -142,11 +142,11 @@ class RepeatedImmutableEnumFieldGenerator : public ImmutableFieldGenerator {
void GenerateEqualsCode(io::Printer* printer) const;
void GenerateHashCode(io::Printer* printer) const;
- string GetBoxedType() const;
+ std::string GetBoxedType() const;
private:
const FieldDescriptor* descriptor_;
- std::map<string, string> variables_;
+ std::map<std::string, std::string> variables_;
const int messageBitIndex_;
const int builderBitIndex_;
Context* context_;
diff --git a/src/google/protobuf/compiler/java/java_enum_field_lite.h b/src/google/protobuf/compiler/java/java_enum_field_lite.h
index 6bda426f..bf25ffaa 100644
--- a/src/google/protobuf/compiler/java/java_enum_field_lite.h
+++ b/src/google/protobuf/compiler/java/java_enum_field_lite.h
@@ -79,11 +79,11 @@ class ImmutableEnumFieldLiteGenerator : public ImmutableFieldLiteGenerator {
void GenerateEqualsCode(io::Printer* printer) const;
void GenerateHashCode(io::Printer* printer) const;
- string GetBoxedType() const;
+ std::string GetBoxedType() const;
protected:
const FieldDescriptor* descriptor_;
- std::map<string, string> variables_;
+ std::map<std::string, std::string> variables_;
const int messageBitIndex_;
Context* context_;
ClassNameResolver* name_resolver_;
@@ -136,11 +136,11 @@ class RepeatedImmutableEnumFieldLiteGenerator
void GenerateEqualsCode(io::Printer* printer) const;
void GenerateHashCode(io::Printer* printer) const;
- string GetBoxedType() const;
+ std::string GetBoxedType() const;
private:
const FieldDescriptor* descriptor_;
- std::map<string, string> variables_;
+ std::map<std::string, std::string> variables_;
const int messageBitIndex_;
Context* context_;
ClassNameResolver* name_resolver_;
diff --git a/src/google/protobuf/compiler/java/java_extension.h b/src/google/protobuf/compiler/java/java_extension.h
index 7a58373f..1f11324c 100644
--- a/src/google/protobuf/compiler/java/java_extension.h
+++ b/src/google/protobuf/compiler/java/java_extension.h
@@ -80,9 +80,9 @@ class ExtensionGenerator {
protected:
static void InitTemplateVars(const FieldDescriptor* descriptor,
- const string& scope, bool immutable,
+ const std::string& scope, bool immutable,
ClassNameResolver* name_resolver,
- std::map<string, string>* vars_pointer);
+ std::map<std::string, std::string>* vars_pointer);
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ExtensionGenerator);
@@ -102,7 +102,7 @@ class ImmutableExtensionGenerator : public ExtensionGenerator {
const FieldDescriptor* descriptor_;
Context* context_;
ClassNameResolver* name_resolver_;
- string scope_;
+ std::string scope_;
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableExtensionGenerator);
diff --git a/src/google/protobuf/compiler/java/java_extension_lite.h b/src/google/protobuf/compiler/java/java_extension_lite.h
index 34716f9d..eaa90a4b 100644
--- a/src/google/protobuf/compiler/java/java_extension_lite.h
+++ b/src/google/protobuf/compiler/java/java_extension_lite.h
@@ -63,7 +63,7 @@ class ImmutableExtensionLiteGenerator : public ExtensionGenerator {
const FieldDescriptor* descriptor_;
Context* context_;
ClassNameResolver* name_resolver_;
- string scope_;
+ std::string scope_;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableExtensionLiteGenerator);
};
diff --git a/src/google/protobuf/compiler/java/java_field.h b/src/google/protobuf/compiler/java/java_field.h
index 881427d7..abefc589 100644
--- a/src/google/protobuf/compiler/java/java_field.h
+++ b/src/google/protobuf/compiler/java/java_field.h
@@ -87,7 +87,7 @@ class ImmutableFieldGenerator {
virtual void GenerateEqualsCode(io::Printer* printer) const = 0;
virtual void GenerateHashCode(io::Printer* printer) const = 0;
- virtual string GetBoxedType() const = 0;
+ virtual std::string GetBoxedType() const = 0;
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableFieldGenerator);
@@ -118,7 +118,7 @@ class ImmutableFieldLiteGenerator {
virtual void GenerateHashCode(io::Printer* printer) const = 0;
- virtual string GetBoxedType() const = 0;
+ virtual std::string GetBoxedType() const = 0;
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableFieldLiteGenerator);
@@ -171,29 +171,29 @@ FieldGeneratorMap<ImmutableFieldLiteGenerator>::~FieldGeneratorMap();
// Field information used in FieldGeneartors.
struct FieldGeneratorInfo {
- string name;
- string capitalized_name;
- string disambiguated_reason;
+ std::string name;
+ std::string capitalized_name;
+ std::string disambiguated_reason;
};
// Oneof information used in OneofFieldGenerators.
struct OneofGeneratorInfo {
- string name;
- string capitalized_name;
+ std::string name;
+ std::string capitalized_name;
};
// Set some common variables used in variable FieldGenerators.
void SetCommonFieldVariables(const FieldDescriptor* descriptor,
const FieldGeneratorInfo* info,
- std::map<string, string>* variables);
+ std::map<std::string, std::string>* variables);
// Set some common oneof variables used in OneofFieldGenerators.
void SetCommonOneofVariables(const FieldDescriptor* descriptor,
const OneofGeneratorInfo* info,
- std::map<string, string>* variables);
+ std::map<std::string, std::string>* variables);
// Print useful comments before a field's accessors.
-void PrintExtraFieldInfo(const std::map<string, string>& variables,
+void PrintExtraFieldInfo(const std::map<std::string, std::string>& variables,
io::Printer* printer);
} // namespace java
diff --git a/src/google/protobuf/compiler/java/java_file.cc b/src/google/protobuf/compiler/java/java_file.cc
index 5dc2dff8..5356512c 100644
--- a/src/google/protobuf/compiler/java/java_file.cc
+++ b/src/google/protobuf/compiler/java/java_file.cc
@@ -232,7 +232,9 @@ bool FileGenerator::Validate(string* error) {
<< "will be ignored by protoc in the future and protoc will always "
<< "generate full runtime code for Java. To use Java Lite runtime, "
<< "users should use the Java Lite plugin instead. See:\n"
- << " https://github.com/protocolbuffers/protobuf/blob/master/java/lite.md";
+ << " "
+ "https://github.com/protocolbuffers/protobuf/blob/master/java/"
+ "lite.md";
}
return true;
}
diff --git a/src/google/protobuf/compiler/java/java_file.h b/src/google/protobuf/compiler/java/java_file.h
index 4158d48b..9dca82bb 100644
--- a/src/google/protobuf/compiler/java/java_file.h
+++ b/src/google/protobuf/compiler/java/java_file.h
@@ -74,20 +74,20 @@ class FileGenerator {
// Checks for problems that would otherwise lead to cryptic compile errors.
// Returns true if there are no problems, or writes an error description to
// the given string and returns false otherwise.
- bool Validate(string* error);
+ bool Validate(std::string* error);
void Generate(io::Printer* printer);
// If we aren't putting everything into one file, this will write all the
// files other than the outer file (i.e. one for each message, enum, and
// service type).
- void GenerateSiblings(const string& package_dir,
+ void GenerateSiblings(const std::string& package_dir,
GeneratorContext* generator_context,
- std::vector<string>* file_list,
- std::vector<string>* annotation_list);
+ std::vector<std::string>* file_list,
+ std::vector<std::string>* annotation_list);
- const string& java_package() { return java_package_; }
- const string& classname() { return classname_; }
+ const std::string& java_package() { return java_package_; }
+ const std::string& classname() { return classname_; }
private:
void GenerateDescriptorInitializationCodeForImmutable(io::Printer* printer);
@@ -97,8 +97,8 @@ class FileGenerator {
bool immutable_api_);
const FileDescriptor* file_;
- string java_package_;
- string classname_;
+ std::string java_package_;
+ std::string classname_;
std::vector<std::unique_ptr<MessageGenerator>> message_generators_;
std::vector<std::unique_ptr<ExtensionGenerator>> extension_generators_;
diff --git a/src/google/protobuf/compiler/java/java_generator.h b/src/google/protobuf/compiler/java/java_generator.h
index 6eefdd84..21873581 100644
--- a/src/google/protobuf/compiler/java/java_generator.h
+++ b/src/google/protobuf/compiler/java/java_generator.h
@@ -40,6 +40,8 @@
#include <string>
#include <google/protobuf/compiler/code_generator.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace compiler {
@@ -49,16 +51,16 @@ namespace java {
// own protocol compiler binary and you want it to support Java output, you
// can do so by registering an instance of this CodeGenerator with the
// CommandLineInterface in your main() function.
-class LIBPROTOC_EXPORT JavaGenerator : public CodeGenerator {
+class PROTOC_EXPORT JavaGenerator : public CodeGenerator {
public:
JavaGenerator();
~JavaGenerator();
// implements CodeGenerator ----------------------------------------
bool Generate(const FileDescriptor* file,
- const string& parameter,
+ const std::string& parameter,
GeneratorContext* context,
- string* error) const;
+ std::string* error) const;
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(JavaGenerator);
@@ -69,4 +71,6 @@ class LIBPROTOC_EXPORT JavaGenerator : public CodeGenerator {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_GENERATOR_H__
diff --git a/src/google/protobuf/compiler/java/java_helpers.h b/src/google/protobuf/compiler/java/java_helpers.h
index 375bd67d..93caa3dc 100644
--- a/src/google/protobuf/compiler/java/java_helpers.h
+++ b/src/google/protobuf/compiler/java/java_helpers.h
@@ -60,89 +60,89 @@ extern const char kThinSeparator[];
// annotation_file should be generated from the filename of the source file
// being annotated (which in turn must be a Java identifier plus ".java").
void PrintGeneratedAnnotation(io::Printer* printer, char delimiter = '$',
- const string& annotation_file = "");
+ const std::string& annotation_file = "");
// If a GeneratedMessageLite contains non-lite enums, then its verifier
// must be instantiated inline, rather than retrieved from the enum class.
void PrintEnumVerifierLogic(io::Printer* printer,
const FieldDescriptor* descriptor,
- const std::map<string, string>& variables,
+ const std::map<std::string, std::string>& variables,
const char* var_name,
const char* terminating_string,
bool enforce_lite);
// Converts a name to camel-case. If cap_first_letter is true, capitalize the
// first letter.
-string UnderscoresToCamelCase(const string& name, bool cap_first_letter);
+std::string UnderscoresToCamelCase(const std::string& name, bool cap_first_letter);
// Converts the field's name to camel-case, e.g. "foo_bar_baz" becomes
// "fooBarBaz" or "FooBarBaz", respectively.
-string UnderscoresToCamelCase(const FieldDescriptor* field);
-string UnderscoresToCapitalizedCamelCase(const FieldDescriptor* field);
+std::string UnderscoresToCamelCase(const FieldDescriptor* field);
+std::string UnderscoresToCapitalizedCamelCase(const FieldDescriptor* field);
// Similar, but for method names. (Typically, this merely has the effect
// of lower-casing the first letter of the name.)
-string UnderscoresToCamelCase(const MethodDescriptor* method);
+std::string UnderscoresToCamelCase(const MethodDescriptor* method);
// Similar to UnderscoresToCamelCase, but guarentees that the result is a
// complete Java identifier by adding a _ if needed.
-string CamelCaseFieldName(const FieldDescriptor* field);
+std::string CamelCaseFieldName(const FieldDescriptor* field);
// Get an identifier that uniquely identifies this type within the file.
// This is used to declare static variables related to this type at the
// outermost file scope.
-string UniqueFileScopeIdentifier(const Descriptor* descriptor);
+std::string UniqueFileScopeIdentifier(const Descriptor* descriptor);
// Strips ".proto" or ".protodevel" from the end of a filename.
-string StripProto(const string& filename);
+std::string StripProto(const std::string& filename);
// Gets the unqualified class name for the file. For each .proto file, there
// will be one Java class containing all the immutable messages and another
// Java class containing all the mutable messages.
// TODO(xiaofeng): remove the default value after updating client code.
-string FileClassName(const FileDescriptor* file, bool immutable = true);
+std::string FileClassName(const FileDescriptor* file, bool immutable = true);
// Returns the file's Java package name.
-string FileJavaPackage(const FileDescriptor* file);
-string FileJavaPackage(const FileDescriptor* file, bool immutable);
+std::string FileJavaPackage(const FileDescriptor* file);
+std::string FileJavaPackage(const FileDescriptor* file, bool immutable);
// Returns output directory for the given package name.
-string JavaPackageToDir(string package_name);
+std::string JavaPackageToDir(std::string package_name);
// Converts the given fully-qualified name in the proto namespace to its
// fully-qualified name in the Java namespace, given that it is in the given
// file.
// TODO(xiaofeng): this method is deprecated and should be removed in the
// future.
-string ToJavaName(const string& full_name,
+std::string ToJavaName(const std::string& full_name,
const FileDescriptor* file);
// TODO(xiaofeng): the following methods are kept for they are exposed
// publicly in //net/proto2/compiler/java/public/names.h. They return
// immutable names only and should be removed after mutable API is
// integrated into google3.
-string ClassName(const Descriptor* descriptor);
-string ClassName(const EnumDescriptor* descriptor);
-string ClassName(const ServiceDescriptor* descriptor);
-string ClassName(const FileDescriptor* descriptor);
+std::string ClassName(const Descriptor* descriptor);
+std::string ClassName(const EnumDescriptor* descriptor);
+std::string ClassName(const ServiceDescriptor* descriptor);
+std::string ClassName(const FileDescriptor* descriptor);
// Comma-separate list of option-specified interfaces implemented by the
// Message, to follow the "implements" declaration of the Message definition.
-string ExtraMessageInterfaces(const Descriptor* descriptor);
+std::string ExtraMessageInterfaces(const Descriptor* descriptor);
// Comma-separate list of option-specified interfaces implemented by the
// MutableMessage, to follow the "implements" declaration of the MutableMessage
// definition.
-string ExtraMutableMessageInterfaces(const Descriptor* descriptor);
+std::string ExtraMutableMessageInterfaces(const Descriptor* descriptor);
// Comma-separate list of option-specified interfaces implemented by the
// Builder, to follow the "implements" declaration of the Builder definition.
-string ExtraBuilderInterfaces(const Descriptor* descriptor);
+std::string ExtraBuilderInterfaces(const Descriptor* descriptor);
// Comma-separate list of option-specified interfaces extended by the
// MessageOrBuilder, to follow the "extends" declaration of the
// MessageOrBuilder definition.
-string ExtraMessageOrBuilderInterfaces(const Descriptor* descriptor);
+std::string ExtraMessageOrBuilderInterfaces(const Descriptor* descriptor);
// Get the unqualified Java class name for mutable messages. i.e. without
// package or outer classnames.
-inline string ShortMutableJavaClassName(const Descriptor* descriptor) {
+inline std::string ShortMutableJavaClassName(const Descriptor* descriptor) {
return descriptor->name();
}
@@ -179,14 +179,14 @@ inline bool IsOwnFile(const ServiceDescriptor* descriptor, bool immutable) {
// annotation data for that descriptor. `suffix` is usually empty, but may
// (e.g.) be "OrBuilder" for some generated interfaces.
template <typename Descriptor>
-string AnnotationFileName(const Descriptor* descriptor, const string& suffix) {
+std::string AnnotationFileName(const Descriptor* descriptor, const std::string& suffix) {
return descriptor->name() + suffix + ".java.pb.meta";
}
template <typename Descriptor>
void MaybePrintGeneratedAnnotation(Context* context, io::Printer* printer,
Descriptor* descriptor, bool immutable,
- const string& suffix = "") {
+ const std::string& suffix = "") {
if (context->options().annotate_code && IsOwnFile(descriptor, immutable)) {
PrintGeneratedAnnotation(printer, '$',
AnnotationFileName(descriptor, suffix));
@@ -195,7 +195,7 @@ void MaybePrintGeneratedAnnotation(Context* context, io::Printer* printer,
// Get the unqualified name that should be used for a field's field
// number constant.
-string FieldConstantName(const FieldDescriptor *field);
+std::string FieldConstantName(const FieldDescriptor *field);
// Returns the type of the FieldDescriptor.
// This does nothing interesting for the open source release, but is used for
@@ -229,9 +229,9 @@ const char* BoxedPrimitiveTypeName(JavaType type);
const char* FieldTypeName(const FieldDescriptor::Type field_type);
class ClassNameResolver;
-string DefaultValue(const FieldDescriptor* field, bool immutable,
+std::string DefaultValue(const FieldDescriptor* field, bool immutable,
ClassNameResolver* name_resolver);
-inline string ImmutableDefaultValue(const FieldDescriptor* field,
+inline std::string ImmutableDefaultValue(const FieldDescriptor* field,
ClassNameResolver* name_resolver) {
return DefaultValue(field, true, name_resolver);
}
@@ -267,50 +267,50 @@ inline bool HasGenericServices(const FileDescriptor *file, bool enforce_lite) {
// Methods for shared bitfields.
// Gets the name of the shared bitfield for the given index.
-string GetBitFieldName(int index);
+std::string GetBitFieldName(int index);
// Gets the name of the shared bitfield for the given bit index.
// Effectively, GetBitFieldName(bitIndex / 32)
-string GetBitFieldNameForBit(int bitIndex);
+std::string GetBitFieldNameForBit(int bitIndex);
// Generates the java code for the expression that returns the boolean value
// of the bit of the shared bitfields for the given bit index.
// Example: "((bitField1_ & 0x04) == 0x04)"
-string GenerateGetBit(int bitIndex);
+std::string GenerateGetBit(int bitIndex);
// Generates the java code for the expression that sets the bit of the shared
// bitfields for the given bit index.
// Example: "bitField1_ = (bitField1_ | 0x04)"
-string GenerateSetBit(int bitIndex);
+std::string GenerateSetBit(int bitIndex);
// Generates the java code for the expression that clears the bit of the shared
// bitfields for the given bit index.
// Example: "bitField1_ = (bitField1_ & ~0x04)"
-string GenerateClearBit(int bitIndex);
+std::string GenerateClearBit(int bitIndex);
// Does the same as GenerateGetBit but operates on the bit field on a local
// variable. This is used by the builder to copy the value in the builder to
// the message.
// Example: "((from_bitField1_ & 0x04) == 0x04)"
-string GenerateGetBitFromLocal(int bitIndex);
+std::string GenerateGetBitFromLocal(int bitIndex);
// Does the same as GenerateSetBit but operates on the bit field on a local
// variable. This is used by the builder to copy the value in the builder to
// the message.
// Example: "to_bitField1_ = (to_bitField1_ | 0x04)"
-string GenerateSetBitToLocal(int bitIndex);
+std::string GenerateSetBitToLocal(int bitIndex);
// Does the same as GenerateGetBit but operates on the bit field on a local
// variable. This is used by the parsing constructor to record if a repeated
// field is mutable.
// Example: "((mutable_bitField1_ & 0x04) == 0x04)"
-string GenerateGetBitMutableLocal(int bitIndex);
+std::string GenerateGetBitMutableLocal(int bitIndex);
// Does the same as GenerateSetBit but operates on the bit field on a local
// variable. This is used by the parsing constructor to record if a repeated
// field is mutable.
// Example: "mutable_bitField1_ = (mutable_bitField1_ | 0x04)"
-string GenerateSetBitMutableLocal(int bitIndex);
+std::string GenerateSetBitMutableLocal(int bitIndex);
// Returns whether the JavaType is a reference type.
bool IsReferenceType(JavaType type);
@@ -398,7 +398,7 @@ inline bool CheckUtf8(const FieldDescriptor* descriptor) {
descriptor->file()->options().java_string_check_utf8();
}
-inline string GeneratedCodeVersionSuffix() {
+inline std::string GeneratedCodeVersionSuffix() {
return "V3";
}
@@ -410,7 +410,7 @@ inline void WriteIntToUtf16CharSequence(int value,
}
// Escape a UTF-16 character so it can be embedded in a Java string literal.
-void EscapeUtf16ToString(uint16 code, string* output);
+void EscapeUtf16ToString(uint16 code, std::string* output);
// Only the lowest two bytes of the return value are used. The lowest byte
// is the integer value of a j/c/g/protobuf/FieldType enum. For the other
diff --git a/src/google/protobuf/compiler/java/java_map_field.h b/src/google/protobuf/compiler/java/java_map_field.h
index 90c90eb2..b123b041 100644
--- a/src/google/protobuf/compiler/java/java_map_field.h
+++ b/src/google/protobuf/compiler/java/java_map_field.h
@@ -63,11 +63,11 @@ class ImmutableMapFieldGenerator : public ImmutableFieldGenerator {
void GenerateEqualsCode(io::Printer* printer) const;
void GenerateHashCode(io::Printer* printer) const;
- string GetBoxedType() const;
+ std::string GetBoxedType() const;
private:
const FieldDescriptor* descriptor_;
- std::map<string, string> variables_;
+ std::map<std::string, std::string> variables_;
ClassNameResolver* name_resolver_;
void GenerateMapGetters(io::Printer* printer) const;
};
diff --git a/src/google/protobuf/compiler/java/java_map_field_lite.h b/src/google/protobuf/compiler/java/java_map_field_lite.h
index 710617ae..df5fe64d 100644
--- a/src/google/protobuf/compiler/java/java_map_field_lite.h
+++ b/src/google/protobuf/compiler/java/java_map_field_lite.h
@@ -62,11 +62,11 @@ class ImmutableMapFieldLiteGenerator : public ImmutableFieldLiteGenerator {
void GenerateHashCode(io::Printer* printer) const;
- string GetBoxedType() const;
+ std::string GetBoxedType() const;
private:
const FieldDescriptor* descriptor_;
- std::map<string, string> variables_;
+ std::map<std::string, std::string> variables_;
Context* context_;
ClassNameResolver* name_resolver_;
};
diff --git a/src/google/protobuf/compiler/java/java_message_field.h b/src/google/protobuf/compiler/java/java_message_field.h
index d70d8270..58344e55 100644
--- a/src/google/protobuf/compiler/java/java_message_field.h
+++ b/src/google/protobuf/compiler/java/java_message_field.h
@@ -82,11 +82,11 @@ class ImmutableMessageFieldGenerator : public ImmutableFieldGenerator {
void GenerateEqualsCode(io::Printer* printer) const;
void GenerateHashCode(io::Printer* printer) const;
- string GetBoxedType() const;
+ std::string GetBoxedType() const;
protected:
const FieldDescriptor* descriptor_;
- std::map<string, string> variables_;
+ std::map<std::string, std::string> variables_;
const int messageBitIndex_;
const int builderBitIndex_;
Context* context_;
@@ -150,11 +150,11 @@ class RepeatedImmutableMessageFieldGenerator : public ImmutableFieldGenerator {
void GenerateEqualsCode(io::Printer* printer) const;
void GenerateHashCode(io::Printer* printer) const;
- string GetBoxedType() const;
+ std::string GetBoxedType() const;
protected:
const FieldDescriptor* descriptor_;
- std::map<string, string> variables_;
+ std::map<std::string, std::string> variables_;
const int messageBitIndex_;
const int builderBitIndex_;
Context* context_;
diff --git a/src/google/protobuf/compiler/java/java_message_field_lite.h b/src/google/protobuf/compiler/java/java_message_field_lite.h
index c9eb30b8..7e78ca4f 100644
--- a/src/google/protobuf/compiler/java/java_message_field_lite.h
+++ b/src/google/protobuf/compiler/java/java_message_field_lite.h
@@ -79,11 +79,11 @@ class ImmutableMessageFieldLiteGenerator : public ImmutableFieldLiteGenerator {
void GenerateEqualsCode(io::Printer* printer) const;
void GenerateHashCode(io::Printer* printer) const;
- string GetBoxedType() const;
+ std::string GetBoxedType() const;
protected:
const FieldDescriptor* descriptor_;
- std::map<string, string> variables_;
+ std::map<std::string, std::string> variables_;
const int messageBitIndex_;
Context* context_;
ClassNameResolver* name_resolver_;
@@ -136,11 +136,11 @@ class RepeatedImmutableMessageFieldLiteGenerator
void GenerateHashCode(io::Printer* printer) const;
- string GetBoxedType() const;
+ std::string GetBoxedType() const;
protected:
const FieldDescriptor* descriptor_;
- std::map<string, string> variables_;
+ std::map<std::string, std::string> variables_;
const int messageBitIndex_;
Context* context_;
ClassNameResolver* name_resolver_;
diff --git a/src/google/protobuf/compiler/java/java_message_lite.cc b/src/google/protobuf/compiler/java/java_message_lite.cc
index 85a7453d..a131e8cc 100644
--- a/src/google/protobuf/compiler/java/java_message_lite.cc
+++ b/src/google/protobuf/compiler/java/java_message_lite.cc
@@ -736,14 +736,14 @@ void ImmutableMessageLiteGenerator::GenerateSerializeOneExtensionRange(
void ImmutableMessageLiteGenerator::GenerateBuilder(io::Printer* printer) {
printer->Print(
- "public static Builder newBuilder() {\n"
- " return (Builder) DEFAULT_INSTANCE.createBuilder();\n"
- "}\n"
- "public static Builder newBuilder($classname$ prototype) {\n"
- " return (Builder) DEFAULT_INSTANCE.createBuilder(prototype);\n"
- "}\n"
- "\n",
- "classname", name_resolver_->GetImmutableClassName(descriptor_));
+ "public static Builder newBuilder() {\n"
+ " return (Builder) DEFAULT_INSTANCE.createBuilder();\n"
+ "}\n"
+ "public static Builder newBuilder($classname$ prototype) {\n"
+ " return (Builder) DEFAULT_INSTANCE.createBuilder(prototype);\n"
+ "}\n"
+ "\n",
+ "classname", name_resolver_->GetImmutableClassName(descriptor_));
MessageBuilderLiteGenerator builderGenerator(descriptor_, context_);
builderGenerator.Generate(printer);
diff --git a/src/google/protobuf/compiler/java/java_name_resolver.h b/src/google/protobuf/compiler/java/java_name_resolver.h
index 90684da2..aa19f007 100644
--- a/src/google/protobuf/compiler/java/java_name_resolver.h
+++ b/src/google/protobuf/compiler/java/java_name_resolver.h
@@ -56,63 +56,63 @@ class ClassNameResolver {
~ClassNameResolver();
// Gets the unqualified outer class name for the file.
- string GetFileClassName(const FileDescriptor* file, bool immutable);
+ std::string GetFileClassName(const FileDescriptor* file, bool immutable);
// Gets the unqualified immutable outer class name of a file.
- string GetFileImmutableClassName(const FileDescriptor* file);
+ std::string GetFileImmutableClassName(const FileDescriptor* file);
// Gets the unqualified default immutable outer class name of a file
// (converted from the proto file's name).
- string GetFileDefaultImmutableClassName(const FileDescriptor* file);
+ std::string GetFileDefaultImmutableClassName(const FileDescriptor* file);
// Check whether there is any type defined in the proto file that has
// the given class name.
bool HasConflictingClassName(const FileDescriptor* file,
- const string& classname);
+ const std::string& classname);
// Gets the name of the outer class that holds descriptor information.
// Descriptors are shared between immutable messages and mutable messages.
// Since both of them are generated optionally, the descriptors need to be
// put in another common place.
- string GetDescriptorClassName(const FileDescriptor* file);
+ std::string GetDescriptorClassName(const FileDescriptor* file);
// Gets the fully-qualified class name corresponding to the given descriptor.
- string GetClassName(const Descriptor* descriptor, bool immutable);
- string GetClassName(const EnumDescriptor* descriptor, bool immutable);
- string GetClassName(const ServiceDescriptor* descriptor, bool immutable);
- string GetClassName(const FileDescriptor* descriptor, bool immutable);
+ std::string GetClassName(const Descriptor* descriptor, bool immutable);
+ std::string GetClassName(const EnumDescriptor* descriptor, bool immutable);
+ std::string GetClassName(const ServiceDescriptor* descriptor, bool immutable);
+ std::string GetClassName(const FileDescriptor* descriptor, bool immutable);
template<class DescriptorType>
- string GetImmutableClassName(const DescriptorType* descriptor) {
+ std::string GetImmutableClassName(const DescriptorType* descriptor) {
return GetClassName(descriptor, true);
}
template<class DescriptorType>
- string GetMutableClassName(const DescriptorType* descriptor) {
+ std::string GetMutableClassName(const DescriptorType* descriptor) {
return GetClassName(descriptor, false);
}
// Gets the fully qualified name of an extension identifier.
- string GetExtensionIdentifierName(const FieldDescriptor* descriptor,
+ std::string GetExtensionIdentifierName(const FieldDescriptor* descriptor,
bool immutable);
// Gets the fully qualified name for generated classes in Java convention.
// Nested classes will be separated using '$' instead of '.'
// For example:
// com.package.OuterClass$OuterMessage$InnerMessage
- string GetJavaImmutableClassName(const Descriptor* descriptor);
- string GetJavaImmutableClassName(const EnumDescriptor* descriptor);
+ std::string GetJavaImmutableClassName(const Descriptor* descriptor);
+ std::string GetJavaImmutableClassName(const EnumDescriptor* descriptor);
private:
// Get the full name of a Java class by prepending the Java package name
// or outer class name.
- string GetClassFullName(const string& name_without_package,
+ std::string GetClassFullName(const std::string& name_without_package,
const FileDescriptor* file,
bool immutable,
bool multiple_files);
// Get the Java Class style full name of a message.
- string GetJavaClassFullName(
- const string& name_without_package,
+ std::string GetJavaClassFullName(
+ const std::string& name_without_package,
const FileDescriptor* file,
bool immutable);
// Caches the result to provide better performance.
- std::map<const FileDescriptor*, string> file_immutable_outer_class_names_;
+ std::map<const FileDescriptor*, std::string> file_immutable_outer_class_names_;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ClassNameResolver);
};
diff --git a/src/google/protobuf/compiler/java/java_names.h b/src/google/protobuf/compiler/java/java_names.h
index 39e8c51f..a8efbb49 100644
--- a/src/google/protobuf/compiler/java/java_names.h
+++ b/src/google/protobuf/compiler/java/java_names.h
@@ -57,41 +57,41 @@ namespace java {
//
// Returns:
// The fully-qualified Java class name.
-string ClassName(const Descriptor* descriptor);
+std::string ClassName(const Descriptor* descriptor);
// Requires:
// descriptor != NULL
//
// Returns:
// The fully-qualified Java class name.
-string ClassName(const EnumDescriptor* descriptor);
+std::string ClassName(const EnumDescriptor* descriptor);
// Requires:
// descriptor != NULL
//
// Returns:
// The fully-qualified Java class name.
-string ClassName(const FileDescriptor* descriptor);
+std::string ClassName(const FileDescriptor* descriptor);
// Requires:
// descriptor != NULL
//
// Returns:
// The fully-qualified Java class name.
-string ClassName(const ServiceDescriptor* descriptor);
+std::string ClassName(const ServiceDescriptor* descriptor);
// Requires:
// descriptor != NULL
//
// Returns:
// Java package name.
-string FileJavaPackage(const FileDescriptor* descriptor);
+std::string FileJavaPackage(const FileDescriptor* descriptor);
// Requires:
// descriptor != NULL
// Returns:
// Captialized camel case name field name.
-string CapitalizedFieldName(const FieldDescriptor* descriptor);
+std::string CapitalizedFieldName(const FieldDescriptor* descriptor);
// Requires:
// descriptor != NULL
diff --git a/src/google/protobuf/compiler/java/java_primitive_field.h b/src/google/protobuf/compiler/java/java_primitive_field.h
index a1368057..185a268e 100644
--- a/src/google/protobuf/compiler/java/java_primitive_field.h
+++ b/src/google/protobuf/compiler/java/java_primitive_field.h
@@ -82,11 +82,11 @@ class ImmutablePrimitiveFieldGenerator : public ImmutableFieldGenerator {
void GenerateEqualsCode(io::Printer* printer) const;
void GenerateHashCode(io::Printer* printer) const;
- string GetBoxedType() const;
+ std::string GetBoxedType() const;
protected:
const FieldDescriptor* descriptor_;
- std::map<string, string> variables_;
+ std::map<std::string, std::string> variables_;
const int messageBitIndex_;
const int builderBitIndex_;
Context* context_;
@@ -143,11 +143,11 @@ class RepeatedImmutablePrimitiveFieldGenerator
void GenerateEqualsCode(io::Printer* printer) const;
void GenerateHashCode(io::Printer* printer) const;
- string GetBoxedType() const;
+ std::string GetBoxedType() const;
private:
const FieldDescriptor* descriptor_;
- std::map<string, string> variables_;
+ std::map<std::string, std::string> variables_;
const int messageBitIndex_;
const int builderBitIndex_;
Context* context_;
diff --git a/src/google/protobuf/compiler/java/java_primitive_field_lite.h b/src/google/protobuf/compiler/java/java_primitive_field_lite.h
index c12e458c..6c05521f 100644
--- a/src/google/protobuf/compiler/java/java_primitive_field_lite.h
+++ b/src/google/protobuf/compiler/java/java_primitive_field_lite.h
@@ -82,11 +82,11 @@ class ImmutablePrimitiveFieldLiteGenerator
void GenerateHashCode(io::Printer* printer) const;
- string GetBoxedType() const;
+ std::string GetBoxedType() const;
protected:
const FieldDescriptor* descriptor_;
- std::map<string, string> variables_;
+ std::map<std::string, std::string> variables_;
const int messageBitIndex_;
Context* context_;
ClassNameResolver* name_resolver_;
@@ -143,11 +143,11 @@ class RepeatedImmutablePrimitiveFieldLiteGenerator
void GenerateHashCode(io::Printer* printer) const;
- string GetBoxedType() const;
+ std::string GetBoxedType() const;
private:
const FieldDescriptor* descriptor_;
- std::map<string, string> variables_;
+ std::map<std::string, std::string> variables_;
const int messageBitIndex_;
Context* context_;
ClassNameResolver* name_resolver_;
diff --git a/src/google/protobuf/compiler/java/java_service.h b/src/google/protobuf/compiler/java/java_service.h
index f34cd798..24b0ccaa 100644
--- a/src/google/protobuf/compiler/java/java_service.h
+++ b/src/google/protobuf/compiler/java/java_service.h
@@ -125,7 +125,7 @@ class ImmutableServiceGenerator : public ServiceGenerator {
const MethodDescriptor* method);
// Return the output type of the method.
- string GetOutput(const MethodDescriptor* method);
+ std::string GetOutput(const MethodDescriptor* method);
Context* context_;
ClassNameResolver* name_resolver_;
diff --git a/src/google/protobuf/compiler/java/java_shared_code_generator.h b/src/google/protobuf/compiler/java/java_shared_code_generator.h
index 1eb6feaf..2f09c3a9 100644
--- a/src/google/protobuf/compiler/java/java_shared_code_generator.h
+++ b/src/google/protobuf/compiler/java/java_shared_code_generator.h
@@ -70,8 +70,8 @@ class SharedCodeGenerator {
~SharedCodeGenerator();
void Generate(GeneratorContext* generator_context,
- std::vector<string>* file_list,
- std::vector<string>* annotation_file_list);
+ std::vector<std::string>* file_list,
+ std::vector<std::string>* annotation_file_list);
void GenerateDescriptors(io::Printer* printer);
diff --git a/src/google/protobuf/compiler/java/java_string_field.h b/src/google/protobuf/compiler/java/java_string_field.h
index 7f9fa0ed..38fb8365 100644
--- a/src/google/protobuf/compiler/java/java_string_field.h
+++ b/src/google/protobuf/compiler/java/java_string_field.h
@@ -82,11 +82,11 @@ class ImmutableStringFieldGenerator : public ImmutableFieldGenerator {
void GenerateEqualsCode(io::Printer* printer) const;
void GenerateHashCode(io::Printer* printer) const;
- string GetBoxedType() const;
+ std::string GetBoxedType() const;
protected:
const FieldDescriptor* descriptor_;
- std::map<string, string> variables_;
+ std::map<std::string, std::string> variables_;
const int messageBitIndex_;
const int builderBitIndex_;
Context* context_;
@@ -141,11 +141,11 @@ class RepeatedImmutableStringFieldGenerator : public ImmutableFieldGenerator {
void GenerateEqualsCode(io::Printer* printer) const;
void GenerateHashCode(io::Printer* printer) const;
- string GetBoxedType() const;
+ std::string GetBoxedType() const;
private:
const FieldDescriptor* descriptor_;
- std::map<string, string> variables_;
+ std::map<std::string, std::string> variables_;
const int messageBitIndex_;
const int builderBitIndex_;
Context* context_;
diff --git a/src/google/protobuf/compiler/java/java_string_field_lite.h b/src/google/protobuf/compiler/java/java_string_field_lite.h
index 684d3b00..89d5c1ae 100644
--- a/src/google/protobuf/compiler/java/java_string_field_lite.h
+++ b/src/google/protobuf/compiler/java/java_string_field_lite.h
@@ -81,11 +81,11 @@ class ImmutableStringFieldLiteGenerator : public ImmutableFieldLiteGenerator {
void GenerateHashCode(io::Printer* printer) const;
- string GetBoxedType() const;
+ std::string GetBoxedType() const;
protected:
const FieldDescriptor* descriptor_;
- std::map<string, string> variables_;
+ std::map<std::string, std::string> variables_;
const int messageBitIndex_;
Context* context_;
ClassNameResolver* name_resolver_;
@@ -137,11 +137,11 @@ class RepeatedImmutableStringFieldLiteGenerator
void GenerateHashCode(io::Printer* printer) const;
- string GetBoxedType() const;
+ std::string GetBoxedType() const;
private:
const FieldDescriptor* descriptor_;
- std::map<string, string> variables_;
+ std::map<std::string, std::string> variables_;
const int messageBitIndex_;
Context* context_;
ClassNameResolver* name_resolver_;
diff --git a/src/google/protobuf/compiler/js/js_generator.h b/src/google/protobuf/compiler/js/js_generator.h
index 21e03bc1..4567b07a 100644
--- a/src/google/protobuf/compiler/js/js_generator.h
+++ b/src/google/protobuf/compiler/js/js_generator.h
@@ -40,6 +40,8 @@
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/compiler/code_generator.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
@@ -56,9 +58,9 @@ namespace js {
struct GeneratorOptions {
// Output path.
- string output_dir;
+ std::string output_dir;
// Namespace prefix.
- string namespace_prefix;
+ std::string namespace_prefix;
// Enable binary-format support?
bool binary;
// What style of imports should be used.
@@ -84,11 +86,11 @@ struct GeneratorOptions {
annotate_code(false) {}
bool ParseFromOptions(
- const std::vector< std::pair< string, string > >& options,
- string* error);
+ const std::vector< std::pair< std::string, std::string > >& options,
+ std::string* error);
// Returns the file name extension to use for generated code.
- string GetFileNameExtension() const {
+ std::string GetFileNameExtension() const {
return import_style == kImportClosure ? extension : "_pb.js";
}
@@ -113,11 +115,11 @@ struct GeneratorOptions {
bool testonly;
// Create a library with name <name>_lib.js rather than a separate .js file
// per type?
- string library;
+ std::string library;
// Error if there are two types that would generate the same output file?
bool error_on_name_conflict;
// The extension to use for output file names.
- string extension;
+ std::string extension;
// Create a separate output file for each input file?
bool one_output_file_per_input_file;
// If true, we should build .meta files that contain annotations for
@@ -129,15 +131,15 @@ struct GeneratorOptions {
// header. If you create your own protocol compiler binary and you want it to
// support JavaScript output, you can do so by registering an instance of this
// CodeGenerator with the CommandLineInterface in your main() function.
-class LIBPROTOC_EXPORT Generator : public CodeGenerator {
+class PROTOC_EXPORT Generator : public CodeGenerator {
public:
Generator() {}
virtual ~Generator() {}
virtual bool Generate(const FileDescriptor* file,
- const string& parameter,
+ const std::string& parameter,
GeneratorContext* context,
- string* error) const {
+ std::string* error) const {
*error = "Unimplemented Generate() method. Call GenerateAll() instead.";
return false;
}
@@ -145,9 +147,9 @@ class LIBPROTOC_EXPORT Generator : public CodeGenerator {
virtual bool HasGenerateAll() const { return true; }
virtual bool GenerateAll(const std::vector<const FileDescriptor*>& files,
- const string& parameter,
+ const std::string& parameter,
GeneratorContext* context,
- string* error) const;
+ std::string* error) const;
private:
void GenerateHeader(const GeneratorOptions& options,
@@ -157,28 +159,28 @@ class LIBPROTOC_EXPORT Generator : public CodeGenerator {
void FindProvides(const GeneratorOptions& options,
io::Printer* printer,
const std::vector<const FileDescriptor*>& file,
- std::set<string>* provided) const;
+ std::set<std::string>* provided) const;
void FindProvidesForFile(const GeneratorOptions& options,
io::Printer* printer,
const FileDescriptor* file,
- std::set<string>* provided) const;
+ std::set<std::string>* provided) const;
void FindProvidesForMessage(const GeneratorOptions& options,
io::Printer* printer,
const Descriptor* desc,
- std::set<string>* provided) const;
+ std::set<std::string>* provided) const;
void FindProvidesForEnum(const GeneratorOptions& options,
io::Printer* printer,
const EnumDescriptor* enumdesc,
- std::set<string>* provided) const;
+ std::set<std::string>* provided) const;
// For extension fields at file scope.
void FindProvidesForFields(const GeneratorOptions& options,
io::Printer* printer,
const std::vector<const FieldDescriptor*>& fields,
- std::set<string>* provided) const;
+ std::set<std::string>* provided) const;
// Print the goog.provides() found by the methods above.
void GenerateProvides(const GeneratorOptions& options,
io::Printer* printer,
- std::set<string>* provided) const;
+ std::set<std::string>* provided) const;
// Generate goog.setTestOnly() if indicated.
void GenerateTestOnly(const GeneratorOptions& options,
@@ -188,34 +190,34 @@ class LIBPROTOC_EXPORT Generator : public CodeGenerator {
void GenerateRequiresForLibrary(
const GeneratorOptions& options, io::Printer* printer,
const std::vector<const FileDescriptor*>& files,
- std::set<string>* provided) const;
+ std::set<std::string>* provided) const;
void GenerateRequiresForMessage(const GeneratorOptions& options,
io::Printer* printer,
const Descriptor* desc,
- std::set<string>* provided) const;
+ std::set<std::string>* provided) const;
// For extension fields at file scope.
void GenerateRequiresForExtensions(
const GeneratorOptions& options, io::Printer* printer,
const std::vector<const FieldDescriptor*>& fields,
- std::set<string>* provided) const;
+ std::set<std::string>* provided) const;
void GenerateRequiresImpl(const GeneratorOptions& options,
- io::Printer* printer, std::set<string>* required,
- std::set<string>* forwards,
- std::set<string>* provided, bool require_jspb,
+ io::Printer* printer, std::set<std::string>* required,
+ std::set<std::string>* forwards,
+ std::set<std::string>* provided, bool require_jspb,
bool require_extension, bool require_map) const;
void FindRequiresForMessage(const GeneratorOptions& options,
const Descriptor* desc,
- std::set<string>* required,
- std::set<string>* forwards,
+ std::set<std::string>* required,
+ std::set<std::string>* forwards,
bool* have_message) const;
void FindRequiresForField(const GeneratorOptions& options,
const FieldDescriptor* field,
- std::set<string>* required,
- std::set<string>* forwards) const;
+ std::set<std::string>* required,
+ std::set<std::string>* forwards) const;
void FindRequiresForExtension(const GeneratorOptions& options,
const FieldDescriptor* field,
- std::set<string>* required,
- std::set<string>* forwards) const;
+ std::set<std::string>* required,
+ std::set<std::string>* forwards) const;
void GenerateFile(const GeneratorOptions& options,
io::Printer* printer,
@@ -331,4 +333,6 @@ class LIBPROTOC_EXPORT Generator : public CodeGenerator {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_COMPILER_JS_GENERATOR_H__
diff --git a/src/google/protobuf/compiler/mock_code_generator.h b/src/google/protobuf/compiler/mock_code_generator.h
index 3b59bc4b..e6370b34 100644
--- a/src/google/protobuf/compiler/mock_code_generator.h
+++ b/src/google/protobuf/compiler/mock_code_generator.h
@@ -74,7 +74,7 @@ namespace compiler {
// that can later be verified with CheckGeneratedAnnotations.
class MockCodeGenerator : public CodeGenerator {
public:
- MockCodeGenerator(const string& name);
+ MockCodeGenerator(const std::string& name);
virtual ~MockCodeGenerator();
// Expect (via gTest) that a MockCodeGenerator with the given name was called
@@ -84,45 +84,45 @@ class MockCodeGenerator : public CodeGenerator {
// should have inserted lines into this file.
// |parsed_file_list| is a comma-separated list of names of the files
// that are being compiled together in this run.
- static void ExpectGenerated(const string& name,
- const string& parameter,
- const string& insertions,
- const string& file,
- const string& first_message_name,
- const string& parsed_file_list,
- const string& output_directory);
+ static void ExpectGenerated(const std::string& name,
+ const std::string& parameter,
+ const std::string& insertions,
+ const std::string& file,
+ const std::string& first_message_name,
+ const std::string& parsed_file_list,
+ const std::string& output_directory);
// Checks that the correct text ranges were annotated by the
// MockCodeGenerator_Annotate directive.
- static void CheckGeneratedAnnotations(const string& name,
- const string& file,
- const string& output_directory);
+ static void CheckGeneratedAnnotations(const std::string& name,
+ const std::string& file,
+ const std::string& output_directory);
// Get the name of the file which would be written by the given generator.
- static string GetOutputFileName(const string& generator_name,
+ static std::string GetOutputFileName(const std::string& generator_name,
const FileDescriptor* file);
- static string GetOutputFileName(const string& generator_name,
- const string& file);
+ static std::string GetOutputFileName(const std::string& generator_name,
+ const std::string& file);
// implements CodeGenerator ----------------------------------------
virtual bool Generate(const FileDescriptor* file,
- const string& parameter,
+ const std::string& parameter,
GeneratorContext* context,
- string* error) const;
+ std::string* error) const;
private:
- string name_;
+ std::string name_;
- static string GetOutputFileContent(const string& generator_name,
- const string& parameter,
+ static std::string GetOutputFileContent(const std::string& generator_name,
+ const std::string& parameter,
const FileDescriptor* file,
GeneratorContext *context);
- static string GetOutputFileContent(const string& generator_name,
- const string& parameter,
- const string& file,
- const string& parsed_file_list,
- const string& first_message_name);
+ static std::string GetOutputFileContent(const std::string& generator_name,
+ const std::string& parameter,
+ const std::string& file,
+ const std::string& parsed_file_list,
+ const std::string& first_message_name);
};
} // namespace compiler
diff --git a/src/google/protobuf/compiler/objectivec/objectivec_generator.h b/src/google/protobuf/compiler/objectivec/objectivec_generator.h
index 3e43f732..ac20cfdb 100644
--- a/src/google/protobuf/compiler/objectivec/objectivec_generator.h
+++ b/src/google/protobuf/compiler/objectivec/objectivec_generator.h
@@ -36,6 +36,8 @@
#include <string>
#include <google/protobuf/compiler/code_generator.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace compiler {
@@ -45,7 +47,7 @@ namespace objectivec {
// header. If you create your own protocol compiler binary and you want it to
// support ObjectiveC output, you can do so by registering an instance of this
// CodeGenerator with the CommandLineInterface in your main() function.
-class LIBPROTOC_EXPORT ObjectiveCGenerator : public CodeGenerator {
+class PROTOC_EXPORT ObjectiveCGenerator : public CodeGenerator {
public:
ObjectiveCGenerator();
~ObjectiveCGenerator();
@@ -69,4 +71,7 @@ class LIBPROTOC_EXPORT ObjectiveCGenerator : public CodeGenerator {
} // namespace compiler
} // namespace protobuf
} // namespace google
+
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_GENERATOR_H__
diff --git a/src/google/protobuf/compiler/objectivec/objectivec_helpers.h b/src/google/protobuf/compiler/objectivec/objectivec_helpers.h
index 8999aa59..e7f21f28 100644
--- a/src/google/protobuf/compiler/objectivec/objectivec_helpers.h
+++ b/src/google/protobuf/compiler/objectivec/objectivec_helpers.h
@@ -39,6 +39,8 @@
#include <google/protobuf/descriptor.h>
#include <google/protobuf/descriptor.pb.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace compiler {
@@ -53,66 +55,67 @@ struct Options {
};
// Escape C++ trigraphs by escaping question marks to "\?".
-string LIBPROTOC_EXPORT EscapeTrigraphs(const string& to_escape);
+string PROTOC_EXPORT EscapeTrigraphs(const string& to_escape);
// Strips ".proto" or ".protodevel" from the end of a filename.
-string LIBPROTOC_EXPORT StripProto(const string& filename);
+string PROTOC_EXPORT StripProto(const string& filename);
// Remove white space from either end of a StringPiece.
-void LIBPROTOC_EXPORT StringPieceTrimWhitespace(StringPiece* input);
+void PROTOC_EXPORT StringPieceTrimWhitespace(StringPiece* input);
// Returns true if the name requires a ns_returns_not_retained attribute applied
// to it.
-bool LIBPROTOC_EXPORT IsRetainedName(const string& name);
+bool PROTOC_EXPORT IsRetainedName(const string& name);
// Returns true if the name starts with "init" and will need to have special
// handling under ARC.
-bool LIBPROTOC_EXPORT IsInitName(const string& name);
+bool PROTOC_EXPORT IsInitName(const string& name);
// Gets the objc_class_prefix.
-string LIBPROTOC_EXPORT FileClassPrefix(const FileDescriptor* file);
+string PROTOC_EXPORT FileClassPrefix(const FileDescriptor* file);
// Gets the path of the file we're going to generate (sans the .pb.h
// extension). The path will be dependent on the objectivec package
// declared in the proto package.
-string LIBPROTOC_EXPORT FilePath(const FileDescriptor* file);
+string PROTOC_EXPORT FilePath(const FileDescriptor* file);
// Just like FilePath(), but without the directory part.
-string LIBPROTOC_EXPORT FilePathBasename(const FileDescriptor* file);
+string PROTOC_EXPORT FilePathBasename(const FileDescriptor* file);
// Gets the name of the root class we'll generate in the file. This class
// is not meant for external consumption, but instead contains helpers that
// the rest of the classes need
-string LIBPROTOC_EXPORT FileClassName(const FileDescriptor* file);
+string PROTOC_EXPORT FileClassName(const FileDescriptor* file);
// These return the fully-qualified class name corresponding to the given
// descriptor.
-string LIBPROTOC_EXPORT ClassName(const Descriptor* descriptor);
-string LIBPROTOC_EXPORT ClassName(const Descriptor* descriptor, string* out_suffix_added);
-string LIBPROTOC_EXPORT EnumName(const EnumDescriptor* descriptor);
+string PROTOC_EXPORT ClassName(const Descriptor* descriptor);
+string PROTOC_EXPORT ClassName(const Descriptor* descriptor,
+ string* out_suffix_added);
+string PROTOC_EXPORT EnumName(const EnumDescriptor* descriptor);
// Returns the fully-qualified name of the enum value corresponding to the
// the descriptor.
-string LIBPROTOC_EXPORT EnumValueName(const EnumValueDescriptor* descriptor);
+string PROTOC_EXPORT EnumValueName(const EnumValueDescriptor* descriptor);
// Returns the name of the enum value corresponding to the descriptor.
-string LIBPROTOC_EXPORT EnumValueShortName(const EnumValueDescriptor* descriptor);
+string PROTOC_EXPORT EnumValueShortName(const EnumValueDescriptor* descriptor);
// Reverse what an enum does.
-string LIBPROTOC_EXPORT UnCamelCaseEnumShortName(const string& name);
+string PROTOC_EXPORT UnCamelCaseEnumShortName(const string& name);
// Returns the name to use for the extension (used as the method off the file's
// Root class).
-string LIBPROTOC_EXPORT ExtensionMethodName(const FieldDescriptor* descriptor);
+string PROTOC_EXPORT ExtensionMethodName(const FieldDescriptor* descriptor);
// Returns the transformed field name.
-string LIBPROTOC_EXPORT FieldName(const FieldDescriptor* field);
-string LIBPROTOC_EXPORT FieldNameCapitalized(const FieldDescriptor* field);
+string PROTOC_EXPORT FieldName(const FieldDescriptor* field);
+string PROTOC_EXPORT FieldNameCapitalized(const FieldDescriptor* field);
// Returns the transformed oneof name.
-string LIBPROTOC_EXPORT OneofEnumName(const OneofDescriptor* descriptor);
-string LIBPROTOC_EXPORT OneofName(const OneofDescriptor* descriptor);
-string LIBPROTOC_EXPORT OneofNameCapitalized(const OneofDescriptor* descriptor);
+string PROTOC_EXPORT OneofEnumName(const OneofDescriptor* descriptor);
+string PROTOC_EXPORT OneofName(const OneofDescriptor* descriptor);
+string PROTOC_EXPORT OneofNameCapitalized(const OneofDescriptor* descriptor);
inline bool HasFieldPresence(const FileDescriptor* file) {
return file->syntax() != FileDescriptor::SYNTAX_PROTO3;
@@ -127,7 +130,8 @@ inline bool IsMapEntryMessage(const Descriptor* descriptor) {
}
// Reverse of the above.
-string LIBPROTOC_EXPORT UnCamelCaseFieldName(const string& name, const FieldDescriptor* field);
+string PROTOC_EXPORT UnCamelCaseFieldName(const string& name,
+ const FieldDescriptor* field);
enum ObjectiveCType {
OBJECTIVECTYPE_INT32,
@@ -175,48 +179,52 @@ string GetOptionalDeprecatedAttribute(
}
}
-string LIBPROTOC_EXPORT GetCapitalizedType(const FieldDescriptor* field);
+string PROTOC_EXPORT GetCapitalizedType(const FieldDescriptor* field);
-ObjectiveCType LIBPROTOC_EXPORT GetObjectiveCType(FieldDescriptor::Type field_type);
+ObjectiveCType PROTOC_EXPORT
+GetObjectiveCType(FieldDescriptor::Type field_type);
inline ObjectiveCType GetObjectiveCType(const FieldDescriptor* field) {
return GetObjectiveCType(field->type());
}
-bool LIBPROTOC_EXPORT IsPrimitiveType(const FieldDescriptor* field);
-bool LIBPROTOC_EXPORT IsReferenceType(const FieldDescriptor* field);
+bool PROTOC_EXPORT IsPrimitiveType(const FieldDescriptor* field);
+bool PROTOC_EXPORT IsReferenceType(const FieldDescriptor* field);
-string LIBPROTOC_EXPORT GPBGenericValueFieldName(const FieldDescriptor* field);
-string LIBPROTOC_EXPORT DefaultValue(const FieldDescriptor* field);
-bool LIBPROTOC_EXPORT HasNonZeroDefaultValue(const FieldDescriptor* field);
+string PROTOC_EXPORT GPBGenericValueFieldName(const FieldDescriptor* field);
+string PROTOC_EXPORT DefaultValue(const FieldDescriptor* field);
+bool PROTOC_EXPORT HasNonZeroDefaultValue(const FieldDescriptor* field);
-string LIBPROTOC_EXPORT BuildFlagsString(const FlagType type, const std::vector<string>& strings);
+string PROTOC_EXPORT BuildFlagsString(const FlagType type,
+ const std::vector<string>& strings);
// Builds HeaderDoc/appledoc style comments out of the comments in the .proto
// file.
-string LIBPROTOC_EXPORT BuildCommentsString(const SourceLocation& location,
- bool prefer_single_line);
+string PROTOC_EXPORT BuildCommentsString(const SourceLocation& location,
+ bool prefer_single_line);
// The name the commonly used by the library when built as a framework.
// This lines up to the name used in the CocoaPod.
-extern LIBPROTOC_EXPORT const char* const ProtobufLibraryFrameworkName;
+extern PROTOC_EXPORT const char* const ProtobufLibraryFrameworkName;
// Returns the CPP symbol name to use as the gate for framework style imports
// for the given framework name to use.
-string LIBPROTOC_EXPORT ProtobufFrameworkImportSymbol(const string& framework_name);
+string PROTOC_EXPORT
+ProtobufFrameworkImportSymbol(const string& framework_name);
// Checks if the file is one of the proto's bundled with the library.
-bool LIBPROTOC_EXPORT IsProtobufLibraryBundledProtoFile(const FileDescriptor* file);
+bool PROTOC_EXPORT
+IsProtobufLibraryBundledProtoFile(const FileDescriptor* file);
// Checks the prefix for the given files and outputs any warnings as needed. If
// there are flat out errors, then out_error is filled in with the first error
// and the result is false.
-bool LIBPROTOC_EXPORT ValidateObjCClassPrefixes(const std::vector<const FileDescriptor*>& files,
- const Options& generation_options,
- string* out_error);
+bool PROTOC_EXPORT
+ValidateObjCClassPrefixes(const std::vector<const FileDescriptor*>& files,
+ const Options& generation_options, string* out_error);
// Generate decode data needed for ObjC's GPBDecodeTextFormatName() to transform
// the input into the expected output.
-class LIBPROTOC_EXPORT TextFormatDecodeData {
+class PROTOC_EXPORT TextFormatDecodeData {
public:
TextFormatDecodeData();
~TextFormatDecodeData();
@@ -237,20 +245,20 @@ class LIBPROTOC_EXPORT TextFormatDecodeData {
};
// Helper for parsing simple files.
-class LIBPROTOC_EXPORT LineConsumer {
+class PROTOC_EXPORT LineConsumer {
public:
LineConsumer();
virtual ~LineConsumer();
virtual bool ConsumeLine(const StringPiece& line, string* out_error) = 0;
};
-bool LIBPROTOC_EXPORT ParseSimpleFile(
- const string& path, LineConsumer* line_consumer, string* out_error);
-
+bool PROTOC_EXPORT ParseSimpleFile(const string& path,
+ LineConsumer* line_consumer,
+ string* out_error);
// Helper class for parsing framework import mappings and generating
// import statements.
-class LIBPROTOC_EXPORT ImportWriter {
+class PROTOC_EXPORT ImportWriter {
public:
ImportWriter(const string& generate_for_named_framework,
const string& named_framework_to_proto_path_mappings_path,
@@ -290,4 +298,7 @@ class LIBPROTOC_EXPORT ImportWriter {
} // namespace compiler
} // namespace protobuf
} // namespace google
+
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_HELPERS_H__
diff --git a/src/google/protobuf/compiler/parser.h b/src/google/protobuf/compiler/parser.h
index b55750ca..9ae6c6da 100644
--- a/src/google/protobuf/compiler/parser.h
+++ b/src/google/protobuf/compiler/parser.h
@@ -45,6 +45,8 @@
#include <google/protobuf/descriptor.h>
#include <google/protobuf/repeated_field.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
@@ -63,7 +65,7 @@ class SourceLocationTable;
// to a FileDescriptorProto. It does not resolve import directives or perform
// many other kinds of validation needed to construct a complete
// FileDescriptor.
-class LIBPROTOBUF_EXPORT Parser {
+class PROTOBUF_EXPORT Parser {
public:
Parser();
~Parser();
@@ -93,7 +95,7 @@ class LIBPROTOBUF_EXPORT Parser {
// Returns the identifier used in the "syntax = " declaration, if one was
// seen during the last call to Parse(), or the empty string otherwise.
- const string& GetSyntaxIdentifier() { return syntax_identifier_; }
+ const std::string& GetSyntaxIdentifier() { return syntax_identifier_; }
// If set true, input files will be required to begin with a syntax
// identifier. Otherwise, files may omit this. If a syntax identifier
@@ -163,7 +165,7 @@ class LIBPROTOBUF_EXPORT Parser {
// where "text" is the expected token text.
bool Consume(const char* text);
// Consume a token of type IDENTIFIER and store its text in "output".
- bool ConsumeIdentifier(string* output, const char* error);
+ bool ConsumeIdentifier(std::string* output, const char* error);
// Consume an integer and store its value in "output".
bool ConsumeInteger(int* output, const char* error);
// Consume a signed integer and store its value in "output".
@@ -175,7 +177,7 @@ class LIBPROTOBUF_EXPORT Parser {
// tokens of either INTEGER or FLOAT type.
bool ConsumeNumber(double* output, const char* error);
// Consume a string literal and store its (unescaped) value in "output".
- bool ConsumeString(string* output, const char* error);
+ bool ConsumeString(std::string* output, const char* error);
// Consume a token representing the end of the statement. Comments between
// this token and the next will be harvested for documentation. The given
@@ -198,18 +200,18 @@ class LIBPROTOBUF_EXPORT Parser {
// Error logging helpers
// Invokes error_collector_->AddError(), if error_collector_ is not NULL.
- void AddError(int line, int column, const string& error);
+ void AddError(int line, int column, const std::string& error);
// Invokes error_collector_->AddError() with the line and column number
// of the current token.
- void AddError(const string& error);
+ void AddError(const std::string& error);
// Records a location in the SourceCodeInfo.location table (see
// descriptor.proto). We use RAII to ensure that the start and end locations
// are recorded -- the constructor records the start location and the
// destructor records the end location. Since the parser is
// recursive-descent, this works out beautifully.
- class LIBPROTOBUF_EXPORT LocationRecorder {
+ class PROTOBUF_EXPORT LocationRecorder {
public:
// Construct the file's "root" location.
LocationRecorder(Parser* parser);
@@ -264,8 +266,8 @@ class LIBPROTOBUF_EXPORT Parser {
//
// TODO(kenton): See comment on TryConsumeEndOfDeclaration(), above, for
// why this is const.
- void AttachComments(string* leading, string* trailing,
- std::vector<string>* detached_comments) const;
+ void AttachComments(std::string* leading, std::string* trailing,
+ std::vector<std::string>* detached_comments) const;
private:
// Indexes of parent and current location in the parent
@@ -313,7 +315,7 @@ class LIBPROTOBUF_EXPORT Parser {
bool ParsePackage(FileDescriptorProto* file,
const LocationRecorder& root_location,
const FileDescriptorProto* containing_file);
- bool ParseImport(RepeatedPtrField<string>* dependency,
+ bool ParseImport(RepeatedPtrField<std::string>* dependency,
RepeatedField<int32>* public_dependency,
RepeatedField<int32>* weak_dependency,
const LocationRecorder& root_location,
@@ -437,10 +439,10 @@ class LIBPROTOBUF_EXPORT Parser {
// Parse a type name and fill in "type" (if it is a primitive) or
// "type_name" (if it is not) with the type parsed.
bool ParseType(FieldDescriptorProto::Type* type,
- string* type_name);
+ std::string* type_name);
// Parse a user-defined type and fill in "type_name" with the name.
// If a primitive type is named, it is treated as an error.
- bool ParseUserDefinedType(string* type_name);
+ bool ParseUserDefinedType(std::string* type_name);
// Parses field options, i.e. the stuff in square brackets at the end
// of a field definition. Also parses default value.
@@ -489,7 +491,7 @@ class LIBPROTOBUF_EXPORT Parser {
// REQUIRES: LookingAt("{")
// When finished successfully, we are looking at the first token past
// the ending brace.
- bool ParseUninterpretedBlock(string* value);
+ bool ParseUninterpretedBlock(std::string* value);
struct MapField {
// Whether the field is a map field.
@@ -498,8 +500,8 @@ class LIBPROTOBUF_EXPORT Parser {
FieldDescriptorProto::Type key_type;
FieldDescriptorProto::Type value_type;
// Or the type names string if the types are customized types.
- string key_type_name;
- string value_type_name;
+ std::string key_type_name;
+ std::string value_type_name;
MapField() : is_map_field(false) {}
};
@@ -524,18 +526,18 @@ class LIBPROTOBUF_EXPORT Parser {
bool had_errors_;
bool require_syntax_identifier_;
bool stop_after_syntax_identifier_;
- string syntax_identifier_;
+ std::string syntax_identifier_;
// Leading doc comments for the next declaration. These are not complete
// yet; use ConsumeEndOfDeclaration() to get the complete comments.
- string upcoming_doc_comments_;
+ std::string upcoming_doc_comments_;
// Detached comments are not connected to any syntax entities. Elements in
// this vector are paragraphs of comments separated by empty lines. The
// detached comments will be put into the leading_detached_comments field for
// the next element (See SourceCodeInfo.Location in descriptor.proto), when
// ConsumeEndOfDeclaration() is called.
- std::vector<string> upcoming_detached_comments_;
+ std::vector<std::string> upcoming_detached_comments_;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Parser);
};
@@ -548,7 +550,7 @@ class LIBPROTOBUF_EXPORT Parser {
// far more complete information about source locations. However, as of this
// writing you still need to use SourceLocationTable when integrating with
// DescriptorPool.
-class LIBPROTOBUF_EXPORT SourceLocationTable {
+class PROTOBUF_EXPORT SourceLocationTable {
public:
SourceLocationTable();
~SourceLocationTable();
@@ -581,4 +583,6 @@ class LIBPROTOBUF_EXPORT SourceLocationTable {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_COMPILER_PARSER_H__
diff --git a/src/google/protobuf/compiler/php/php_generator.h b/src/google/protobuf/compiler/php/php_generator.h
index b851d9b4..283767ec 100644
--- a/src/google/protobuf/compiler/php/php_generator.h
+++ b/src/google/protobuf/compiler/php/php_generator.h
@@ -36,12 +36,14 @@
#include <string>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace compiler {
namespace php {
-class LIBPROTOC_EXPORT Generator
+class PROTOC_EXPORT Generator
: public google::protobuf::compiler::CodeGenerator {
virtual bool Generate(
const FileDescriptor* file,
@@ -53,11 +55,11 @@ class LIBPROTOC_EXPORT Generator
// To skip reserved keywords in php, some generated classname are prefixed.
// Other code generators may need following API to figure out the actual
// classname.
-LIBPROTOC_EXPORT std::string GeneratedClassName(
+PROTOC_EXPORT std::string GeneratedClassName(
const google::protobuf::Descriptor* desc);
-LIBPROTOC_EXPORT std::string GeneratedClassName(
+PROTOC_EXPORT std::string GeneratedClassName(
const google::protobuf::EnumDescriptor* desc);
-LIBPROTOC_EXPORT std::string GeneratedClassName(
+PROTOC_EXPORT std::string GeneratedClassName(
const google::protobuf::ServiceDescriptor* desc);
} // namespace php
@@ -65,4 +67,6 @@ LIBPROTOC_EXPORT std::string GeneratedClassName(
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_COMPILER_PHP_GENERATOR_H__
diff --git a/src/google/protobuf/compiler/plugin.h b/src/google/protobuf/compiler/plugin.h
index c6649173..48db3c1c 100644
--- a/src/google/protobuf/compiler/plugin.h
+++ b/src/google/protobuf/compiler/plugin.h
@@ -64,7 +64,8 @@
#include <string>
-#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace compiler {
@@ -74,17 +75,20 @@ class CodeGeneratorRequest;
class CodeGeneratorResponse;
// Implements main() for a protoc plugin exposing the given code generator.
-LIBPROTOC_EXPORT int PluginMain(int argc, char* argv[], const CodeGenerator* generator);
+PROTOC_EXPORT int PluginMain(int argc, char* argv[],
+ const CodeGenerator* generator);
// Generates code using the given code generator. Returns true if the code
// generation is successful. If the code geneartion fails, error_msg may be
// populated to describe the failure cause.
bool GenerateCode(const CodeGeneratorRequest& request,
const CodeGenerator& generator, CodeGeneratorResponse* response,
- string* error_msg);
+ std::string* error_msg);
} // namespace compiler
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_COMPILER_PLUGIN_H__
diff --git a/src/google/protobuf/compiler/plugin.pb.cc b/src/google/protobuf/compiler/plugin.pb.cc
index 7569f27f..234be0dd 100644
--- a/src/google/protobuf/compiler/plugin.pb.cc
+++ b/src/google/protobuf/compiler/plugin.pb.cc
@@ -13,10 +13,6 @@
#include <google/protobuf/generated_message_reflection.h>
#include <google/protobuf/reflection_ops.h>
#include <google/protobuf/wire_format.h>
-// This is a temporary google only hack
-#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
-#include "third_party/protobuf/version.h"
-#endif
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>
@@ -56,7 +52,7 @@ static void InitDefaultsVersion_google_2fprotobuf_2fcompiler_2fplugin_2eproto()
::google::protobuf::compiler::Version::InitAsDefaultInstance();
}
-LIBPROTOC_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_Version_google_2fprotobuf_2fcompiler_2fplugin_2eproto =
+PROTOC_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_Version_google_2fprotobuf_2fcompiler_2fplugin_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsVersion_google_2fprotobuf_2fcompiler_2fplugin_2eproto}, {}};
static void InitDefaultsCodeGeneratorRequest_google_2fprotobuf_2fcompiler_2fplugin_2eproto() {
@@ -70,7 +66,7 @@ static void InitDefaultsCodeGeneratorRequest_google_2fprotobuf_2fcompiler_2fplug
::google::protobuf::compiler::CodeGeneratorRequest::InitAsDefaultInstance();
}
-LIBPROTOC_EXPORT ::google::protobuf::internal::SCCInfo<2> scc_info_CodeGeneratorRequest_google_2fprotobuf_2fcompiler_2fplugin_2eproto =
+PROTOC_EXPORT ::google::protobuf::internal::SCCInfo<2> scc_info_CodeGeneratorRequest_google_2fprotobuf_2fcompiler_2fplugin_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 2, InitDefaultsCodeGeneratorRequest_google_2fprotobuf_2fcompiler_2fplugin_2eproto}, {
&scc_info_FileDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base,
&scc_info_Version_google_2fprotobuf_2fcompiler_2fplugin_2eproto.base,}};
@@ -86,7 +82,7 @@ static void InitDefaultsCodeGeneratorResponse_File_google_2fprotobuf_2fcompiler_
::google::protobuf::compiler::CodeGeneratorResponse_File::InitAsDefaultInstance();
}
-LIBPROTOC_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_CodeGeneratorResponse_File_google_2fprotobuf_2fcompiler_2fplugin_2eproto =
+PROTOC_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_CodeGeneratorResponse_File_google_2fprotobuf_2fcompiler_2fplugin_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsCodeGeneratorResponse_File_google_2fprotobuf_2fcompiler_2fplugin_2eproto}, {}};
static void InitDefaultsCodeGeneratorResponse_google_2fprotobuf_2fcompiler_2fplugin_2eproto() {
@@ -100,7 +96,7 @@ static void InitDefaultsCodeGeneratorResponse_google_2fprotobuf_2fcompiler_2fplu
::google::protobuf::compiler::CodeGeneratorResponse::InitAsDefaultInstance();
}
-LIBPROTOC_EXPORT ::google::protobuf::internal::SCCInfo<1> scc_info_CodeGeneratorResponse_google_2fprotobuf_2fcompiler_2fplugin_2eproto =
+PROTOC_EXPORT ::google::protobuf::internal::SCCInfo<1> scc_info_CodeGeneratorResponse_google_2fprotobuf_2fcompiler_2fplugin_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsCodeGeneratorResponse_google_2fprotobuf_2fcompiler_2fplugin_2eproto}, {
&scc_info_CodeGeneratorResponse_File_google_2fprotobuf_2fcompiler_2fplugin_2eproto.base,}};
@@ -115,55 +111,55 @@ void InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto() {
constexpr ::google::protobuf::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto = nullptr;
constexpr ::google::protobuf::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto = nullptr;
-const ::google::protobuf::uint32 TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto::offsets[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::compiler::Version, _has_bits_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::compiler::Version, _internal_metadata_),
+const ::google::protobuf::uint32 TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::compiler::Version, _has_bits_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::compiler::Version, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::compiler::Version, major_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::compiler::Version, minor_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::compiler::Version, patch_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::compiler::Version, suffix_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::compiler::Version, major_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::compiler::Version, minor_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::compiler::Version, patch_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::compiler::Version, suffix_),
1,
2,
3,
0,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::compiler::CodeGeneratorRequest, _has_bits_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::compiler::CodeGeneratorRequest, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::compiler::CodeGeneratorRequest, _has_bits_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::compiler::CodeGeneratorRequest, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::compiler::CodeGeneratorRequest, file_to_generate_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::compiler::CodeGeneratorRequest, parameter_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::compiler::CodeGeneratorRequest, proto_file_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::compiler::CodeGeneratorRequest, compiler_version_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::compiler::CodeGeneratorRequest, file_to_generate_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::compiler::CodeGeneratorRequest, parameter_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::compiler::CodeGeneratorRequest, proto_file_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::compiler::CodeGeneratorRequest, compiler_version_),
~0u,
0,
~0u,
1,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::compiler::CodeGeneratorResponse_File, _has_bits_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::compiler::CodeGeneratorResponse_File, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::compiler::CodeGeneratorResponse_File, _has_bits_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::compiler::CodeGeneratorResponse_File, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::compiler::CodeGeneratorResponse_File, name_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::compiler::CodeGeneratorResponse_File, insertion_point_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::compiler::CodeGeneratorResponse_File, content_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::compiler::CodeGeneratorResponse_File, name_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::compiler::CodeGeneratorResponse_File, insertion_point_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::compiler::CodeGeneratorResponse_File, content_),
0,
1,
2,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::compiler::CodeGeneratorResponse, _has_bits_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::compiler::CodeGeneratorResponse, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::compiler::CodeGeneratorResponse, _has_bits_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::compiler::CodeGeneratorResponse, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::compiler::CodeGeneratorResponse, error_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::compiler::CodeGeneratorResponse, file_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::compiler::CodeGeneratorResponse, error_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::compiler::CodeGeneratorResponse, file_),
0,
~0u,
};
-static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
+static const ::google::protobuf::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
{ 0, 9, sizeof(::google::protobuf::compiler::Version)},
{ 13, 22, sizeof(::google::protobuf::compiler::CodeGeneratorRequest)},
{ 26, 34, sizeof(::google::protobuf::compiler::CodeGeneratorResponse_File)},
@@ -323,15 +319,14 @@ const char* Version::_InternalParse(const char* begin, const char* end, void* ob
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// optional int32 major = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 8) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
::google::protobuf::int32 value = val;
msg->set_major(value);
break;
@@ -341,7 +336,7 @@ const char* Version::_InternalParse(const char* begin, const char* end, void* ob
if (static_cast<::google::protobuf::uint8>(tag) != 16) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
::google::protobuf::int32 value = val;
msg->set_minor(value);
break;
@@ -351,7 +346,7 @@ const char* Version::_InternalParse(const char* begin, const char* end, void* ob
if (static_cast<::google::protobuf::uint8>(tag) != 24) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
::google::protobuf::int32 value = val;
msg->set_patch(value);
break;
@@ -360,7 +355,7 @@ const char* Version::_InternalParse(const char* begin, const char* end, void* ob
case 4: {
if (static_cast<::google::protobuf::uint8>(tag) != 34) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.compiler.Version.suffix");
parser_till_end = ::google::protobuf::internal::StringParserUTF8Verify;
::std::string* str = msg->mutable_suffix();
@@ -368,14 +363,15 @@ const char* Version::_InternalParse(const char* begin, const char* end, void* ob
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
@@ -386,8 +382,6 @@ const char* Version::_InternalParse(const char* begin, const char* end, void* ob
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -399,7 +393,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool Version::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.compiler.Version)
for (;;) {
@@ -806,15 +800,14 @@ const char* CodeGeneratorRequest::_InternalParse(const char* begin, const char*
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// repeated string file_to_generate = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 10) goto handle_unusual;
do {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.compiler.CodeGeneratorRequest.file_to_generate");
parser_till_end = ::google::protobuf::internal::StringParserUTF8Verify;
::std::string* str = msg->add_file_to_generate();
@@ -822,17 +815,17 @@ const char* CodeGeneratorRequest::_InternalParse(const char* begin, const char*
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 255) == 10 && (ptr += 1));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 10 && (ptr += 1));
break;
}
// optional string parameter = 2;
case 2: {
if (static_cast<::google::protobuf::uint8>(tag) != 18) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.compiler.CodeGeneratorRequest.parameter");
parser_till_end = ::google::protobuf::internal::StringParserUTF8Verify;
::std::string* str = msg->mutable_parameter();
@@ -840,20 +833,22 @@ const char* CodeGeneratorRequest::_InternalParse(const char* begin, const char*
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// optional .google.protobuf.compiler.Version compiler_version = 3;
case 3: {
if (static_cast<::google::protobuf::uint8>(tag) != 26) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::compiler::Version::_InternalParse;
object = msg->mutable_compiler_version();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
break;
}
@@ -862,21 +857,24 @@ const char* CodeGeneratorRequest::_InternalParse(const char* begin, const char*
if (static_cast<::google::protobuf::uint8>(tag) != 122) goto handle_unusual;
do {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::FileDescriptorProto::_InternalParse;
object = msg->add_proto_file();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 255) == 122 && (ptr += 1));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 122 && (ptr += 1));
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
@@ -887,8 +885,6 @@ const char* CodeGeneratorRequest::_InternalParse(const char* begin, const char*
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -900,7 +896,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool CodeGeneratorRequest::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.compiler.CodeGeneratorRequest)
for (;;) {
@@ -1322,14 +1318,13 @@ const char* CodeGeneratorResponse_File::_InternalParse(const char* begin, const
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// optional string name = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 10) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.compiler.CodeGeneratorResponse.File.name");
parser_till_end = ::google::protobuf::internal::StringParserUTF8Verify;
::std::string* str = msg->mutable_name();
@@ -1337,15 +1332,15 @@ const char* CodeGeneratorResponse_File::_InternalParse(const char* begin, const
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// optional string insertion_point = 2;
case 2: {
if (static_cast<::google::protobuf::uint8>(tag) != 18) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point");
parser_till_end = ::google::protobuf::internal::StringParserUTF8Verify;
::std::string* str = msg->mutable_insertion_point();
@@ -1353,15 +1348,15 @@ const char* CodeGeneratorResponse_File::_InternalParse(const char* begin, const
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// optional string content = 15;
case 15: {
if (static_cast<::google::protobuf::uint8>(tag) != 122) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.compiler.CodeGeneratorResponse.File.content");
parser_till_end = ::google::protobuf::internal::StringParserUTF8Verify;
::std::string* str = msg->mutable_content();
@@ -1369,14 +1364,15 @@ const char* CodeGeneratorResponse_File::_InternalParse(const char* begin, const
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
@@ -1387,8 +1383,6 @@ const char* CodeGeneratorResponse_File::_InternalParse(const char* begin, const
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -1400,7 +1394,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool CodeGeneratorResponse_File::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.compiler.CodeGeneratorResponse.File)
for (;;) {
@@ -1772,14 +1766,13 @@ const char* CodeGeneratorResponse::_InternalParse(const char* begin, const char*
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// optional string error = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 10) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.compiler.CodeGeneratorResponse.error");
parser_till_end = ::google::protobuf::internal::StringParserUTF8Verify;
::std::string* str = msg->mutable_error();
@@ -1787,8 +1780,8 @@ const char* CodeGeneratorResponse::_InternalParse(const char* begin, const char*
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15;
@@ -1796,21 +1789,24 @@ const char* CodeGeneratorResponse::_InternalParse(const char* begin, const char*
if (static_cast<::google::protobuf::uint8>(tag) != 122) goto handle_unusual;
do {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::compiler::CodeGeneratorResponse_File::_InternalParse;
object = msg->add_file();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 255) == 122 && (ptr += 1));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 122 && (ptr += 1));
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
@@ -1821,8 +1817,6 @@ const char* CodeGeneratorResponse::_InternalParse(const char* begin, const char*
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -1834,7 +1828,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool CodeGeneratorResponse::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.compiler.CodeGeneratorResponse)
for (;;) {
@@ -2066,19 +2060,20 @@ void CodeGeneratorResponse::InternalSwap(CodeGeneratorResponse* other) {
} // namespace google
namespace google {
namespace protobuf {
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::compiler::Version* Arena::CreateMaybeMessage< ::google::protobuf::compiler::Version >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::compiler::Version* Arena::CreateMaybeMessage< ::google::protobuf::compiler::Version >(Arena* arena) {
return Arena::CreateInternal< ::google::protobuf::compiler::Version >(arena);
}
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::compiler::CodeGeneratorRequest* Arena::CreateMaybeMessage< ::google::protobuf::compiler::CodeGeneratorRequest >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::compiler::CodeGeneratorRequest* Arena::CreateMaybeMessage< ::google::protobuf::compiler::CodeGeneratorRequest >(Arena* arena) {
return Arena::CreateInternal< ::google::protobuf::compiler::CodeGeneratorRequest >(arena);
}
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::compiler::CodeGeneratorResponse_File* Arena::CreateMaybeMessage< ::google::protobuf::compiler::CodeGeneratorResponse_File >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::compiler::CodeGeneratorResponse_File* Arena::CreateMaybeMessage< ::google::protobuf::compiler::CodeGeneratorResponse_File >(Arena* arena) {
return Arena::CreateInternal< ::google::protobuf::compiler::CodeGeneratorResponse_File >(arena);
}
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::compiler::CodeGeneratorResponse* Arena::CreateMaybeMessage< ::google::protobuf::compiler::CodeGeneratorResponse >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::compiler::CodeGeneratorResponse* Arena::CreateMaybeMessage< ::google::protobuf::compiler::CodeGeneratorResponse >(Arena* arena) {
return Arena::CreateInternal< ::google::protobuf::compiler::CodeGeneratorResponse >(arena);
}
} // namespace protobuf
} // namespace google
// @@protoc_insertion_point(global_scope)
+#include <google/protobuf/port_undef.inc>
diff --git a/src/google/protobuf/compiler/plugin.pb.h b/src/google/protobuf/compiler/plugin.pb.h
index 4b7527e5..187587ca 100644
--- a/src/google/protobuf/compiler/plugin.pb.h
+++ b/src/google/protobuf/compiler/plugin.pb.h
@@ -7,18 +7,19 @@
#include <limits>
#include <string>
-#include <google/protobuf/stubs/common.h>
-#if GOOGLE_PROTOBUF_VERSION < 3006000
+#include <google/protobuf/port_def.inc>
+#if PROTOBUF_VERSION < 3006001
#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 3006001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 3006001 < 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.
#endif
+#include <google/protobuf/port_undef.inc>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
@@ -33,7 +34,7 @@
#include <google/protobuf/descriptor.pb.h>
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>
-#define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fcompiler_2fplugin_2eproto LIBPROTOC_EXPORT
+#define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fcompiler_2fplugin_2eproto PROTOC_EXPORT
#ifdef major
#undef major
#endif
@@ -42,38 +43,38 @@
#endif
// Internal implementation detail -- do not use these members.
-struct LIBPROTOC_EXPORT TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto {
+struct PROTOC_EXPORT TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto {
static const ::google::protobuf::internal::ParseTableField entries[]
- GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold);
+ PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::google::protobuf::internal::AuxillaryParseTableField aux[]
- GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold);
+ PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::google::protobuf::internal::ParseTable schema[4]
- GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold);
+ PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::google::protobuf::internal::FieldMetadata field_metadata[];
static const ::google::protobuf::internal::SerializationTable serialization_table[];
static const ::google::protobuf::uint32 offsets[];
};
-void LIBPROTOC_EXPORT AddDescriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto();
+void PROTOC_EXPORT AddDescriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto();
namespace google {
namespace protobuf {
namespace compiler {
class CodeGeneratorRequest;
class CodeGeneratorRequestDefaultTypeInternal;
-LIBPROTOC_EXPORT extern CodeGeneratorRequestDefaultTypeInternal _CodeGeneratorRequest_default_instance_;
+PROTOC_EXPORT extern CodeGeneratorRequestDefaultTypeInternal _CodeGeneratorRequest_default_instance_;
class CodeGeneratorResponse;
class CodeGeneratorResponseDefaultTypeInternal;
-LIBPROTOC_EXPORT extern CodeGeneratorResponseDefaultTypeInternal _CodeGeneratorResponse_default_instance_;
+PROTOC_EXPORT extern CodeGeneratorResponseDefaultTypeInternal _CodeGeneratorResponse_default_instance_;
class CodeGeneratorResponse_File;
class CodeGeneratorResponse_FileDefaultTypeInternal;
-LIBPROTOC_EXPORT extern CodeGeneratorResponse_FileDefaultTypeInternal _CodeGeneratorResponse_File_default_instance_;
+PROTOC_EXPORT extern CodeGeneratorResponse_FileDefaultTypeInternal _CodeGeneratorResponse_File_default_instance_;
class Version;
class VersionDefaultTypeInternal;
-LIBPROTOC_EXPORT extern VersionDefaultTypeInternal _Version_default_instance_;
+PROTOC_EXPORT extern VersionDefaultTypeInternal _Version_default_instance_;
} // namespace compiler
-template<> LIBPROTOC_EXPORT ::google::protobuf::compiler::CodeGeneratorRequest* Arena::CreateMaybeMessage<::google::protobuf::compiler::CodeGeneratorRequest>(Arena*);
-template<> LIBPROTOC_EXPORT ::google::protobuf::compiler::CodeGeneratorResponse* Arena::CreateMaybeMessage<::google::protobuf::compiler::CodeGeneratorResponse>(Arena*);
-template<> LIBPROTOC_EXPORT ::google::protobuf::compiler::CodeGeneratorResponse_File* Arena::CreateMaybeMessage<::google::protobuf::compiler::CodeGeneratorResponse_File>(Arena*);
-template<> LIBPROTOC_EXPORT ::google::protobuf::compiler::Version* Arena::CreateMaybeMessage<::google::protobuf::compiler::Version>(Arena*);
+template<> PROTOC_EXPORT ::google::protobuf::compiler::CodeGeneratorRequest* Arena::CreateMaybeMessage<::google::protobuf::compiler::CodeGeneratorRequest>(Arena*);
+template<> PROTOC_EXPORT ::google::protobuf::compiler::CodeGeneratorResponse* Arena::CreateMaybeMessage<::google::protobuf::compiler::CodeGeneratorResponse>(Arena*);
+template<> PROTOC_EXPORT ::google::protobuf::compiler::CodeGeneratorResponse_File* Arena::CreateMaybeMessage<::google::protobuf::compiler::CodeGeneratorResponse_File>(Arena*);
+template<> PROTOC_EXPORT ::google::protobuf::compiler::Version* Arena::CreateMaybeMessage<::google::protobuf::compiler::Version>(Arena*);
} // namespace protobuf
} // namespace google
namespace google {
@@ -82,7 +83,7 @@ namespace compiler {
// ===================================================================
-class LIBPROTOC_EXPORT Version : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.Version) */ {
+class PROTOC_EXPORT Version : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.Version) */ {
public:
Version();
virtual ~Version();
@@ -234,7 +235,7 @@ class LIBPROTOC_EXPORT Version : public ::google::protobuf::Message /* @@protoc_
};
// -------------------------------------------------------------------
-class LIBPROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.CodeGeneratorRequest) */ {
+class PROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.CodeGeneratorRequest) */ {
public:
CodeGeneratorRequest();
virtual ~CodeGeneratorRequest();
@@ -408,7 +409,7 @@ class LIBPROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message
};
// -------------------------------------------------------------------
-class LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.CodeGeneratorResponse.File) */ {
+class PROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.CodeGeneratorResponse.File) */ {
public:
CodeGeneratorResponse_File();
virtual ~CodeGeneratorResponse_File();
@@ -568,7 +569,7 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::M
};
// -------------------------------------------------------------------
-class LIBPROTOC_EXPORT CodeGeneratorResponse : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.CodeGeneratorResponse) */ {
+class PROTOC_EXPORT CodeGeneratorResponse : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.CodeGeneratorResponse) */ {
public:
CodeGeneratorResponse();
virtual ~CodeGeneratorResponse();
diff --git a/src/google/protobuf/compiler/python/python_generator.h b/src/google/protobuf/compiler/python/python_generator.h
index 99a73832..c21c36da 100644
--- a/src/google/protobuf/compiler/python/python_generator.h
+++ b/src/google/protobuf/compiler/python/python_generator.h
@@ -39,6 +39,8 @@
#include <google/protobuf/compiler/code_generator.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
@@ -58,16 +60,16 @@ namespace python {
// If you create your own protocol compiler binary and you want it to support
// Python output, you can do so by registering an instance of this
// CodeGenerator with the CommandLineInterface in your main() function.
-class LIBPROTOC_EXPORT Generator : public CodeGenerator {
+class PROTOC_EXPORT Generator : public CodeGenerator {
public:
Generator();
virtual ~Generator();
// CodeGenerator methods.
virtual bool Generate(const FileDescriptor* file,
- const string& parameter,
+ const std::string& parameter,
GeneratorContext* generator_context,
- string* error) const;
+ std::string* error) const;
private:
void PrintImports() const;
@@ -84,7 +86,7 @@ class LIBPROTOC_EXPORT Generator : public CodeGenerator {
void PrintFieldDescriptorsInDescriptor(
const Descriptor& message_descriptor,
bool is_extension,
- const string& list_variable_name,
+ const std::string& list_variable_name,
int (Descriptor::*CountFn)() const,
const FieldDescriptor* (Descriptor::*GetterFn)(int) const) const;
void PrintFieldsInDescriptor(const Descriptor& message_descriptor) const;
@@ -94,11 +96,11 @@ class LIBPROTOC_EXPORT Generator : public CodeGenerator {
void PrintNestedDescriptors(const Descriptor& containing_descriptor) const;
void PrintMessages() const;
- void PrintMessage(const Descriptor& message_descriptor, const string& prefix,
- std::vector<string>* to_register) const;
+ void PrintMessage(const Descriptor& message_descriptor, const std::string& prefix,
+ std::vector<std::string>* to_register) const;
void PrintNestedMessages(const Descriptor& containing_descriptor,
- const string& prefix,
- std::vector<string>* to_register) const;
+ const std::string& prefix,
+ std::vector<std::string>* to_register) const;
void FixForeignFieldsInDescriptors() const;
void FixForeignFieldsInDescriptor(
@@ -106,14 +108,14 @@ class LIBPROTOC_EXPORT Generator : public CodeGenerator {
const Descriptor* containing_descriptor) const;
void FixForeignFieldsInField(const Descriptor* containing_type,
const FieldDescriptor& field,
- const string& python_dict_name) const;
+ const std::string& python_dict_name) const;
void AddMessageToFileDescriptor(const Descriptor& descriptor) const;
void AddEnumToFileDescriptor(const EnumDescriptor& descriptor) const;
void AddExtensionToFileDescriptor(const FieldDescriptor& descriptor) const;
void AddServiceToFileDescriptor(const ServiceDescriptor& descriptor) const;
- string FieldReferencingExpression(const Descriptor* containing_type,
+ std::string FieldReferencingExpression(const Descriptor* containing_type,
const FieldDescriptor& field,
- const string& python_dict_name) const;
+ const std::string& python_dict_name) const;
template <typename DescriptorT>
void FixContainingTypeInDescriptor(
const DescriptorT& descriptor,
@@ -133,13 +135,13 @@ class LIBPROTOC_EXPORT Generator : public CodeGenerator {
const ServiceDescriptor& descriptor) const;
void PrintEnumValueDescriptor(const EnumValueDescriptor& descriptor) const;
- string OptionsValue(const string& serialized_options) const;
+ std::string OptionsValue(const std::string& serialized_options) const;
bool GeneratingDescriptorProto() const;
template <typename DescriptorT>
- string ModuleLevelDescriptorName(const DescriptorT& descriptor) const;
- string ModuleLevelMessageName(const Descriptor& descriptor) const;
- string ModuleLevelServiceDescriptorName(
+ std::string ModuleLevelDescriptorName(const DescriptorT& descriptor) const;
+ std::string ModuleLevelMessageName(const Descriptor& descriptor) const;
+ std::string ModuleLevelServiceDescriptorName(
const ServiceDescriptor& descriptor) const;
template <typename DescriptorT, typename DescriptorProtoT>
@@ -153,13 +155,13 @@ class LIBPROTOC_EXPORT Generator : public CodeGenerator {
void FixOptionsForMessage(const Descriptor& descriptor) const;
void CopyPublicDependenciesAliases(
- const string& copy_from, const FileDescriptor* file) const;
+ const std::string& copy_from, const FileDescriptor* file) const;
// Very coarse-grained lock to ensure that Generate() is reentrant.
// Guards file_, printer_ and file_descriptor_serialized_.
mutable Mutex mutex_;
mutable const FileDescriptor* file_; // Set in Generate(). Under mutex_.
- mutable string file_descriptor_serialized_;
+ mutable std::string file_descriptor_serialized_;
mutable io::Printer* printer_; // Set in Generate(). Under mutex_.
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Generator);
@@ -170,4 +172,6 @@ class LIBPROTOC_EXPORT Generator : public CodeGenerator {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_COMPILER_PYTHON_GENERATOR_H__
diff --git a/src/google/protobuf/compiler/ruby/ruby_generator.h b/src/google/protobuf/compiler/ruby/ruby_generator.h
index 8c1dfa26..521697fb 100644
--- a/src/google/protobuf/compiler/ruby/ruby_generator.h
+++ b/src/google/protobuf/compiler/ruby/ruby_generator.h
@@ -37,6 +37,8 @@
#include <google/protobuf/compiler/code_generator.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace compiler {
@@ -46,7 +48,7 @@ namespace ruby {
// If you create your own protocol compiler binary and you want it to support
// Ruby output, you can do so by registering an instance of this
// CodeGenerator with the CommandLineInterface in your main() function.
-class LIBPROTOC_EXPORT Generator
+class PROTOC_EXPORT Generator
: public google::protobuf::compiler::CodeGenerator {
virtual bool Generate(
const FileDescriptor* file,
@@ -60,5 +62,7 @@ class LIBPROTOC_EXPORT Generator
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_COMPILER_RUBY_GENERATOR_H__
diff --git a/src/google/protobuf/compiler/scc.h b/src/google/protobuf/compiler/scc.h
index 69a47f1b..c8cf77d6 100644
--- a/src/google/protobuf/compiler/scc.h
+++ b/src/google/protobuf/compiler/scc.h
@@ -35,6 +35,8 @@
#include <google/protobuf/descriptor.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace compiler {
@@ -52,7 +54,7 @@ struct SCC {
// This class is used for analyzing the SCC for each message, to ensure linear
// instead of quadratic performance, if we do this per message we would get
// O(V*(V+E)).
-class LIBPROTOC_EXPORT SCCAnalyzer {
+class PROTOC_EXPORT SCCAnalyzer {
public:
explicit SCCAnalyzer() : index_(0) {}
@@ -92,4 +94,6 @@ class LIBPROTOC_EXPORT SCCAnalyzer {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_COMPILER_SCC_H__
diff --git a/src/google/protobuf/compiler/subprocess.h b/src/google/protobuf/compiler/subprocess.h
index dad5daba..977abff7 100644
--- a/src/google/protobuf/compiler/subprocess.h
+++ b/src/google/protobuf/compiler/subprocess.h
@@ -44,6 +44,8 @@
#include <string>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
@@ -52,7 +54,7 @@ class Message;
namespace compiler {
// Utility class for launching sub-processes.
-class LIBPROTOC_EXPORT Subprocess {
+class PROTOC_EXPORT Subprocess {
public:
Subprocess();
~Subprocess();
@@ -64,19 +66,19 @@ class LIBPROTOC_EXPORT Subprocess {
// Start the subprocess. Currently we don't provide a way to specify
// arguments as protoc plugins don't have any.
- void Start(const string& program, SearchMode search_mode);
+ void Start(const std::string& program, SearchMode search_mode);
// Serialize the input message and pipe it to the subprocess's stdin, then
// close the pipe. Meanwhile, read from the subprocess's stdout and parse
// the data into *output. All this is done carefully to avoid deadlocks.
// Returns true if successful. On any sort of error, returns false and sets
// *error to a description of the problem.
- bool Communicate(const Message& input, Message* output, string* error);
+ bool Communicate(const Message& input, Message* output, std::string* error);
#ifdef _WIN32
// Given an error code, returns a human-readable error message. This is
// defined here so that CommandLineInterface can share it.
- static string Win32ErrorMessage(DWORD error_code);
+ static std::string Win32ErrorMessage(DWORD error_code);
#endif
private:
@@ -104,4 +106,6 @@ class LIBPROTOC_EXPORT Subprocess {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_COMPILER_SUBPROCESS_H__
diff --git a/src/google/protobuf/compiler/zip_writer.h b/src/google/protobuf/compiler/zip_writer.h
index 03db4d57..a99bb78c 100644
--- a/src/google/protobuf/compiler/zip_writer.h
+++ b/src/google/protobuf/compiler/zip_writer.h
@@ -73,12 +73,12 @@ class ZipWriter {
ZipWriter(io::ZeroCopyOutputStream* raw_output);
~ZipWriter();
- bool Write(const string& filename, const string& contents);
+ bool Write(const std::string& filename, const std::string& contents);
bool WriteDirectory();
private:
struct FileInfo {
- string name;
+ std::string name;
uint32 offset;
uint32 size;
uint32 crc32;
diff --git a/src/google/protobuf/descriptor.cc b/src/google/protobuf/descriptor.cc
index 5486ab92..26f2b8c8 100644
--- a/src/google/protobuf/descriptor.cc
+++ b/src/google/protobuf/descriptor.cc
@@ -70,6 +70,8 @@
#undef PACKAGE // autoheader #defines this. :(
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
@@ -776,7 +778,7 @@ class FileDescriptorTables {
FieldsByNumberMap fields_by_number_; // Not including extensions.
EnumValuesByNumberMap enum_values_by_number_;
mutable EnumValuesByNumberMap unknown_enum_values_by_number_
- GOOGLE_GUARDED_BY(unknown_enum_values_mu_);
+ PROTOBUF_GUARDED_BY(unknown_enum_values_mu_);
// Populated on first request to save space, hence constness games.
mutable internal::once_flag locations_by_path_once_;
diff --git a/src/google/protobuf/descriptor.h b/src/google/protobuf/descriptor.h
index 08caab2e..cf0a52bb 100644
--- a/src/google/protobuf/descriptor.h
+++ b/src/google/protobuf/descriptor.h
@@ -62,11 +62,17 @@
#include <google/protobuf/stubs/mutex.h>
#include <google/protobuf/stubs/once.h>
+#include <google/protobuf/port_def.inc>
+
// TYPE_BOOL is defined in the MacOS's ConditionalMacros.h.
#ifdef TYPE_BOOL
#undef TYPE_BOOL
#endif // TYPE_BOOL
+#ifdef SWIG
+#define PROTOBUF_EXPORT
+#endif
+
namespace google {
namespace protobuf {
@@ -147,9 +153,9 @@ struct SourceLocation {
// Doc comments found at the source location.
// See the comments in SourceCodeInfo.Location (descriptor.proto) for details.
- string leading_comments;
- string trailing_comments;
- std::vector<string> leading_detached_comments;
+ std::string leading_comments;
+ std::string trailing_comments;
+ std::vector<std::string> leading_detached_comments;
};
// Options when generating machine-parsable output from a descriptor with
@@ -175,7 +181,7 @@ struct DebugStringOptions {
// which is needed when a pool has lazily_build_dependencies_ set.
// Must be instantiated as mutable in a descriptor.
namespace internal {
-class LIBPROTOBUF_EXPORT LazyDescriptor {
+class PROTOBUF_EXPORT LazyDescriptor {
public:
// Init function to be called at init time of a descriptor containing
// a LazyDescriptor.
@@ -197,7 +203,7 @@ class LIBPROTOBUF_EXPORT LazyDescriptor {
// build time if the symbol wasn't found and building of the file containing
// that type is delayed because lazily_build_dependencies_ is set on the pool.
// Should not be called after Set() has been called.
- void SetLazy(const string& name, const FileDescriptor* file);
+ void SetLazy(const std::string& name, const FileDescriptor* file);
// Returns the current value of the descriptor, thread-safe. If SetLazy(...)
// has been called, will do a one-time cross link of the type specified,
@@ -213,7 +219,7 @@ class LIBPROTOBUF_EXPORT LazyDescriptor {
void Once();
const Descriptor* descriptor_;
- const string* name_;
+ const std::string* name_;
internal::once_flag* once_;
const FileDescriptor* file_;
};
@@ -224,17 +230,17 @@ class LIBPROTOBUF_EXPORT LazyDescriptor {
// Message::GetDescriptor(). Generated message classes also have a
// static method called descriptor() which returns the type's descriptor.
// Use DescriptorPool to construct your own descriptors.
-class LIBPROTOBUF_EXPORT Descriptor {
+class PROTOBUF_EXPORT Descriptor {
public:
// The name of the message type, not including its scope.
- const string& name() const;
+ const std::string& name() const;
// The fully-qualified name of the message type, scope delimited by
// periods. For example, message type "Foo" which is declared in package
// "bar" has full name "bar.Foo". If a type "Baz" is nested within
// Foo, Baz's full_name is "bar.Foo.Baz". To get only the part that
// comes after the last '.', use name().
- const string& full_name() const;
+ const std::string& full_name() const;
// Index of this descriptor within the file or containing type's message
// type array.
@@ -260,11 +266,11 @@ class LIBPROTOBUF_EXPORT Descriptor {
// Write the contents of this decriptor in a human-readable form. Output
// will be suitable for re-parsing.
- string DebugString() const;
+ std::string DebugString() const;
// Similar to DebugString(), but additionally takes options (e.g.,
// include original user comments in output).
- string DebugStringWithOptions(const DebugStringOptions& options) const;
+ std::string DebugStringWithOptions(const DebugStringOptions& options) const;
// Returns true if this is a placeholder for an unknown type. This will
// only be the case if this descriptor comes from a DescriptorPool
@@ -283,20 +289,20 @@ class LIBPROTOBUF_EXPORT Descriptor {
// exists.
const FieldDescriptor* FindFieldByNumber(int number) const;
// Looks up a field by name. Returns NULL if no such field exists.
- const FieldDescriptor* FindFieldByName(const string& name) const;
+ const FieldDescriptor* FindFieldByName(const std::string& name) const;
// Looks up a field by lowercased name (as returned by lowercase_name()).
// This lookup may be ambiguous if multiple field names differ only by case,
// in which case the field returned is chosen arbitrarily from the matches.
const FieldDescriptor* FindFieldByLowercaseName(
- const string& lowercase_name) const;
+ const std::string& lowercase_name) const;
// Looks up a field by camel-case name (as returned by camelcase_name()).
// This lookup may be ambiguous if multiple field names differ in a way that
// leads them to have identical camel-case names, in which case the field
// returned is chosen arbitrarily from the matches.
const FieldDescriptor* FindFieldByCamelcaseName(
- const string& camelcase_name) const;
+ const std::string& camelcase_name) const;
// The number of oneofs in this message type.
int oneof_decl_count() const;
@@ -305,7 +311,7 @@ class LIBPROTOBUF_EXPORT Descriptor {
const OneofDescriptor* oneof_decl(int index) const;
// Looks up a oneof by name. Returns NULL if no such oneof exists.
- const OneofDescriptor* FindOneofByName(const string& name) const;
+ const OneofDescriptor* FindOneofByName(const std::string& name) const;
// Nested type stuff -----------------------------------------------
@@ -317,7 +323,7 @@ class LIBPROTOBUF_EXPORT Descriptor {
// Looks up a nested type by name. Returns NULL if no such nested type
// exists.
- const Descriptor* FindNestedTypeByName(const string& name) const;
+ const Descriptor* FindNestedTypeByName(const std::string& name) const;
// Enum stuff ------------------------------------------------------
@@ -328,11 +334,11 @@ class LIBPROTOBUF_EXPORT Descriptor {
const EnumDescriptor* enum_type(int index) const;
// Looks up an enum type by name. Returns NULL if no such enum type exists.
- const EnumDescriptor* FindEnumTypeByName(const string& name) const;
+ const EnumDescriptor* FindEnumTypeByName(const std::string& name) const;
// Looks up an enum value by name, among all enum types in this message.
// Returns NULL if no such value exists.
- const EnumValueDescriptor* FindEnumValueByName(const string& name) const;
+ const EnumValueDescriptor* FindEnumValueByName(const std::string& name) const;
// Extensions ------------------------------------------------------
@@ -372,15 +378,15 @@ class LIBPROTOBUF_EXPORT Descriptor {
// Looks up a named extension (which extends some *other* message type)
// defined within this message type's scope.
- const FieldDescriptor* FindExtensionByName(const string& name) const;
+ const FieldDescriptor* FindExtensionByName(const std::string& name) const;
// Similar to FindFieldByLowercaseName(), but finds extensions defined within
// this message type's scope.
- const FieldDescriptor* FindExtensionByLowercaseName(const string& name) const;
+ const FieldDescriptor* FindExtensionByLowercaseName(const std::string& name) const;
// Similar to FindFieldByCamelcaseName(), but finds extensions defined within
// this message type's scope.
- const FieldDescriptor* FindExtensionByCamelcaseName(const string& name) const;
+ const FieldDescriptor* FindExtensionByCamelcaseName(const std::string& name) const;
// Reserved fields -------------------------------------------------
@@ -407,10 +413,10 @@ class LIBPROTOBUF_EXPORT Descriptor {
int reserved_name_count() const;
// Gets a reserved name by index, where 0 <= index < reserved_name_count().
- const string& reserved_name(int index) const;
+ const std::string& reserved_name(int index) const;
// Returns true if the field name is reserved.
- bool IsReservedName(const string& name) const;
+ bool IsReservedName(const std::string& name) const;
// Source Location ---------------------------------------------------
@@ -436,7 +442,7 @@ class LIBPROTOBUF_EXPORT Descriptor {
// correct depth. Takes |options| to control debug-string options, and
// |include_opening_clause| to indicate whether the "message ... " part of the
// clause has already been generated (this varies depending on context).
- void DebugString(int depth, string *contents,
+ void DebugString(int depth, std::string *contents,
const DebugStringOptions& options,
bool include_opening_clause) const;
@@ -444,8 +450,8 @@ class LIBPROTOBUF_EXPORT Descriptor {
// to this descriptor from the file root.
void GetLocationPath(std::vector<int>* output) const;
- const string* name_;
- const string* full_name_;
+ const std::string* name_;
+ const std::string* full_name_;
const FileDescriptor* file_;
const Descriptor* containing_type_;
const MessageOptions* options_;
@@ -458,7 +464,7 @@ class LIBPROTOBUF_EXPORT Descriptor {
ExtensionRange* extension_ranges_;
FieldDescriptor* extensions_;
ReservedRange* reserved_ranges_;
- const string** reserved_names_;
+ const std::string** reserved_names_;
int field_count_;
int oneof_decl_count_;
@@ -503,7 +509,7 @@ class LIBPROTOBUF_EXPORT Descriptor {
// Reflection::FindKnownExtensionByName() or
// Reflection::FindKnownExtensionByNumber().
// Use DescriptorPool to construct your own descriptors.
-class LIBPROTOBUF_EXPORT FieldDescriptor {
+class PROTOBUF_EXPORT FieldDescriptor {
public:
// Identifies a field type. 0 is reserved for errors. The order is weird
// for historical reasons. Types 12 and up are new in proto2.
@@ -576,9 +582,9 @@ class LIBPROTOBUF_EXPORT FieldDescriptor {
// Users may not declare fields that use reserved numbers.
static const int kLastReservedNumber = 19999;
- const string& name() const; // Name of this field within the message.
- const string& full_name() const; // Fully-qualified name of the field.
- const string& json_name() const; // JSON name of this field.
+ const std::string& name() const; // Name of this field within the message.
+ const std::string& full_name() const; // Fully-qualified name of the field.
+ const std::string& json_name() const; // JSON name of this field.
const FileDescriptor* file() const;// File in which this field was defined.
bool is_extension() const; // Is this an extension field?
int number() const; // Declared tag number.
@@ -589,7 +595,7 @@ class LIBPROTOBUF_EXPORT FieldDescriptor {
// field names should be lowercased anyway according to the protobuf style
// guide, so this only makes a difference when dealing with old .proto files
// which do not follow the guide.)
- const string& lowercase_name() const;
+ const std::string& lowercase_name() const;
// Same as name() except converted to camel-case. In this conversion, any
// time an underscore appears in the name, it is removed and the next
@@ -600,7 +606,7 @@ class LIBPROTOBUF_EXPORT FieldDescriptor {
// fooBar -> fooBar
// This (and especially the FindFieldByCamelcaseName() method) can be useful
// when parsing formats which prefer to use camel-case naming style.
- const string& camelcase_name() const;
+ const std::string& camelcase_name() const;
Type type() const; // Declared type of this field.
const char* type_name() const; // Name of the declared type.
@@ -657,7 +663,7 @@ class LIBPROTOBUF_EXPORT FieldDescriptor {
const EnumValueDescriptor* default_value_enum() const;
// Get the field default value if cpp_type() == CPPTYPE_STRING. If no
// explicit default was defined, the default is the empty string.
- const string& default_value_string() const;
+ const std::string& default_value_string() const;
// The Descriptor for the message of which this is a field. For extensions,
// this is the extended type. Never NULL.
@@ -695,10 +701,10 @@ class LIBPROTOBUF_EXPORT FieldDescriptor {
void CopyTo(FieldDescriptorProto* proto) const;
// See Descriptor::DebugString().
- string DebugString() const;
+ std::string DebugString() const;
// See Descriptor::DebugStringWithOptions().
- string DebugStringWithOptions(const DebugStringOptions& options) const;
+ std::string DebugStringWithOptions(const DebugStringOptions& options) const;
// Helper method to get the CppType for a particular Type.
static CppType TypeToCppType(Type type);
@@ -732,15 +738,15 @@ class LIBPROTOBUF_EXPORT FieldDescriptor {
// See Descriptor::DebugString().
enum PrintLabelFlag { PRINT_LABEL, OMIT_LABEL };
void DebugString(int depth, PrintLabelFlag print_label_flag,
- string* contents, const DebugStringOptions& options) const;
+ std::string* contents, const DebugStringOptions& options) const;
// formats the default value appropriately and returns it as a string.
// Must have a default value to call this. If quote_string_type is true, then
// types of CPPTYPE_STRING whill be surrounded by quotes and CEscaped.
- string DefaultValueAsString(bool quote_string_type) const;
+ std::string DefaultValueAsString(bool quote_string_type) const;
// Helper function that returns the field type name for DebugString.
- string FieldTypeNameDebugString() const;
+ std::string FieldTypeNameDebugString() const;
// Walks up the descriptor tree to generate the source location path
// to this descriptor from the file root.
@@ -749,13 +755,13 @@ class LIBPROTOBUF_EXPORT FieldDescriptor {
// Returns true if this is a map message type.
bool is_map_message_type() const;
- const string* name_;
- const string* full_name_;
- const string* lowercase_name_;
- const string* camelcase_name_;
+ const std::string* name_;
+ const std::string* full_name_;
+ const std::string* lowercase_name_;
+ const std::string* camelcase_name_;
// If has_json_name_ is true, it's the value specified by the user.
// Otherwise, it has the same value as camelcase_name_.
- const string* json_name_;
+ const std::string* json_name_;
const FileDescriptor* file_;
internal::once_flag* type_once_;
static void TypeOnceInit(const FieldDescriptor* to_init);
@@ -775,8 +781,8 @@ class LIBPROTOBUF_EXPORT FieldDescriptor {
mutable const Descriptor* message_type_;
mutable const EnumDescriptor* enum_type_;
const FieldOptions* options_;
- const string* type_name_;
- const string* default_value_enum_name_;
+ const std::string* type_name_;
+ const std::string* default_value_enum_name_;
// IMPORTANT: If you add a new field, make sure to search for all instances
// of Allocate<FieldDescriptor>() and AllocateArray<FieldDescriptor>() in
// descriptor.cc and update them to initialize the field.
@@ -791,7 +797,7 @@ class LIBPROTOBUF_EXPORT FieldDescriptor {
bool default_value_bool_;
mutable const EnumValueDescriptor* default_value_enum_;
- const string* default_value_string_;
+ const std::string* default_value_string_;
};
static const CppType kTypeToCppTypeMap[MAX_TYPE + 1];
@@ -813,10 +819,10 @@ class LIBPROTOBUF_EXPORT FieldDescriptor {
// Describes a oneof defined in a message type.
-class LIBPROTOBUF_EXPORT OneofDescriptor {
+class PROTOBUF_EXPORT OneofDescriptor {
public:
- const string& name() const; // Name of this oneof.
- const string& full_name() const; // Fully-qualified name of the oneof.
+ const std::string& name() const; // Name of this oneof.
+ const std::string& full_name() const; // Fully-qualified name of the oneof.
// Index of this oneof within the message's oneof array.
int index() const;
@@ -838,10 +844,10 @@ class LIBPROTOBUF_EXPORT OneofDescriptor {
void CopyTo(OneofDescriptorProto* proto) const;
// See Descriptor::DebugString().
- string DebugString() const;
+ std::string DebugString() const;
// See Descriptor::DebugStringWithOptions().
- string DebugStringWithOptions(const DebugStringOptions& options) const;
+ std::string DebugStringWithOptions(const DebugStringOptions& options) const;
// Source Location ---------------------------------------------------
@@ -858,15 +864,15 @@ class LIBPROTOBUF_EXPORT OneofDescriptor {
friend class compiler::cpp::Formatter;
// See Descriptor::DebugString().
- void DebugString(int depth, string* contents,
+ void DebugString(int depth, std::string* contents,
const DebugStringOptions& options) const;
// Walks up the descriptor tree to generate the source location path
// to this descriptor from the file root.
void GetLocationPath(std::vector<int>* output) const;
- const string* name_;
- const string* full_name_;
+ const std::string* name_;
+ const std::string* full_name_;
const Descriptor* containing_type_;
bool is_extendable_;
int field_count_;
@@ -887,13 +893,13 @@ class LIBPROTOBUF_EXPORT OneofDescriptor {
// Describes an enum type defined in a .proto file. To get the EnumDescriptor
// for a generated enum type, call TypeName_descriptor(). Use DescriptorPool
// to construct your own descriptors.
-class LIBPROTOBUF_EXPORT EnumDescriptor {
+class PROTOBUF_EXPORT EnumDescriptor {
public:
// The name of this enum type in the containing scope.
- const string& name() const;
+ const std::string& name() const;
// The fully-qualified name of the enum type, scope delimited by periods.
- const string& full_name() const;
+ const std::string& full_name() const;
// Index of this enum within the file or containing message's enum array.
int index() const;
@@ -909,7 +915,7 @@ class LIBPROTOBUF_EXPORT EnumDescriptor {
const EnumValueDescriptor* value(int index) const;
// Looks up a value by name. Returns NULL if no such value exists.
- const EnumValueDescriptor* FindValueByName(const string& name) const;
+ const EnumValueDescriptor* FindValueByName(const std::string& name) const;
// Looks up a value by number. Returns NULL if no such value exists. If
// multiple values have this number, the first one defined is returned.
const EnumValueDescriptor* FindValueByNumber(int number) const;
@@ -928,10 +934,10 @@ class LIBPROTOBUF_EXPORT EnumDescriptor {
void CopyTo(EnumDescriptorProto* proto) const;
// See Descriptor::DebugString().
- string DebugString() const;
+ std::string DebugString() const;
// See Descriptor::DebugStringWithOptions().
- string DebugStringWithOptions(const DebugStringOptions& options) const;
+ std::string DebugStringWithOptions(const DebugStringOptions& options) const;
// Returns true if this is a placeholder for an unknown enum. This will
// only be the case if this descriptor comes from a DescriptorPool
@@ -964,10 +970,10 @@ class LIBPROTOBUF_EXPORT EnumDescriptor {
int reserved_name_count() const;
// Gets a reserved name by index, where 0 <= index < reserved_name_count().
- const string& reserved_name(int index) const;
+ const std::string& reserved_name(int index) const;
// Returns true if the field name is reserved.
- bool IsReservedName(const string& name) const;
+ bool IsReservedName(const std::string& name) const;
// Source Location ---------------------------------------------------
@@ -996,15 +1002,15 @@ class LIBPROTOBUF_EXPORT EnumDescriptor {
// See Descriptor::DebugString().
- void DebugString(int depth, string *contents,
+ void DebugString(int depth, std::string *contents,
const DebugStringOptions& options) const;
// Walks up the descriptor tree to generate the source location path
// to this descriptor from the file root.
void GetLocationPath(std::vector<int>* output) const;
- const string* name_;
- const string* full_name_;
+ const std::string* name_;
+ const std::string* full_name_;
const FileDescriptor* file_;
const Descriptor* containing_type_;
const EnumOptions* options_;
@@ -1020,7 +1026,7 @@ class LIBPROTOBUF_EXPORT EnumDescriptor {
int reserved_range_count_;
int reserved_name_count_;
EnumDescriptor::ReservedRange* reserved_ranges_;
- const string** reserved_names_;
+ const std::string** reserved_names_;
// IMPORTANT: If you add a new field, make sure to search for all instances
// of Allocate<EnumDescriptor>() and AllocateArray<EnumDescriptor>() in
@@ -1043,9 +1049,9 @@ class LIBPROTOBUF_EXPORT EnumDescriptor {
// for its type, then use EnumDescriptor::FindValueByName() or
// EnumDescriptor::FindValueByNumber(). Use DescriptorPool to construct
// your own descriptors.
-class LIBPROTOBUF_EXPORT EnumValueDescriptor {
+class PROTOBUF_EXPORT EnumValueDescriptor {
public:
- const string& name() const; // Name of this enum constant.
+ const std::string& name() const; // Name of this enum constant.
int index() const; // Index within the enums's Descriptor.
int number() const; // Numeric value of this enum constant.
@@ -1054,7 +1060,7 @@ class LIBPROTOBUF_EXPORT EnumValueDescriptor {
// "google.protobuf.FieldDescriptorProto.TYPE_INT32", NOT
// "google.protobuf.FieldDescriptorProto.Type.TYPE_INT32". This is to conform
// with C++ scoping rules for enums.
- const string& full_name() const;
+ const std::string& full_name() const;
// The .proto file in which this value was defined. Never NULL.
const FileDescriptor* file() const;
@@ -1071,10 +1077,10 @@ class LIBPROTOBUF_EXPORT EnumValueDescriptor {
void CopyTo(EnumValueDescriptorProto* proto) const;
// See Descriptor::DebugString().
- string DebugString() const;
+ std::string DebugString() const;
// See Descriptor::DebugStringWithOptions().
- string DebugStringWithOptions(const DebugStringOptions& options) const;
+ std::string DebugStringWithOptions(const DebugStringOptions& options) const;
// Source Location ---------------------------------------------------
@@ -1092,15 +1098,15 @@ class LIBPROTOBUF_EXPORT EnumValueDescriptor {
friend class compiler::cpp::Formatter;
// See Descriptor::DebugString().
- void DebugString(int depth, string *contents,
+ void DebugString(int depth, std::string *contents,
const DebugStringOptions& options) const;
// Walks up the descriptor tree to generate the source location path
// to this descriptor from the file root.
void GetLocationPath(std::vector<int>* output) const;
- const string* name_;
- const string* full_name_;
+ const std::string* name_;
+ const std::string* full_name_;
int number_;
const EnumDescriptor* type_;
const EnumValueOptions* options_;
@@ -1121,12 +1127,12 @@ class LIBPROTOBUF_EXPORT EnumValueDescriptor {
// call Service::GetDescriptor(). Generated service classes also have a
// static method called descriptor() which returns the type's
// ServiceDescriptor. Use DescriptorPool to construct your own descriptors.
-class LIBPROTOBUF_EXPORT ServiceDescriptor {
+class PROTOBUF_EXPORT ServiceDescriptor {
public:
// The name of the service, not including its containing scope.
- const string& name() const;
+ const std::string& name() const;
// The fully-qualified name of the service, scope delimited by periods.
- const string& full_name() const;
+ const std::string& full_name() const;
// Index of this service within the file's services array.
int index() const;
@@ -1146,15 +1152,15 @@ class LIBPROTOBUF_EXPORT ServiceDescriptor {
const MethodDescriptor* method(int index) const;
// Look up a MethodDescriptor by name.
- const MethodDescriptor* FindMethodByName(const string& name) const;
+ const MethodDescriptor* FindMethodByName(const std::string& name) const;
// See Descriptor::CopyTo().
void CopyTo(ServiceDescriptorProto* proto) const;
// See Descriptor::DebugString().
- string DebugString() const;
+ std::string DebugString() const;
// See Descriptor::DebugStringWithOptions().
- string DebugStringWithOptions(const DebugStringOptions& options) const;
+ std::string DebugStringWithOptions(const DebugStringOptions& options) const;
// Source Location ---------------------------------------------------
@@ -1172,14 +1178,14 @@ class LIBPROTOBUF_EXPORT ServiceDescriptor {
friend class compiler::cpp::Formatter;
// See Descriptor::DebugString().
- void DebugString(string *contents, const DebugStringOptions& options) const;
+ void DebugString(std::string *contents, const DebugStringOptions& options) const;
// Walks up the descriptor tree to generate the source location path
// to this descriptor from the file root.
void GetLocationPath(std::vector<int>* output) const;
- const string* name_;
- const string* full_name_;
+ const std::string* name_;
+ const std::string* full_name_;
const FileDescriptor* file_;
const ServiceOptions* options_;
MethodDescriptor* methods_;
@@ -1201,12 +1207,12 @@ class LIBPROTOBUF_EXPORT ServiceDescriptor {
// a service, first get its ServiceDescriptor, then call
// ServiceDescriptor::FindMethodByName(). Use DescriptorPool to construct your
// own descriptors.
-class LIBPROTOBUF_EXPORT MethodDescriptor {
+class PROTOBUF_EXPORT MethodDescriptor {
public:
// Name of this method, not including containing scope.
- const string& name() const;
+ const std::string& name() const;
// The fully-qualified name of the method, scope delimited by periods.
- const string& full_name() const;
+ const std::string& full_name() const;
// Index within the service's Descriptor.
int index() const;
@@ -1235,10 +1241,10 @@ class LIBPROTOBUF_EXPORT MethodDescriptor {
void CopyTo(MethodDescriptorProto* proto) const;
// See Descriptor::DebugString().
- string DebugString() const;
+ std::string DebugString() const;
// See Descriptor::DebugStringWithOptions().
- string DebugStringWithOptions(const DebugStringOptions& options) const;
+ std::string DebugStringWithOptions(const DebugStringOptions& options) const;
// Source Location ---------------------------------------------------
@@ -1256,15 +1262,15 @@ class LIBPROTOBUF_EXPORT MethodDescriptor {
friend class compiler::cpp::Formatter;
// See Descriptor::DebugString().
- void DebugString(int depth, string *contents,
+ void DebugString(int depth, std::string *contents,
const DebugStringOptions& options) const;
// Walks up the descriptor tree to generate the source location path
// to this descriptor from the file root.
void GetLocationPath(std::vector<int>* output) const;
- const string* name_;
- const string* full_name_;
+ const std::string* name_;
+ const std::string* full_name_;
const ServiceDescriptor* service_;
mutable internal::LazyDescriptor input_type_;
mutable internal::LazyDescriptor output_type_;
@@ -1286,14 +1292,14 @@ class LIBPROTOBUF_EXPORT MethodDescriptor {
// Describes a whole .proto file. To get the FileDescriptor for a compiled-in
// file, get the descriptor for something defined in that file and call
// descriptor->file(). Use DescriptorPool to construct your own descriptors.
-class LIBPROTOBUF_EXPORT FileDescriptor {
+class PROTOBUF_EXPORT FileDescriptor {
public:
// The filename, relative to the source tree.
// e.g. "foo/bar/baz.proto"
- const string& name() const;
+ const std::string& name() const;
// The package, e.g. "google.protobuf.compiler".
- const string& package() const;
+ const std::string& package() const;
// The DescriptorPool in which this FileDescriptor and all its contents were
// allocated. Never NULL.
@@ -1364,22 +1370,22 @@ class LIBPROTOBUF_EXPORT FileDescriptor {
static const char* SyntaxName(Syntax syntax);
// Find a top-level message type by name. Returns NULL if not found.
- const Descriptor* FindMessageTypeByName(const string& name) const;
+ const Descriptor* FindMessageTypeByName(const std::string& name) const;
// Find a top-level enum type by name. Returns NULL if not found.
- const EnumDescriptor* FindEnumTypeByName(const string& name) const;
+ const EnumDescriptor* FindEnumTypeByName(const std::string& name) const;
// Find an enum value defined in any top-level enum by name. Returns NULL if
// not found.
- const EnumValueDescriptor* FindEnumValueByName(const string& name) const;
+ const EnumValueDescriptor* FindEnumValueByName(const std::string& name) const;
// Find a service definition by name. Returns NULL if not found.
- const ServiceDescriptor* FindServiceByName(const string& name) const;
+ const ServiceDescriptor* FindServiceByName(const std::string& name) const;
// Find a top-level extension definition by name. Returns NULL if not found.
- const FieldDescriptor* FindExtensionByName(const string& name) const;
+ const FieldDescriptor* FindExtensionByName(const std::string& name) const;
// Similar to FindExtensionByName(), but searches by lowercased-name. See
// Descriptor::FindFieldByLowercaseName().
- const FieldDescriptor* FindExtensionByLowercaseName(const string& name) const;
+ const FieldDescriptor* FindExtensionByLowercaseName(const std::string& name) const;
// Similar to FindExtensionByName(), but searches by camelcased-name. See
// Descriptor::FindFieldByCamelcaseName().
- const FieldDescriptor* FindExtensionByCamelcaseName(const string& name) const;
+ const FieldDescriptor* FindExtensionByCamelcaseName(const std::string& name) const;
// See Descriptor::CopyTo().
// Notes:
@@ -1394,10 +1400,10 @@ class LIBPROTOBUF_EXPORT FileDescriptor {
void CopyJsonNameTo(FileDescriptorProto* proto) const;
// See Descriptor::DebugString().
- string DebugString() const;
+ std::string DebugString() const;
// See Descriptor::DebugStringWithOptions().
- string DebugStringWithOptions(const DebugStringOptions& options) const;
+ std::string DebugStringWithOptions(const DebugStringOptions& options) const;
// Returns true if this is a placeholder for an unknown file. This will
// only be the case if this descriptor comes from a DescriptorPool
@@ -1419,8 +1425,8 @@ class LIBPROTOBUF_EXPORT FileDescriptor {
private:
typedef FileOptions OptionsType;
- const string* name_;
- const string* package_;
+ const std::string* name_;
+ const std::string* package_;
const DescriptorPool* pool_;
internal::once_flag* dependencies_once_;
static void DependenciesOnceInit(const FileDescriptor* to_init);
@@ -1443,7 +1449,7 @@ class LIBPROTOBUF_EXPORT FileDescriptor {
bool finished_building_;
mutable const FileDescriptor** dependencies_;
- const string** dependencies_names_;
+ const std::string** dependencies_names_;
int* public_dependencies_;
int* weak_dependencies_;
Descriptor* message_types_;
@@ -1500,7 +1506,7 @@ class LIBPROTOBUF_EXPORT FileDescriptor {
//
// You can also search for descriptors within a DescriptorPool by name, and
// extensions by number.
-class LIBPROTOBUF_EXPORT DescriptorPool {
+class PROTOBUF_EXPORT DescriptorPool {
public:
// Create a normal, empty DescriptorPool.
DescriptorPool();
@@ -1542,28 +1548,28 @@ class LIBPROTOBUF_EXPORT DescriptorPool {
// Find a FileDescriptor in the pool by file name. Returns NULL if not
// found.
- const FileDescriptor* FindFileByName(const string& name) const;
+ const FileDescriptor* FindFileByName(const std::string& name) const;
// Find the FileDescriptor in the pool which defines the given symbol.
// If any of the Find*ByName() methods below would succeed, then this is
// equivalent to calling that method and calling the result's file() method.
// Otherwise this returns NULL.
const FileDescriptor* FindFileContainingSymbol(
- const string& symbol_name) const;
+ const std::string& symbol_name) const;
// Looking up descriptors ------------------------------------------
// These find descriptors by fully-qualified name. These will find both
// top-level descriptors and nested descriptors. They return NULL if not
// found.
- const Descriptor* FindMessageTypeByName(const string& name) const;
- const FieldDescriptor* FindFieldByName(const string& name) const;
- const FieldDescriptor* FindExtensionByName(const string& name) const;
- const OneofDescriptor* FindOneofByName(const string& name) const;
- const EnumDescriptor* FindEnumTypeByName(const string& name) const;
- const EnumValueDescriptor* FindEnumValueByName(const string& name) const;
- const ServiceDescriptor* FindServiceByName(const string& name) const;
- const MethodDescriptor* FindMethodByName(const string& name) const;
+ const Descriptor* FindMessageTypeByName(const std::string& name) const;
+ const FieldDescriptor* FindFieldByName(const std::string& name) const;
+ const FieldDescriptor* FindExtensionByName(const std::string& name) const;
+ const OneofDescriptor* FindOneofByName(const std::string& name) const;
+ const EnumDescriptor* FindEnumTypeByName(const std::string& name) const;
+ const EnumValueDescriptor* FindEnumValueByName(const std::string& name) const;
+ const ServiceDescriptor* FindServiceByName(const std::string& name) const;
+ const MethodDescriptor* FindMethodByName(const std::string& name) const;
// Finds an extension of the given type by number. The extendee must be
// a member of this DescriptorPool or one of its underlays.
@@ -1583,7 +1589,7 @@ class LIBPROTOBUF_EXPORT DescriptorPool {
// When converting a FileDescriptorProto to a FileDescriptor, various
// errors might be detected in the input. The caller may handle these
// programmatically by implementing an ErrorCollector.
- class LIBPROTOBUF_EXPORT ErrorCollector {
+ class PROTOBUF_EXPORT ErrorCollector {
public:
inline ErrorCollector() {}
virtual ~ErrorCollector();
@@ -1607,21 +1613,21 @@ class LIBPROTOBUF_EXPORT DescriptorPool {
// Reports an error in the FileDescriptorProto. Use this function if the
// problem occurred should interrupt building the FileDescriptorProto.
virtual void AddError(
- const string& filename, // File name in which the error occurred.
- const string& element_name, // Full name of the erroneous element.
+ const std::string& filename, // File name in which the error occurred.
+ const std::string& element_name, // Full name of the erroneous element.
const Message* descriptor, // Descriptor of the erroneous element.
ErrorLocation location, // One of the location constants, above.
- const string& message // Human-readable error message.
+ const std::string& message // Human-readable error message.
) = 0;
// Reports a warning in the FileDescriptorProto. Use this function if the
// problem occurred should NOT interrupt building the FileDescriptorProto.
virtual void AddWarning(
- const string& /*filename*/, // File name in which the error occurred.
- const string& /*element_name*/, // Full name of the erroneous element.
+ const std::string& /*filename*/, // File name in which the error occurred.
+ const std::string& /*element_name*/, // Full name of the erroneous element.
const Message* /*descriptor*/, // Descriptor of the erroneous element.
ErrorLocation /*location*/, // One of the location constants, above.
- const string& /*message*/ // Human-readable error message.
+ const std::string& /*message*/ // Human-readable error message.
) {}
private:
@@ -1734,12 +1740,12 @@ class LIBPROTOBUF_EXPORT DescriptorPool {
// For internal (unit test) use only: Returns true if a FileDescriptor has
// been constructed for the given file, false otherwise. Useful for testing
// lazy descriptor initialization behavior.
- bool InternalIsFileLoaded(const string& filename) const;
+ bool InternalIsFileLoaded(const std::string& filename) const;
// Add a file to unused_import_track_files_. DescriptorBuilder will log
// warnings for those files if there is any unused import.
- void AddUnusedImportTrackFile(const string& file_name);
+ void AddUnusedImportTrackFile(const std::string& file_name);
void ClearUnusedImportTrackFiles();
private:
@@ -1757,14 +1763,14 @@ class LIBPROTOBUF_EXPORT DescriptorPool {
// Return true if the given name is a sub-symbol of any non-package
// descriptor that already exists in the descriptor pool. (The full
// definition of such types is already known.)
- bool IsSubSymbolOfBuiltType(const string& name) const;
+ bool IsSubSymbolOfBuiltType(const std::string& name) const;
// Tries to find something in the fallback database and link in the
// corresponding proto file. Returns true if successful, in which case
// the caller should search for the thing again. These are declared
// const because they are called by (semantically) const methods.
- bool TryFindFileInFallbackDatabase(const string& name) const;
- bool TryFindSymbolInFallbackDatabase(const string& name) const;
+ bool TryFindFileInFallbackDatabase(const std::string& name) const;
+ bool TryFindSymbolInFallbackDatabase(const std::string& name) const;
bool TryFindExtensionInFallbackDatabase(const Descriptor* containing_type,
int field_number) const;
@@ -1779,11 +1785,11 @@ class LIBPROTOBUF_EXPORT DescriptorPool {
// symbol is defined if necessary. Will create a placeholder if the type
// doesn't exist in the fallback database, or the file doesn't build
// successfully.
- Symbol CrossLinkOnDemandHelper(const string& name, bool expecting_enum) const;
+ Symbol CrossLinkOnDemandHelper(const std::string& name, bool expecting_enum) const;
// Create a placeholder FileDescriptor of the specified name
- FileDescriptor* NewPlaceholderFile(const string& name) const;
- FileDescriptor* NewPlaceholderFileWithMutexHeld(const string& name) const;
+ FileDescriptor* NewPlaceholderFile(const std::string& name) const;
+ FileDescriptor* NewPlaceholderFileWithMutexHeld(const std::string& name) const;
enum PlaceholderType {
PLACEHOLDER_MESSAGE,
@@ -1791,9 +1797,9 @@ class LIBPROTOBUF_EXPORT DescriptorPool {
PLACEHOLDER_EXTENDABLE_MESSAGE
};
// Create a placeholder Descriptor of the specified name
- Symbol NewPlaceholder(const string& name,
+ Symbol NewPlaceholder(const std::string& name,
PlaceholderType placeholder_type) const;
- Symbol NewPlaceholderWithMutexHeld(const string& name,
+ Symbol NewPlaceholderWithMutexHeld(const std::string& name,
PlaceholderType placeholder_type) const;
// If fallback_database_ is NULL, this is NULL. Otherwise, this is a mutex
@@ -1815,7 +1821,7 @@ class LIBPROTOBUF_EXPORT DescriptorPool {
bool allow_unknown_;
bool enforce_weak_;
bool disallow_enforce_utf8_;
- std::set<string> unused_import_track_files_;
+ std::set<std::string> unused_import_track_files_;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DescriptorPool);
};
@@ -1829,7 +1835,7 @@ class LIBPROTOBUF_EXPORT DescriptorPool {
// Strings fields are stored as pointers but returned as const references.
#define PROTOBUF_DEFINE_STRING_ACCESSOR(CLASS, FIELD) \
- inline const string& CLASS::FIELD() const { return *FIELD##_; }
+ inline const std::string& CLASS::FIELD() const { return *FIELD##_; }
// Arrays take an index parameter, obviously.
#define PROTOBUF_DEFINE_ARRAY_ACCESSOR(CLASS, FIELD, TYPE) \
@@ -1969,7 +1975,7 @@ inline bool Descriptor::IsReservedNumber(int number) const {
return FindReservedRangeContainingNumber(number) != NULL;
}
-inline bool Descriptor::IsReservedName(const string& name) const {
+inline bool Descriptor::IsReservedName(const std::string& name) const {
for (int i = 0; i < reserved_name_count(); i++) {
if (name == reserved_name(i)) {
return true;
@@ -1980,7 +1986,7 @@ inline bool Descriptor::IsReservedName(const string& name) const {
// Can't use PROTOBUF_DEFINE_ARRAY_ACCESSOR because reserved_names_ is actually
// an array of pointers rather than the usual array of objects.
-inline const string& Descriptor::reserved_name(int index) const {
+inline const std::string& Descriptor::reserved_name(int index) const {
return *reserved_names_[index];
}
@@ -1988,7 +1994,7 @@ inline bool EnumDescriptor::IsReservedNumber(int number) const {
return FindReservedRangeContainingNumber(number) != NULL;
}
-inline bool EnumDescriptor::IsReservedName(const string& name) const {
+inline bool EnumDescriptor::IsReservedName(const std::string& name) const {
for (int i = 0; i < reserved_name_count(); i++) {
if (name == reserved_name(i)) {
return true;
@@ -1999,7 +2005,7 @@ inline bool EnumDescriptor::IsReservedName(const string& name) const {
// Can't use PROTOBUF_DEFINE_ARRAY_ACCESSOR because reserved_names_ is actually
// an array of pointers rather than the usual array of objects.
-inline const string& EnumDescriptor::reserved_name(int index) const {
+inline const std::string& EnumDescriptor::reserved_name(int index) const {
return *reserved_names_[index];
}
@@ -2140,4 +2146,6 @@ inline const FieldDescriptor* OneofDescriptor::field(int index) const {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_DESCRIPTOR_H__
diff --git a/src/google/protobuf/descriptor.pb.cc b/src/google/protobuf/descriptor.pb.cc
index 01accf94..f85ed136 100644
--- a/src/google/protobuf/descriptor.pb.cc
+++ b/src/google/protobuf/descriptor.pb.cc
@@ -13,10 +13,6 @@
#include <google/protobuf/generated_message_reflection.h>
#include <google/protobuf/reflection_ops.h>
#include <google/protobuf/wire_format.h>
-// This is a temporary google only hack
-#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
-#include "third_party/protobuf/version.h"
-#endif
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>
@@ -168,7 +164,7 @@ static void InitDefaultsFileDescriptorSet_google_2fprotobuf_2fdescriptor_2eproto
::google::protobuf::FileDescriptorSet::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<1> scc_info_FileDescriptorSet_google_2fprotobuf_2fdescriptor_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<1> scc_info_FileDescriptorSet_google_2fprotobuf_2fdescriptor_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsFileDescriptorSet_google_2fprotobuf_2fdescriptor_2eproto}, {
&scc_info_FileDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base,}};
@@ -183,7 +179,7 @@ static void InitDefaultsFileDescriptorProto_google_2fprotobuf_2fdescriptor_2epro
::google::protobuf::FileDescriptorProto::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<6> scc_info_FileDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<6> scc_info_FileDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 6, InitDefaultsFileDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto}, {
&scc_info_DescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base,
&scc_info_EnumDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base,
@@ -203,7 +199,7 @@ static void InitDefaultsDescriptorProto_ExtensionRange_google_2fprotobuf_2fdescr
::google::protobuf::DescriptorProto_ExtensionRange::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<1> scc_info_DescriptorProto_ExtensionRange_google_2fprotobuf_2fdescriptor_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<1> scc_info_DescriptorProto_ExtensionRange_google_2fprotobuf_2fdescriptor_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsDescriptorProto_ExtensionRange_google_2fprotobuf_2fdescriptor_2eproto}, {
&scc_info_ExtensionRangeOptions_google_2fprotobuf_2fdescriptor_2eproto.base,}};
@@ -218,7 +214,7 @@ static void InitDefaultsDescriptorProto_ReservedRange_google_2fprotobuf_2fdescri
::google::protobuf::DescriptorProto_ReservedRange::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_DescriptorProto_ReservedRange_google_2fprotobuf_2fdescriptor_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_DescriptorProto_ReservedRange_google_2fprotobuf_2fdescriptor_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsDescriptorProto_ReservedRange_google_2fprotobuf_2fdescriptor_2eproto}, {}};
static void InitDefaultsDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto() {
@@ -232,7 +228,7 @@ static void InitDefaultsDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto()
::google::protobuf::DescriptorProto::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<6> scc_info_DescriptorProto_google_2fprotobuf_2fdescriptor_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<6> scc_info_DescriptorProto_google_2fprotobuf_2fdescriptor_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 6, InitDefaultsDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto}, {
&scc_info_FieldDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base,
&scc_info_EnumDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base,
@@ -252,7 +248,7 @@ static void InitDefaultsExtensionRangeOptions_google_2fprotobuf_2fdescriptor_2ep
::google::protobuf::ExtensionRangeOptions::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<1> scc_info_ExtensionRangeOptions_google_2fprotobuf_2fdescriptor_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<1> scc_info_ExtensionRangeOptions_google_2fprotobuf_2fdescriptor_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsExtensionRangeOptions_google_2fprotobuf_2fdescriptor_2eproto}, {
&scc_info_UninterpretedOption_google_2fprotobuf_2fdescriptor_2eproto.base,}};
@@ -267,7 +263,7 @@ static void InitDefaultsFieldDescriptorProto_google_2fprotobuf_2fdescriptor_2epr
::google::protobuf::FieldDescriptorProto::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<1> scc_info_FieldDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<1> scc_info_FieldDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsFieldDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto}, {
&scc_info_FieldOptions_google_2fprotobuf_2fdescriptor_2eproto.base,}};
@@ -282,7 +278,7 @@ static void InitDefaultsOneofDescriptorProto_google_2fprotobuf_2fdescriptor_2epr
::google::protobuf::OneofDescriptorProto::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<1> scc_info_OneofDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<1> scc_info_OneofDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsOneofDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto}, {
&scc_info_OneofOptions_google_2fprotobuf_2fdescriptor_2eproto.base,}};
@@ -297,7 +293,7 @@ static void InitDefaultsEnumDescriptorProto_EnumReservedRange_google_2fprotobuf_
::google::protobuf::EnumDescriptorProto_EnumReservedRange::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_EnumDescriptorProto_EnumReservedRange_google_2fprotobuf_2fdescriptor_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_EnumDescriptorProto_EnumReservedRange_google_2fprotobuf_2fdescriptor_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsEnumDescriptorProto_EnumReservedRange_google_2fprotobuf_2fdescriptor_2eproto}, {}};
static void InitDefaultsEnumDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto() {
@@ -311,7 +307,7 @@ static void InitDefaultsEnumDescriptorProto_google_2fprotobuf_2fdescriptor_2epro
::google::protobuf::EnumDescriptorProto::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<3> scc_info_EnumDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<3> scc_info_EnumDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 3, InitDefaultsEnumDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto}, {
&scc_info_EnumValueDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base,
&scc_info_EnumOptions_google_2fprotobuf_2fdescriptor_2eproto.base,
@@ -328,7 +324,7 @@ static void InitDefaultsEnumValueDescriptorProto_google_2fprotobuf_2fdescriptor_
::google::protobuf::EnumValueDescriptorProto::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<1> scc_info_EnumValueDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<1> scc_info_EnumValueDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsEnumValueDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto}, {
&scc_info_EnumValueOptions_google_2fprotobuf_2fdescriptor_2eproto.base,}};
@@ -343,7 +339,7 @@ static void InitDefaultsServiceDescriptorProto_google_2fprotobuf_2fdescriptor_2e
::google::protobuf::ServiceDescriptorProto::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<2> scc_info_ServiceDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<2> scc_info_ServiceDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 2, InitDefaultsServiceDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto}, {
&scc_info_MethodDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base,
&scc_info_ServiceOptions_google_2fprotobuf_2fdescriptor_2eproto.base,}};
@@ -359,7 +355,7 @@ static void InitDefaultsMethodDescriptorProto_google_2fprotobuf_2fdescriptor_2ep
::google::protobuf::MethodDescriptorProto::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<1> scc_info_MethodDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<1> scc_info_MethodDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsMethodDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto}, {
&scc_info_MethodOptions_google_2fprotobuf_2fdescriptor_2eproto.base,}};
@@ -374,7 +370,7 @@ static void InitDefaultsFileOptions_google_2fprotobuf_2fdescriptor_2eproto() {
::google::protobuf::FileOptions::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<1> scc_info_FileOptions_google_2fprotobuf_2fdescriptor_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<1> scc_info_FileOptions_google_2fprotobuf_2fdescriptor_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsFileOptions_google_2fprotobuf_2fdescriptor_2eproto}, {
&scc_info_UninterpretedOption_google_2fprotobuf_2fdescriptor_2eproto.base,}};
@@ -389,7 +385,7 @@ static void InitDefaultsMessageOptions_google_2fprotobuf_2fdescriptor_2eproto()
::google::protobuf::MessageOptions::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<1> scc_info_MessageOptions_google_2fprotobuf_2fdescriptor_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<1> scc_info_MessageOptions_google_2fprotobuf_2fdescriptor_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsMessageOptions_google_2fprotobuf_2fdescriptor_2eproto}, {
&scc_info_UninterpretedOption_google_2fprotobuf_2fdescriptor_2eproto.base,}};
@@ -404,7 +400,7 @@ static void InitDefaultsFieldOptions_google_2fprotobuf_2fdescriptor_2eproto() {
::google::protobuf::FieldOptions::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<1> scc_info_FieldOptions_google_2fprotobuf_2fdescriptor_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<1> scc_info_FieldOptions_google_2fprotobuf_2fdescriptor_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsFieldOptions_google_2fprotobuf_2fdescriptor_2eproto}, {
&scc_info_UninterpretedOption_google_2fprotobuf_2fdescriptor_2eproto.base,}};
@@ -419,7 +415,7 @@ static void InitDefaultsOneofOptions_google_2fprotobuf_2fdescriptor_2eproto() {
::google::protobuf::OneofOptions::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<1> scc_info_OneofOptions_google_2fprotobuf_2fdescriptor_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<1> scc_info_OneofOptions_google_2fprotobuf_2fdescriptor_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsOneofOptions_google_2fprotobuf_2fdescriptor_2eproto}, {
&scc_info_UninterpretedOption_google_2fprotobuf_2fdescriptor_2eproto.base,}};
@@ -434,7 +430,7 @@ static void InitDefaultsEnumOptions_google_2fprotobuf_2fdescriptor_2eproto() {
::google::protobuf::EnumOptions::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<1> scc_info_EnumOptions_google_2fprotobuf_2fdescriptor_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<1> scc_info_EnumOptions_google_2fprotobuf_2fdescriptor_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsEnumOptions_google_2fprotobuf_2fdescriptor_2eproto}, {
&scc_info_UninterpretedOption_google_2fprotobuf_2fdescriptor_2eproto.base,}};
@@ -449,7 +445,7 @@ static void InitDefaultsEnumValueOptions_google_2fprotobuf_2fdescriptor_2eproto(
::google::protobuf::EnumValueOptions::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<1> scc_info_EnumValueOptions_google_2fprotobuf_2fdescriptor_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<1> scc_info_EnumValueOptions_google_2fprotobuf_2fdescriptor_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsEnumValueOptions_google_2fprotobuf_2fdescriptor_2eproto}, {
&scc_info_UninterpretedOption_google_2fprotobuf_2fdescriptor_2eproto.base,}};
@@ -464,7 +460,7 @@ static void InitDefaultsServiceOptions_google_2fprotobuf_2fdescriptor_2eproto()
::google::protobuf::ServiceOptions::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<1> scc_info_ServiceOptions_google_2fprotobuf_2fdescriptor_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<1> scc_info_ServiceOptions_google_2fprotobuf_2fdescriptor_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsServiceOptions_google_2fprotobuf_2fdescriptor_2eproto}, {
&scc_info_UninterpretedOption_google_2fprotobuf_2fdescriptor_2eproto.base,}};
@@ -479,7 +475,7 @@ static void InitDefaultsMethodOptions_google_2fprotobuf_2fdescriptor_2eproto() {
::google::protobuf::MethodOptions::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<1> scc_info_MethodOptions_google_2fprotobuf_2fdescriptor_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<1> scc_info_MethodOptions_google_2fprotobuf_2fdescriptor_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsMethodOptions_google_2fprotobuf_2fdescriptor_2eproto}, {
&scc_info_UninterpretedOption_google_2fprotobuf_2fdescriptor_2eproto.base,}};
@@ -494,7 +490,7 @@ static void InitDefaultsUninterpretedOption_NamePart_google_2fprotobuf_2fdescrip
::google::protobuf::UninterpretedOption_NamePart::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_UninterpretedOption_NamePart_google_2fprotobuf_2fdescriptor_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_UninterpretedOption_NamePart_google_2fprotobuf_2fdescriptor_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsUninterpretedOption_NamePart_google_2fprotobuf_2fdescriptor_2eproto}, {}};
static void InitDefaultsUninterpretedOption_google_2fprotobuf_2fdescriptor_2eproto() {
@@ -508,7 +504,7 @@ static void InitDefaultsUninterpretedOption_google_2fprotobuf_2fdescriptor_2epro
::google::protobuf::UninterpretedOption::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<1> scc_info_UninterpretedOption_google_2fprotobuf_2fdescriptor_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<1> scc_info_UninterpretedOption_google_2fprotobuf_2fdescriptor_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsUninterpretedOption_google_2fprotobuf_2fdescriptor_2eproto}, {
&scc_info_UninterpretedOption_NamePart_google_2fprotobuf_2fdescriptor_2eproto.base,}};
@@ -523,7 +519,7 @@ static void InitDefaultsSourceCodeInfo_Location_google_2fprotobuf_2fdescriptor_2
::google::protobuf::SourceCodeInfo_Location::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_SourceCodeInfo_Location_google_2fprotobuf_2fdescriptor_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_SourceCodeInfo_Location_google_2fprotobuf_2fdescriptor_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsSourceCodeInfo_Location_google_2fprotobuf_2fdescriptor_2eproto}, {}};
static void InitDefaultsSourceCodeInfo_google_2fprotobuf_2fdescriptor_2eproto() {
@@ -537,7 +533,7 @@ static void InitDefaultsSourceCodeInfo_google_2fprotobuf_2fdescriptor_2eproto()
::google::protobuf::SourceCodeInfo::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<1> scc_info_SourceCodeInfo_google_2fprotobuf_2fdescriptor_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<1> scc_info_SourceCodeInfo_google_2fprotobuf_2fdescriptor_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsSourceCodeInfo_google_2fprotobuf_2fdescriptor_2eproto}, {
&scc_info_SourceCodeInfo_Location_google_2fprotobuf_2fdescriptor_2eproto.base,}};
@@ -552,7 +548,7 @@ static void InitDefaultsGeneratedCodeInfo_Annotation_google_2fprotobuf_2fdescrip
::google::protobuf::GeneratedCodeInfo_Annotation::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_GeneratedCodeInfo_Annotation_google_2fprotobuf_2fdescriptor_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_GeneratedCodeInfo_Annotation_google_2fprotobuf_2fdescriptor_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsGeneratedCodeInfo_Annotation_google_2fprotobuf_2fdescriptor_2eproto}, {}};
static void InitDefaultsGeneratedCodeInfo_google_2fprotobuf_2fdescriptor_2eproto() {
@@ -566,7 +562,7 @@ static void InitDefaultsGeneratedCodeInfo_google_2fprotobuf_2fdescriptor_2eproto
::google::protobuf::GeneratedCodeInfo::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<1> scc_info_GeneratedCodeInfo_google_2fprotobuf_2fdescriptor_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<1> scc_info_GeneratedCodeInfo_google_2fprotobuf_2fdescriptor_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsGeneratedCodeInfo_google_2fprotobuf_2fdescriptor_2eproto}, {
&scc_info_GeneratedCodeInfo_Annotation_google_2fprotobuf_2fdescriptor_2eproto.base,}};
@@ -604,31 +600,31 @@ void InitDefaults_google_2fprotobuf_2fdescriptor_2eproto() {
const ::google::protobuf::EnumDescriptor* file_level_enum_descriptors_google_2fprotobuf_2fdescriptor_2eproto[6];
constexpr ::google::protobuf::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fdescriptor_2eproto = nullptr;
-const ::google::protobuf::uint32 TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileDescriptorSet, _has_bits_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileDescriptorSet, _internal_metadata_),
+const ::google::protobuf::uint32 TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FileDescriptorSet, _has_bits_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FileDescriptorSet, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileDescriptorSet, file_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FileDescriptorSet, file_),
~0u,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileDescriptorProto, _has_bits_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileDescriptorProto, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FileDescriptorProto, _has_bits_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FileDescriptorProto, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileDescriptorProto, name_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileDescriptorProto, package_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileDescriptorProto, dependency_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileDescriptorProto, public_dependency_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileDescriptorProto, weak_dependency_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileDescriptorProto, message_type_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileDescriptorProto, enum_type_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileDescriptorProto, service_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileDescriptorProto, extension_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileDescriptorProto, options_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileDescriptorProto, source_code_info_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileDescriptorProto, syntax_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FileDescriptorProto, name_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FileDescriptorProto, package_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FileDescriptorProto, dependency_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FileDescriptorProto, public_dependency_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FileDescriptorProto, weak_dependency_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FileDescriptorProto, message_type_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FileDescriptorProto, enum_type_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FileDescriptorProto, service_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FileDescriptorProto, extension_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FileDescriptorProto, options_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FileDescriptorProto, source_code_info_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FileDescriptorProto, syntax_),
0,
1,
~0u,
@@ -641,41 +637,41 @@ const ::google::protobuf::uint32 TableStruct_google_2fprotobuf_2fdescriptor_2epr
3,
4,
2,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::DescriptorProto_ExtensionRange, _has_bits_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::DescriptorProto_ExtensionRange, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::DescriptorProto_ExtensionRange, _has_bits_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::DescriptorProto_ExtensionRange, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::DescriptorProto_ExtensionRange, start_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::DescriptorProto_ExtensionRange, end_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::DescriptorProto_ExtensionRange, options_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::DescriptorProto_ExtensionRange, start_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::DescriptorProto_ExtensionRange, end_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::DescriptorProto_ExtensionRange, options_),
1,
2,
0,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::DescriptorProto_ReservedRange, _has_bits_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::DescriptorProto_ReservedRange, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::DescriptorProto_ReservedRange, _has_bits_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::DescriptorProto_ReservedRange, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::DescriptorProto_ReservedRange, start_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::DescriptorProto_ReservedRange, end_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::DescriptorProto_ReservedRange, start_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::DescriptorProto_ReservedRange, end_),
0,
1,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::DescriptorProto, _has_bits_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::DescriptorProto, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::DescriptorProto, _has_bits_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::DescriptorProto, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::DescriptorProto, name_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::DescriptorProto, field_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::DescriptorProto, extension_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::DescriptorProto, nested_type_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::DescriptorProto, enum_type_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::DescriptorProto, extension_range_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::DescriptorProto, oneof_decl_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::DescriptorProto, options_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::DescriptorProto, reserved_range_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::DescriptorProto, reserved_name_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::DescriptorProto, name_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::DescriptorProto, field_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::DescriptorProto, extension_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::DescriptorProto, nested_type_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::DescriptorProto, enum_type_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::DescriptorProto, extension_range_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::DescriptorProto, oneof_decl_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::DescriptorProto, options_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::DescriptorProto, reserved_range_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::DescriptorProto, reserved_name_),
0,
~0u,
~0u,
@@ -686,28 +682,28 @@ const ::google::protobuf::uint32 TableStruct_google_2fprotobuf_2fdescriptor_2epr
1,
~0u,
~0u,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::ExtensionRangeOptions, _has_bits_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::ExtensionRangeOptions, _internal_metadata_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::ExtensionRangeOptions, _extensions_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::ExtensionRangeOptions, _has_bits_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::ExtensionRangeOptions, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::ExtensionRangeOptions, _extensions_),
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::ExtensionRangeOptions, uninterpreted_option_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::ExtensionRangeOptions, uninterpreted_option_),
~0u,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldDescriptorProto, _has_bits_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldDescriptorProto, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FieldDescriptorProto, _has_bits_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FieldDescriptorProto, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldDescriptorProto, name_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldDescriptorProto, number_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldDescriptorProto, label_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldDescriptorProto, type_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldDescriptorProto, type_name_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldDescriptorProto, extendee_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldDescriptorProto, default_value_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldDescriptorProto, oneof_index_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldDescriptorProto, json_name_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldDescriptorProto, options_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FieldDescriptorProto, name_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FieldDescriptorProto, number_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FieldDescriptorProto, label_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FieldDescriptorProto, type_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FieldDescriptorProto, type_name_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FieldDescriptorProto, extendee_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FieldDescriptorProto, default_value_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FieldDescriptorProto, oneof_index_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FieldDescriptorProto, json_name_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FieldDescriptorProto, options_),
0,
6,
8,
@@ -718,104 +714,104 @@ const ::google::protobuf::uint32 TableStruct_google_2fprotobuf_2fdescriptor_2epr
7,
4,
5,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::OneofDescriptorProto, _has_bits_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::OneofDescriptorProto, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::OneofDescriptorProto, _has_bits_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::OneofDescriptorProto, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::OneofDescriptorProto, name_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::OneofDescriptorProto, options_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::OneofDescriptorProto, name_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::OneofDescriptorProto, options_),
0,
1,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumDescriptorProto_EnumReservedRange, _has_bits_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumDescriptorProto_EnumReservedRange, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::EnumDescriptorProto_EnumReservedRange, _has_bits_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::EnumDescriptorProto_EnumReservedRange, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumDescriptorProto_EnumReservedRange, start_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumDescriptorProto_EnumReservedRange, end_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::EnumDescriptorProto_EnumReservedRange, start_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::EnumDescriptorProto_EnumReservedRange, end_),
0,
1,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumDescriptorProto, _has_bits_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumDescriptorProto, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::EnumDescriptorProto, _has_bits_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::EnumDescriptorProto, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumDescriptorProto, name_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumDescriptorProto, value_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumDescriptorProto, options_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumDescriptorProto, reserved_range_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumDescriptorProto, reserved_name_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::EnumDescriptorProto, name_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::EnumDescriptorProto, value_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::EnumDescriptorProto, options_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::EnumDescriptorProto, reserved_range_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::EnumDescriptorProto, reserved_name_),
0,
~0u,
1,
~0u,
~0u,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumValueDescriptorProto, _has_bits_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumValueDescriptorProto, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::EnumValueDescriptorProto, _has_bits_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::EnumValueDescriptorProto, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumValueDescriptorProto, name_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumValueDescriptorProto, number_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumValueDescriptorProto, options_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::EnumValueDescriptorProto, name_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::EnumValueDescriptorProto, number_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::EnumValueDescriptorProto, options_),
0,
2,
1,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::ServiceDescriptorProto, _has_bits_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::ServiceDescriptorProto, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::ServiceDescriptorProto, _has_bits_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::ServiceDescriptorProto, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::ServiceDescriptorProto, name_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::ServiceDescriptorProto, method_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::ServiceDescriptorProto, options_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::ServiceDescriptorProto, name_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::ServiceDescriptorProto, method_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::ServiceDescriptorProto, options_),
0,
~0u,
1,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::MethodDescriptorProto, _has_bits_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::MethodDescriptorProto, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::MethodDescriptorProto, _has_bits_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::MethodDescriptorProto, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::MethodDescriptorProto, name_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::MethodDescriptorProto, input_type_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::MethodDescriptorProto, output_type_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::MethodDescriptorProto, options_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::MethodDescriptorProto, client_streaming_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::MethodDescriptorProto, server_streaming_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::MethodDescriptorProto, name_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::MethodDescriptorProto, input_type_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::MethodDescriptorProto, output_type_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::MethodDescriptorProto, options_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::MethodDescriptorProto, client_streaming_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::MethodDescriptorProto, server_streaming_),
0,
1,
2,
3,
4,
5,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileOptions, _has_bits_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileOptions, _internal_metadata_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileOptions, _extensions_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FileOptions, _has_bits_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FileOptions, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FileOptions, _extensions_),
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileOptions, java_package_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileOptions, java_outer_classname_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileOptions, java_multiple_files_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileOptions, java_generate_equals_and_hash_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileOptions, java_string_check_utf8_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileOptions, optimize_for_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileOptions, go_package_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileOptions, cc_generic_services_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileOptions, java_generic_services_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileOptions, py_generic_services_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileOptions, php_generic_services_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileOptions, deprecated_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileOptions, cc_enable_arenas_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileOptions, objc_class_prefix_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FileOptions, csharp_namespace_),
- 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_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FileOptions, java_package_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FileOptions, java_outer_classname_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FileOptions, java_multiple_files_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FileOptions, java_generate_equals_and_hash_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FileOptions, java_string_check_utf8_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FileOptions, optimize_for_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FileOptions, go_package_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FileOptions, cc_generic_services_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FileOptions, java_generic_services_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FileOptions, py_generic_services_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FileOptions, php_generic_services_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FileOptions, deprecated_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FileOptions, cc_enable_arenas_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FileOptions, objc_class_prefix_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FileOptions, csharp_namespace_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FileOptions, swift_prefix_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FileOptions, php_class_prefix_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FileOptions, php_namespace_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FileOptions, php_metadata_namespace_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FileOptions, ruby_package_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FileOptions, uninterpreted_option_),
0,
1,
10,
@@ -837,33 +833,33 @@ const ::google::protobuf::uint32 TableStruct_google_2fprotobuf_2fdescriptor_2epr
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_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::MessageOptions, _extensions_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::MessageOptions, _has_bits_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::MessageOptions, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::MessageOptions, _extensions_),
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::MessageOptions, message_set_wire_format_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::MessageOptions, no_standard_descriptor_accessor_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::MessageOptions, deprecated_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::MessageOptions, map_entry_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::MessageOptions, uninterpreted_option_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::MessageOptions, message_set_wire_format_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::MessageOptions, no_standard_descriptor_accessor_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::MessageOptions, deprecated_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::MessageOptions, map_entry_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::MessageOptions, uninterpreted_option_),
0,
1,
2,
3,
~0u,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldOptions, _has_bits_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldOptions, _internal_metadata_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldOptions, _extensions_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FieldOptions, _has_bits_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FieldOptions, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FieldOptions, _extensions_),
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldOptions, ctype_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldOptions, packed_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldOptions, jstype_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldOptions, lazy_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldOptions, deprecated_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldOptions, weak_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldOptions, uninterpreted_option_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FieldOptions, ctype_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FieldOptions, packed_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FieldOptions, jstype_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FieldOptions, lazy_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FieldOptions, deprecated_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FieldOptions, weak_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FieldOptions, uninterpreted_option_),
0,
1,
5,
@@ -871,74 +867,74 @@ const ::google::protobuf::uint32 TableStruct_google_2fprotobuf_2fdescriptor_2epr
3,
4,
~0u,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::OneofOptions, _has_bits_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::OneofOptions, _internal_metadata_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::OneofOptions, _extensions_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::OneofOptions, _has_bits_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::OneofOptions, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::OneofOptions, _extensions_),
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::OneofOptions, uninterpreted_option_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::OneofOptions, uninterpreted_option_),
~0u,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumOptions, _has_bits_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumOptions, _internal_metadata_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumOptions, _extensions_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::EnumOptions, _has_bits_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::EnumOptions, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::EnumOptions, _extensions_),
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumOptions, allow_alias_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumOptions, deprecated_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumOptions, uninterpreted_option_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::EnumOptions, allow_alias_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::EnumOptions, deprecated_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::EnumOptions, uninterpreted_option_),
0,
1,
~0u,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumValueOptions, _has_bits_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumValueOptions, _internal_metadata_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumValueOptions, _extensions_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::EnumValueOptions, _has_bits_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::EnumValueOptions, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::EnumValueOptions, _extensions_),
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumValueOptions, deprecated_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumValueOptions, uninterpreted_option_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::EnumValueOptions, deprecated_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::EnumValueOptions, uninterpreted_option_),
0,
~0u,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::ServiceOptions, _has_bits_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::ServiceOptions, _internal_metadata_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::ServiceOptions, _extensions_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::ServiceOptions, _has_bits_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::ServiceOptions, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::ServiceOptions, _extensions_),
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::ServiceOptions, deprecated_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::ServiceOptions, uninterpreted_option_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::ServiceOptions, deprecated_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::ServiceOptions, uninterpreted_option_),
0,
~0u,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::MethodOptions, _has_bits_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::MethodOptions, _internal_metadata_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::MethodOptions, _extensions_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::MethodOptions, _has_bits_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::MethodOptions, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::MethodOptions, _extensions_),
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::MethodOptions, deprecated_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::MethodOptions, idempotency_level_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::MethodOptions, uninterpreted_option_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::MethodOptions, deprecated_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::MethodOptions, idempotency_level_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::MethodOptions, uninterpreted_option_),
0,
1,
~0u,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::UninterpretedOption_NamePart, _has_bits_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::UninterpretedOption_NamePart, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::UninterpretedOption_NamePart, _has_bits_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::UninterpretedOption_NamePart, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::UninterpretedOption_NamePart, name_part_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::UninterpretedOption_NamePart, is_extension_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::UninterpretedOption_NamePart, name_part_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::UninterpretedOption_NamePart, is_extension_),
0,
1,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::UninterpretedOption, _has_bits_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::UninterpretedOption, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::UninterpretedOption, _has_bits_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::UninterpretedOption, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::UninterpretedOption, name_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::UninterpretedOption, identifier_value_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::UninterpretedOption, positive_int_value_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::UninterpretedOption, negative_int_value_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::UninterpretedOption, double_value_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::UninterpretedOption, string_value_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::UninterpretedOption, aggregate_value_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::UninterpretedOption, name_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::UninterpretedOption, identifier_value_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::UninterpretedOption, positive_int_value_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::UninterpretedOption, negative_int_value_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::UninterpretedOption, double_value_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::UninterpretedOption, string_value_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::UninterpretedOption, aggregate_value_),
~0u,
0,
3,
@@ -946,50 +942,50 @@ const ::google::protobuf::uint32 TableStruct_google_2fprotobuf_2fdescriptor_2epr
5,
1,
2,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::SourceCodeInfo_Location, _has_bits_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::SourceCodeInfo_Location, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::SourceCodeInfo_Location, _has_bits_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::SourceCodeInfo_Location, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::SourceCodeInfo_Location, path_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::SourceCodeInfo_Location, span_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::SourceCodeInfo_Location, leading_comments_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::SourceCodeInfo_Location, trailing_comments_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::SourceCodeInfo_Location, leading_detached_comments_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::SourceCodeInfo_Location, path_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::SourceCodeInfo_Location, span_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::SourceCodeInfo_Location, leading_comments_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::SourceCodeInfo_Location, trailing_comments_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::SourceCodeInfo_Location, leading_detached_comments_),
~0u,
~0u,
0,
1,
~0u,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::SourceCodeInfo, _has_bits_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::SourceCodeInfo, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::SourceCodeInfo, _has_bits_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::SourceCodeInfo, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::SourceCodeInfo, location_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::SourceCodeInfo, location_),
~0u,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::GeneratedCodeInfo_Annotation, _has_bits_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::GeneratedCodeInfo_Annotation, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::GeneratedCodeInfo_Annotation, _has_bits_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::GeneratedCodeInfo_Annotation, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::GeneratedCodeInfo_Annotation, path_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::GeneratedCodeInfo_Annotation, source_file_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::GeneratedCodeInfo_Annotation, begin_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::GeneratedCodeInfo_Annotation, end_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::GeneratedCodeInfo_Annotation, path_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::GeneratedCodeInfo_Annotation, source_file_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::GeneratedCodeInfo_Annotation, begin_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::GeneratedCodeInfo_Annotation, end_),
~0u,
0,
1,
2,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::GeneratedCodeInfo, _has_bits_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::GeneratedCodeInfo, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::GeneratedCodeInfo, _has_bits_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::GeneratedCodeInfo, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::GeneratedCodeInfo, annotation_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::GeneratedCodeInfo, annotation_),
~0u,
};
-static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
+static const ::google::protobuf::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
{ 0, 6, sizeof(::google::protobuf::FileDescriptorSet)},
{ 7, 24, sizeof(::google::protobuf::FileDescriptorProto)},
{ 36, 44, sizeof(::google::protobuf::DescriptorProto_ExtensionRange)},
@@ -1477,29 +1473,31 @@ const char* FileDescriptorSet::_InternalParse(const char* begin, const char* end
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// repeated .google.protobuf.FileDescriptorProto file = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 10) goto handle_unusual;
do {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::FileDescriptorProto::_InternalParse;
object = msg->add_file();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 255) == 10 && (ptr += 1));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 10 && (ptr += 1));
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
@@ -1510,8 +1508,6 @@ const char* FileDescriptorSet::_InternalParse(const char* begin, const char* end
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -1523,7 +1519,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool FileDescriptorSet::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.FileDescriptorSet)
for (;;) {
@@ -1938,14 +1934,13 @@ const char* FileDescriptorProto::_InternalParse(const char* begin, const char* e
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// optional string name = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 10) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.FileDescriptorProto.name");
parser_till_end = ::google::protobuf::internal::StringParserUTF8Verify;
::std::string* str = msg->mutable_name();
@@ -1953,15 +1948,15 @@ const char* FileDescriptorProto::_InternalParse(const char* begin, const char* e
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// optional string package = 2;
case 2: {
if (static_cast<::google::protobuf::uint8>(tag) != 18) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.FileDescriptorProto.package");
parser_till_end = ::google::protobuf::internal::StringParserUTF8Verify;
::std::string* str = msg->mutable_package();
@@ -1969,8 +1964,8 @@ const char* FileDescriptorProto::_InternalParse(const char* begin, const char* e
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// repeated string dependency = 3;
@@ -1978,7 +1973,7 @@ const char* FileDescriptorProto::_InternalParse(const char* begin, const char* e
if (static_cast<::google::protobuf::uint8>(tag) != 26) goto handle_unusual;
do {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.FileDescriptorProto.dependency");
parser_till_end = ::google::protobuf::internal::StringParserUTF8Verify;
::std::string* str = msg->add_dependency();
@@ -1986,10 +1981,10 @@ const char* FileDescriptorProto::_InternalParse(const char* begin, const char* e
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 255) == 26 && (ptr += 1));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 26 && (ptr += 1));
break;
}
// repeated .google.protobuf.DescriptorProto message_type = 4;
@@ -1997,15 +1992,17 @@ const char* FileDescriptorProto::_InternalParse(const char* begin, const char* e
if (static_cast<::google::protobuf::uint8>(tag) != 34) goto handle_unusual;
do {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::DescriptorProto::_InternalParse;
object = msg->add_message_type();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 255) == 34 && (ptr += 1));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 34 && (ptr += 1));
break;
}
// repeated .google.protobuf.EnumDescriptorProto enum_type = 5;
@@ -2013,15 +2010,17 @@ const char* FileDescriptorProto::_InternalParse(const char* begin, const char* e
if (static_cast<::google::protobuf::uint8>(tag) != 42) goto handle_unusual;
do {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::EnumDescriptorProto::_InternalParse;
object = msg->add_enum_type();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 255) == 42 && (ptr += 1));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 42 && (ptr += 1));
break;
}
// repeated .google.protobuf.ServiceDescriptorProto service = 6;
@@ -2029,15 +2028,17 @@ const char* FileDescriptorProto::_InternalParse(const char* begin, const char* e
if (static_cast<::google::protobuf::uint8>(tag) != 50) goto handle_unusual;
do {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::ServiceDescriptorProto::_InternalParse;
object = msg->add_service();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 255) == 50 && (ptr += 1));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 50 && (ptr += 1));
break;
}
// repeated .google.protobuf.FieldDescriptorProto extension = 7;
@@ -2045,27 +2046,31 @@ const char* FileDescriptorProto::_InternalParse(const char* begin, const char* e
if (static_cast<::google::protobuf::uint8>(tag) != 58) goto handle_unusual;
do {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::FieldDescriptorProto::_InternalParse;
object = msg->add_extension();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 255) == 58 && (ptr += 1));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 58 && (ptr += 1));
break;
}
// optional .google.protobuf.FileOptions options = 8;
case 8: {
if (static_cast<::google::protobuf::uint8>(tag) != 66) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::FileOptions::_InternalParse;
object = msg->mutable_options();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
break;
}
@@ -2073,12 +2078,14 @@ const char* FileDescriptorProto::_InternalParse(const char* begin, const char* e
case 9: {
if (static_cast<::google::protobuf::uint8>(tag) != 74) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::SourceCodeInfo::_InternalParse;
object = msg->mutable_source_code_info();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
break;
}
@@ -2088,21 +2095,21 @@ const char* FileDescriptorProto::_InternalParse(const char* begin, const char* e
do {
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
::google::protobuf::int32 value = val;
msg->add_public_dependency(value);
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 255) == 80 && (ptr += 1));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 80 && (ptr += 1));
break;
} else if (static_cast<::google::protobuf::uint8>(tag) != 82) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::internal::PackedInt32Parser;
object = msg->mutable_public_dependency();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// repeated int32 weak_dependency = 11;
@@ -2111,28 +2118,28 @@ const char* FileDescriptorProto::_InternalParse(const char* begin, const char* e
do {
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
::google::protobuf::int32 value = val;
msg->add_weak_dependency(value);
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 255) == 88 && (ptr += 1));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 88 && (ptr += 1));
break;
} else if (static_cast<::google::protobuf::uint8>(tag) != 90) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::internal::PackedInt32Parser;
object = msg->mutable_weak_dependency();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// optional string syntax = 12;
case 12: {
if (static_cast<::google::protobuf::uint8>(tag) != 98) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.FileDescriptorProto.syntax");
parser_till_end = ::google::protobuf::internal::StringParserUTF8Verify;
::std::string* str = msg->mutable_syntax();
@@ -2140,14 +2147,15 @@ const char* FileDescriptorProto::_InternalParse(const char* begin, const char* e
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
@@ -2158,8 +2166,6 @@ const char* FileDescriptorProto::_InternalParse(const char* begin, const char* e
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -2171,7 +2177,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool FileDescriptorProto::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.FileDescriptorProto)
for (;;) {
@@ -2967,15 +2973,14 @@ const char* DescriptorProto_ExtensionRange::_InternalParse(const char* begin, co
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// optional int32 start = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 8) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
::google::protobuf::int32 value = val;
msg->set_start(value);
break;
@@ -2985,7 +2990,7 @@ const char* DescriptorProto_ExtensionRange::_InternalParse(const char* begin, co
if (static_cast<::google::protobuf::uint8>(tag) != 16) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
::google::protobuf::int32 value = val;
msg->set_end(value);
break;
@@ -2994,19 +2999,22 @@ const char* DescriptorProto_ExtensionRange::_InternalParse(const char* begin, co
case 3: {
if (static_cast<::google::protobuf::uint8>(tag) != 26) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::ExtensionRangeOptions::_InternalParse;
object = msg->mutable_options();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
@@ -3017,8 +3025,6 @@ const char* DescriptorProto_ExtensionRange::_InternalParse(const char* begin, co
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -3030,7 +3036,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool DescriptorProto_ExtensionRange::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.DescriptorProto.ExtensionRange)
for (;;) {
@@ -3392,15 +3398,14 @@ const char* DescriptorProto_ReservedRange::_InternalParse(const char* begin, con
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// optional int32 start = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 8) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
::google::protobuf::int32 value = val;
msg->set_start(value);
break;
@@ -3410,15 +3415,16 @@ const char* DescriptorProto_ReservedRange::_InternalParse(const char* begin, con
if (static_cast<::google::protobuf::uint8>(tag) != 16) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
::google::protobuf::int32 value = val;
msg->set_end(value);
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
@@ -3429,8 +3435,6 @@ const char* DescriptorProto_ReservedRange::_InternalParse(const char* begin, con
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -3442,7 +3446,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool DescriptorProto_ReservedRange::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.DescriptorProto.ReservedRange)
for (;;) {
@@ -3832,14 +3836,13 @@ const char* DescriptorProto::_InternalParse(const char* begin, const char* end,
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// optional string name = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 10) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.DescriptorProto.name");
parser_till_end = ::google::protobuf::internal::StringParserUTF8Verify;
::std::string* str = msg->mutable_name();
@@ -3847,8 +3850,8 @@ const char* DescriptorProto::_InternalParse(const char* begin, const char* end,
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// repeated .google.protobuf.FieldDescriptorProto field = 2;
@@ -3856,15 +3859,17 @@ const char* DescriptorProto::_InternalParse(const char* begin, const char* end,
if (static_cast<::google::protobuf::uint8>(tag) != 18) goto handle_unusual;
do {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::FieldDescriptorProto::_InternalParse;
object = msg->add_field();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 255) == 18 && (ptr += 1));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 18 && (ptr += 1));
break;
}
// repeated .google.protobuf.DescriptorProto nested_type = 3;
@@ -3872,15 +3877,17 @@ const char* DescriptorProto::_InternalParse(const char* begin, const char* end,
if (static_cast<::google::protobuf::uint8>(tag) != 26) goto handle_unusual;
do {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::DescriptorProto::_InternalParse;
object = msg->add_nested_type();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 255) == 26 && (ptr += 1));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 26 && (ptr += 1));
break;
}
// repeated .google.protobuf.EnumDescriptorProto enum_type = 4;
@@ -3888,15 +3895,17 @@ const char* DescriptorProto::_InternalParse(const char* begin, const char* end,
if (static_cast<::google::protobuf::uint8>(tag) != 34) goto handle_unusual;
do {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::EnumDescriptorProto::_InternalParse;
object = msg->add_enum_type();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 255) == 34 && (ptr += 1));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 34 && (ptr += 1));
break;
}
// repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5;
@@ -3904,15 +3913,17 @@ const char* DescriptorProto::_InternalParse(const char* begin, const char* end,
if (static_cast<::google::protobuf::uint8>(tag) != 42) goto handle_unusual;
do {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::DescriptorProto_ExtensionRange::_InternalParse;
object = msg->add_extension_range();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 255) == 42 && (ptr += 1));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 42 && (ptr += 1));
break;
}
// repeated .google.protobuf.FieldDescriptorProto extension = 6;
@@ -3920,27 +3931,31 @@ const char* DescriptorProto::_InternalParse(const char* begin, const char* end,
if (static_cast<::google::protobuf::uint8>(tag) != 50) goto handle_unusual;
do {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::FieldDescriptorProto::_InternalParse;
object = msg->add_extension();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 255) == 50 && (ptr += 1));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 50 && (ptr += 1));
break;
}
// optional .google.protobuf.MessageOptions options = 7;
case 7: {
if (static_cast<::google::protobuf::uint8>(tag) != 58) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::MessageOptions::_InternalParse;
object = msg->mutable_options();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
break;
}
@@ -3949,15 +3964,17 @@ const char* DescriptorProto::_InternalParse(const char* begin, const char* end,
if (static_cast<::google::protobuf::uint8>(tag) != 66) goto handle_unusual;
do {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::OneofDescriptorProto::_InternalParse;
object = msg->add_oneof_decl();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 255) == 66 && (ptr += 1));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 66 && (ptr += 1));
break;
}
// repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9;
@@ -3965,15 +3982,17 @@ const char* DescriptorProto::_InternalParse(const char* begin, const char* end,
if (static_cast<::google::protobuf::uint8>(tag) != 74) goto handle_unusual;
do {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::DescriptorProto_ReservedRange::_InternalParse;
object = msg->add_reserved_range();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 255) == 74 && (ptr += 1));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 74 && (ptr += 1));
break;
}
// repeated string reserved_name = 10;
@@ -3981,7 +4000,7 @@ const char* DescriptorProto::_InternalParse(const char* begin, const char* end,
if (static_cast<::google::protobuf::uint8>(tag) != 82) goto handle_unusual;
do {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.DescriptorProto.reserved_name");
parser_till_end = ::google::protobuf::internal::StringParserUTF8Verify;
::std::string* str = msg->add_reserved_name();
@@ -3989,16 +4008,17 @@ const char* DescriptorProto::_InternalParse(const char* begin, const char* end,
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 255) == 82 && (ptr += 1));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 82 && (ptr += 1));
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
@@ -4009,8 +4029,6 @@ const char* DescriptorProto::_InternalParse(const char* begin, const char* end,
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -4022,7 +4040,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool DescriptorProto::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.DescriptorProto)
for (;;) {
@@ -4691,29 +4709,31 @@ const char* ExtensionRangeOptions::_InternalParse(const char* begin, const char*
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
case 999: {
if (static_cast<::google::protobuf::uint8>(tag) != 58) goto handle_unusual;
do {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::UninterpretedOption::_InternalParse;
object = msg->add_uninterpreted_option();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 65535) == 16058 && (ptr += 2));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 65535) == 16058 && (ptr += 2));
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
if ((8000u <= tag)) {
@@ -4731,8 +4751,6 @@ const char* ExtensionRangeOptions::_InternalParse(const char* begin, const char*
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -4744,7 +4762,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool ExtensionRangeOptions::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.ExtensionRangeOptions)
for (;;) {
@@ -5176,14 +5194,13 @@ const char* FieldDescriptorProto::_InternalParse(const char* begin, const char*
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// optional string name = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 10) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.FieldDescriptorProto.name");
parser_till_end = ::google::protobuf::internal::StringParserUTF8Verify;
::std::string* str = msg->mutable_name();
@@ -5191,15 +5208,15 @@ const char* FieldDescriptorProto::_InternalParse(const char* begin, const char*
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// optional string extendee = 2;
case 2: {
if (static_cast<::google::protobuf::uint8>(tag) != 18) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.FieldDescriptorProto.extendee");
parser_till_end = ::google::protobuf::internal::StringParserUTF8Verify;
::std::string* str = msg->mutable_extendee();
@@ -5207,8 +5224,8 @@ const char* FieldDescriptorProto::_InternalParse(const char* begin, const char*
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// optional int32 number = 3;
@@ -5216,7 +5233,7 @@ const char* FieldDescriptorProto::_InternalParse(const char* begin, const char*
if (static_cast<::google::protobuf::uint8>(tag) != 24) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
::google::protobuf::int32 value = val;
msg->set_number(value);
break;
@@ -5226,7 +5243,7 @@ const char* FieldDescriptorProto::_InternalParse(const char* begin, const char*
if (static_cast<::google::protobuf::uint8>(tag) != 32) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
if (!::google::protobuf::FieldDescriptorProto_Label_IsValid(val)) {
::google::protobuf::internal::WriteVarint(4, val, msg->mutable_unknown_fields());
break;
@@ -5240,7 +5257,7 @@ const char* FieldDescriptorProto::_InternalParse(const char* begin, const char*
if (static_cast<::google::protobuf::uint8>(tag) != 40) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
if (!::google::protobuf::FieldDescriptorProto_Type_IsValid(val)) {
::google::protobuf::internal::WriteVarint(5, val, msg->mutable_unknown_fields());
break;
@@ -5253,7 +5270,7 @@ const char* FieldDescriptorProto::_InternalParse(const char* begin, const char*
case 6: {
if (static_cast<::google::protobuf::uint8>(tag) != 50) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.FieldDescriptorProto.type_name");
parser_till_end = ::google::protobuf::internal::StringParserUTF8Verify;
::std::string* str = msg->mutable_type_name();
@@ -5261,15 +5278,15 @@ const char* FieldDescriptorProto::_InternalParse(const char* begin, const char*
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// optional string default_value = 7;
case 7: {
if (static_cast<::google::protobuf::uint8>(tag) != 58) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.FieldDescriptorProto.default_value");
parser_till_end = ::google::protobuf::internal::StringParserUTF8Verify;
::std::string* str = msg->mutable_default_value();
@@ -5277,20 +5294,22 @@ const char* FieldDescriptorProto::_InternalParse(const char* begin, const char*
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// optional .google.protobuf.FieldOptions options = 8;
case 8: {
if (static_cast<::google::protobuf::uint8>(tag) != 66) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::FieldOptions::_InternalParse;
object = msg->mutable_options();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
break;
}
@@ -5299,7 +5318,7 @@ const char* FieldDescriptorProto::_InternalParse(const char* begin, const char*
if (static_cast<::google::protobuf::uint8>(tag) != 72) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
::google::protobuf::int32 value = val;
msg->set_oneof_index(value);
break;
@@ -5308,7 +5327,7 @@ const char* FieldDescriptorProto::_InternalParse(const char* begin, const char*
case 10: {
if (static_cast<::google::protobuf::uint8>(tag) != 82) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.FieldDescriptorProto.json_name");
parser_till_end = ::google::protobuf::internal::StringParserUTF8Verify;
::std::string* str = msg->mutable_json_name();
@@ -5316,14 +5335,15 @@ const char* FieldDescriptorProto::_InternalParse(const char* begin, const char*
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
@@ -5334,8 +5354,6 @@ const char* FieldDescriptorProto::_InternalParse(const char* begin, const char*
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -5347,7 +5365,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool FieldDescriptorProto::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.FieldDescriptorProto)
for (;;) {
@@ -6070,14 +6088,13 @@ const char* OneofDescriptorProto::_InternalParse(const char* begin, const char*
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// optional string name = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 10) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.OneofDescriptorProto.name");
parser_till_end = ::google::protobuf::internal::StringParserUTF8Verify;
::std::string* str = msg->mutable_name();
@@ -6085,27 +6102,30 @@ const char* OneofDescriptorProto::_InternalParse(const char* begin, const char*
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// optional .google.protobuf.OneofOptions options = 2;
case 2: {
if (static_cast<::google::protobuf::uint8>(tag) != 18) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::OneofOptions::_InternalParse;
object = msg->mutable_options();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
@@ -6116,8 +6136,6 @@ const char* OneofDescriptorProto::_InternalParse(const char* begin, const char*
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -6129,7 +6147,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool OneofDescriptorProto::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.OneofDescriptorProto)
for (;;) {
@@ -6470,15 +6488,14 @@ const char* EnumDescriptorProto_EnumReservedRange::_InternalParse(const char* be
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// optional int32 start = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 8) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
::google::protobuf::int32 value = val;
msg->set_start(value);
break;
@@ -6488,15 +6505,16 @@ const char* EnumDescriptorProto_EnumReservedRange::_InternalParse(const char* be
if (static_cast<::google::protobuf::uint8>(tag) != 16) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
::google::protobuf::int32 value = val;
msg->set_end(value);
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
@@ -6507,8 +6525,6 @@ const char* EnumDescriptorProto_EnumReservedRange::_InternalParse(const char* be
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -6520,7 +6536,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool EnumDescriptorProto_EnumReservedRange::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.EnumDescriptorProto.EnumReservedRange)
for (;;) {
@@ -6890,14 +6906,13 @@ const char* EnumDescriptorProto::_InternalParse(const char* begin, const char* e
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// optional string name = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 10) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.EnumDescriptorProto.name");
parser_till_end = ::google::protobuf::internal::StringParserUTF8Verify;
::std::string* str = msg->mutable_name();
@@ -6905,8 +6920,8 @@ const char* EnumDescriptorProto::_InternalParse(const char* begin, const char* e
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// repeated .google.protobuf.EnumValueDescriptorProto value = 2;
@@ -6914,27 +6929,31 @@ const char* EnumDescriptorProto::_InternalParse(const char* begin, const char* e
if (static_cast<::google::protobuf::uint8>(tag) != 18) goto handle_unusual;
do {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::EnumValueDescriptorProto::_InternalParse;
object = msg->add_value();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 255) == 18 && (ptr += 1));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 18 && (ptr += 1));
break;
}
// optional .google.protobuf.EnumOptions options = 3;
case 3: {
if (static_cast<::google::protobuf::uint8>(tag) != 26) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::EnumOptions::_InternalParse;
object = msg->mutable_options();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
break;
}
@@ -6943,15 +6962,17 @@ const char* EnumDescriptorProto::_InternalParse(const char* begin, const char* e
if (static_cast<::google::protobuf::uint8>(tag) != 34) goto handle_unusual;
do {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::EnumDescriptorProto_EnumReservedRange::_InternalParse;
object = msg->add_reserved_range();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 255) == 34 && (ptr += 1));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 34 && (ptr += 1));
break;
}
// repeated string reserved_name = 5;
@@ -6959,7 +6980,7 @@ const char* EnumDescriptorProto::_InternalParse(const char* begin, const char* e
if (static_cast<::google::protobuf::uint8>(tag) != 42) goto handle_unusual;
do {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.EnumDescriptorProto.reserved_name");
parser_till_end = ::google::protobuf::internal::StringParserUTF8Verify;
::std::string* str = msg->add_reserved_name();
@@ -6967,16 +6988,17 @@ const char* EnumDescriptorProto::_InternalParse(const char* begin, const char* e
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 255) == 42 && (ptr += 1));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 42 && (ptr += 1));
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
@@ -6987,8 +7009,6 @@ const char* EnumDescriptorProto::_InternalParse(const char* begin, const char* e
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -7000,7 +7020,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool EnumDescriptorProto::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.EnumDescriptorProto)
for (;;) {
@@ -7512,14 +7532,13 @@ const char* EnumValueDescriptorProto::_InternalParse(const char* begin, const ch
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// optional string name = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 10) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.EnumValueDescriptorProto.name");
parser_till_end = ::google::protobuf::internal::StringParserUTF8Verify;
::std::string* str = msg->mutable_name();
@@ -7527,8 +7546,8 @@ const char* EnumValueDescriptorProto::_InternalParse(const char* begin, const ch
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// optional int32 number = 2;
@@ -7536,7 +7555,7 @@ const char* EnumValueDescriptorProto::_InternalParse(const char* begin, const ch
if (static_cast<::google::protobuf::uint8>(tag) != 16) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
::google::protobuf::int32 value = val;
msg->set_number(value);
break;
@@ -7545,19 +7564,22 @@ const char* EnumValueDescriptorProto::_InternalParse(const char* begin, const ch
case 3: {
if (static_cast<::google::protobuf::uint8>(tag) != 26) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::EnumValueOptions::_InternalParse;
object = msg->mutable_options();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
@@ -7568,8 +7590,6 @@ const char* EnumValueDescriptorProto::_InternalParse(const char* begin, const ch
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -7581,7 +7601,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool EnumValueDescriptorProto::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.EnumValueDescriptorProto)
for (;;) {
@@ -7995,14 +8015,13 @@ const char* ServiceDescriptorProto::_InternalParse(const char* begin, const char
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// optional string name = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 10) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.ServiceDescriptorProto.name");
parser_till_end = ::google::protobuf::internal::StringParserUTF8Verify;
::std::string* str = msg->mutable_name();
@@ -8010,8 +8029,8 @@ const char* ServiceDescriptorProto::_InternalParse(const char* begin, const char
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// repeated .google.protobuf.MethodDescriptorProto method = 2;
@@ -8019,34 +8038,39 @@ const char* ServiceDescriptorProto::_InternalParse(const char* begin, const char
if (static_cast<::google::protobuf::uint8>(tag) != 18) goto handle_unusual;
do {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::MethodDescriptorProto::_InternalParse;
object = msg->add_method();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 255) == 18 && (ptr += 1));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 18 && (ptr += 1));
break;
}
// optional .google.protobuf.ServiceOptions options = 3;
case 3: {
if (static_cast<::google::protobuf::uint8>(tag) != 26) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::ServiceOptions::_InternalParse;
object = msg->mutable_options();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
@@ -8057,8 +8081,6 @@ const char* ServiceDescriptorProto::_InternalParse(const char* begin, const char
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -8070,7 +8092,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool ServiceDescriptorProto::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.ServiceDescriptorProto)
for (;;) {
@@ -8531,14 +8553,13 @@ const char* MethodDescriptorProto::_InternalParse(const char* begin, const char*
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// optional string name = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 10) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.MethodDescriptorProto.name");
parser_till_end = ::google::protobuf::internal::StringParserUTF8Verify;
::std::string* str = msg->mutable_name();
@@ -8546,15 +8567,15 @@ const char* MethodDescriptorProto::_InternalParse(const char* begin, const char*
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// optional string input_type = 2;
case 2: {
if (static_cast<::google::protobuf::uint8>(tag) != 18) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.MethodDescriptorProto.input_type");
parser_till_end = ::google::protobuf::internal::StringParserUTF8Verify;
::std::string* str = msg->mutable_input_type();
@@ -8562,15 +8583,15 @@ const char* MethodDescriptorProto::_InternalParse(const char* begin, const char*
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// optional string output_type = 3;
case 3: {
if (static_cast<::google::protobuf::uint8>(tag) != 26) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.MethodDescriptorProto.output_type");
parser_till_end = ::google::protobuf::internal::StringParserUTF8Verify;
::std::string* str = msg->mutable_output_type();
@@ -8578,20 +8599,22 @@ const char* MethodDescriptorProto::_InternalParse(const char* begin, const char*
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// optional .google.protobuf.MethodOptions options = 4;
case 4: {
if (static_cast<::google::protobuf::uint8>(tag) != 34) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::MethodOptions::_InternalParse;
object = msg->mutable_options();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
break;
}
@@ -8600,7 +8623,7 @@ const char* MethodDescriptorProto::_InternalParse(const char* begin, const char*
if (static_cast<::google::protobuf::uint8>(tag) != 40) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
bool value = val;
msg->set_client_streaming(value);
break;
@@ -8610,15 +8633,16 @@ const char* MethodDescriptorProto::_InternalParse(const char* begin, const char*
if (static_cast<::google::protobuf::uint8>(tag) != 48) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
bool value = val;
msg->set_server_streaming(value);
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
@@ -8629,8 +8653,6 @@ const char* MethodDescriptorProto::_InternalParse(const char* begin, const char*
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -8642,7 +8664,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool MethodDescriptorProto::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.MethodDescriptorProto)
for (;;) {
@@ -9336,14 +9358,13 @@ const char* FileOptions::_InternalParse(const char* begin, const char* end, void
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// optional string java_package = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 10) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.FileOptions.java_package");
parser_till_end = ::google::protobuf::internal::StringParserUTF8Verify;
::std::string* str = msg->mutable_java_package();
@@ -9351,15 +9372,15 @@ const char* FileOptions::_InternalParse(const char* begin, const char* end, void
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// optional string java_outer_classname = 8;
case 8: {
if (static_cast<::google::protobuf::uint8>(tag) != 66) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.FileOptions.java_outer_classname");
parser_till_end = ::google::protobuf::internal::StringParserUTF8Verify;
::std::string* str = msg->mutable_java_outer_classname();
@@ -9367,8 +9388,8 @@ const char* FileOptions::_InternalParse(const char* begin, const char* end, void
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];
@@ -9376,7 +9397,7 @@ const char* FileOptions::_InternalParse(const char* begin, const char* end, void
if (static_cast<::google::protobuf::uint8>(tag) != 72) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
if (!::google::protobuf::FileOptions_OptimizeMode_IsValid(val)) {
::google::protobuf::internal::WriteVarint(9, val, msg->mutable_unknown_fields());
break;
@@ -9390,7 +9411,7 @@ const char* FileOptions::_InternalParse(const char* begin, const char* end, void
if (static_cast<::google::protobuf::uint8>(tag) != 80) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
bool value = val;
msg->set_java_multiple_files(value);
break;
@@ -9399,7 +9420,7 @@ const char* FileOptions::_InternalParse(const char* begin, const char* end, void
case 11: {
if (static_cast<::google::protobuf::uint8>(tag) != 90) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.FileOptions.go_package");
parser_till_end = ::google::protobuf::internal::StringParserUTF8Verify;
::std::string* str = msg->mutable_go_package();
@@ -9407,8 +9428,8 @@ const char* FileOptions::_InternalParse(const char* begin, const char* end, void
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// optional bool cc_generic_services = 16 [default = false];
@@ -9416,7 +9437,7 @@ const char* FileOptions::_InternalParse(const char* begin, const char* end, void
if (static_cast<::google::protobuf::uint8>(tag) != 128) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
bool value = val;
msg->set_cc_generic_services(value);
break;
@@ -9426,7 +9447,7 @@ const char* FileOptions::_InternalParse(const char* begin, const char* end, void
if (static_cast<::google::protobuf::uint8>(tag) != 136) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
bool value = val;
msg->set_java_generic_services(value);
break;
@@ -9436,7 +9457,7 @@ const char* FileOptions::_InternalParse(const char* begin, const char* end, void
if (static_cast<::google::protobuf::uint8>(tag) != 144) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
bool value = val;
msg->set_py_generic_services(value);
break;
@@ -9446,7 +9467,7 @@ const char* FileOptions::_InternalParse(const char* begin, const char* end, void
if (static_cast<::google::protobuf::uint8>(tag) != 160) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
bool value = val;
msg->set_java_generate_equals_and_hash(value);
break;
@@ -9456,7 +9477,7 @@ const char* FileOptions::_InternalParse(const char* begin, const char* end, void
if (static_cast<::google::protobuf::uint8>(tag) != 184) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
bool value = val;
msg->set_deprecated(value);
break;
@@ -9466,7 +9487,7 @@ const char* FileOptions::_InternalParse(const char* begin, const char* end, void
if (static_cast<::google::protobuf::uint8>(tag) != 216) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
bool value = val;
msg->set_java_string_check_utf8(value);
break;
@@ -9476,7 +9497,7 @@ const char* FileOptions::_InternalParse(const char* begin, const char* end, void
if (static_cast<::google::protobuf::uint8>(tag) != 248) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
bool value = val;
msg->set_cc_enable_arenas(value);
break;
@@ -9485,7 +9506,7 @@ const char* FileOptions::_InternalParse(const char* begin, const char* end, void
case 36: {
if (static_cast<::google::protobuf::uint8>(tag) != 34) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.FileOptions.objc_class_prefix");
parser_till_end = ::google::protobuf::internal::StringParserUTF8Verify;
::std::string* str = msg->mutable_objc_class_prefix();
@@ -9493,15 +9514,15 @@ const char* FileOptions::_InternalParse(const char* begin, const char* end, void
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// optional string csharp_namespace = 37;
case 37: {
if (static_cast<::google::protobuf::uint8>(tag) != 42) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.FileOptions.csharp_namespace");
parser_till_end = ::google::protobuf::internal::StringParserUTF8Verify;
::std::string* str = msg->mutable_csharp_namespace();
@@ -9509,15 +9530,15 @@ const char* FileOptions::_InternalParse(const char* begin, const char* end, void
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// optional string swift_prefix = 39;
case 39: {
if (static_cast<::google::protobuf::uint8>(tag) != 58) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.FileOptions.swift_prefix");
parser_till_end = ::google::protobuf::internal::StringParserUTF8Verify;
::std::string* str = msg->mutable_swift_prefix();
@@ -9525,15 +9546,15 @@ const char* FileOptions::_InternalParse(const char* begin, const char* end, void
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// optional string php_class_prefix = 40;
case 40: {
if (static_cast<::google::protobuf::uint8>(tag) != 66) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.FileOptions.php_class_prefix");
parser_till_end = ::google::protobuf::internal::StringParserUTF8Verify;
::std::string* str = msg->mutable_php_class_prefix();
@@ -9541,15 +9562,15 @@ const char* FileOptions::_InternalParse(const char* begin, const char* end, void
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// optional string php_namespace = 41;
case 41: {
if (static_cast<::google::protobuf::uint8>(tag) != 74) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.FileOptions.php_namespace");
parser_till_end = ::google::protobuf::internal::StringParserUTF8Verify;
::std::string* str = msg->mutable_php_namespace();
@@ -9557,8 +9578,8 @@ const char* FileOptions::_InternalParse(const char* begin, const char* end, void
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// optional bool php_generic_services = 42 [default = false];
@@ -9566,7 +9587,7 @@ const char* FileOptions::_InternalParse(const char* begin, const char* end, void
if (static_cast<::google::protobuf::uint8>(tag) != 80) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
bool value = val;
msg->set_php_generic_services(value);
break;
@@ -9575,7 +9596,7 @@ const char* FileOptions::_InternalParse(const char* begin, const char* end, void
case 44: {
if (static_cast<::google::protobuf::uint8>(tag) != 98) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.FileOptions.php_metadata_namespace");
parser_till_end = ::google::protobuf::internal::StringParserUTF8Verify;
::std::string* str = msg->mutable_php_metadata_namespace();
@@ -9583,15 +9604,15 @@ const char* FileOptions::_InternalParse(const char* begin, const char* end, void
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// optional string ruby_package = 45;
case 45: {
if (static_cast<::google::protobuf::uint8>(tag) != 106) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.FileOptions.ruby_package");
parser_till_end = ::google::protobuf::internal::StringParserUTF8Verify;
::std::string* str = msg->mutable_ruby_package();
@@ -9599,8 +9620,8 @@ const char* FileOptions::_InternalParse(const char* begin, const char* end, void
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
@@ -9608,21 +9629,24 @@ const char* FileOptions::_InternalParse(const char* begin, const char* end, void
if (static_cast<::google::protobuf::uint8>(tag) != 58) goto handle_unusual;
do {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::UninterpretedOption::_InternalParse;
object = msg->add_uninterpreted_option();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 65535) == 16058 && (ptr += 2));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 65535) == 16058 && (ptr += 2));
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
if ((8000u <= tag)) {
@@ -9640,8 +9664,6 @@ const char* FileOptions::_InternalParse(const char* begin, const char* end, void
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -9653,7 +9675,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool FileOptions::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.FileOptions)
for (;;) {
@@ -10804,15 +10826,14 @@ const char* MessageOptions::_InternalParse(const char* begin, const char* end, v
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// optional bool message_set_wire_format = 1 [default = false];
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 8) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
bool value = val;
msg->set_message_set_wire_format(value);
break;
@@ -10822,7 +10843,7 @@ const char* MessageOptions::_InternalParse(const char* begin, const char* end, v
if (static_cast<::google::protobuf::uint8>(tag) != 16) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
bool value = val;
msg->set_no_standard_descriptor_accessor(value);
break;
@@ -10832,7 +10853,7 @@ const char* MessageOptions::_InternalParse(const char* begin, const char* end, v
if (static_cast<::google::protobuf::uint8>(tag) != 24) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
bool value = val;
msg->set_deprecated(value);
break;
@@ -10842,7 +10863,7 @@ const char* MessageOptions::_InternalParse(const char* begin, const char* end, v
if (static_cast<::google::protobuf::uint8>(tag) != 56) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
bool value = val;
msg->set_map_entry(value);
break;
@@ -10852,21 +10873,24 @@ const char* MessageOptions::_InternalParse(const char* begin, const char* end, v
if (static_cast<::google::protobuf::uint8>(tag) != 58) goto handle_unusual;
do {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::UninterpretedOption::_InternalParse;
object = msg->add_uninterpreted_option();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 65535) == 16058 && (ptr += 2));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 65535) == 16058 && (ptr += 2));
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
if ((8000u <= tag)) {
@@ -10884,8 +10908,6 @@ const char* MessageOptions::_InternalParse(const char* begin, const char* end, v
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -10897,7 +10919,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool MessageOptions::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.MessageOptions)
for (;;) {
@@ -11369,15 +11391,14 @@ const char* FieldOptions::_InternalParse(const char* begin, const char* end, voi
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING];
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 8) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
if (!::google::protobuf::FieldOptions_CType_IsValid(val)) {
::google::protobuf::internal::WriteVarint(1, val, msg->mutable_unknown_fields());
break;
@@ -11391,7 +11412,7 @@ const char* FieldOptions::_InternalParse(const char* begin, const char* end, voi
if (static_cast<::google::protobuf::uint8>(tag) != 16) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
bool value = val;
msg->set_packed(value);
break;
@@ -11401,7 +11422,7 @@ const char* FieldOptions::_InternalParse(const char* begin, const char* end, voi
if (static_cast<::google::protobuf::uint8>(tag) != 24) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
bool value = val;
msg->set_deprecated(value);
break;
@@ -11411,7 +11432,7 @@ const char* FieldOptions::_InternalParse(const char* begin, const char* end, voi
if (static_cast<::google::protobuf::uint8>(tag) != 40) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
bool value = val;
msg->set_lazy(value);
break;
@@ -11421,7 +11442,7 @@ const char* FieldOptions::_InternalParse(const char* begin, const char* end, voi
if (static_cast<::google::protobuf::uint8>(tag) != 48) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
if (!::google::protobuf::FieldOptions_JSType_IsValid(val)) {
::google::protobuf::internal::WriteVarint(6, val, msg->mutable_unknown_fields());
break;
@@ -11435,7 +11456,7 @@ const char* FieldOptions::_InternalParse(const char* begin, const char* end, voi
if (static_cast<::google::protobuf::uint8>(tag) != 80) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
bool value = val;
msg->set_weak(value);
break;
@@ -11445,21 +11466,24 @@ const char* FieldOptions::_InternalParse(const char* begin, const char* end, voi
if (static_cast<::google::protobuf::uint8>(tag) != 58) goto handle_unusual;
do {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::UninterpretedOption::_InternalParse;
object = msg->add_uninterpreted_option();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 65535) == 16058 && (ptr += 2));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 65535) == 16058 && (ptr += 2));
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
if ((8000u <= tag)) {
@@ -11477,8 +11501,6 @@ const char* FieldOptions::_InternalParse(const char* begin, const char* end, voi
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -11490,7 +11512,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool FieldOptions::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.FieldOptions)
for (;;) {
@@ -12008,29 +12030,31 @@ const char* OneofOptions::_InternalParse(const char* begin, const char* end, voi
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
case 999: {
if (static_cast<::google::protobuf::uint8>(tag) != 58) goto handle_unusual;
do {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::UninterpretedOption::_InternalParse;
object = msg->add_uninterpreted_option();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 65535) == 16058 && (ptr += 2));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 65535) == 16058 && (ptr += 2));
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
if ((8000u <= tag)) {
@@ -12048,8 +12072,6 @@ const char* OneofOptions::_InternalParse(const char* begin, const char* end, voi
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -12061,7 +12083,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool OneofOptions::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.OneofOptions)
for (;;) {
@@ -12377,15 +12399,14 @@ const char* EnumOptions::_InternalParse(const char* begin, const char* end, void
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// optional bool allow_alias = 2;
case 2: {
if (static_cast<::google::protobuf::uint8>(tag) != 16) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
bool value = val;
msg->set_allow_alias(value);
break;
@@ -12395,7 +12416,7 @@ const char* EnumOptions::_InternalParse(const char* begin, const char* end, void
if (static_cast<::google::protobuf::uint8>(tag) != 24) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
bool value = val;
msg->set_deprecated(value);
break;
@@ -12405,21 +12426,24 @@ const char* EnumOptions::_InternalParse(const char* begin, const char* end, void
if (static_cast<::google::protobuf::uint8>(tag) != 58) goto handle_unusual;
do {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::UninterpretedOption::_InternalParse;
object = msg->add_uninterpreted_option();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 65535) == 16058 && (ptr += 2));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 65535) == 16058 && (ptr += 2));
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
if ((8000u <= tag)) {
@@ -12437,8 +12461,6 @@ const char* EnumOptions::_InternalParse(const char* begin, const char* end, void
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -12450,7 +12472,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool EnumOptions::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.EnumOptions)
for (;;) {
@@ -12829,15 +12851,14 @@ const char* EnumValueOptions::_InternalParse(const char* begin, const char* end,
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// optional bool deprecated = 1 [default = false];
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 8) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
bool value = val;
msg->set_deprecated(value);
break;
@@ -12847,21 +12868,24 @@ const char* EnumValueOptions::_InternalParse(const char* begin, const char* end,
if (static_cast<::google::protobuf::uint8>(tag) != 58) goto handle_unusual;
do {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::UninterpretedOption::_InternalParse;
object = msg->add_uninterpreted_option();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 65535) == 16058 && (ptr += 2));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 65535) == 16058 && (ptr += 2));
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
if ((8000u <= tag)) {
@@ -12879,8 +12903,6 @@ const char* EnumValueOptions::_InternalParse(const char* begin, const char* end,
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -12892,7 +12914,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool EnumValueOptions::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.EnumValueOptions)
for (;;) {
@@ -13233,15 +13255,14 @@ const char* ServiceOptions::_InternalParse(const char* begin, const char* end, v
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// optional bool deprecated = 33 [default = false];
case 33: {
if (static_cast<::google::protobuf::uint8>(tag) != 8) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
bool value = val;
msg->set_deprecated(value);
break;
@@ -13251,21 +13272,24 @@ const char* ServiceOptions::_InternalParse(const char* begin, const char* end, v
if (static_cast<::google::protobuf::uint8>(tag) != 58) goto handle_unusual;
do {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::UninterpretedOption::_InternalParse;
object = msg->add_uninterpreted_option();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 65535) == 16058 && (ptr += 2));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 65535) == 16058 && (ptr += 2));
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
if ((8000u <= tag)) {
@@ -13283,8 +13307,6 @@ const char* ServiceOptions::_InternalParse(const char* begin, const char* end, v
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -13296,7 +13318,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool ServiceOptions::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.ServiceOptions)
for (;;) {
@@ -13650,15 +13672,14 @@ const char* MethodOptions::_InternalParse(const char* begin, const char* end, vo
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// optional bool deprecated = 33 [default = false];
case 33: {
if (static_cast<::google::protobuf::uint8>(tag) != 8) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
bool value = val;
msg->set_deprecated(value);
break;
@@ -13668,7 +13689,7 @@ const char* MethodOptions::_InternalParse(const char* begin, const char* end, vo
if (static_cast<::google::protobuf::uint8>(tag) != 16) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
if (!::google::protobuf::MethodOptions_IdempotencyLevel_IsValid(val)) {
::google::protobuf::internal::WriteVarint(34, val, msg->mutable_unknown_fields());
break;
@@ -13682,21 +13703,24 @@ const char* MethodOptions::_InternalParse(const char* begin, const char* end, vo
if (static_cast<::google::protobuf::uint8>(tag) != 58) goto handle_unusual;
do {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::UninterpretedOption::_InternalParse;
object = msg->add_uninterpreted_option();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 65535) == 16058 && (ptr += 2));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 65535) == 16058 && (ptr += 2));
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
if ((8000u <= tag)) {
@@ -13714,8 +13738,6 @@ const char* MethodOptions::_InternalParse(const char* begin, const char* end, vo
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -13727,7 +13749,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool MethodOptions::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.MethodOptions)
for (;;) {
@@ -14123,14 +14145,13 @@ const char* UninterpretedOption_NamePart::_InternalParse(const char* begin, cons
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// required string name_part = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 10) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.UninterpretedOption.NamePart.name_part");
parser_till_end = ::google::protobuf::internal::StringParserUTF8Verify;
::std::string* str = msg->mutable_name_part();
@@ -14138,8 +14159,8 @@ const char* UninterpretedOption_NamePart::_InternalParse(const char* begin, cons
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// required bool is_extension = 2;
@@ -14147,15 +14168,16 @@ const char* UninterpretedOption_NamePart::_InternalParse(const char* begin, cons
if (static_cast<::google::protobuf::uint8>(tag) != 16) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
bool value = val;
msg->set_is_extension(value);
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
@@ -14166,8 +14188,6 @@ const char* UninterpretedOption_NamePart::_InternalParse(const char* begin, cons
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -14179,7 +14199,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool UninterpretedOption_NamePart::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.UninterpretedOption.NamePart)
for (;;) {
@@ -14585,30 +14605,31 @@ const char* UninterpretedOption::_InternalParse(const char* begin, const char* e
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// repeated .google.protobuf.UninterpretedOption.NamePart name = 2;
case 2: {
if (static_cast<::google::protobuf::uint8>(tag) != 18) goto handle_unusual;
do {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::UninterpretedOption_NamePart::_InternalParse;
object = msg->add_name();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 255) == 18 && (ptr += 1));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 18 && (ptr += 1));
break;
}
// optional string identifier_value = 3;
case 3: {
if (static_cast<::google::protobuf::uint8>(tag) != 26) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.UninterpretedOption.identifier_value");
parser_till_end = ::google::protobuf::internal::StringParserUTF8Verify;
::std::string* str = msg->mutable_identifier_value();
@@ -14616,8 +14637,8 @@ const char* UninterpretedOption::_InternalParse(const char* begin, const char* e
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// optional uint64 positive_int_value = 4;
@@ -14625,7 +14646,7 @@ const char* UninterpretedOption::_InternalParse(const char* begin, const char* e
if (static_cast<::google::protobuf::uint8>(tag) != 32) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
::google::protobuf::uint64 value = val;
msg->set_positive_int_value(value);
break;
@@ -14635,7 +14656,7 @@ const char* UninterpretedOption::_InternalParse(const char* begin, const char* e
if (static_cast<::google::protobuf::uint8>(tag) != 40) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
::google::protobuf::int64 value = val;
msg->set_negative_int_value(value);
break;
@@ -14653,22 +14674,21 @@ const char* UninterpretedOption::_InternalParse(const char* begin, const char* e
case 7: {
if (static_cast<::google::protobuf::uint8>(tag) != 58) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::internal::StringParser;
::std::string* str = msg->mutable_string_value();
str->clear();
object = str;
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ str->append(ptr, size);
+ ptr += size;
break;
}
// optional string aggregate_value = 8;
case 8: {
if (static_cast<::google::protobuf::uint8>(tag) != 66) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.UninterpretedOption.aggregate_value");
parser_till_end = ::google::protobuf::internal::StringParserUTF8Verify;
::std::string* str = msg->mutable_aggregate_value();
@@ -14676,14 +14696,15 @@ const char* UninterpretedOption::_InternalParse(const char* begin, const char* e
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
@@ -14694,8 +14715,6 @@ const char* UninterpretedOption::_InternalParse(const char* begin, const char* e
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -14707,7 +14726,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool UninterpretedOption::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.UninterpretedOption)
for (;;) {
@@ -15262,60 +15281,59 @@ const char* SourceCodeInfo_Location::_InternalParse(const char* begin, const cha
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// repeated int32 path = 1 [packed = true];
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) == 10) {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::internal::PackedInt32Parser;
object = msg->mutable_path();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
} else if (static_cast<::google::protobuf::uint8>(tag) != 8) goto handle_unusual;
do {
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
::google::protobuf::int32 value = val;
msg->add_path(value);
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 255) == 8 && (ptr += 1));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 8 && (ptr += 1));
break;
}
// repeated int32 span = 2 [packed = true];
case 2: {
if (static_cast<::google::protobuf::uint8>(tag) == 18) {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::internal::PackedInt32Parser;
object = msg->mutable_span();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
} else if (static_cast<::google::protobuf::uint8>(tag) != 16) goto handle_unusual;
do {
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
::google::protobuf::int32 value = val;
msg->add_span(value);
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 255) == 16 && (ptr += 1));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 16 && (ptr += 1));
break;
}
// optional string leading_comments = 3;
case 3: {
if (static_cast<::google::protobuf::uint8>(tag) != 26) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.SourceCodeInfo.Location.leading_comments");
parser_till_end = ::google::protobuf::internal::StringParserUTF8Verify;
::std::string* str = msg->mutable_leading_comments();
@@ -15323,15 +15341,15 @@ const char* SourceCodeInfo_Location::_InternalParse(const char* begin, const cha
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// optional string trailing_comments = 4;
case 4: {
if (static_cast<::google::protobuf::uint8>(tag) != 34) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.SourceCodeInfo.Location.trailing_comments");
parser_till_end = ::google::protobuf::internal::StringParserUTF8Verify;
::std::string* str = msg->mutable_trailing_comments();
@@ -15339,8 +15357,8 @@ const char* SourceCodeInfo_Location::_InternalParse(const char* begin, const cha
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// repeated string leading_detached_comments = 6;
@@ -15348,7 +15366,7 @@ const char* SourceCodeInfo_Location::_InternalParse(const char* begin, const cha
if (static_cast<::google::protobuf::uint8>(tag) != 50) goto handle_unusual;
do {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.SourceCodeInfo.Location.leading_detached_comments");
parser_till_end = ::google::protobuf::internal::StringParserUTF8Verify;
::std::string* str = msg->add_leading_detached_comments();
@@ -15356,16 +15374,17 @@ const char* SourceCodeInfo_Location::_InternalParse(const char* begin, const cha
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 255) == 50 && (ptr += 1));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 50 && (ptr += 1));
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
@@ -15376,8 +15395,6 @@ const char* SourceCodeInfo_Location::_InternalParse(const char* begin, const cha
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -15389,7 +15406,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool SourceCodeInfo_Location::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.SourceCodeInfo.Location)
for (;;) {
@@ -15886,29 +15903,31 @@ const char* SourceCodeInfo::_InternalParse(const char* begin, const char* end, v
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// repeated .google.protobuf.SourceCodeInfo.Location location = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 10) goto handle_unusual;
do {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::SourceCodeInfo_Location::_InternalParse;
object = msg->add_location();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 255) == 10 && (ptr += 1));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 10 && (ptr += 1));
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
@@ -15919,8 +15938,6 @@ const char* SourceCodeInfo::_InternalParse(const char* begin, const char* end, v
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -15932,7 +15949,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool SourceCodeInfo::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.SourceCodeInfo)
for (;;) {
@@ -16240,37 +16257,36 @@ const char* GeneratedCodeInfo_Annotation::_InternalParse(const char* begin, cons
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// repeated int32 path = 1 [packed = true];
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) == 10) {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::internal::PackedInt32Parser;
object = msg->mutable_path();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
} else if (static_cast<::google::protobuf::uint8>(tag) != 8) goto handle_unusual;
do {
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
::google::protobuf::int32 value = val;
msg->add_path(value);
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 255) == 8 && (ptr += 1));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 8 && (ptr += 1));
break;
}
// optional string source_file = 2;
case 2: {
if (static_cast<::google::protobuf::uint8>(tag) != 18) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.GeneratedCodeInfo.Annotation.source_file");
parser_till_end = ::google::protobuf::internal::StringParserUTF8Verify;
::std::string* str = msg->mutable_source_file();
@@ -16278,8 +16294,8 @@ const char* GeneratedCodeInfo_Annotation::_InternalParse(const char* begin, cons
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// optional int32 begin = 3;
@@ -16287,7 +16303,7 @@ const char* GeneratedCodeInfo_Annotation::_InternalParse(const char* begin, cons
if (static_cast<::google::protobuf::uint8>(tag) != 24) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
::google::protobuf::int32 value = val;
msg->set_begin(value);
break;
@@ -16297,15 +16313,16 @@ const char* GeneratedCodeInfo_Annotation::_InternalParse(const char* begin, cons
if (static_cast<::google::protobuf::uint8>(tag) != 32) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
::google::protobuf::int32 value = val;
msg->set_end(value);
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
@@ -16316,8 +16333,6 @@ const char* GeneratedCodeInfo_Annotation::_InternalParse(const char* begin, cons
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -16329,7 +16344,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool GeneratedCodeInfo_Annotation::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.GeneratedCodeInfo.Annotation)
for (;;) {
@@ -16744,29 +16759,31 @@ const char* GeneratedCodeInfo::_InternalParse(const char* begin, const char* end
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 10) goto handle_unusual;
do {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::GeneratedCodeInfo_Annotation::_InternalParse;
object = msg->add_annotation();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 255) == 10 && (ptr += 1));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 10 && (ptr += 1));
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
@@ -16777,8 +16794,6 @@ const char* GeneratedCodeInfo::_InternalParse(const char* begin, const char* end
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -16790,7 +16805,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool GeneratedCodeInfo::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.GeneratedCodeInfo)
for (;;) {
@@ -16984,88 +16999,89 @@ void GeneratedCodeInfo::InternalSwap(GeneratedCodeInfo* other) {
} // namespace google
namespace google {
namespace protobuf {
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::FileDescriptorSet* Arena::CreateMaybeMessage< ::google::protobuf::FileDescriptorSet >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::FileDescriptorSet* Arena::CreateMaybeMessage< ::google::protobuf::FileDescriptorSet >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::FileDescriptorSet >(arena);
}
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::FileDescriptorProto* Arena::CreateMaybeMessage< ::google::protobuf::FileDescriptorProto >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::FileDescriptorProto* Arena::CreateMaybeMessage< ::google::protobuf::FileDescriptorProto >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::FileDescriptorProto >(arena);
}
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::DescriptorProto_ExtensionRange* Arena::CreateMaybeMessage< ::google::protobuf::DescriptorProto_ExtensionRange >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::DescriptorProto_ExtensionRange* Arena::CreateMaybeMessage< ::google::protobuf::DescriptorProto_ExtensionRange >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::DescriptorProto_ExtensionRange >(arena);
}
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::DescriptorProto_ReservedRange* Arena::CreateMaybeMessage< ::google::protobuf::DescriptorProto_ReservedRange >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::DescriptorProto_ReservedRange* Arena::CreateMaybeMessage< ::google::protobuf::DescriptorProto_ReservedRange >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::DescriptorProto_ReservedRange >(arena);
}
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::DescriptorProto* Arena::CreateMaybeMessage< ::google::protobuf::DescriptorProto >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::DescriptorProto* Arena::CreateMaybeMessage< ::google::protobuf::DescriptorProto >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::DescriptorProto >(arena);
}
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::ExtensionRangeOptions* Arena::CreateMaybeMessage< ::google::protobuf::ExtensionRangeOptions >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::ExtensionRangeOptions* Arena::CreateMaybeMessage< ::google::protobuf::ExtensionRangeOptions >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::ExtensionRangeOptions >(arena);
}
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::FieldDescriptorProto* Arena::CreateMaybeMessage< ::google::protobuf::FieldDescriptorProto >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::FieldDescriptorProto* Arena::CreateMaybeMessage< ::google::protobuf::FieldDescriptorProto >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::FieldDescriptorProto >(arena);
}
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::OneofDescriptorProto* Arena::CreateMaybeMessage< ::google::protobuf::OneofDescriptorProto >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::OneofDescriptorProto* Arena::CreateMaybeMessage< ::google::protobuf::OneofDescriptorProto >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::OneofDescriptorProto >(arena);
}
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::EnumDescriptorProto_EnumReservedRange* Arena::CreateMaybeMessage< ::google::protobuf::EnumDescriptorProto_EnumReservedRange >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::EnumDescriptorProto_EnumReservedRange* Arena::CreateMaybeMessage< ::google::protobuf::EnumDescriptorProto_EnumReservedRange >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::EnumDescriptorProto_EnumReservedRange >(arena);
}
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::EnumDescriptorProto* Arena::CreateMaybeMessage< ::google::protobuf::EnumDescriptorProto >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::EnumDescriptorProto* Arena::CreateMaybeMessage< ::google::protobuf::EnumDescriptorProto >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::EnumDescriptorProto >(arena);
}
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::EnumValueDescriptorProto* Arena::CreateMaybeMessage< ::google::protobuf::EnumValueDescriptorProto >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::EnumValueDescriptorProto* Arena::CreateMaybeMessage< ::google::protobuf::EnumValueDescriptorProto >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::EnumValueDescriptorProto >(arena);
}
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::ServiceDescriptorProto* Arena::CreateMaybeMessage< ::google::protobuf::ServiceDescriptorProto >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::ServiceDescriptorProto* Arena::CreateMaybeMessage< ::google::protobuf::ServiceDescriptorProto >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::ServiceDescriptorProto >(arena);
}
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::MethodDescriptorProto* Arena::CreateMaybeMessage< ::google::protobuf::MethodDescriptorProto >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::MethodDescriptorProto* Arena::CreateMaybeMessage< ::google::protobuf::MethodDescriptorProto >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::MethodDescriptorProto >(arena);
}
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::FileOptions* Arena::CreateMaybeMessage< ::google::protobuf::FileOptions >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::FileOptions* Arena::CreateMaybeMessage< ::google::protobuf::FileOptions >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::FileOptions >(arena);
}
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::MessageOptions* Arena::CreateMaybeMessage< ::google::protobuf::MessageOptions >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::MessageOptions* Arena::CreateMaybeMessage< ::google::protobuf::MessageOptions >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::MessageOptions >(arena);
}
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::FieldOptions* Arena::CreateMaybeMessage< ::google::protobuf::FieldOptions >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::FieldOptions* Arena::CreateMaybeMessage< ::google::protobuf::FieldOptions >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::FieldOptions >(arena);
}
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::OneofOptions* Arena::CreateMaybeMessage< ::google::protobuf::OneofOptions >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::OneofOptions* Arena::CreateMaybeMessage< ::google::protobuf::OneofOptions >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::OneofOptions >(arena);
}
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::EnumOptions* Arena::CreateMaybeMessage< ::google::protobuf::EnumOptions >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::EnumOptions* Arena::CreateMaybeMessage< ::google::protobuf::EnumOptions >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::EnumOptions >(arena);
}
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::EnumValueOptions* Arena::CreateMaybeMessage< ::google::protobuf::EnumValueOptions >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::EnumValueOptions* Arena::CreateMaybeMessage< ::google::protobuf::EnumValueOptions >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::EnumValueOptions >(arena);
}
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::ServiceOptions* Arena::CreateMaybeMessage< ::google::protobuf::ServiceOptions >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::ServiceOptions* Arena::CreateMaybeMessage< ::google::protobuf::ServiceOptions >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::ServiceOptions >(arena);
}
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::MethodOptions* Arena::CreateMaybeMessage< ::google::protobuf::MethodOptions >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::MethodOptions* Arena::CreateMaybeMessage< ::google::protobuf::MethodOptions >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::MethodOptions >(arena);
}
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::UninterpretedOption_NamePart* Arena::CreateMaybeMessage< ::google::protobuf::UninterpretedOption_NamePart >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::UninterpretedOption_NamePart* Arena::CreateMaybeMessage< ::google::protobuf::UninterpretedOption_NamePart >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::UninterpretedOption_NamePart >(arena);
}
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::UninterpretedOption* Arena::CreateMaybeMessage< ::google::protobuf::UninterpretedOption >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::UninterpretedOption* Arena::CreateMaybeMessage< ::google::protobuf::UninterpretedOption >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::UninterpretedOption >(arena);
}
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::SourceCodeInfo_Location* Arena::CreateMaybeMessage< ::google::protobuf::SourceCodeInfo_Location >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::SourceCodeInfo_Location* Arena::CreateMaybeMessage< ::google::protobuf::SourceCodeInfo_Location >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::SourceCodeInfo_Location >(arena);
}
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::SourceCodeInfo* Arena::CreateMaybeMessage< ::google::protobuf::SourceCodeInfo >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::SourceCodeInfo* Arena::CreateMaybeMessage< ::google::protobuf::SourceCodeInfo >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::SourceCodeInfo >(arena);
}
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::GeneratedCodeInfo_Annotation* Arena::CreateMaybeMessage< ::google::protobuf::GeneratedCodeInfo_Annotation >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::GeneratedCodeInfo_Annotation* Arena::CreateMaybeMessage< ::google::protobuf::GeneratedCodeInfo_Annotation >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::GeneratedCodeInfo_Annotation >(arena);
}
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::GeneratedCodeInfo* Arena::CreateMaybeMessage< ::google::protobuf::GeneratedCodeInfo >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::GeneratedCodeInfo* Arena::CreateMaybeMessage< ::google::protobuf::GeneratedCodeInfo >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::GeneratedCodeInfo >(arena);
}
} // namespace protobuf
} // namespace google
// @@protoc_insertion_point(global_scope)
+#include <google/protobuf/port_undef.inc>
diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h
index 3459a073..c4b83652 100644
--- a/src/google/protobuf/descriptor.pb.h
+++ b/src/google/protobuf/descriptor.pb.h
@@ -7,18 +7,19 @@
#include <limits>
#include <string>
-#include <google/protobuf/stubs/common.h>
-#if GOOGLE_PROTOBUF_VERSION < 3006000
+#include <google/protobuf/port_def.inc>
+#if PROTOBUF_VERSION < 3006001
#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 3006001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 3006001 < 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.
#endif
+#include <google/protobuf/port_undef.inc>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
@@ -33,131 +34,131 @@
#include <google/protobuf/unknown_field_set.h>
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>
-#define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fdescriptor_2eproto LIBPROTOBUF_EXPORT
+#define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fdescriptor_2eproto PROTOBUF_EXPORT
// Internal implementation detail -- do not use these members.
-struct LIBPROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fdescriptor_2eproto {
+struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fdescriptor_2eproto {
static const ::google::protobuf::internal::ParseTableField entries[]
- GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold);
+ PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::google::protobuf::internal::AuxillaryParseTableField aux[]
- GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold);
+ PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::google::protobuf::internal::ParseTable schema[27]
- GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold);
+ PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::google::protobuf::internal::FieldMetadata field_metadata[];
static const ::google::protobuf::internal::SerializationTable serialization_table[];
static const ::google::protobuf::uint32 offsets[];
};
-void LIBPROTOBUF_EXPORT AddDescriptors_google_2fprotobuf_2fdescriptor_2eproto();
+void PROTOBUF_EXPORT AddDescriptors_google_2fprotobuf_2fdescriptor_2eproto();
namespace google {
namespace protobuf {
class DescriptorProto;
class DescriptorProtoDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern DescriptorProtoDefaultTypeInternal _DescriptorProto_default_instance_;
+PROTOBUF_EXPORT extern DescriptorProtoDefaultTypeInternal _DescriptorProto_default_instance_;
class DescriptorProto_ExtensionRange;
class DescriptorProto_ExtensionRangeDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern DescriptorProto_ExtensionRangeDefaultTypeInternal _DescriptorProto_ExtensionRange_default_instance_;
+PROTOBUF_EXPORT extern DescriptorProto_ExtensionRangeDefaultTypeInternal _DescriptorProto_ExtensionRange_default_instance_;
class DescriptorProto_ReservedRange;
class DescriptorProto_ReservedRangeDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern DescriptorProto_ReservedRangeDefaultTypeInternal _DescriptorProto_ReservedRange_default_instance_;
+PROTOBUF_EXPORT extern DescriptorProto_ReservedRangeDefaultTypeInternal _DescriptorProto_ReservedRange_default_instance_;
class EnumDescriptorProto;
class EnumDescriptorProtoDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern EnumDescriptorProtoDefaultTypeInternal _EnumDescriptorProto_default_instance_;
+PROTOBUF_EXPORT extern EnumDescriptorProtoDefaultTypeInternal _EnumDescriptorProto_default_instance_;
class EnumDescriptorProto_EnumReservedRange;
class EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal _EnumDescriptorProto_EnumReservedRange_default_instance_;
+PROTOBUF_EXPORT extern EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal _EnumDescriptorProto_EnumReservedRange_default_instance_;
class EnumOptions;
class EnumOptionsDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern EnumOptionsDefaultTypeInternal _EnumOptions_default_instance_;
+PROTOBUF_EXPORT extern EnumOptionsDefaultTypeInternal _EnumOptions_default_instance_;
class EnumValueDescriptorProto;
class EnumValueDescriptorProtoDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern EnumValueDescriptorProtoDefaultTypeInternal _EnumValueDescriptorProto_default_instance_;
+PROTOBUF_EXPORT extern EnumValueDescriptorProtoDefaultTypeInternal _EnumValueDescriptorProto_default_instance_;
class EnumValueOptions;
class EnumValueOptionsDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern EnumValueOptionsDefaultTypeInternal _EnumValueOptions_default_instance_;
+PROTOBUF_EXPORT extern EnumValueOptionsDefaultTypeInternal _EnumValueOptions_default_instance_;
class ExtensionRangeOptions;
class ExtensionRangeOptionsDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern ExtensionRangeOptionsDefaultTypeInternal _ExtensionRangeOptions_default_instance_;
+PROTOBUF_EXPORT extern ExtensionRangeOptionsDefaultTypeInternal _ExtensionRangeOptions_default_instance_;
class FieldDescriptorProto;
class FieldDescriptorProtoDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern FieldDescriptorProtoDefaultTypeInternal _FieldDescriptorProto_default_instance_;
+PROTOBUF_EXPORT extern FieldDescriptorProtoDefaultTypeInternal _FieldDescriptorProto_default_instance_;
class FieldOptions;
class FieldOptionsDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern FieldOptionsDefaultTypeInternal _FieldOptions_default_instance_;
+PROTOBUF_EXPORT extern FieldOptionsDefaultTypeInternal _FieldOptions_default_instance_;
class FileDescriptorProto;
class FileDescriptorProtoDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern FileDescriptorProtoDefaultTypeInternal _FileDescriptorProto_default_instance_;
+PROTOBUF_EXPORT extern FileDescriptorProtoDefaultTypeInternal _FileDescriptorProto_default_instance_;
class FileDescriptorSet;
class FileDescriptorSetDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern FileDescriptorSetDefaultTypeInternal _FileDescriptorSet_default_instance_;
+PROTOBUF_EXPORT extern FileDescriptorSetDefaultTypeInternal _FileDescriptorSet_default_instance_;
class FileOptions;
class FileOptionsDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern FileOptionsDefaultTypeInternal _FileOptions_default_instance_;
+PROTOBUF_EXPORT extern FileOptionsDefaultTypeInternal _FileOptions_default_instance_;
class GeneratedCodeInfo;
class GeneratedCodeInfoDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern GeneratedCodeInfoDefaultTypeInternal _GeneratedCodeInfo_default_instance_;
+PROTOBUF_EXPORT extern GeneratedCodeInfoDefaultTypeInternal _GeneratedCodeInfo_default_instance_;
class GeneratedCodeInfo_Annotation;
class GeneratedCodeInfo_AnnotationDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern GeneratedCodeInfo_AnnotationDefaultTypeInternal _GeneratedCodeInfo_Annotation_default_instance_;
+PROTOBUF_EXPORT extern GeneratedCodeInfo_AnnotationDefaultTypeInternal _GeneratedCodeInfo_Annotation_default_instance_;
class MessageOptions;
class MessageOptionsDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern MessageOptionsDefaultTypeInternal _MessageOptions_default_instance_;
+PROTOBUF_EXPORT extern MessageOptionsDefaultTypeInternal _MessageOptions_default_instance_;
class MethodDescriptorProto;
class MethodDescriptorProtoDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern MethodDescriptorProtoDefaultTypeInternal _MethodDescriptorProto_default_instance_;
+PROTOBUF_EXPORT extern MethodDescriptorProtoDefaultTypeInternal _MethodDescriptorProto_default_instance_;
class MethodOptions;
class MethodOptionsDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern MethodOptionsDefaultTypeInternal _MethodOptions_default_instance_;
+PROTOBUF_EXPORT extern MethodOptionsDefaultTypeInternal _MethodOptions_default_instance_;
class OneofDescriptorProto;
class OneofDescriptorProtoDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern OneofDescriptorProtoDefaultTypeInternal _OneofDescriptorProto_default_instance_;
+PROTOBUF_EXPORT extern OneofDescriptorProtoDefaultTypeInternal _OneofDescriptorProto_default_instance_;
class OneofOptions;
class OneofOptionsDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern OneofOptionsDefaultTypeInternal _OneofOptions_default_instance_;
+PROTOBUF_EXPORT extern OneofOptionsDefaultTypeInternal _OneofOptions_default_instance_;
class ServiceDescriptorProto;
class ServiceDescriptorProtoDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern ServiceDescriptorProtoDefaultTypeInternal _ServiceDescriptorProto_default_instance_;
+PROTOBUF_EXPORT extern ServiceDescriptorProtoDefaultTypeInternal _ServiceDescriptorProto_default_instance_;
class ServiceOptions;
class ServiceOptionsDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern ServiceOptionsDefaultTypeInternal _ServiceOptions_default_instance_;
+PROTOBUF_EXPORT extern ServiceOptionsDefaultTypeInternal _ServiceOptions_default_instance_;
class SourceCodeInfo;
class SourceCodeInfoDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern SourceCodeInfoDefaultTypeInternal _SourceCodeInfo_default_instance_;
+PROTOBUF_EXPORT extern SourceCodeInfoDefaultTypeInternal _SourceCodeInfo_default_instance_;
class SourceCodeInfo_Location;
class SourceCodeInfo_LocationDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern SourceCodeInfo_LocationDefaultTypeInternal _SourceCodeInfo_Location_default_instance_;
+PROTOBUF_EXPORT extern SourceCodeInfo_LocationDefaultTypeInternal _SourceCodeInfo_Location_default_instance_;
class UninterpretedOption;
class UninterpretedOptionDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern UninterpretedOptionDefaultTypeInternal _UninterpretedOption_default_instance_;
+PROTOBUF_EXPORT extern UninterpretedOptionDefaultTypeInternal _UninterpretedOption_default_instance_;
class UninterpretedOption_NamePart;
class UninterpretedOption_NamePartDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern UninterpretedOption_NamePartDefaultTypeInternal _UninterpretedOption_NamePart_default_instance_;
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::DescriptorProto* Arena::CreateMaybeMessage<::google::protobuf::DescriptorProto>(Arena*);
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::DescriptorProto_ExtensionRange* Arena::CreateMaybeMessage<::google::protobuf::DescriptorProto_ExtensionRange>(Arena*);
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::DescriptorProto_ReservedRange* Arena::CreateMaybeMessage<::google::protobuf::DescriptorProto_ReservedRange>(Arena*);
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::EnumDescriptorProto* Arena::CreateMaybeMessage<::google::protobuf::EnumDescriptorProto>(Arena*);
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::EnumDescriptorProto_EnumReservedRange* Arena::CreateMaybeMessage<::google::protobuf::EnumDescriptorProto_EnumReservedRange>(Arena*);
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::EnumOptions* Arena::CreateMaybeMessage<::google::protobuf::EnumOptions>(Arena*);
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::EnumValueDescriptorProto* Arena::CreateMaybeMessage<::google::protobuf::EnumValueDescriptorProto>(Arena*);
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::EnumValueOptions* Arena::CreateMaybeMessage<::google::protobuf::EnumValueOptions>(Arena*);
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::ExtensionRangeOptions* Arena::CreateMaybeMessage<::google::protobuf::ExtensionRangeOptions>(Arena*);
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::FieldDescriptorProto* Arena::CreateMaybeMessage<::google::protobuf::FieldDescriptorProto>(Arena*);
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::FieldOptions* Arena::CreateMaybeMessage<::google::protobuf::FieldOptions>(Arena*);
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::FileDescriptorProto* Arena::CreateMaybeMessage<::google::protobuf::FileDescriptorProto>(Arena*);
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::FileDescriptorSet* Arena::CreateMaybeMessage<::google::protobuf::FileDescriptorSet>(Arena*);
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::FileOptions* Arena::CreateMaybeMessage<::google::protobuf::FileOptions>(Arena*);
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::GeneratedCodeInfo* Arena::CreateMaybeMessage<::google::protobuf::GeneratedCodeInfo>(Arena*);
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::GeneratedCodeInfo_Annotation* Arena::CreateMaybeMessage<::google::protobuf::GeneratedCodeInfo_Annotation>(Arena*);
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::MessageOptions* Arena::CreateMaybeMessage<::google::protobuf::MessageOptions>(Arena*);
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::MethodDescriptorProto* Arena::CreateMaybeMessage<::google::protobuf::MethodDescriptorProto>(Arena*);
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::MethodOptions* Arena::CreateMaybeMessage<::google::protobuf::MethodOptions>(Arena*);
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::OneofDescriptorProto* Arena::CreateMaybeMessage<::google::protobuf::OneofDescriptorProto>(Arena*);
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::OneofOptions* Arena::CreateMaybeMessage<::google::protobuf::OneofOptions>(Arena*);
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::ServiceDescriptorProto* Arena::CreateMaybeMessage<::google::protobuf::ServiceDescriptorProto>(Arena*);
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::ServiceOptions* Arena::CreateMaybeMessage<::google::protobuf::ServiceOptions>(Arena*);
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::SourceCodeInfo* Arena::CreateMaybeMessage<::google::protobuf::SourceCodeInfo>(Arena*);
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::SourceCodeInfo_Location* Arena::CreateMaybeMessage<::google::protobuf::SourceCodeInfo_Location>(Arena*);
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::UninterpretedOption* Arena::CreateMaybeMessage<::google::protobuf::UninterpretedOption>(Arena*);
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::UninterpretedOption_NamePart* Arena::CreateMaybeMessage<::google::protobuf::UninterpretedOption_NamePart>(Arena*);
+PROTOBUF_EXPORT extern UninterpretedOption_NamePartDefaultTypeInternal _UninterpretedOption_NamePart_default_instance_;
+template<> PROTOBUF_EXPORT ::google::protobuf::DescriptorProto* Arena::CreateMaybeMessage<::google::protobuf::DescriptorProto>(Arena*);
+template<> PROTOBUF_EXPORT ::google::protobuf::DescriptorProto_ExtensionRange* Arena::CreateMaybeMessage<::google::protobuf::DescriptorProto_ExtensionRange>(Arena*);
+template<> PROTOBUF_EXPORT ::google::protobuf::DescriptorProto_ReservedRange* Arena::CreateMaybeMessage<::google::protobuf::DescriptorProto_ReservedRange>(Arena*);
+template<> PROTOBUF_EXPORT ::google::protobuf::EnumDescriptorProto* Arena::CreateMaybeMessage<::google::protobuf::EnumDescriptorProto>(Arena*);
+template<> PROTOBUF_EXPORT ::google::protobuf::EnumDescriptorProto_EnumReservedRange* Arena::CreateMaybeMessage<::google::protobuf::EnumDescriptorProto_EnumReservedRange>(Arena*);
+template<> PROTOBUF_EXPORT ::google::protobuf::EnumOptions* Arena::CreateMaybeMessage<::google::protobuf::EnumOptions>(Arena*);
+template<> PROTOBUF_EXPORT ::google::protobuf::EnumValueDescriptorProto* Arena::CreateMaybeMessage<::google::protobuf::EnumValueDescriptorProto>(Arena*);
+template<> PROTOBUF_EXPORT ::google::protobuf::EnumValueOptions* Arena::CreateMaybeMessage<::google::protobuf::EnumValueOptions>(Arena*);
+template<> PROTOBUF_EXPORT ::google::protobuf::ExtensionRangeOptions* Arena::CreateMaybeMessage<::google::protobuf::ExtensionRangeOptions>(Arena*);
+template<> PROTOBUF_EXPORT ::google::protobuf::FieldDescriptorProto* Arena::CreateMaybeMessage<::google::protobuf::FieldDescriptorProto>(Arena*);
+template<> PROTOBUF_EXPORT ::google::protobuf::FieldOptions* Arena::CreateMaybeMessage<::google::protobuf::FieldOptions>(Arena*);
+template<> PROTOBUF_EXPORT ::google::protobuf::FileDescriptorProto* Arena::CreateMaybeMessage<::google::protobuf::FileDescriptorProto>(Arena*);
+template<> PROTOBUF_EXPORT ::google::protobuf::FileDescriptorSet* Arena::CreateMaybeMessage<::google::protobuf::FileDescriptorSet>(Arena*);
+template<> PROTOBUF_EXPORT ::google::protobuf::FileOptions* Arena::CreateMaybeMessage<::google::protobuf::FileOptions>(Arena*);
+template<> PROTOBUF_EXPORT ::google::protobuf::GeneratedCodeInfo* Arena::CreateMaybeMessage<::google::protobuf::GeneratedCodeInfo>(Arena*);
+template<> PROTOBUF_EXPORT ::google::protobuf::GeneratedCodeInfo_Annotation* Arena::CreateMaybeMessage<::google::protobuf::GeneratedCodeInfo_Annotation>(Arena*);
+template<> PROTOBUF_EXPORT ::google::protobuf::MessageOptions* Arena::CreateMaybeMessage<::google::protobuf::MessageOptions>(Arena*);
+template<> PROTOBUF_EXPORT ::google::protobuf::MethodDescriptorProto* Arena::CreateMaybeMessage<::google::protobuf::MethodDescriptorProto>(Arena*);
+template<> PROTOBUF_EXPORT ::google::protobuf::MethodOptions* Arena::CreateMaybeMessage<::google::protobuf::MethodOptions>(Arena*);
+template<> PROTOBUF_EXPORT ::google::protobuf::OneofDescriptorProto* Arena::CreateMaybeMessage<::google::protobuf::OneofDescriptorProto>(Arena*);
+template<> PROTOBUF_EXPORT ::google::protobuf::OneofOptions* Arena::CreateMaybeMessage<::google::protobuf::OneofOptions>(Arena*);
+template<> PROTOBUF_EXPORT ::google::protobuf::ServiceDescriptorProto* Arena::CreateMaybeMessage<::google::protobuf::ServiceDescriptorProto>(Arena*);
+template<> PROTOBUF_EXPORT ::google::protobuf::ServiceOptions* Arena::CreateMaybeMessage<::google::protobuf::ServiceOptions>(Arena*);
+template<> PROTOBUF_EXPORT ::google::protobuf::SourceCodeInfo* Arena::CreateMaybeMessage<::google::protobuf::SourceCodeInfo>(Arena*);
+template<> PROTOBUF_EXPORT ::google::protobuf::SourceCodeInfo_Location* Arena::CreateMaybeMessage<::google::protobuf::SourceCodeInfo_Location>(Arena*);
+template<> PROTOBUF_EXPORT ::google::protobuf::UninterpretedOption* Arena::CreateMaybeMessage<::google::protobuf::UninterpretedOption>(Arena*);
+template<> PROTOBUF_EXPORT ::google::protobuf::UninterpretedOption_NamePart* Arena::CreateMaybeMessage<::google::protobuf::UninterpretedOption_NamePart>(Arena*);
} // namespace protobuf
} // namespace google
namespace google {
@@ -183,12 +184,12 @@ enum FieldDescriptorProto_Type {
FieldDescriptorProto_Type_TYPE_SINT32 = 17,
FieldDescriptorProto_Type_TYPE_SINT64 = 18
};
-LIBPROTOBUF_EXPORT bool FieldDescriptorProto_Type_IsValid(int value);
+PROTOBUF_EXPORT bool FieldDescriptorProto_Type_IsValid(int value);
const FieldDescriptorProto_Type FieldDescriptorProto_Type_Type_MIN = FieldDescriptorProto_Type_TYPE_DOUBLE;
const FieldDescriptorProto_Type FieldDescriptorProto_Type_Type_MAX = FieldDescriptorProto_Type_TYPE_SINT64;
const int FieldDescriptorProto_Type_Type_ARRAYSIZE = FieldDescriptorProto_Type_Type_MAX + 1;
-LIBPROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* FieldDescriptorProto_Type_descriptor();
+PROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* FieldDescriptorProto_Type_descriptor();
inline const ::std::string& FieldDescriptorProto_Type_Name(FieldDescriptorProto_Type value) {
return ::google::protobuf::internal::NameOfEnum(
FieldDescriptorProto_Type_descriptor(), value);
@@ -203,12 +204,12 @@ enum FieldDescriptorProto_Label {
FieldDescriptorProto_Label_LABEL_REQUIRED = 2,
FieldDescriptorProto_Label_LABEL_REPEATED = 3
};
-LIBPROTOBUF_EXPORT bool FieldDescriptorProto_Label_IsValid(int value);
+PROTOBUF_EXPORT bool FieldDescriptorProto_Label_IsValid(int value);
const FieldDescriptorProto_Label FieldDescriptorProto_Label_Label_MIN = FieldDescriptorProto_Label_LABEL_OPTIONAL;
const FieldDescriptorProto_Label FieldDescriptorProto_Label_Label_MAX = FieldDescriptorProto_Label_LABEL_REPEATED;
const int FieldDescriptorProto_Label_Label_ARRAYSIZE = FieldDescriptorProto_Label_Label_MAX + 1;
-LIBPROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* FieldDescriptorProto_Label_descriptor();
+PROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* FieldDescriptorProto_Label_descriptor();
inline const ::std::string& FieldDescriptorProto_Label_Name(FieldDescriptorProto_Label value) {
return ::google::protobuf::internal::NameOfEnum(
FieldDescriptorProto_Label_descriptor(), value);
@@ -223,12 +224,12 @@ enum FileOptions_OptimizeMode {
FileOptions_OptimizeMode_CODE_SIZE = 2,
FileOptions_OptimizeMode_LITE_RUNTIME = 3
};
-LIBPROTOBUF_EXPORT bool FileOptions_OptimizeMode_IsValid(int value);
+PROTOBUF_EXPORT bool FileOptions_OptimizeMode_IsValid(int value);
const FileOptions_OptimizeMode FileOptions_OptimizeMode_OptimizeMode_MIN = FileOptions_OptimizeMode_SPEED;
const FileOptions_OptimizeMode FileOptions_OptimizeMode_OptimizeMode_MAX = FileOptions_OptimizeMode_LITE_RUNTIME;
const int FileOptions_OptimizeMode_OptimizeMode_ARRAYSIZE = FileOptions_OptimizeMode_OptimizeMode_MAX + 1;
-LIBPROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* FileOptions_OptimizeMode_descriptor();
+PROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* FileOptions_OptimizeMode_descriptor();
inline const ::std::string& FileOptions_OptimizeMode_Name(FileOptions_OptimizeMode value) {
return ::google::protobuf::internal::NameOfEnum(
FileOptions_OptimizeMode_descriptor(), value);
@@ -243,12 +244,12 @@ enum FieldOptions_CType {
FieldOptions_CType_CORD = 1,
FieldOptions_CType_STRING_PIECE = 2
};
-LIBPROTOBUF_EXPORT bool FieldOptions_CType_IsValid(int value);
+PROTOBUF_EXPORT bool FieldOptions_CType_IsValid(int value);
const FieldOptions_CType FieldOptions_CType_CType_MIN = FieldOptions_CType_STRING;
const FieldOptions_CType FieldOptions_CType_CType_MAX = FieldOptions_CType_STRING_PIECE;
const int FieldOptions_CType_CType_ARRAYSIZE = FieldOptions_CType_CType_MAX + 1;
-LIBPROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* FieldOptions_CType_descriptor();
+PROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* FieldOptions_CType_descriptor();
inline const ::std::string& FieldOptions_CType_Name(FieldOptions_CType value) {
return ::google::protobuf::internal::NameOfEnum(
FieldOptions_CType_descriptor(), value);
@@ -263,12 +264,12 @@ enum FieldOptions_JSType {
FieldOptions_JSType_JS_STRING = 1,
FieldOptions_JSType_JS_NUMBER = 2
};
-LIBPROTOBUF_EXPORT bool FieldOptions_JSType_IsValid(int value);
+PROTOBUF_EXPORT bool FieldOptions_JSType_IsValid(int value);
const FieldOptions_JSType FieldOptions_JSType_JSType_MIN = FieldOptions_JSType_JS_NORMAL;
const FieldOptions_JSType FieldOptions_JSType_JSType_MAX = FieldOptions_JSType_JS_NUMBER;
const int FieldOptions_JSType_JSType_ARRAYSIZE = FieldOptions_JSType_JSType_MAX + 1;
-LIBPROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* FieldOptions_JSType_descriptor();
+PROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* FieldOptions_JSType_descriptor();
inline const ::std::string& FieldOptions_JSType_Name(FieldOptions_JSType value) {
return ::google::protobuf::internal::NameOfEnum(
FieldOptions_JSType_descriptor(), value);
@@ -283,12 +284,12 @@ enum MethodOptions_IdempotencyLevel {
MethodOptions_IdempotencyLevel_NO_SIDE_EFFECTS = 1,
MethodOptions_IdempotencyLevel_IDEMPOTENT = 2
};
-LIBPROTOBUF_EXPORT bool MethodOptions_IdempotencyLevel_IsValid(int value);
+PROTOBUF_EXPORT bool MethodOptions_IdempotencyLevel_IsValid(int value);
const MethodOptions_IdempotencyLevel MethodOptions_IdempotencyLevel_IdempotencyLevel_MIN = MethodOptions_IdempotencyLevel_IDEMPOTENCY_UNKNOWN;
const MethodOptions_IdempotencyLevel MethodOptions_IdempotencyLevel_IdempotencyLevel_MAX = MethodOptions_IdempotencyLevel_IDEMPOTENT;
const int MethodOptions_IdempotencyLevel_IdempotencyLevel_ARRAYSIZE = MethodOptions_IdempotencyLevel_IdempotencyLevel_MAX + 1;
-LIBPROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* MethodOptions_IdempotencyLevel_descriptor();
+PROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* MethodOptions_IdempotencyLevel_descriptor();
inline const ::std::string& MethodOptions_IdempotencyLevel_Name(MethodOptions_IdempotencyLevel value) {
return ::google::protobuf::internal::NameOfEnum(
MethodOptions_IdempotencyLevel_descriptor(), value);
@@ -300,7 +301,7 @@ inline bool MethodOptions_IdempotencyLevel_Parse(
}
// ===================================================================
-class LIBPROTOBUF_EXPORT FileDescriptorSet : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FileDescriptorSet) */ {
+class PROTOBUF_EXPORT FileDescriptorSet : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FileDescriptorSet) */ {
public:
FileDescriptorSet();
virtual ~FileDescriptorSet();
@@ -440,7 +441,7 @@ class LIBPROTOBUF_EXPORT FileDescriptorSet : public ::google::protobuf::Message
};
// -------------------------------------------------------------------
-class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FileDescriptorProto) */ {
+class PROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FileDescriptorProto) */ {
public:
FileDescriptorProto();
virtual ~FileDescriptorProto();
@@ -769,7 +770,7 @@ class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Messag
};
// -------------------------------------------------------------------
-class LIBPROTOBUF_EXPORT DescriptorProto_ExtensionRange : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.DescriptorProto.ExtensionRange) */ {
+class PROTOBUF_EXPORT DescriptorProto_ExtensionRange : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.DescriptorProto.ExtensionRange) */ {
public:
DescriptorProto_ExtensionRange();
virtual ~DescriptorProto_ExtensionRange();
@@ -925,7 +926,7 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ExtensionRange : public ::google::proto
};
// -------------------------------------------------------------------
-class LIBPROTOBUF_EXPORT DescriptorProto_ReservedRange : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.DescriptorProto.ReservedRange) */ {
+class PROTOBUF_EXPORT DescriptorProto_ReservedRange : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.DescriptorProto.ReservedRange) */ {
public:
DescriptorProto_ReservedRange();
virtual ~DescriptorProto_ReservedRange();
@@ -1068,7 +1069,7 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ReservedRange : public ::google::protob
};
// -------------------------------------------------------------------
-class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.DescriptorProto) */ {
+class PROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.DescriptorProto) */ {
public:
DescriptorProto();
virtual ~DescriptorProto();
@@ -1350,7 +1351,7 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /*
};
// -------------------------------------------------------------------
-class LIBPROTOBUF_EXPORT ExtensionRangeOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.ExtensionRangeOptions) */ {
+class PROTOBUF_EXPORT ExtensionRangeOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.ExtensionRangeOptions) */ {
public:
ExtensionRangeOptions();
virtual ~ExtensionRangeOptions();
@@ -1493,7 +1494,7 @@ class LIBPROTOBUF_EXPORT ExtensionRangeOptions : public ::google::protobuf::Mess
};
// -------------------------------------------------------------------
-class LIBPROTOBUF_EXPORT FieldDescriptorProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FieldDescriptorProto) */ {
+class PROTOBUF_EXPORT FieldDescriptorProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FieldDescriptorProto) */ {
public:
FieldDescriptorProto();
virtual ~FieldDescriptorProto();
@@ -1876,7 +1877,7 @@ class LIBPROTOBUF_EXPORT FieldDescriptorProto : public ::google::protobuf::Messa
};
// -------------------------------------------------------------------
-class LIBPROTOBUF_EXPORT OneofDescriptorProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.OneofDescriptorProto) */ {
+class PROTOBUF_EXPORT OneofDescriptorProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.OneofDescriptorProto) */ {
public:
OneofDescriptorProto();
virtual ~OneofDescriptorProto();
@@ -2041,7 +2042,7 @@ class LIBPROTOBUF_EXPORT OneofDescriptorProto : public ::google::protobuf::Messa
};
// -------------------------------------------------------------------
-class LIBPROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumDescriptorProto.EnumReservedRange) */ {
+class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumDescriptorProto.EnumReservedRange) */ {
public:
EnumDescriptorProto_EnumReservedRange();
virtual ~EnumDescriptorProto_EnumReservedRange();
@@ -2184,7 +2185,7 @@ class LIBPROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange : public ::google
};
// -------------------------------------------------------------------
-class LIBPROTOBUF_EXPORT EnumDescriptorProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumDescriptorProto) */ {
+class PROTOBUF_EXPORT EnumDescriptorProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumDescriptorProto) */ {
public:
EnumDescriptorProto();
virtual ~EnumDescriptorProto();
@@ -2400,7 +2401,7 @@ class LIBPROTOBUF_EXPORT EnumDescriptorProto : public ::google::protobuf::Messag
};
// -------------------------------------------------------------------
-class LIBPROTOBUF_EXPORT EnumValueDescriptorProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumValueDescriptorProto) */ {
+class PROTOBUF_EXPORT EnumValueDescriptorProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumValueDescriptorProto) */ {
public:
EnumValueDescriptorProto();
virtual ~EnumValueDescriptorProto();
@@ -2573,7 +2574,7 @@ class LIBPROTOBUF_EXPORT EnumValueDescriptorProto : public ::google::protobuf::M
};
// -------------------------------------------------------------------
-class LIBPROTOBUF_EXPORT ServiceDescriptorProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.ServiceDescriptorProto) */ {
+class PROTOBUF_EXPORT ServiceDescriptorProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.ServiceDescriptorProto) */ {
public:
ServiceDescriptorProto();
virtual ~ServiceDescriptorProto();
@@ -2751,7 +2752,7 @@ class LIBPROTOBUF_EXPORT ServiceDescriptorProto : public ::google::protobuf::Mes
};
// -------------------------------------------------------------------
-class LIBPROTOBUF_EXPORT MethodDescriptorProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.MethodDescriptorProto) */ {
+class PROTOBUF_EXPORT MethodDescriptorProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.MethodDescriptorProto) */ {
public:
MethodDescriptorProto();
virtual ~MethodDescriptorProto();
@@ -2982,7 +2983,7 @@ class LIBPROTOBUF_EXPORT MethodDescriptorProto : public ::google::protobuf::Mess
};
// -------------------------------------------------------------------
-class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FileOptions) */ {
+class PROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FileOptions) */ {
public:
FileOptions();
virtual ~FileOptions();
@@ -3383,11 +3384,11 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p
void set_java_multiple_files(bool value);
// optional bool java_generate_equals_and_hash = 20 [deprecated = true];
- GOOGLE_PROTOBUF_DEPRECATED bool has_java_generate_equals_and_hash() const;
- GOOGLE_PROTOBUF_DEPRECATED void clear_java_generate_equals_and_hash();
- GOOGLE_PROTOBUF_DEPRECATED static const int kJavaGenerateEqualsAndHashFieldNumber = 20;
- GOOGLE_PROTOBUF_DEPRECATED bool java_generate_equals_and_hash() const;
- GOOGLE_PROTOBUF_DEPRECATED void set_java_generate_equals_and_hash(bool value);
+ PROTOBUF_DEPRECATED bool has_java_generate_equals_and_hash() const;
+ PROTOBUF_DEPRECATED void clear_java_generate_equals_and_hash();
+ PROTOBUF_DEPRECATED static const int kJavaGenerateEqualsAndHashFieldNumber = 20;
+ PROTOBUF_DEPRECATED bool java_generate_equals_and_hash() const;
+ PROTOBUF_DEPRECATED void set_java_generate_equals_and_hash(bool value);
// optional bool java_string_check_utf8 = 27 [default = false];
bool has_java_string_check_utf8() const;
@@ -3483,7 +3484,7 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p
};
// -------------------------------------------------------------------
-class LIBPROTOBUF_EXPORT MessageOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.MessageOptions) */ {
+class PROTOBUF_EXPORT MessageOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.MessageOptions) */ {
public:
MessageOptions();
virtual ~MessageOptions();
@@ -3658,7 +3659,7 @@ class LIBPROTOBUF_EXPORT MessageOptions : public ::google::protobuf::Message /*
};
// -------------------------------------------------------------------
-class LIBPROTOBUF_EXPORT FieldOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FieldOptions) */ {
+class PROTOBUF_EXPORT FieldOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FieldOptions) */ {
public:
FieldOptions();
virtual ~FieldOptions();
@@ -3905,7 +3906,7 @@ class LIBPROTOBUF_EXPORT FieldOptions : public ::google::protobuf::Message /* @@
};
// -------------------------------------------------------------------
-class LIBPROTOBUF_EXPORT OneofOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.OneofOptions) */ {
+class PROTOBUF_EXPORT OneofOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.OneofOptions) */ {
public:
OneofOptions();
virtual ~OneofOptions();
@@ -4048,7 +4049,7 @@ class LIBPROTOBUF_EXPORT OneofOptions : public ::google::protobuf::Message /* @@
};
// -------------------------------------------------------------------
-class LIBPROTOBUF_EXPORT EnumOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumOptions) */ {
+class PROTOBUF_EXPORT EnumOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumOptions) */ {
public:
EnumOptions();
virtual ~EnumOptions();
@@ -4207,7 +4208,7 @@ class LIBPROTOBUF_EXPORT EnumOptions : public ::google::protobuf::Message /* @@p
};
// -------------------------------------------------------------------
-class LIBPROTOBUF_EXPORT EnumValueOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumValueOptions) */ {
+class PROTOBUF_EXPORT EnumValueOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumValueOptions) */ {
public:
EnumValueOptions();
virtual ~EnumValueOptions();
@@ -4358,7 +4359,7 @@ class LIBPROTOBUF_EXPORT EnumValueOptions : public ::google::protobuf::Message /
};
// -------------------------------------------------------------------
-class LIBPROTOBUF_EXPORT ServiceOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.ServiceOptions) */ {
+class PROTOBUF_EXPORT ServiceOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.ServiceOptions) */ {
public:
ServiceOptions();
virtual ~ServiceOptions();
@@ -4509,7 +4510,7 @@ class LIBPROTOBUF_EXPORT ServiceOptions : public ::google::protobuf::Message /*
};
// -------------------------------------------------------------------
-class LIBPROTOBUF_EXPORT MethodOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.MethodOptions) */ {
+class PROTOBUF_EXPORT MethodOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.MethodOptions) */ {
public:
MethodOptions();
virtual ~MethodOptions();
@@ -4696,7 +4697,7 @@ class LIBPROTOBUF_EXPORT MethodOptions : public ::google::protobuf::Message /* @
};
// -------------------------------------------------------------------
-class LIBPROTOBUF_EXPORT UninterpretedOption_NamePart : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.UninterpretedOption.NamePart) */ {
+class PROTOBUF_EXPORT UninterpretedOption_NamePart : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.UninterpretedOption.NamePart) */ {
public:
UninterpretedOption_NamePart();
virtual ~UninterpretedOption_NamePart();
@@ -4859,7 +4860,7 @@ class LIBPROTOBUF_EXPORT UninterpretedOption_NamePart : public ::google::protobu
};
// -------------------------------------------------------------------
-class LIBPROTOBUF_EXPORT UninterpretedOption : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.UninterpretedOption) */ {
+class PROTOBUF_EXPORT UninterpretedOption : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.UninterpretedOption) */ {
public:
UninterpretedOption();
virtual ~UninterpretedOption();
@@ -5100,7 +5101,7 @@ class LIBPROTOBUF_EXPORT UninterpretedOption : public ::google::protobuf::Messag
};
// -------------------------------------------------------------------
-class LIBPROTOBUF_EXPORT SourceCodeInfo_Location : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.SourceCodeInfo.Location) */ {
+class PROTOBUF_EXPORT SourceCodeInfo_Location : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.SourceCodeInfo.Location) */ {
public:
SourceCodeInfo_Location();
virtual ~SourceCodeInfo_Location();
@@ -5328,7 +5329,7 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo_Location : public ::google::protobuf::Me
};
// -------------------------------------------------------------------
-class LIBPROTOBUF_EXPORT SourceCodeInfo : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.SourceCodeInfo) */ {
+class PROTOBUF_EXPORT SourceCodeInfo : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.SourceCodeInfo) */ {
public:
SourceCodeInfo();
virtual ~SourceCodeInfo();
@@ -5470,7 +5471,7 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo : public ::google::protobuf::Message /*
};
// -------------------------------------------------------------------
-class LIBPROTOBUF_EXPORT GeneratedCodeInfo_Annotation : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.GeneratedCodeInfo.Annotation) */ {
+class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.GeneratedCodeInfo.Annotation) */ {
public:
GeneratedCodeInfo_Annotation();
virtual ~GeneratedCodeInfo_Annotation();
@@ -5652,7 +5653,7 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo_Annotation : public ::google::protobu
};
// -------------------------------------------------------------------
-class LIBPROTOBUF_EXPORT GeneratedCodeInfo : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.GeneratedCodeInfo) */ {
+class PROTOBUF_EXPORT GeneratedCodeInfo : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.GeneratedCodeInfo) */ {
public:
GeneratedCodeInfo();
virtual ~GeneratedCodeInfo();
@@ -10535,7 +10536,7 @@ inline bool UninterpretedOption::has_positive_int_value() const {
return (_has_bits_[0] & 0x00000008u) != 0;
}
inline void UninterpretedOption::clear_positive_int_value() {
- positive_int_value_ = GOOGLE_PROTOBUF_ULONGLONG(0);
+ positive_int_value_ = PROTOBUF_ULONGLONG(0);
_has_bits_[0] &= ~0x00000008u;
}
inline ::google::protobuf::uint64 UninterpretedOption::positive_int_value() const {
@@ -10553,7 +10554,7 @@ inline bool UninterpretedOption::has_negative_int_value() const {
return (_has_bits_[0] & 0x00000010u) != 0;
}
inline void UninterpretedOption::clear_negative_int_value() {
- negative_int_value_ = GOOGLE_PROTOBUF_LONGLONG(0);
+ negative_int_value_ = PROTOBUF_LONGLONG(0);
_has_bits_[0] &= ~0x00000010u;
}
inline ::google::protobuf::int64 UninterpretedOption::negative_int_value() const {
diff --git a/src/google/protobuf/descriptor_database.h b/src/google/protobuf/descriptor_database.h
index 0a87a147..48892af1 100644
--- a/src/google/protobuf/descriptor_database.h
+++ b/src/google/protobuf/descriptor_database.h
@@ -44,6 +44,12 @@
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/descriptor.h>
+#include <google/protobuf/port_def.inc>
+
+#ifdef SWIG
+#define PROTOBUF_EXPORT
+#endif
+
namespace google {
namespace protobuf {
@@ -62,27 +68,27 @@ class MergedDescriptorDatabase;
// calling DescriptorPool::BuildFile() for each one. Instead, a DescriptorPool
// can be created which wraps a DescriptorDatabase and only builds particular
// descriptors when they are needed.
-class LIBPROTOBUF_EXPORT DescriptorDatabase {
+class PROTOBUF_EXPORT DescriptorDatabase {
public:
inline DescriptorDatabase() {}
virtual ~DescriptorDatabase();
// Find a file by file name. Fills in in *output and returns true if found.
// Otherwise, returns false, leaving the contents of *output undefined.
- virtual bool FindFileByName(const string& filename,
+ virtual bool FindFileByName(const std::string& filename,
FileDescriptorProto* output) = 0;
// Find the file that declares the given fully-qualified symbol name.
// If found, fills in *output and returns true, otherwise returns false
// and leaves *output undefined.
- virtual bool FindFileContainingSymbol(const string& symbol_name,
+ virtual bool FindFileContainingSymbol(const std::string& symbol_name,
FileDescriptorProto* output) = 0;
// Find the file which defines an extension extending the given message type
// with the given field number. If found, fills in *output and returns true,
// otherwise returns false and leaves *output undefined. containing_type
// must be a fully-qualified type name.
- virtual bool FindFileContainingExtension(const string& containing_type,
+ virtual bool FindFileContainingExtension(const std::string& containing_type,
int field_number,
FileDescriptorProto* output) = 0;
@@ -96,7 +102,7 @@ class LIBPROTOBUF_EXPORT DescriptorDatabase {
//
// This method has a default implementation that always returns
// false.
- virtual bool FindAllExtensionNumbers(const string& /* extendee_type */,
+ virtual bool FindAllExtensionNumbers(const std::string& /* extendee_type */,
std::vector<int>* /* output */) {
return false;
}
@@ -110,7 +116,7 @@ class LIBPROTOBUF_EXPORT DescriptorDatabase {
//
// This method has a default implementation that always returns
// false.
- virtual bool FindAllFileNames(std::vector<string>* output) {
+ virtual bool FindAllFileNames(std::vector<std::string>* output) {
return false;
}
@@ -139,7 +145,7 @@ class LIBPROTOBUF_EXPORT DescriptorDatabase {
// FileDescriptor::CopyTo()) will always use fully-qualified names for all
// types. You only need to worry if you are constructing FileDescriptorProtos
// yourself, or are calling compiler::Parser directly.
-class LIBPROTOBUF_EXPORT SimpleDescriptorDatabase : public DescriptorDatabase {
+class PROTOBUF_EXPORT SimpleDescriptorDatabase : public DescriptorDatabase {
public:
SimpleDescriptorDatabase();
~SimpleDescriptorDatabase() override;
@@ -154,17 +160,17 @@ class LIBPROTOBUF_EXPORT SimpleDescriptorDatabase : public DescriptorDatabase {
bool AddAndOwn(const FileDescriptorProto* file);
// implements DescriptorDatabase -----------------------------------
- bool FindFileByName(const string& filename,
+ bool FindFileByName(const std::string& filename,
FileDescriptorProto* output) override;
- bool FindFileContainingSymbol(const string& symbol_name,
+ bool FindFileContainingSymbol(const std::string& symbol_name,
FileDescriptorProto* output) override;
- bool FindFileContainingExtension(const string& containing_type,
+ bool FindFileContainingExtension(const std::string& containing_type,
int field_number,
FileDescriptorProto* output) override;
- bool FindAllExtensionNumbers(const string& extendee_type,
+ bool FindAllExtensionNumbers(const std::string& extendee_type,
std::vector<int>* output) override;
- bool FindAllFileNames(std::vector<string>* output) override;
+ bool FindAllFileNames(std::vector<std::string>* output) override;
private:
// So that it can use DescriptorIndex.
@@ -179,23 +185,23 @@ class LIBPROTOBUF_EXPORT SimpleDescriptorDatabase : public DescriptorDatabase {
// to the index.
bool AddFile(const FileDescriptorProto& file,
Value value);
- bool AddSymbol(const string& name, Value value);
+ bool AddSymbol(const std::string& name, Value value);
bool AddNestedExtensions(const DescriptorProto& message_type,
Value value);
bool AddExtension(const FieldDescriptorProto& field,
Value value);
- Value FindFile(const string& filename);
- Value FindSymbol(const string& name);
- Value FindExtension(const string& containing_type, int field_number);
- bool FindAllExtensionNumbers(const string& containing_type,
+ Value FindFile(const std::string& filename);
+ Value FindSymbol(const std::string& name);
+ Value FindExtension(const std::string& containing_type, int field_number);
+ bool FindAllExtensionNumbers(const std::string& containing_type,
std::vector<int>* output);
- void FindAllFileNames(std::vector<string>* output);
+ void FindAllFileNames(std::vector<std::string>* output);
private:
- std::map<string, Value> by_name_;
- std::map<string, Value> by_symbol_;
- std::map<std::pair<string, int>, Value> by_extension_;
+ std::map<std::string, Value> by_name_;
+ std::map<std::string, Value> by_symbol_;
+ std::map<std::pair<std::string, int>, Value> by_extension_;
// Invariant: The by_symbol_ map does not contain any symbols which are
// prefixes of other symbols in the map. For example, "foo.bar" is a
@@ -250,17 +256,17 @@ class LIBPROTOBUF_EXPORT SimpleDescriptorDatabase : public DescriptorDatabase {
// Find the last entry in the by_symbol_ map whose key is less than or
// equal to the given name.
- typename std::map<string, Value>::iterator FindLastLessOrEqual(
- const string& name);
+ typename std::map<std::string, Value>::iterator FindLastLessOrEqual(
+ const std::string& name);
// True if either the arguments are equal or super_symbol identifies a
// parent symbol of sub_symbol (e.g. "foo.bar" is a parent of
// "foo.bar.baz", but not a parent of "foo.barbaz").
- bool IsSubSymbol(const string& sub_symbol, const string& super_symbol);
+ bool IsSubSymbol(const std::string& sub_symbol, const std::string& super_symbol);
// Returns true if and only if all characters in the name are alphanumerics,
// underscores, or periods.
- bool ValidateSymbolName(const string& name);
+ bool ValidateSymbolName(const std::string& name);
};
@@ -280,7 +286,7 @@ class LIBPROTOBUF_EXPORT SimpleDescriptorDatabase : public DescriptorDatabase {
//
// The same caveats regarding FindFileContainingExtension() apply as with
// SimpleDescriptorDatabase.
-class LIBPROTOBUF_EXPORT EncodedDescriptorDatabase : public DescriptorDatabase {
+class PROTOBUF_EXPORT EncodedDescriptorDatabase : public DescriptorDatabase {
public:
EncodedDescriptorDatabase();
~EncodedDescriptorDatabase() override;
@@ -298,18 +304,18 @@ class LIBPROTOBUF_EXPORT EncodedDescriptorDatabase : public DescriptorDatabase {
bool AddCopy(const void* encoded_file_descriptor, int size);
// Like FindFileContainingSymbol but returns only the name of the file.
- bool FindNameOfFileContainingSymbol(const string& symbol_name,
- string* output);
+ bool FindNameOfFileContainingSymbol(const std::string& symbol_name,
+ std::string* output);
// implements DescriptorDatabase -----------------------------------
- bool FindFileByName(const string& filename,
+ bool FindFileByName(const std::string& filename,
FileDescriptorProto* output) override;
- bool FindFileContainingSymbol(const string& symbol_name,
+ bool FindFileContainingSymbol(const std::string& symbol_name,
FileDescriptorProto* output) override;
- bool FindFileContainingExtension(const string& containing_type,
+ bool FindFileContainingExtension(const std::string& containing_type,
int field_number,
FileDescriptorProto* output) override;
- bool FindAllExtensionNumbers(const string& extendee_type,
+ bool FindAllExtensionNumbers(const std::string& extendee_type,
std::vector<int>* output) override;
private:
@@ -326,20 +332,20 @@ class LIBPROTOBUF_EXPORT EncodedDescriptorDatabase : public DescriptorDatabase {
};
// A DescriptorDatabase that fetches files from a given pool.
-class LIBPROTOBUF_EXPORT DescriptorPoolDatabase : public DescriptorDatabase {
+class PROTOBUF_EXPORT DescriptorPoolDatabase : public DescriptorDatabase {
public:
explicit DescriptorPoolDatabase(const DescriptorPool& pool);
~DescriptorPoolDatabase() override;
// implements DescriptorDatabase -----------------------------------
- bool FindFileByName(const string& filename,
+ bool FindFileByName(const std::string& filename,
FileDescriptorProto* output) override;
- bool FindFileContainingSymbol(const string& symbol_name,
+ bool FindFileContainingSymbol(const std::string& symbol_name,
FileDescriptorProto* output) override;
- bool FindFileContainingExtension(const string& containing_type,
+ bool FindFileContainingExtension(const std::string& containing_type,
int field_number,
FileDescriptorProto* output) override;
- bool FindAllExtensionNumbers(const string& extendee_type,
+ bool FindAllExtensionNumbers(const std::string& extendee_type,
std::vector<int>* output) override;
private:
@@ -349,7 +355,7 @@ class LIBPROTOBUF_EXPORT DescriptorPoolDatabase : public DescriptorDatabase {
// A DescriptorDatabase that wraps two or more others. It first searches the
// first database and, if that fails, tries the second, and so on.
-class LIBPROTOBUF_EXPORT MergedDescriptorDatabase : public DescriptorDatabase {
+class PROTOBUF_EXPORT MergedDescriptorDatabase : public DescriptorDatabase {
public:
// Merge just two databases. The sources remain property of the caller.
MergedDescriptorDatabase(DescriptorDatabase* source1,
@@ -362,16 +368,16 @@ class LIBPROTOBUF_EXPORT MergedDescriptorDatabase : public DescriptorDatabase {
~MergedDescriptorDatabase() override;
// implements DescriptorDatabase -----------------------------------
- bool FindFileByName(const string& filename,
+ bool FindFileByName(const std::string& filename,
FileDescriptorProto* output) override;
- bool FindFileContainingSymbol(const string& symbol_name,
+ bool FindFileContainingSymbol(const std::string& symbol_name,
FileDescriptorProto* output) override;
- bool FindFileContainingExtension(const string& containing_type,
+ bool FindFileContainingExtension(const std::string& containing_type,
int field_number,
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,
+ bool FindAllExtensionNumbers(const std::string& extendee_type,
std::vector<int>* output) override;
@@ -383,4 +389,6 @@ class LIBPROTOBUF_EXPORT MergedDescriptorDatabase : public DescriptorDatabase {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_DESCRIPTOR_DATABASE_H__
diff --git a/src/google/protobuf/descriptor_unittest.cc b/src/google/protobuf/descriptor_unittest.cc
index 0d16078e..e48e440f 100644
--- a/src/google/protobuf/descriptor_unittest.cc
+++ b/src/google/protobuf/descriptor_unittest.cc
@@ -62,6 +62,8 @@
#include <gtest/gtest.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
@@ -2507,11 +2509,11 @@ TEST_F(MiscTest, DefaultValues) {
ASSERT_TRUE(message->field(9)->has_default_value());
ASSERT_TRUE(message->field(10)->has_default_value());
- EXPECT_EQ(-1 , message->field(0)->default_value_int32 ());
- EXPECT_EQ(-GOOGLE_ULONGLONG(1000000000000),
- message->field(1)->default_value_int64 ());
- EXPECT_EQ(42 , message->field(2)->default_value_uint32());
- EXPECT_EQ(GOOGLE_ULONGLONG(2000000000000),
+ EXPECT_EQ(-1, message->field(0)->default_value_int32());
+ EXPECT_EQ(-PROTOBUF_ULONGLONG(1000000000000),
+ message->field(1)->default_value_int64());
+ EXPECT_EQ(42, message->field(2)->default_value_uint32());
+ EXPECT_EQ(PROTOBUF_ULONGLONG(2000000000000),
message->field(3)->default_value_uint64());
EXPECT_EQ(4.5 , message->field(4)->default_value_float ());
EXPECT_EQ(10e100 , message->field(5)->default_value_double());
@@ -2926,11 +2928,11 @@ TEST(CustomOptions, OptionLocations) {
file->FindServiceByName("TestServiceWithCustomOptions");
const MethodDescriptor* method = service->FindMethodByName("Foo");
- EXPECT_EQ(GOOGLE_LONGLONG(9876543210),
+ EXPECT_EQ(PROTOBUF_LONGLONG(9876543210),
file->options().GetExtension(protobuf_unittest::file_opt1));
EXPECT_EQ(-56,
message->options().GetExtension(protobuf_unittest::message_opt1));
- EXPECT_EQ(GOOGLE_LONGLONG(8765432109),
+ EXPECT_EQ(PROTOBUF_LONGLONG(8765432109),
field->options().GetExtension(protobuf_unittest::field_opt1));
EXPECT_EQ(42, // Check that we get the default for an option we don't set.
field->options().GetExtension(protobuf_unittest::field_opt2));
@@ -2941,7 +2943,7 @@ TEST(CustomOptions, OptionLocations) {
EXPECT_EQ(123,
enm->value(1)->options().GetExtension(
protobuf_unittest::enum_value_opt1));
- EXPECT_EQ(GOOGLE_LONGLONG(-9876543210),
+ EXPECT_EQ(PROTOBUF_LONGLONG(-9876543210),
service->options().GetExtension(protobuf_unittest::service_opt1));
EXPECT_EQ(protobuf_unittest::METHODOPT1_VAL2,
method->options().GetExtension(protobuf_unittest::method_opt1));
diff --git a/src/google/protobuf/duration.pb.cc b/src/google/protobuf/duration.pb.cc
index e9a82770..02602d28 100644
--- a/src/google/protobuf/duration.pb.cc
+++ b/src/google/protobuf/duration.pb.cc
@@ -13,10 +13,6 @@
#include <google/protobuf/generated_message_reflection.h>
#include <google/protobuf/reflection_ops.h>
#include <google/protobuf/wire_format.h>
-// This is a temporary google only hack
-#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
-#include "third_party/protobuf/version.h"
-#endif
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>
@@ -39,7 +35,7 @@ static void InitDefaultsDuration_google_2fprotobuf_2fduration_2eproto() {
::google::protobuf::Duration::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_Duration_google_2fprotobuf_2fduration_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_Duration_google_2fprotobuf_2fduration_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsDuration_google_2fprotobuf_2fduration_2eproto}, {}};
void InitDefaults_google_2fprotobuf_2fduration_2eproto() {
@@ -50,16 +46,16 @@ void InitDefaults_google_2fprotobuf_2fduration_2eproto() {
constexpr ::google::protobuf::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2fduration_2eproto = nullptr;
constexpr ::google::protobuf::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fduration_2eproto = nullptr;
-const ::google::protobuf::uint32 TableStruct_google_2fprotobuf_2fduration_2eproto::offsets[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
+const ::google::protobuf::uint32 TableStruct_google_2fprotobuf_2fduration_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
~0u, // no _has_bits_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Duration, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Duration, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Duration, seconds_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Duration, nanos_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Duration, seconds_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Duration, nanos_),
};
-static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
+static const ::google::protobuf::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
{ 0, -1, sizeof(::google::protobuf::Duration)},
};
@@ -185,15 +181,14 @@ const char* Duration::_InternalParse(const char* begin, const char* end, void* o
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// int64 seconds = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 8) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
::google::protobuf::int64 value = val;
msg->set_seconds(value);
break;
@@ -203,15 +198,16 @@ const char* Duration::_InternalParse(const char* begin, const char* end, void* o
if (static_cast<::google::protobuf::uint8>(tag) != 16) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
::google::protobuf::int32 value = val;
msg->set_nanos(value);
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
@@ -222,8 +218,6 @@ const char* Duration::_InternalParse(const char* begin, const char* end, void* o
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -235,7 +229,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool Duration::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.Duration)
for (;;) {
@@ -455,10 +449,11 @@ void Duration::InternalSwap(Duration* other) {
} // namespace google
namespace google {
namespace protobuf {
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Duration* Arena::CreateMaybeMessage< ::google::protobuf::Duration >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::Duration* Arena::CreateMaybeMessage< ::google::protobuf::Duration >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::Duration >(arena);
}
} // namespace protobuf
} // namespace google
// @@protoc_insertion_point(global_scope)
+#include <google/protobuf/port_undef.inc>
diff --git a/src/google/protobuf/duration.pb.h b/src/google/protobuf/duration.pb.h
index 1d32e1bb..78d94665 100644
--- a/src/google/protobuf/duration.pb.h
+++ b/src/google/protobuf/duration.pb.h
@@ -7,18 +7,19 @@
#include <limits>
#include <string>
-#include <google/protobuf/stubs/common.h>
-#if GOOGLE_PROTOBUF_VERSION < 3006000
+#include <google/protobuf/port_def.inc>
+#if PROTOBUF_VERSION < 3006001
#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 3006001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 3006001 < 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.
#endif
+#include <google/protobuf/port_undef.inc>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
@@ -32,27 +33,27 @@
#include <google/protobuf/unknown_field_set.h>
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>
-#define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fduration_2eproto LIBPROTOBUF_EXPORT
+#define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fduration_2eproto PROTOBUF_EXPORT
// Internal implementation detail -- do not use these members.
-struct LIBPROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fduration_2eproto {
+struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fduration_2eproto {
static const ::google::protobuf::internal::ParseTableField entries[]
- GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold);
+ PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::google::protobuf::internal::AuxillaryParseTableField aux[]
- GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold);
+ PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::google::protobuf::internal::ParseTable schema[1]
- GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold);
+ PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::google::protobuf::internal::FieldMetadata field_metadata[];
static const ::google::protobuf::internal::SerializationTable serialization_table[];
static const ::google::protobuf::uint32 offsets[];
};
-void LIBPROTOBUF_EXPORT AddDescriptors_google_2fprotobuf_2fduration_2eproto();
+void PROTOBUF_EXPORT AddDescriptors_google_2fprotobuf_2fduration_2eproto();
namespace google {
namespace protobuf {
class Duration;
class DurationDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern DurationDefaultTypeInternal _Duration_default_instance_;
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::Duration* Arena::CreateMaybeMessage<::google::protobuf::Duration>(Arena*);
+PROTOBUF_EXPORT extern DurationDefaultTypeInternal _Duration_default_instance_;
+template<> PROTOBUF_EXPORT ::google::protobuf::Duration* Arena::CreateMaybeMessage<::google::protobuf::Duration>(Arena*);
} // namespace protobuf
} // namespace google
namespace google {
@@ -60,7 +61,7 @@ namespace protobuf {
// ===================================================================
-class LIBPROTOBUF_EXPORT Duration : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Duration) */ {
+class PROTOBUF_EXPORT Duration : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Duration) */ {
public:
Duration();
virtual ~Duration();
@@ -204,7 +205,7 @@ class LIBPROTOBUF_EXPORT Duration : public ::google::protobuf::Message /* @@prot
// int64 seconds = 1;
inline void Duration::clear_seconds() {
- seconds_ = GOOGLE_PROTOBUF_LONGLONG(0);
+ seconds_ = PROTOBUF_LONGLONG(0);
}
inline ::google::protobuf::int64 Duration::seconds() const {
// @@protoc_insertion_point(field_get:google.protobuf.Duration.seconds)
diff --git a/src/google/protobuf/dynamic_message.h b/src/google/protobuf/dynamic_message.h
index c614ee5a..1ea6f66f 100644
--- a/src/google/protobuf/dynamic_message.h
+++ b/src/google/protobuf/dynamic_message.h
@@ -51,6 +51,8 @@
#error "You cannot SWIG proto headers"
#endif
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
@@ -75,7 +77,7 @@ class DescriptorPool; // descriptor.h
// encapsulates this "cache". All DynamicMessages of the same type created
// from the same factory will share the same support data. Any Descriptors
// used with a particular factory must outlive the factory.
-class LIBPROTOBUF_EXPORT DynamicMessageFactory : public MessageFactory {
+class PROTOBUF_EXPORT DynamicMessageFactory : public MessageFactory {
public:
// Construct a DynamicMessageFactory that will search for extensions in
// the DescriptorPool in which the extendee is defined.
@@ -151,7 +153,7 @@ class LIBPROTOBUF_EXPORT DynamicMessageFactory : public MessageFactory {
};
// Helper for computing a sorted list of map entries via reflection.
-class LIBPROTOBUF_EXPORT DynamicMapSorter {
+class PROTOBUF_EXPORT DynamicMapSorter {
public:
static std::vector<const Message*> Sort(const Message& message,
int map_size,
@@ -182,7 +184,7 @@ class LIBPROTOBUF_EXPORT DynamicMapSorter {
}
private:
- class LIBPROTOBUF_EXPORT MapEntryMessageComparator {
+ class PROTOBUF_EXPORT MapEntryMessageComparator {
public:
explicit MapEntryMessageComparator(const Descriptor* descriptor)
: field_(descriptor->field(0)) {}
@@ -216,8 +218,8 @@ class LIBPROTOBUF_EXPORT DynamicMapSorter {
return first < second;
}
case FieldDescriptor::CPPTYPE_STRING: {
- string first = reflection->GetString(*a, field_);
- string second = reflection->GetString(*b, field_);
+ std::string first = reflection->GetString(*a, field_);
+ std::string second = reflection->GetString(*b, field_);
return first < second;
}
default:
@@ -234,4 +236,6 @@ class LIBPROTOBUF_EXPORT DynamicMapSorter {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_DYNAMIC_MESSAGE_H__
diff --git a/src/google/protobuf/empty.pb.cc b/src/google/protobuf/empty.pb.cc
index 5ca92661..9d0f9ae0 100644
--- a/src/google/protobuf/empty.pb.cc
+++ b/src/google/protobuf/empty.pb.cc
@@ -13,10 +13,6 @@
#include <google/protobuf/generated_message_reflection.h>
#include <google/protobuf/reflection_ops.h>
#include <google/protobuf/wire_format.h>
-// This is a temporary google only hack
-#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
-#include "third_party/protobuf/version.h"
-#endif
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>
@@ -39,7 +35,7 @@ static void InitDefaultsEmpty_google_2fprotobuf_2fempty_2eproto() {
::google::protobuf::Empty::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_Empty_google_2fprotobuf_2fempty_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_Empty_google_2fprotobuf_2fempty_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsEmpty_google_2fprotobuf_2fempty_2eproto}, {}};
void InitDefaults_google_2fprotobuf_2fempty_2eproto() {
@@ -50,14 +46,14 @@ void InitDefaults_google_2fprotobuf_2fempty_2eproto() {
constexpr ::google::protobuf::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2fempty_2eproto = nullptr;
constexpr ::google::protobuf::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fempty_2eproto = nullptr;
-const ::google::protobuf::uint32 TableStruct_google_2fprotobuf_2fempty_2eproto::offsets[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
+const ::google::protobuf::uint32 TableStruct_google_2fprotobuf_2fempty_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
~0u, // no _has_bits_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Empty, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Empty, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
};
-static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
+static const ::google::protobuf::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
{ 0, -1, sizeof(::google::protobuf::Empty)},
};
@@ -171,13 +167,13 @@ const char* Empty::_InternalParse(const char* begin, const char* end, void* obje
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
@@ -188,8 +184,6 @@ const char* Empty::_InternalParse(const char* begin, const char* end, void* obje
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -201,7 +195,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool Empty::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.Empty)
for (;;) {
@@ -348,10 +342,11 @@ void Empty::InternalSwap(Empty* other) {
} // namespace google
namespace google {
namespace protobuf {
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Empty* Arena::CreateMaybeMessage< ::google::protobuf::Empty >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::Empty* Arena::CreateMaybeMessage< ::google::protobuf::Empty >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::Empty >(arena);
}
} // namespace protobuf
} // namespace google
// @@protoc_insertion_point(global_scope)
+#include <google/protobuf/port_undef.inc>
diff --git a/src/google/protobuf/empty.pb.h b/src/google/protobuf/empty.pb.h
index 65f0b192..39b944b1 100644
--- a/src/google/protobuf/empty.pb.h
+++ b/src/google/protobuf/empty.pb.h
@@ -7,18 +7,19 @@
#include <limits>
#include <string>
-#include <google/protobuf/stubs/common.h>
-#if GOOGLE_PROTOBUF_VERSION < 3006000
+#include <google/protobuf/port_def.inc>
+#if PROTOBUF_VERSION < 3006001
#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 3006001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 3006001 < 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.
#endif
+#include <google/protobuf/port_undef.inc>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
@@ -32,27 +33,27 @@
#include <google/protobuf/unknown_field_set.h>
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>
-#define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fempty_2eproto LIBPROTOBUF_EXPORT
+#define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fempty_2eproto PROTOBUF_EXPORT
// Internal implementation detail -- do not use these members.
-struct LIBPROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fempty_2eproto {
+struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fempty_2eproto {
static const ::google::protobuf::internal::ParseTableField entries[]
- GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold);
+ PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::google::protobuf::internal::AuxillaryParseTableField aux[]
- GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold);
+ PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::google::protobuf::internal::ParseTable schema[1]
- GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold);
+ PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::google::protobuf::internal::FieldMetadata field_metadata[];
static const ::google::protobuf::internal::SerializationTable serialization_table[];
static const ::google::protobuf::uint32 offsets[];
};
-void LIBPROTOBUF_EXPORT AddDescriptors_google_2fprotobuf_2fempty_2eproto();
+void PROTOBUF_EXPORT AddDescriptors_google_2fprotobuf_2fempty_2eproto();
namespace google {
namespace protobuf {
class Empty;
class EmptyDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern EmptyDefaultTypeInternal _Empty_default_instance_;
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::Empty* Arena::CreateMaybeMessage<::google::protobuf::Empty>(Arena*);
+PROTOBUF_EXPORT extern EmptyDefaultTypeInternal _Empty_default_instance_;
+template<> PROTOBUF_EXPORT ::google::protobuf::Empty* Arena::CreateMaybeMessage<::google::protobuf::Empty>(Arena*);
} // namespace protobuf
} // namespace google
namespace google {
@@ -60,7 +61,7 @@ namespace protobuf {
// ===================================================================
-class LIBPROTOBUF_EXPORT Empty : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Empty) */ {
+class PROTOBUF_EXPORT Empty : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Empty) */ {
public:
Empty();
virtual ~Empty();
diff --git a/src/google/protobuf/extension_set.cc b/src/google/protobuf/extension_set.cc
index cb40ab71..6629ec04 100644
--- a/src/google/protobuf/extension_set.cc
+++ b/src/google/protobuf/extension_set.cc
@@ -206,7 +206,7 @@ ExtensionSet::~ExtensionSet() {
// Deletes all allocated extensions.
if (arena_ == NULL) {
ForEach([](int /* number */, Extension& ext) { ext.Free(); });
- if (GOOGLE_PREDICT_FALSE(is_large())) {
+ if (PROTOBUF_PREDICT_FALSE(is_large())) {
delete map_.large;
} else {
DeleteFlatMap(map_.flat, flat_capacity_);
@@ -912,8 +912,8 @@ size_t SizeOfUnion(ItX it_xs, ItX end_xs, ItY it_ys, ItY end_ys) {
} // namespace
void ExtensionSet::MergeFrom(const ExtensionSet& other) {
- if (GOOGLE_PREDICT_TRUE(!is_large())) {
- if (GOOGLE_PREDICT_TRUE(!other.is_large())) {
+ if (PROTOBUF_PREDICT_TRUE(!is_large())) {
+ if (PROTOBUF_PREDICT_TRUE(!other.is_large())) {
GrowCapacity(SizeOfUnion(flat_begin(), flat_end(), other.flat_begin(),
other.flat_end()));
} else {
@@ -1141,7 +1141,7 @@ void ExtensionSet::SwapExtension(ExtensionSet* other,
bool ExtensionSet::IsInitialized() const {
// Extensions are never required. However, we need to check that all
// embedded messages are initialized.
- if (GOOGLE_PREDICT_FALSE(is_large())) {
+ if (PROTOBUF_PREDICT_FALSE(is_large())) {
for (const auto& kv : *map_.large) {
if (!kv.second.IsInitialized()) return false;
}
@@ -1202,16 +1202,16 @@ bool ExtensionSet::ParseField(uint32 tag, io::CodedInputStream* input,
#if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
std::pair<const char*, bool> ExtensionSet::ParseField(
- uint32 tag, ParseClosure parent, const char* begin, const char* end,
+ uint64 tag, ParseClosure parent, const char* begin, const char* end,
const MessageLite* containing_type,
internal::InternalMetadataWithArenaLite* metadata,
internal::ParseContext* ctx) {
GeneratedExtensionFinder finder(containing_type);
- int number;
+ int number = tag >> 3;
bool was_packed_on_wire;
ExtensionInfo extension;
- if (!FindExtensionInfoFromTag(tag, &finder, &number, &extension,
- &was_packed_on_wire)) {
+ if (!FindExtensionInfoFromFieldNumber(tag & 7, number, &finder, &extension,
+ &was_packed_on_wire)) {
return UnknownFieldParse(tag, parent, begin, end,
metadata->mutable_unknown_fields(), ctx);
}
@@ -1265,7 +1265,7 @@ std::pair<const char*, bool> ExtensionSet::ParseField(
case WireFormatLite::TYPE_##UPPERCASE: { \
uint64 value; \
ptr = Varint::Parse64(ptr, &value); \
- if (ptr == nullptr) goto error; \
+ GOOGLE_PROTOBUF_ASSERT_RETURN(ptr, std::make_pair(nullptr, true)); \
if (extension.is_repeated) { \
Add##CPP_CAMELCASE(number, WireFormatLite::TYPE_##UPPERCASE, \
extension.is_packed, value, extension.descriptor); \
@@ -1284,6 +1284,7 @@ std::pair<const char*, bool> ExtensionSet::ParseField(
case WireFormatLite::TYPE_##UPPERCASE: { \
uint64 val; \
ptr = Varint::Parse64(ptr, &val); \
+ GOOGLE_PROTOBUF_ASSERT_RETURN(ptr, std::make_pair(nullptr, true)); \
auto value = WireFormatLite::ZigZagDecode##SIZE(val); \
if (extension.is_repeated) { \
Add##CPP_CAMELCASE(number, WireFormatLite::TYPE_##UPPERCASE, \
@@ -1323,7 +1324,7 @@ std::pair<const char*, bool> ExtensionSet::ParseField(
case WireFormatLite::TYPE_ENUM: {
uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (ptr == nullptr) goto error;
+ GOOGLE_PROTOBUF_ASSERT_RETURN(ptr, std::make_pair(nullptr, true));
int value = val;
if (!extension.enum_validity_check.func(
@@ -1359,9 +1360,10 @@ std::pair<const char*, bool> ExtensionSet::ParseField(
*extension.message_prototype,
extension.descriptor);
child = {value->_ParseFunc(), value};
- if (!ctx->PrepareGroup(tag, &depth)) goto error;
+ bool ok = ctx->PrepareGroup(tag, &depth);
+ GOOGLE_PROTOBUF_ASSERT_RETURN(ok, std::make_pair(nullptr, true));
ptr = child(ptr, end, ctx);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_ASSERT_RETURN(ptr, std::make_pair(nullptr, true));
if (ctx->GroupContinues(depth)) goto group_continues;
break;
}
@@ -1382,19 +1384,15 @@ std::pair<const char*, bool> ExtensionSet::ParseField(
return std::make_pair(ptr, false);
-error:
- return std::make_pair(nullptr, true);
-
length_delim:
uint32 size;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_ASSERT_RETURN(ptr, std::make_pair(nullptr, true));
if (size > end - ptr) goto len_delim_till_end;
{
auto newend = ptr + size;
- if (!ctx->ParseExactRange(child, ptr, newend)) {
- goto error;
- }
+ bool ok = ctx->ParseExactRange(child, ptr, newend);
+ GOOGLE_PROTOBUF_ASSERT_RETURN(ok, std::make_pair(nullptr, true));
ptr = newend;
}
return std::make_pair(ptr, false);
@@ -1641,7 +1639,7 @@ bool ExtensionSet::ParseMessageSet(io::CodedInputStream* input,
void ExtensionSet::SerializeWithCachedSizes(
int start_field_number, int end_field_number,
io::CodedOutputStream* output) const {
- if (GOOGLE_PREDICT_FALSE(is_large())) {
+ if (PROTOBUF_PREDICT_FALSE(is_large())) {
const auto& end = map_.large->end();
for (auto it = map_.large->lower_bound(start_field_number);
it != end && it->first < end_field_number; ++it) {
@@ -2071,7 +2069,7 @@ bool ExtensionSet::Extension::IsInitialized() const {
void ExtensionSet::LazyMessageExtension::UnusedKeyMethod() {}
const ExtensionSet::Extension* ExtensionSet::FindOrNull(int key) const {
- if (GOOGLE_PREDICT_FALSE(is_large())) {
+ if (PROTOBUF_PREDICT_FALSE(is_large())) {
return FindOrNullInLargeMap(key);
}
const KeyValue* end = flat_end();
@@ -2094,7 +2092,7 @@ const ExtensionSet::Extension* ExtensionSet::FindOrNullInLargeMap(
}
ExtensionSet::Extension* ExtensionSet::FindOrNull(int key) {
- if (GOOGLE_PREDICT_FALSE(is_large())) {
+ if (PROTOBUF_PREDICT_FALSE(is_large())) {
return FindOrNullInLargeMap(key);
}
KeyValue* end = flat_end();
@@ -2116,7 +2114,7 @@ ExtensionSet::Extension* ExtensionSet::FindOrNullInLargeMap(int key) {
}
std::pair<ExtensionSet::Extension*, bool> ExtensionSet::Insert(int key) {
- if (GOOGLE_PREDICT_FALSE(is_large())) {
+ if (PROTOBUF_PREDICT_FALSE(is_large())) {
auto maybe = map_.large->insert({key, Extension()});
return {&maybe.first->second, maybe.second};
}
@@ -2138,7 +2136,7 @@ std::pair<ExtensionSet::Extension*, bool> ExtensionSet::Insert(int key) {
}
void ExtensionSet::GrowCapacity(size_t minimum_new_capacity) {
- if (GOOGLE_PREDICT_FALSE(is_large())) {
+ if (PROTOBUF_PREDICT_FALSE(is_large())) {
return; // LargeMap does not have a "reserve" method.
}
if (flat_capacity_ >= minimum_new_capacity) {
@@ -2174,7 +2172,7 @@ void ExtensionSet::GrowCapacity(size_t minimum_new_capacity) {
constexpr uint16 ExtensionSet::kMaximumFlatCapacity;
void ExtensionSet::Erase(int key) {
- if (GOOGLE_PREDICT_FALSE(is_large())) {
+ if (PROTOBUF_PREDICT_FALSE(is_large())) {
map_.large->erase(key);
return;
}
@@ -2201,6 +2199,82 @@ RepeatedStringTypeTraits::GetDefaultRepeatedField() {
return instance;
}
+void ExtensionSet::Extension::SerializeMessageSetItemWithCachedSizes(
+ int number,
+ io::CodedOutputStream* output) const {
+ if (type != WireFormatLite::TYPE_MESSAGE || is_repeated) {
+ // Not a valid MessageSet extension, but serialize it the normal way.
+ SerializeFieldWithCachedSizes(number, output);
+ return;
+ }
+
+ if (is_cleared) return;
+
+ // Start group.
+ output->WriteTag(WireFormatLite::kMessageSetItemStartTag);
+
+ // Write type ID.
+ WireFormatLite::WriteUInt32(WireFormatLite::kMessageSetTypeIdNumber,
+ number,
+ output);
+ // Write message.
+ if (is_lazy) {
+ lazymessage_value->WriteMessage(
+ WireFormatLite::kMessageSetMessageNumber, output);
+ } else {
+ WireFormatLite::WriteMessageMaybeToArray(
+ WireFormatLite::kMessageSetMessageNumber,
+ *message_value,
+ output);
+ }
+
+ // End group.
+ output->WriteTag(WireFormatLite::kMessageSetItemEndTag);
+}
+
+size_t ExtensionSet::Extension::MessageSetItemByteSize(int number) const {
+ if (type != WireFormatLite::TYPE_MESSAGE || is_repeated) {
+ // Not a valid MessageSet extension, but compute the byte size for it the
+ // normal way.
+ return ByteSize(number);
+ }
+
+ if (is_cleared) return 0;
+
+ size_t our_size = WireFormatLite::kMessageSetItemTagsSize;
+
+ // type_id
+ our_size += io::CodedOutputStream::VarintSize32(number);
+
+ // message
+ size_t message_size = 0;
+ if (is_lazy) {
+ message_size = lazymessage_value->ByteSizeLong();
+ } else {
+ message_size = message_value->ByteSizeLong();
+ }
+
+ our_size += io::CodedOutputStream::VarintSize32(message_size);
+ our_size += message_size;
+
+ return our_size;
+}
+
+void ExtensionSet::SerializeMessageSetWithCachedSizes(
+ io::CodedOutputStream* output) const {
+ ForEach([output](int number, const Extension& ext) {
+ ext.SerializeMessageSetItemWithCachedSizes(number, output);
+ });
+}
+
+size_t ExtensionSet::MessageSetByteSize() const {
+ size_t total_size = 0;
+ ForEach([&total_size](int number, const Extension& ext) {
+ total_size += ext.MessageSetItemByteSize(number);
+ });
+ return total_size;
+}
+
} // namespace internal
} // namespace protobuf
} // namespace google
diff --git a/src/google/protobuf/extension_set.h b/src/google/protobuf/extension_set.h
index c22dfe07..b31c8c4f 100644
--- a/src/google/protobuf/extension_set.h
+++ b/src/google/protobuf/extension_set.h
@@ -47,7 +47,9 @@
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/logging.h>
+#include <google/protobuf/port.h>
#include <google/protobuf/repeated_field.h>
+#include <google/protobuf/wire_format_lite.h>
#include <google/protobuf/port_def.inc>
@@ -132,7 +134,7 @@ struct ExtensionInfo {
// Abstract interface for an object which looks up extension definitions. Used
// when parsing.
-class LIBPROTOBUF_EXPORT ExtensionFinder {
+class PROTOBUF_EXPORT ExtensionFinder {
public:
virtual ~ExtensionFinder();
@@ -142,7 +144,7 @@ class LIBPROTOBUF_EXPORT ExtensionFinder {
// Implementation of ExtensionFinder which finds extensions defined in .proto
// files which have been compiled into the binary.
-class LIBPROTOBUF_EXPORT GeneratedExtensionFinder : public ExtensionFinder {
+class PROTOBUF_EXPORT GeneratedExtensionFinder : public ExtensionFinder {
public:
GeneratedExtensionFinder(const MessageLite* containing_type)
: containing_type_(containing_type) {}
@@ -172,7 +174,7 @@ class MessageSetFieldSkipper;
// ExtensionSet. When parsing, if a tag number is encountered which is
// inside one of the message type's extension ranges, the tag is passed
// off to the ExtensionSet for parsing. Etc.
-class LIBPROTOBUF_EXPORT ExtensionSet {
+class PROTOBUF_EXPORT ExtensionSet {
public:
ExtensionSet();
explicit ExtensionSet(Arena* arena);
@@ -249,7 +251,7 @@ class LIBPROTOBUF_EXPORT ExtensionSet {
double GetDouble(int number, double default_value) const;
bool GetBool(int number, bool default_value) const;
int GetEnum(int number, int default_value) const;
- const string& GetString(int number, const string& default_value) const;
+ const std::string& GetString(int number, const std::string& default_value) const;
const MessageLite& GetMessage(int number,
const MessageLite& default_value) const;
const MessageLite& GetMessage(int number, const Descriptor* message_type,
@@ -267,8 +269,8 @@ class LIBPROTOBUF_EXPORT ExtensionSet {
void SetDouble(int number, FieldType type, double value, desc);
void SetBool(int number, FieldType type, bool value, desc);
void SetEnum(int number, FieldType type, int value, desc);
- void SetString(int number, FieldType type, const string& value, desc);
- string* MutableString(int number, FieldType type, desc);
+ void SetString(int number, FieldType type, const std::string& value, desc);
+ std::string* MutableString(int number, FieldType type, desc);
MessageLite* MutableMessage(int number, FieldType type,
const MessageLite& prototype, desc);
MessageLite* MutableMessage(const FieldDescriptor* decsriptor,
@@ -319,7 +321,7 @@ class LIBPROTOBUF_EXPORT ExtensionSet {
double GetRepeatedDouble(int number, int index) const;
bool GetRepeatedBool(int number, int index) const;
int GetRepeatedEnum(int number, int index) const;
- const string& GetRepeatedString(int number, int index) const;
+ const std::string& GetRepeatedString(int number, int index) const;
const MessageLite& GetRepeatedMessage(int number, int index) const;
void SetRepeatedInt32(int number, int index, int32 value);
@@ -330,8 +332,8 @@ class LIBPROTOBUF_EXPORT ExtensionSet {
void SetRepeatedDouble(int number, int index, double value);
void SetRepeatedBool(int number, int index, bool value);
void SetRepeatedEnum(int number, int index, int value);
- void SetRepeatedString(int number, int index, const string& value);
- string* MutableRepeatedString(int number, int index);
+ void SetRepeatedString(int number, int index, const std::string& value);
+ std::string* MutableRepeatedString(int number, int index);
MessageLite* MutableRepeatedMessage(int number, int index);
#define desc const FieldDescriptor* descriptor // avoid line wrapping
@@ -343,8 +345,8 @@ class LIBPROTOBUF_EXPORT ExtensionSet {
void AddDouble(int number, FieldType type, bool packed, double value, desc);
void AddBool(int number, FieldType type, bool packed, bool value, desc);
void AddEnum(int number, FieldType type, bool packed, int value, desc);
- void AddString(int number, FieldType type, const string& value, desc);
- string* AddString(int number, FieldType type, desc);
+ void AddString(int number, FieldType type, const std::string& value, desc);
+ std::string* AddString(int number, FieldType type, desc);
MessageLite* AddMessage(int number, FieldType type,
const MessageLite& prototype, desc);
MessageLite* AddMessage(const FieldDescriptor* descriptor,
@@ -396,13 +398,13 @@ class LIBPROTOBUF_EXPORT ExtensionSet {
#if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
// Lite parser
std::pair<const char*, bool> ParseField(
- uint32 tag, ParseClosure parent, const char* begin, const char* end,
+ uint64 tag, ParseClosure parent, const char* begin, const char* end,
const MessageLite* containing_type,
internal::InternalMetadataWithArenaLite* metadata,
internal::ParseContext* ctx);
// Full parser
std::pair<const char*, bool> ParseField(
- uint32 tag, ParseClosure parent, const char* begin, const char* end,
+ uint64 tag, ParseClosure parent, const char* begin, const char* end,
const Message* containing_type,
internal::InternalMetadataWithArena* metadata,
internal::ParseContext* ctx);
@@ -426,7 +428,7 @@ class LIBPROTOBUF_EXPORT ExtensionSet {
// FieldSkipper automatically).
bool ParseMessageSet(io::CodedInputStream* input,
const MessageLite* containing_type,
- string* unknown_fields);
+ std::string* unknown_fields);
bool ParseMessageSet(io::CodedInputStream* input,
const Message* containing_type,
UnknownFieldSet* unknown_fields);
@@ -485,7 +487,7 @@ class LIBPROTOBUF_EXPORT ExtensionSet {
private:
// Interface of a lazily parsed singular message extension.
- class LIBPROTOBUF_EXPORT LazyMessageExtension {
+ class PROTOBUF_EXPORT LazyMessageExtension {
public:
LazyMessageExtension() {}
virtual ~LazyMessageExtension() {}
@@ -502,7 +504,7 @@ class LIBPROTOBUF_EXPORT ExtensionSet {
virtual bool IsInitialized() const = 0;
- GOOGLE_PROTOBUF_DEPRECATED_MSG("Please use ByteSizeLong() instead")
+ PROTOBUF_DEPRECATED_MSG("Please use ByteSizeLong() instead")
virtual int ByteSize() const { return internal::ToIntSize(ByteSizeLong()); }
virtual size_t ByteSizeLong() const = 0;
virtual size_t SpaceUsedLong() const = 0;
@@ -539,7 +541,7 @@ class LIBPROTOBUF_EXPORT ExtensionSet {
double double_value;
bool bool_value;
int enum_value;
- string* string_value;
+ std::string* string_value;
MessageLite* message_value;
LazyMessageExtension* lazymessage_value;
@@ -551,7 +553,7 @@ class LIBPROTOBUF_EXPORT ExtensionSet {
RepeatedField<double>* repeated_double_value;
RepeatedField<bool>* repeated_bool_value;
RepeatedField<int>* repeated_enum_value;
- RepeatedPtrField<string>* repeated_string_value;
+ RepeatedPtrField<std::string>* repeated_string_value;
RepeatedPtrField<MessageLite>* repeated_message_value;
};
@@ -655,7 +657,7 @@ class LIBPROTOBUF_EXPORT ExtensionSet {
void Erase(int key);
size_t Size() const {
- return GOOGLE_PREDICT_FALSE(is_large()) ? map_.large->size() : flat_size_;
+ return PROTOBUF_PREDICT_FALSE(is_large()) ? map_.large->size() : flat_size_;
}
// Similar to std::for_each.
@@ -671,7 +673,7 @@ class LIBPROTOBUF_EXPORT ExtensionSet {
// Applies a functor to the <int, Extension&> pairs in sorted order.
template <typename KeyValueFunctor>
KeyValueFunctor ForEach(KeyValueFunctor func) {
- if (GOOGLE_PREDICT_FALSE(is_large())) {
+ if (PROTOBUF_PREDICT_FALSE(is_large())) {
return ForEach(map_.large->begin(), map_.large->end(), std::move(func));
}
return ForEach(flat_begin(), flat_end(), std::move(func));
@@ -680,7 +682,7 @@ class LIBPROTOBUF_EXPORT ExtensionSet {
// Applies a functor to the <int, const Extension&> pairs in sorted order.
template <typename KeyValueFunctor>
KeyValueFunctor ForEach(KeyValueFunctor func) const {
- if (GOOGLE_PREDICT_FALSE(is_large())) {
+ if (PROTOBUF_PREDICT_FALSE(is_large())) {
return ForEach(map_.large->begin(), map_.large->end(), std::move(func));
}
return ForEach(flat_begin(), flat_end(), std::move(func));
@@ -690,10 +692,10 @@ class LIBPROTOBUF_EXPORT ExtensionSet {
void InternalExtensionMergeFrom(int number, const Extension& other_extension);
#if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
- bool FindExtension(uint32 tag, const Message* containing_type,
+ bool FindExtension(int wire_type, uint32 field,
+ const Message* containing_type,
const internal::ParseContext* ctx,
- ExtensionInfo* extension, int* number,
- bool* was_packed_on_wire);
+ ExtensionInfo* extension, bool* was_packed_on_wire);
#endif
// Returns true and fills field_number and extension if extension is found.
@@ -796,18 +798,54 @@ class LIBPROTOBUF_EXPORT ExtensionSet {
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ExtensionSet);
};
+#if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
+template <typename Msg, typename Metadata>
+const char* ParseMessageSet(const char* begin, const char* end, Msg* msg,
+ ExtensionSet* ext, Metadata* metadata,
+ internal::ParseContext* ctx) {
+ auto ptr = begin;
+ int depth;
+ (void)depth;
+ while (ptr < end) {
+ uint32 tag;
+ ptr = Varint::Parse32Inline(ptr, &tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
+ if (tag == WireFormatLite::kMessageSetItemStartTag) {
+ bool ok = ctx->PrepareGroup(tag, &depth);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
+ ctx->extra_parse_data().payload.clear();
+ ptr = Msg::InternalParseMessageSetItem(ptr, end, msg, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
+ if (ctx->GroupContinues(depth)) goto group_continues;
+ } else {
+ auto res =
+ ext->ParseField(tag, {Msg::_InternalParse, msg}, ptr, end,
+ Msg::internal_default_instance(), metadata, ctx);
+ ptr = res.first;
+ if (res.second) break;
+ }
+ }
+ return ptr;
+group_continues:
+ GOOGLE_DCHECK(ptr >= end);
+ ctx->StoreGroup({Msg::_InternalParse, msg},
+ {Msg::InternalParseMessageSetItem, msg}, depth);
+ return ptr;
+}
+#endif
+
// These are just for convenience...
inline void ExtensionSet::SetString(int number, FieldType type,
- const string& value,
+ const std::string& value,
const FieldDescriptor* descriptor) {
MutableString(number, type, descriptor)->assign(value);
}
inline void ExtensionSet::SetRepeatedString(int number, int index,
- const string& value) {
+ const std::string& value) {
MutableRepeatedString(number, index)->assign(value);
}
inline void ExtensionSet::AddString(int number, FieldType type,
- const string& value,
+ const std::string& value,
const FieldDescriptor* descriptor) {
AddString(number, type, descriptor)->assign(value);
}
@@ -922,7 +960,7 @@ class RepeatedPrimitiveTypeTraits {
}
};
-class LIBPROTOBUF_EXPORT RepeatedPrimitiveDefaults {
+class PROTOBUF_EXPORT RepeatedPrimitiveDefaults {
private:
template <typename Type>
friend class RepeatedPrimitiveTypeTraits;
@@ -999,21 +1037,21 @@ PROTOBUF_DEFINE_PRIMITIVE_TYPE(bool, Bool)
// StringTypeTraits
// Strings support both Set() and Mutable().
-class LIBPROTOBUF_EXPORT StringTypeTraits {
+class PROTOBUF_EXPORT StringTypeTraits {
public:
- typedef const string& ConstType;
- typedef string* MutableType;
+ typedef const std::string& ConstType;
+ typedef std::string* MutableType;
typedef StringTypeTraits Singular;
- static inline const string& Get(int number, const ExtensionSet& set,
+ static inline const std::string& Get(int number, const ExtensionSet& set,
ConstType default_value) {
return set.GetString(number, default_value);
}
- static inline void Set(int number, FieldType field_type, const string& value,
+ static inline void Set(int number, FieldType field_type, const std::string& value,
ExtensionSet* set) {
set->SetString(number, field_type, value, NULL);
}
- static inline string* Mutable(int number, FieldType field_type,
+ static inline std::string* Mutable(int number, FieldType field_type,
ExtensionSet* set) {
return set->MutableString(number, field_type, NULL);
}
@@ -1024,44 +1062,44 @@ class LIBPROTOBUF_EXPORT StringTypeTraits {
}
};
-class LIBPROTOBUF_EXPORT RepeatedStringTypeTraits {
+class PROTOBUF_EXPORT RepeatedStringTypeTraits {
public:
- typedef const string& ConstType;
- typedef string* MutableType;
+ typedef const std::string& ConstType;
+ typedef std::string* MutableType;
typedef RepeatedStringTypeTraits Repeated;
- typedef RepeatedPtrField<string> RepeatedFieldType;
+ typedef RepeatedPtrField<std::string> RepeatedFieldType;
- static inline const string& Get(int number, const ExtensionSet& set,
+ static inline const std::string& Get(int number, const ExtensionSet& set,
int index) {
return set.GetRepeatedString(number, index);
}
- static inline void Set(int number, int index, const string& value,
+ static inline void Set(int number, int index, const std::string& value,
ExtensionSet* set) {
set->SetRepeatedString(number, index, value);
}
- static inline string* Mutable(int number, int index, ExtensionSet* set) {
+ static inline std::string* Mutable(int number, int index, ExtensionSet* set) {
return set->MutableRepeatedString(number, index);
}
static inline void Add(int number, FieldType field_type, bool /*is_packed*/,
- const string& value, ExtensionSet* set) {
+ const std::string& value, ExtensionSet* set) {
set->AddString(number, field_type, value, NULL);
}
- static inline string* Add(int number, FieldType field_type,
+ static inline std::string* Add(int number, FieldType field_type,
ExtensionSet* set) {
return set->AddString(number, field_type, NULL);
}
- static inline const RepeatedPtrField<string>& GetRepeated(
+ static inline const RepeatedPtrField<std::string>& GetRepeated(
int number, const ExtensionSet& set) {
- return *reinterpret_cast<const RepeatedPtrField<string>*>(
+ return *reinterpret_cast<const RepeatedPtrField<std::string>*>(
set.GetRawRepeatedField(number, GetDefaultRepeatedField()));
}
- static inline RepeatedPtrField<string>* MutableRepeated(int number,
+ static inline RepeatedPtrField<std::string>* MutableRepeated(int number,
FieldType field_type,
bool is_packed,
ExtensionSet* set) {
- return reinterpret_cast<RepeatedPtrField<string>*>(
+ return reinterpret_cast<RepeatedPtrField<std::string>*>(
set->MutableRawRepeatedField(number, field_type, is_packed, NULL));
}
@@ -1325,101 +1363,101 @@ class ExtensionIdentifier {
//
// For similar reason, we use "_field_type" and "_is_packed" as parameter names
// below, so that "field_type" and "is_packed" can be used as field names.
-#define GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(CLASSNAME) \
+#define GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(CLASSNAME) \
/* Has, Size, Clear */ \
template <typename _proto_TypeTraits, \
- ::GOOGLE_PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
+ ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
bool _is_packed> \
inline bool HasExtension( \
- const ::GOOGLE_PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id) const { \
return _extensions_.Has(id.number()); \
} \
\
template <typename _proto_TypeTraits, \
- ::GOOGLE_PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
+ ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
bool _is_packed> \
inline void ClearExtension( \
- const ::GOOGLE_PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id) { \
_extensions_.ClearExtension(id.number()); \
} \
\
template <typename _proto_TypeTraits, \
- ::GOOGLE_PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
+ ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
bool _is_packed> \
inline int ExtensionSize( \
- const ::GOOGLE_PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id) const { \
return _extensions_.ExtensionSize(id.number()); \
} \
\
/* Singular accessors */ \
template <typename _proto_TypeTraits, \
- ::GOOGLE_PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
+ ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
bool _is_packed> \
inline typename _proto_TypeTraits::Singular::ConstType GetExtension( \
- const ::GOOGLE_PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id) const { \
return _proto_TypeTraits::Get(id.number(), _extensions_, \
id.default_value()); \
} \
\
template <typename _proto_TypeTraits, \
- ::GOOGLE_PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
+ ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
bool _is_packed> \
inline typename _proto_TypeTraits::Singular::MutableType MutableExtension( \
- const ::GOOGLE_PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id) { \
return _proto_TypeTraits::Mutable(id.number(), _field_type, \
&_extensions_); \
} \
\
template <typename _proto_TypeTraits, \
- ::GOOGLE_PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
+ ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
bool _is_packed> \
inline void SetExtension( \
- const ::GOOGLE_PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id, \
typename _proto_TypeTraits::Singular::ConstType value) { \
_proto_TypeTraits::Set(id.number(), _field_type, value, &_extensions_); \
} \
\
template <typename _proto_TypeTraits, \
- ::GOOGLE_PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
+ ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
bool _is_packed> \
inline void SetAllocatedExtension( \
- const ::GOOGLE_PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id, \
typename _proto_TypeTraits::Singular::MutableType value) { \
_proto_TypeTraits::SetAllocated(id.number(), _field_type, value, \
&_extensions_); \
} \
template <typename _proto_TypeTraits, \
- ::GOOGLE_PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
+ ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
bool _is_packed> \
inline void UnsafeArenaSetAllocatedExtension( \
- const ::GOOGLE_PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id, \
typename _proto_TypeTraits::Singular::MutableType value) { \
_proto_TypeTraits::UnsafeArenaSetAllocated(id.number(), _field_type, \
value, &_extensions_); \
} \
template <typename _proto_TypeTraits, \
- ::GOOGLE_PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
+ ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
bool _is_packed> \
inline typename _proto_TypeTraits::Singular::MutableType ReleaseExtension( \
- const ::GOOGLE_PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id) { \
return _proto_TypeTraits::Release(id.number(), _field_type, \
&_extensions_); \
} \
template <typename _proto_TypeTraits, \
- ::GOOGLE_PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
+ ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
bool _is_packed> \
inline typename _proto_TypeTraits::Singular::MutableType \
UnsafeArenaReleaseExtension( \
- const ::GOOGLE_PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id) { \
return _proto_TypeTraits::UnsafeArenaRelease(id.number(), _field_type, \
&_extensions_); \
@@ -1427,49 +1465,49 @@ class ExtensionIdentifier {
\
/* Repeated accessors */ \
template <typename _proto_TypeTraits, \
- ::GOOGLE_PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
+ ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
bool _is_packed> \
inline typename _proto_TypeTraits::Repeated::ConstType GetExtension( \
- const ::GOOGLE_PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id, \
int index) const { \
return _proto_TypeTraits::Get(id.number(), _extensions_, index); \
} \
\
template <typename _proto_TypeTraits, \
- ::GOOGLE_PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
+ ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
bool _is_packed> \
inline typename _proto_TypeTraits::Repeated::MutableType MutableExtension( \
- const ::GOOGLE_PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id, \
int index) { \
return _proto_TypeTraits::Mutable(id.number(), index, &_extensions_); \
} \
\
template <typename _proto_TypeTraits, \
- ::GOOGLE_PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
+ ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
bool _is_packed> \
inline void SetExtension( \
- const ::GOOGLE_PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id, \
int index, typename _proto_TypeTraits::Repeated::ConstType value) { \
_proto_TypeTraits::Set(id.number(), index, value, &_extensions_); \
} \
\
template <typename _proto_TypeTraits, \
- ::GOOGLE_PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
+ ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
bool _is_packed> \
inline typename _proto_TypeTraits::Repeated::MutableType AddExtension( \
- const ::GOOGLE_PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id) { \
return _proto_TypeTraits::Add(id.number(), _field_type, &_extensions_); \
} \
\
template <typename _proto_TypeTraits, \
- ::GOOGLE_PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
+ ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
bool _is_packed> \
inline void AddExtension( \
- const ::GOOGLE_PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id, \
typename _proto_TypeTraits::Repeated::ConstType value) { \
_proto_TypeTraits::Add(id.number(), _field_type, _is_packed, value, \
@@ -1477,21 +1515,21 @@ class ExtensionIdentifier {
} \
\
template <typename _proto_TypeTraits, \
- ::GOOGLE_PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
+ ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
bool _is_packed> \
inline const typename _proto_TypeTraits::Repeated::RepeatedFieldType& \
GetRepeatedExtension( \
- const ::GOOGLE_PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id) const { \
return _proto_TypeTraits::GetRepeated(id.number(), _extensions_); \
} \
\
template <typename _proto_TypeTraits, \
- ::GOOGLE_PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
+ ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
bool _is_packed> \
inline typename _proto_TypeTraits::Repeated::RepeatedFieldType* \
MutableRepeatedExtension( \
- const ::GOOGLE_PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id) { \
return _proto_TypeTraits::MutableRepeated(id.number(), _field_type, \
_is_packed, &_extensions_); \
diff --git a/src/google/protobuf/extension_set_heavy.cc b/src/google/protobuf/extension_set_heavy.cc
index 7c93c61d..20d36ab7 100644
--- a/src/google/protobuf/extension_set_heavy.cc
+++ b/src/google/protobuf/extension_set_heavy.cc
@@ -45,6 +45,7 @@
#include <google/protobuf/repeated_field.h>
#include <google/protobuf/unknown_field_set.h>
#include <google/protobuf/wire_format.h>
+#include <google/protobuf/wire_format_lite.h>
#include <google/protobuf/wire_format_lite_inl.h>
@@ -315,22 +316,23 @@ bool DescriptorPoolExtensionFinder::Find(int number, ExtensionInfo* output) {
}
#if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
-bool ExtensionSet::FindExtension(uint32 tag, const Message* containing_type,
+bool ExtensionSet::FindExtension(int wire_type, uint32 field,
+ const Message* containing_type,
const internal::ParseContext* ctx,
- ExtensionInfo* extension, int* number,
+ ExtensionInfo* extension,
bool* was_packed_on_wire) {
if (ctx->extra_parse_data().pool == nullptr) {
GeneratedExtensionFinder finder(containing_type);
- if (!FindExtensionInfoFromTag(tag, &finder, number, extension,
- was_packed_on_wire)) {
+ if (!FindExtensionInfoFromFieldNumber(wire_type, field, &finder, extension,
+ was_packed_on_wire)) {
return false;
}
} else {
DescriptorPoolExtensionFinder finder(ctx->extra_parse_data().pool,
ctx->extra_parse_data().factory,
containing_type->GetDescriptor());
- if (!FindExtensionInfoFromTag(tag, &finder, number, extension,
- was_packed_on_wire)) {
+ if (!FindExtensionInfoFromFieldNumber(wire_type, field, &finder, extension,
+ was_packed_on_wire)) {
return false;
}
}
@@ -338,14 +340,14 @@ bool ExtensionSet::FindExtension(uint32 tag, const Message* containing_type,
}
std::pair<const char*, bool> ExtensionSet::ParseField(
- uint32 tag, ParseClosure parent, const char* begin, const char* end,
+ uint64 tag, ParseClosure parent, const char* begin, const char* end,
const Message* containing_type,
internal::InternalMetadataWithArena* metadata,
internal::ParseContext* ctx) {
- int number;
+ int number = tag >> 3;
bool was_packed_on_wire;
ExtensionInfo extension;
- if (!FindExtension(tag, containing_type, ctx, &extension, &number,
+ if (!FindExtension(tag & 7, number, containing_type, ctx, &extension,
&was_packed_on_wire)) {
return UnknownFieldParse(tag, parent, begin, end,
metadata->mutable_unknown_fields(), ctx);
@@ -400,7 +402,7 @@ std::pair<const char*, bool> ExtensionSet::ParseField(
case WireFormatLite::TYPE_##UPPERCASE: { \
uint64 value; \
ptr = Varint::Parse64(ptr, &value); \
- if (ptr == nullptr) goto error; \
+ GOOGLE_PROTOBUF_ASSERT_RETURN(ptr, std::make_pair(nullptr, true)); \
if (extension.is_repeated) { \
Add##CPP_CAMELCASE(number, WireFormatLite::TYPE_##UPPERCASE, \
extension.is_packed, value, extension.descriptor); \
@@ -419,6 +421,7 @@ std::pair<const char*, bool> ExtensionSet::ParseField(
case WireFormatLite::TYPE_##UPPERCASE: { \
uint64 val; \
ptr = Varint::Parse64(ptr, &val); \
+ GOOGLE_PROTOBUF_ASSERT_RETURN(ptr, std::make_pair(nullptr, true)); \
auto value = WireFormatLite::ZigZagDecode##SIZE(val); \
if (extension.is_repeated) { \
Add##CPP_CAMELCASE(number, WireFormatLite::TYPE_##UPPERCASE, \
@@ -458,7 +461,7 @@ std::pair<const char*, bool> ExtensionSet::ParseField(
case WireFormatLite::TYPE_ENUM: {
uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (ptr == nullptr) goto error;
+ GOOGLE_PROTOBUF_ASSERT_RETURN(ptr, std::make_pair(nullptr, true));
int value = val;
if (!extension.enum_validity_check.func(
@@ -494,9 +497,10 @@ std::pair<const char*, bool> ExtensionSet::ParseField(
*extension.message_prototype,
extension.descriptor);
child = {value->_ParseFunc(), value};
- if (!ctx->PrepareGroup(tag, &depth)) goto error;
+ bool ok = ctx->PrepareGroup(tag, &depth);
+ GOOGLE_PROTOBUF_ASSERT_RETURN(ok, std::make_pair(nullptr, true));
ptr = child(ptr, end, ctx);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_ASSERT_RETURN(ptr, std::make_pair(nullptr, true));
if (ctx->GroupContinues(depth)) goto group_continues;
break;
}
@@ -517,19 +521,15 @@ std::pair<const char*, bool> ExtensionSet::ParseField(
return std::make_pair(ptr, false);
-error:
- return std::make_pair(nullptr, true);
-
length_delim:
uint32 size;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_ASSERT_RETURN(ptr, std::make_pair(nullptr, true));
if (size > end - ptr) goto len_delim_till_end;
{
auto newend = ptr + size;
- if (!ctx->ParseExactRange(child, ptr, newend)) {
- goto error;
- }
+ bool ok = ctx->ParseExactRange(child, ptr, newend);
+ GOOGLE_PROTOBUF_ASSERT_RETURN(ok, std::make_pair(nullptr, true));
ptr = newend;
}
return std::make_pair(ptr, false);
@@ -570,64 +570,60 @@ const char* ExtensionSet::ParseMessageSetItem(
if (tag == WireFormatLite::kMessageSetTypeIdTag) {
uint32 type_id;
ptr = Varint::Parse32(ptr, &type_id);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
if (ctx->extra_parse_data().payload.empty()) {
tag = *ptr++;
- if (tag == WireFormatLite::kMessageSetMessageTag) {
- auto res = ParseField(type_id * 8 + 2, parent, ptr, end,
- containing_type, metadata, ctx);
- ptr = res.first;
- if (res.second) break;
- } else {
- goto error;
- }
+ GOOGLE_PROTOBUF_PARSER_ASSERT(tag ==
+ WireFormatLite::kMessageSetMessageTag);
+ auto res = ParseField(static_cast<uint64>(type_id) * 8 + 2, parent, ptr,
+ end, containing_type, metadata, ctx);
+ ptr = res.first;
+ if (res.second) break;
} else {
ExtensionInfo extension;
GeneratedExtensionFinder finder(containing_type);
- int number;
bool was_packed_on_wire;
- if (!FindExtension(type_id * 8 + 2, containing_type, ctx, &extension,
- &number, &was_packed_on_wire)) {
+ if (!FindExtension(2, type_id, containing_type, ctx, &extension,
+ &was_packed_on_wire)) {
metadata->mutable_unknown_fields()->AddLengthDelimited(
type_id, ctx->extra_parse_data().payload);
continue;
}
MessageLite* value =
extension.is_repeated
- ? AddMessage(number, WireFormatLite::TYPE_MESSAGE,
+ ? AddMessage(type_id, WireFormatLite::TYPE_MESSAGE,
*extension.message_prototype, extension.descriptor)
- : MutableMessage(number, WireFormatLite::TYPE_MESSAGE,
+ : MutableMessage(type_id, WireFormatLite::TYPE_MESSAGE,
*extension.message_prototype,
extension.descriptor);
ParseClosure parser = {value->_ParseFunc(), value};
StringPiece chunk(ctx->extra_parse_data().payload.data());
- if (!ctx->ParseExactRange(parser, chunk.begin(), chunk.end())) {
- return nullptr;
- }
+ bool ok = ctx->ParseExactRange(parser, chunk.begin(), chunk.end());
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
}
} else if (tag == WireFormatLite::kMessageSetItemEndTag) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
break;
} else if (tag == WireFormatLite::kMessageSetMessageTag) {
uint32 size;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ParseClosure child = {internal::StringParser,
&ctx->extra_parse_data().payload};
if (size > end - ptr) {
return ctx->StoreAndTailCall(ptr, end, parent, child, size);
} else {
auto newend = ptr + size;
- if (!ctx->ParseExactRange(child, ptr, newend)) {
- goto error;
- }
+ bool ok = ctx->ParseExactRange(child, ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
}
} else {
ptr--;
ptr = Varint::Parse32(ptr, &tag);
- if (ptr == nullptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
auto res =
ParseField(tag, parent, ptr, end, containing_type, metadata, ctx);
ptr = res.first;
@@ -635,8 +631,6 @@ const char* ExtensionSet::ParseMessageSetItem(
}
}
return ptr;
-error:
- return nullptr;
}
#endif // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
@@ -744,7 +738,7 @@ uint8* ExtensionSet::SerializeMessageSetWithCachedSizesToArray(
uint8* ExtensionSet::InternalSerializeWithCachedSizesToArray(
int start_field_number, int end_field_number, bool deterministic,
uint8* target) const {
- if (GOOGLE_PREDICT_FALSE(is_large())) {
+ if (PROTOBUF_PREDICT_FALSE(is_large())) {
const auto& end = map_.large->end();
for (auto it = map_.large->lower_bound(start_field_number);
it != end && it->first < end_field_number; ++it) {
@@ -983,82 +977,6 @@ bool ExtensionSet::ParseMessageSetItem(io::CodedInputStream* input,
MSFull{this, extension_finder, field_skipper});
}
-void ExtensionSet::Extension::SerializeMessageSetItemWithCachedSizes(
- int number,
- io::CodedOutputStream* output) const {
- if (type != WireFormatLite::TYPE_MESSAGE || is_repeated) {
- // Not a valid MessageSet extension, but serialize it the normal way.
- SerializeFieldWithCachedSizes(number, output);
- return;
- }
-
- if (is_cleared) return;
-
- // Start group.
- output->WriteTag(WireFormatLite::kMessageSetItemStartTag);
-
- // Write type ID.
- WireFormatLite::WriteUInt32(WireFormatLite::kMessageSetTypeIdNumber,
- number,
- output);
- // Write message.
- if (is_lazy) {
- lazymessage_value->WriteMessage(
- WireFormatLite::kMessageSetMessageNumber, output);
- } else {
- WireFormatLite::WriteMessageMaybeToArray(
- WireFormatLite::kMessageSetMessageNumber,
- *message_value,
- output);
- }
-
- // End group.
- output->WriteTag(WireFormatLite::kMessageSetItemEndTag);
-}
-
-size_t ExtensionSet::Extension::MessageSetItemByteSize(int number) const {
- if (type != WireFormatLite::TYPE_MESSAGE || is_repeated) {
- // Not a valid MessageSet extension, but compute the byte size for it the
- // normal way.
- return ByteSize(number);
- }
-
- if (is_cleared) return 0;
-
- size_t our_size = WireFormatLite::kMessageSetItemTagsSize;
-
- // type_id
- our_size += io::CodedOutputStream::VarintSize32(number);
-
- // message
- size_t message_size = 0;
- if (is_lazy) {
- message_size = lazymessage_value->ByteSizeLong();
- } else {
- message_size = message_value->ByteSizeLong();
- }
-
- our_size += io::CodedOutputStream::VarintSize32(message_size);
- our_size += message_size;
-
- return our_size;
-}
-
-void ExtensionSet::SerializeMessageSetWithCachedSizes(
- io::CodedOutputStream* output) const {
- ForEach([output](int number, const Extension& ext) {
- ext.SerializeMessageSetItemWithCachedSizes(number, output);
- });
-}
-
-size_t ExtensionSet::MessageSetByteSize() const {
- size_t total_size = 0;
- ForEach([&total_size](int number, const Extension& ext) {
- total_size += ext.MessageSetItemByteSize(number);
- });
- return total_size;
-}
-
} // namespace internal
} // namespace protobuf
} // namespace google
diff --git a/src/google/protobuf/extension_set_unittest.cc b/src/google/protobuf/extension_set_unittest.cc
index f3346c88..af398546 100644
--- a/src/google/protobuf/extension_set_unittest.cc
+++ b/src/google/protobuf/extension_set_unittest.cc
@@ -1051,10 +1051,14 @@ TEST(ExtensionSetTest, RepeatedFields) {
enum_const_iter;
RepeatedField<unittest::TestAllTypes_NestedEnum>::const_iterator
enum_const_end;
- for (enum_const_iter = message.GetRepeatedExtension(
- unittest::repeated_nested_enum_extension).begin(),
- enum_const_end = message.GetRepeatedExtension(
- unittest::repeated_nested_enum_extension).end();
+ for (enum_const_iter =
+ message
+ .GetRepeatedExtension(unittest::repeated_nested_enum_extension)
+ .begin(),
+ enum_const_end =
+ message
+ .GetRepeatedExtension(unittest::repeated_nested_enum_extension)
+ .end();
enum_const_iter != enum_const_end; ++enum_const_iter) {
ASSERT_EQ(*enum_const_iter, unittest::TestAllTypes::NestedEnum_MAX);
}
@@ -1271,7 +1275,7 @@ TEST(ExtensionSetTest, DynamicExtensions) {
const Message& sub_message =
message.GetReflection()->GetMessage(message, message_extension);
const unittest::ForeignMessage* typed_sub_message =
-#if GOOGLE_PROTOBUF_RTTI
+#if PROTOBUF_RTTI
dynamic_cast<const unittest::ForeignMessage*>(&sub_message);
#else
static_cast<const unittest::ForeignMessage*>(&sub_message);
diff --git a/src/google/protobuf/field_mask.pb.cc b/src/google/protobuf/field_mask.pb.cc
index 9791b974..8b252996 100644
--- a/src/google/protobuf/field_mask.pb.cc
+++ b/src/google/protobuf/field_mask.pb.cc
@@ -13,10 +13,6 @@
#include <google/protobuf/generated_message_reflection.h>
#include <google/protobuf/reflection_ops.h>
#include <google/protobuf/wire_format.h>
-// This is a temporary google only hack
-#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
-#include "third_party/protobuf/version.h"
-#endif
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>
@@ -39,7 +35,7 @@ static void InitDefaultsFieldMask_google_2fprotobuf_2ffield_5fmask_2eproto() {
::google::protobuf::FieldMask::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_FieldMask_google_2fprotobuf_2ffield_5fmask_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_FieldMask_google_2fprotobuf_2ffield_5fmask_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsFieldMask_google_2fprotobuf_2ffield_5fmask_2eproto}, {}};
void InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto() {
@@ -50,15 +46,15 @@ void InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto() {
constexpr ::google::protobuf::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2ffield_5fmask_2eproto = nullptr;
constexpr ::google::protobuf::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2ffield_5fmask_2eproto = nullptr;
-const ::google::protobuf::uint32 TableStruct_google_2fprotobuf_2ffield_5fmask_2eproto::offsets[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
+const ::google::protobuf::uint32 TableStruct_google_2fprotobuf_2ffield_5fmask_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
~0u, // no _has_bits_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldMask, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FieldMask, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldMask, paths_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FieldMask, paths_),
};
-static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
+static const ::google::protobuf::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
{ 0, -1, sizeof(::google::protobuf::FieldMask)},
};
@@ -179,15 +175,14 @@ const char* FieldMask::_InternalParse(const char* begin, const char* end, void*
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// repeated string paths = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 10) goto handle_unusual;
do {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.FieldMask.paths");
parser_till_end = ::google::protobuf::internal::StringParserUTF8;
::std::string* str = msg->add_paths();
@@ -195,16 +190,17 @@ const char* FieldMask::_InternalParse(const char* begin, const char* end, void*
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 255) == 10 && (ptr += 1));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 10 && (ptr += 1));
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
@@ -215,8 +211,6 @@ const char* FieldMask::_InternalParse(const char* begin, const char* end, void*
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -228,7 +222,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool FieldMask::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.FieldMask)
for (;;) {
@@ -426,10 +420,11 @@ void FieldMask::InternalSwap(FieldMask* other) {
} // namespace google
namespace google {
namespace protobuf {
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::FieldMask* Arena::CreateMaybeMessage< ::google::protobuf::FieldMask >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::FieldMask* Arena::CreateMaybeMessage< ::google::protobuf::FieldMask >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::FieldMask >(arena);
}
} // namespace protobuf
} // namespace google
// @@protoc_insertion_point(global_scope)
+#include <google/protobuf/port_undef.inc>
diff --git a/src/google/protobuf/field_mask.pb.h b/src/google/protobuf/field_mask.pb.h
index 2055e964..5b8561df 100644
--- a/src/google/protobuf/field_mask.pb.h
+++ b/src/google/protobuf/field_mask.pb.h
@@ -7,18 +7,19 @@
#include <limits>
#include <string>
-#include <google/protobuf/stubs/common.h>
-#if GOOGLE_PROTOBUF_VERSION < 3006000
+#include <google/protobuf/port_def.inc>
+#if PROTOBUF_VERSION < 3006001
#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 3006001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 3006001 < 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.
#endif
+#include <google/protobuf/port_undef.inc>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
@@ -32,27 +33,27 @@
#include <google/protobuf/unknown_field_set.h>
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>
-#define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2ffield_5fmask_2eproto LIBPROTOBUF_EXPORT
+#define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2ffield_5fmask_2eproto PROTOBUF_EXPORT
// Internal implementation detail -- do not use these members.
-struct LIBPROTOBUF_EXPORT TableStruct_google_2fprotobuf_2ffield_5fmask_2eproto {
+struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2ffield_5fmask_2eproto {
static const ::google::protobuf::internal::ParseTableField entries[]
- GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold);
+ PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::google::protobuf::internal::AuxillaryParseTableField aux[]
- GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold);
+ PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::google::protobuf::internal::ParseTable schema[1]
- GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold);
+ PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::google::protobuf::internal::FieldMetadata field_metadata[];
static const ::google::protobuf::internal::SerializationTable serialization_table[];
static const ::google::protobuf::uint32 offsets[];
};
-void LIBPROTOBUF_EXPORT AddDescriptors_google_2fprotobuf_2ffield_5fmask_2eproto();
+void PROTOBUF_EXPORT AddDescriptors_google_2fprotobuf_2ffield_5fmask_2eproto();
namespace google {
namespace protobuf {
class FieldMask;
class FieldMaskDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern FieldMaskDefaultTypeInternal _FieldMask_default_instance_;
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::FieldMask* Arena::CreateMaybeMessage<::google::protobuf::FieldMask>(Arena*);
+PROTOBUF_EXPORT extern FieldMaskDefaultTypeInternal _FieldMask_default_instance_;
+template<> PROTOBUF_EXPORT ::google::protobuf::FieldMask* Arena::CreateMaybeMessage<::google::protobuf::FieldMask>(Arena*);
} // namespace protobuf
} // namespace google
namespace google {
@@ -60,7 +61,7 @@ namespace protobuf {
// ===================================================================
-class LIBPROTOBUF_EXPORT FieldMask : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FieldMask) */ {
+class PROTOBUF_EXPORT FieldMask : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FieldMask) */ {
public:
FieldMask();
virtual ~FieldMask();
diff --git a/src/google/protobuf/generated_enum_reflection.h b/src/google/protobuf/generated_enum_reflection.h
index 27aac3f3..774528ee 100644
--- a/src/google/protobuf/generated_enum_reflection.h
+++ b/src/google/protobuf/generated_enum_reflection.h
@@ -48,6 +48,8 @@
#error "You cannot SWIG proto headers"
#endif
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
class EnumDescriptor;
@@ -68,13 +70,12 @@ namespace internal {
// Helper for EnumType_Parse functions: try to parse the string 'name' as an
// enum name of the given type, returning true and filling in value on success,
// or returning false and leaving value unchanged on failure.
-LIBPROTOBUF_EXPORT bool ParseNamedEnum(const EnumDescriptor* descriptor,
- const string& name,
- int* value);
+PROTOBUF_EXPORT bool ParseNamedEnum(const EnumDescriptor* descriptor,
+ const std::string& name, int* value);
template<typename EnumType>
bool ParseNamedEnum(const EnumDescriptor* descriptor,
- const string& name,
+ const std::string& name,
EnumType* value) {
int tmp;
if (!ParseNamedEnum(descriptor, name, &tmp)) return false;
@@ -85,10 +86,13 @@ bool ParseNamedEnum(const EnumDescriptor* descriptor,
// Just a wrapper around printing the name of a value. The main point of this
// function is not to be inlined, so that you can do this without including
// descriptor.h.
-LIBPROTOBUF_EXPORT const string& NameOfEnum(const EnumDescriptor* descriptor, int value);
+PROTOBUF_EXPORT const std::string& NameOfEnum(const EnumDescriptor* descriptor,
+ int value);
} // namespace internal
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_GENERATED_ENUM_REFLECTION_H__
diff --git a/src/google/protobuf/generated_message_reflection.cc b/src/google/protobuf/generated_message_reflection.cc
index e24f0306..f926da27 100644
--- a/src/google/protobuf/generated_message_reflection.cc
+++ b/src/google/protobuf/generated_message_reflection.cc
@@ -1201,8 +1201,9 @@ void GeneratedMessageReflection::SetString(
MutableField<ArenaStringPtr>(message, field)->UnsafeSetDefault(
default_ptr);
}
- MutableField<ArenaStringPtr>(message, field)->Set(default_ptr,
- value, GetArena(message));
+ MutableField<ArenaStringPtr>(message, field)
+ ->Mutable(default_ptr, GetArena(message))
+ ->assign(value);
break;
}
}
@@ -1705,7 +1706,7 @@ void* GeneratedMessageReflection::MutableRawRepeatedField(
if (field->cpp_type() != cpptype)
ReportReflectionUsageTypeError(descriptor_,
field, "MutableRawRepeatedField", cpptype);
- if (ctype >= 0)
+ if (ctype >= 0 && !field->is_extension())
GOOGLE_CHECK_EQ(field->options().ctype(), ctype) << "subtype mismatch";
if (desc != NULL)
GOOGLE_CHECK_EQ(field->message_type(), desc) << "wrong submessage type";
diff --git a/src/google/protobuf/generated_message_reflection.h b/src/google/protobuf/generated_message_reflection.h
index 177312cf..0ffb3ff2 100644
--- a/src/google/protobuf/generated_message_reflection.h
+++ b/src/google/protobuf/generated_message_reflection.h
@@ -361,11 +361,11 @@ class GeneratedMessageReflection final : public Reflection {
const FieldDescriptor* field) const override;
bool GetBool(const Message& message,
const FieldDescriptor* field) const override;
- string GetString(const Message& message,
+ std::string GetString(const Message& message,
const FieldDescriptor* field) const override;
- const string& GetStringReference(const Message& message,
+ const std::string& GetStringReference(const Message& message,
const FieldDescriptor* field,
- string* scratch) const override;
+ std::string* scratch) const override;
const EnumValueDescriptor* GetEnum(
const Message& message, const FieldDescriptor* field) const override;
int GetEnumValue(const Message& message,
@@ -409,7 +409,7 @@ class GeneratedMessageReflection final : public Reflection {
void SetBool(Message* message, const FieldDescriptor* field,
bool value) const override;
void SetString(Message* message, const FieldDescriptor* field,
- const string& value) const override;
+ const std::string& value) const override;
void SetEnum(Message* message, const FieldDescriptor* field,
const EnumValueDescriptor* value) const override;
void SetEnumValue(Message* message, const FieldDescriptor* field,
@@ -435,12 +435,12 @@ class GeneratedMessageReflection final : public Reflection {
int index) const override;
bool GetRepeatedBool(const Message& message, const FieldDescriptor* field,
int index) const override;
- string GetRepeatedString(const Message& message, const FieldDescriptor* field,
+ std::string GetRepeatedString(const Message& message, const FieldDescriptor* field,
int index) const override;
- const string& GetRepeatedStringReference(const Message& message,
+ const std::string& GetRepeatedStringReference(const Message& message,
const FieldDescriptor* field,
int index,
- string* scratch) const override;
+ std::string* scratch) const override;
const EnumValueDescriptor* GetRepeatedEnum(const Message& message,
const FieldDescriptor* field,
int index) const override;
@@ -466,7 +466,7 @@ class GeneratedMessageReflection final : public Reflection {
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;
+ int index, const std::string& value) const override;
void SetRepeatedEnum(Message* message, const FieldDescriptor* field,
int index,
const EnumValueDescriptor* value) const override;
@@ -492,7 +492,7 @@ class GeneratedMessageReflection final : public Reflection {
void AddBool(Message* message, const FieldDescriptor* field,
bool value) const override;
void AddString(Message* message, const FieldDescriptor* field,
- const string& value) const override;
+ const std::string& value) const override;
void AddEnum(Message* message, const FieldDescriptor* field,
const EnumValueDescriptor* value) const override;
void AddEnumValue(Message* message, const FieldDescriptor* field,
@@ -503,7 +503,7 @@ class GeneratedMessageReflection final : public Reflection {
Message* new_entry) const override;
const FieldDescriptor* FindKnownExtensionByName(
- const string& name) const override;
+ const std::string& name) const override;
const FieldDescriptor* FindKnownExtensionByNumber(int number) const override;
bool SupportsUnknownEnumValues() const override;
@@ -681,7 +681,7 @@ class GeneratedMessageReflection final : public Reflection {
typedef void (*InitFunc)();
-struct LIBPROTOBUF_EXPORT AssignDescriptorsTable {
+struct PROTOBUF_EXPORT AssignDescriptorsTable {
once_flag once;
InitFunc add_descriptors;
const char* filename;
@@ -695,9 +695,9 @@ struct LIBPROTOBUF_EXPORT AssignDescriptorsTable {
const ServiceDescriptor** file_level_service_descriptors;
};
-void LIBPROTOBUF_EXPORT AssignDescriptors(AssignDescriptorsTable* table);
+void PROTOBUF_EXPORT AssignDescriptors(AssignDescriptorsTable* table);
-struct LIBPROTOBUF_EXPORT DescriptorTable {
+struct PROTOBUF_EXPORT DescriptorTable {
bool is_initialized;
InitFunc init_defaults;
const char* descriptor;
@@ -706,14 +706,13 @@ struct LIBPROTOBUF_EXPORT DescriptorTable {
int size; // of serialized descriptor
};
-void LIBPROTOBUF_EXPORT AddDescriptors(DescriptorTable* table,
- const InitFunc* deps,
- int num_deps);
+void PROTOBUF_EXPORT AddDescriptors(DescriptorTable* table,
+ const InitFunc* deps, int num_deps);
// These cannot be in lite so we put them in the reflection.
-LIBPROTOBUF_EXPORT void UnknownFieldSetSerializer(const uint8* base, uint32 offset, uint32 tag,
- uint32 has_offset,
- io::CodedOutputStream* output);
+PROTOBUF_EXPORT void UnknownFieldSetSerializer(const uint8* base, uint32 offset,
+ uint32 tag, uint32 has_offset,
+ io::CodedOutputStream* output);
} // namespace internal
} // namespace protobuf
diff --git a/src/google/protobuf/generated_message_table_driven_lite.h b/src/google/protobuf/generated_message_table_driven_lite.h
index 4b461f1b..17e256a7 100644
--- a/src/google/protobuf/generated_message_table_driven_lite.h
+++ b/src/google/protobuf/generated_message_table_driven_lite.h
@@ -44,6 +44,8 @@
#include <type_traits>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace internal {
@@ -83,7 +85,7 @@ inline const Type* Raw(const MessageLite* msg, int64 offset) {
template <typename InternalMetadata>
inline Arena* GetArena(MessageLite* msg, int64 arena_offset) {
- if (GOOGLE_PREDICT_FALSE(arena_offset == -1)) {
+ if (PROTOBUF_PREDICT_FALSE(arena_offset == -1)) {
return NULL;
}
@@ -109,9 +111,9 @@ inline Type* AddField(MessageLite* msg, int64 offset) {
}
template <>
-inline string* AddField<string>(MessageLite* msg, int64 offset) {
- RepeatedPtrField<string>* repeated =
- Raw<RepeatedPtrField<string>>(msg, offset);
+inline std::string* AddField<std::string>(MessageLite* msg, int64 offset) {
+ RepeatedPtrField<std::string>* repeated =
+ Raw<RepeatedPtrField<std::string>>(msg, offset);
return repeated->Add();
}
@@ -205,11 +207,11 @@ inline void ResetOneofField(const ParseTable& table, int field_number,
switch (field_type) {
case ProcessingType_STRING:
Raw<ArenaStringPtr>(msg, offset)
- ->UnsafeSetDefault(static_cast<const string*>(default_ptr));
+ ->UnsafeSetDefault(static_cast<const std::string*>(default_ptr));
break;
case ProcessingType_INLINED:
new (Raw<InlinedStringField>(msg, offset))
- InlinedStringField(*static_cast<const string*>(default_ptr));
+ InlinedStringField(*static_cast<const std::string*>(default_ptr));
break;
case ProcessingType_MESSAGE:
MessageLite** submessage = Raw<MessageLite*>(msg, offset);
@@ -250,7 +252,7 @@ static inline bool HandleString(io::CodedInputStream* input, MessageLite* msg,
GOOGLE_DCHECK(s != nullptr);
::std::string* value = s->MutableNoArena(NULL);
- if (GOOGLE_PREDICT_FALSE(!WireFormatLite::ReadString(input, value))) {
+ if (PROTOBUF_PREDICT_FALSE(!WireFormatLite::ReadString(input, value))) {
return false;
}
@@ -261,25 +263,25 @@ static inline bool HandleString(io::CodedInputStream* input, MessageLite* msg,
break;
}
case StringType_STRING: {
- string* value;
+ std::string* value;
switch (cardinality) {
case Cardinality_SINGULAR:
// TODO(ckennelly): Is this optimal?
value =
MutableField<ArenaStringPtr>(msg, has_bits, has_bit_index, offset)
- ->Mutable(static_cast<const string*>(default_ptr), arena);
+ ->Mutable(static_cast<const std::string*>(default_ptr), arena);
break;
case Cardinality_REPEATED:
- value = AddField<string>(msg, offset);
+ value = AddField<std::string>(msg, offset);
break;
case Cardinality_ONEOF:
value = Raw<ArenaStringPtr>(msg, offset)
- ->Mutable(static_cast<const string*>(default_ptr), arena);
+ ->Mutable(static_cast<const std::string*>(default_ptr), arena);
break;
}
GOOGLE_DCHECK(value != nullptr);
- if (GOOGLE_PREDICT_FALSE(!WireFormatLite::ReadString(input, value))) {
+ if (PROTOBUF_PREDICT_FALSE(!WireFormatLite::ReadString(input, value))) {
return false;
}
@@ -308,7 +310,7 @@ inline bool HandleEnum(const ParseTable& table, io::CodedInputStream* input,
uint32 presence_index, int64 offset, uint32 tag,
int field_number) {
int value;
- if (GOOGLE_PREDICT_FALSE(
+ if (PROTOBUF_PREDICT_FALSE(
(!WireFormatLite::ReadPrimitive<int, WireFormatLite::TYPE_ENUM>(
input, &value)))) {
return false;
@@ -394,7 +396,7 @@ bool MergePartialFromCodedStreamImpl(MessageLite* msg, const ParseTable& table,
continue;
}
- if (GOOGLE_PREDICT_FALSE(
+ if (PROTOBUF_PREDICT_FALSE(
!UnknownFieldHandler::Skip(msg, table, input, tag))) {
return false;
}
@@ -422,7 +424,7 @@ bool MergePartialFromCodedStreamImpl(MessageLite* msg, const ParseTable& table,
#define HANDLE_TYPE(TYPE, CPPTYPE) \
case (WireFormatLite::TYPE_##TYPE): { \
CPPTYPE value; \
- if (GOOGLE_PREDICT_FALSE( \
+ if (PROTOBUF_PREDICT_FALSE( \
(!WireFormatLite::ReadPrimitive< \
CPPTYPE, WireFormatLite::TYPE_##TYPE>(input, &value)))) { \
return false; \
@@ -432,8 +434,8 @@ bool MergePartialFromCodedStreamImpl(MessageLite* msg, const ParseTable& table,
} \
case (WireFormatLite::TYPE_##TYPE) | kRepeatedMask: { \
RepeatedField<CPPTYPE>* values = Raw<RepeatedField<CPPTYPE>>(msg, offset); \
- if (GOOGLE_PREDICT_FALSE((!WireFormatLite::ReadRepeatedPrimitive< \
- CPPTYPE, WireFormatLite::TYPE_##TYPE>( \
+ if (PROTOBUF_PREDICT_FALSE((!WireFormatLite::ReadRepeatedPrimitive< \
+ CPPTYPE, WireFormatLite::TYPE_##TYPE>( \
data->tag_size, tag, input, values)))) { \
return false; \
} \
@@ -442,7 +444,7 @@ bool MergePartialFromCodedStreamImpl(MessageLite* msg, const ParseTable& table,
case (WireFormatLite::TYPE_##TYPE) | kOneofMask: { \
uint32* oneof_case = Raw<uint32>(msg, table.oneof_case_offset); \
CPPTYPE value; \
- if (GOOGLE_PREDICT_FALSE( \
+ if (PROTOBUF_PREDICT_FALSE( \
(!WireFormatLite::ReadPrimitive< \
CPPTYPE, WireFormatLite::TYPE_##TYPE>(input, &value)))) { \
return false; \
@@ -480,7 +482,7 @@ bool MergePartialFromCodedStreamImpl(MessageLite* msg, const ParseTable& table,
GetArena<InternalMetadata>(msg, table.arena_offset);
const void* default_ptr = table.aux[field_number].strings.default_ptr;
- if (GOOGLE_PREDICT_FALSE((
+ if (PROTOBUF_PREDICT_FALSE((
!HandleString<Cardinality_SINGULAR, false, StringType_STRING>(
input, msg, arena, has_bits, presence_index, offset,
default_ptr, NULL)))) {
@@ -497,8 +499,8 @@ bool MergePartialFromCodedStreamImpl(MessageLite* msg, const ParseTable& table,
GetArena<InternalMetadata>(msg, table.arena_offset);
const void* default_ptr = table.aux[field_number].strings.default_ptr;
- if (GOOGLE_PREDICT_FALSE((!HandleString<Cardinality_SINGULAR, false,
- StringType_INLINED>(
+ if (PROTOBUF_PREDICT_FALSE((!HandleString<Cardinality_SINGULAR, false,
+ StringType_INLINED>(
input, msg, arena, has_bits, presence_index, offset,
default_ptr, NULL)))) {
return false;
@@ -519,7 +521,7 @@ bool MergePartialFromCodedStreamImpl(MessageLite* msg, const ParseTable& table,
table, field_number, arena, msg, oneof_case + presence_index,
offset, default_ptr);
- if (GOOGLE_PREDICT_FALSE(
+ if (PROTOBUF_PREDICT_FALSE(
(!HandleString<Cardinality_ONEOF, false, StringType_STRING>(
input, msg, arena, has_bits, presence_index, offset,
default_ptr, NULL)))) {
@@ -539,7 +541,7 @@ bool MergePartialFromCodedStreamImpl(MessageLite* msg, const ParseTable& table,
const void* default_ptr =
table.aux[field_number].strings.default_ptr;
- if (GOOGLE_PREDICT_FALSE((
+ if (PROTOBUF_PREDICT_FALSE((
!HandleString<Cardinality_REPEATED, false, StringType_STRING>(
input, msg, arena, has_bits, presence_index, offset,
default_ptr, NULL)))) {
@@ -554,7 +556,7 @@ bool MergePartialFromCodedStreamImpl(MessageLite* msg, const ParseTable& table,
const void* default_ptr = table.aux[field_number].strings.default_ptr;
const char* field_name = table.aux[field_number].strings.field_name;
- if (GOOGLE_PREDICT_FALSE(
+ if (PROTOBUF_PREDICT_FALSE(
(!HandleString<Cardinality_SINGULAR, true, StringType_STRING>(
input, msg, arena, has_bits, presence_index, offset,
default_ptr, field_name)))) {
@@ -569,7 +571,7 @@ bool MergePartialFromCodedStreamImpl(MessageLite* msg, const ParseTable& table,
const void* default_ptr = table.aux[field_number].strings.default_ptr;
const char* field_name = table.aux[field_number].strings.field_name;
- if (GOOGLE_PREDICT_FALSE(
+ if (PROTOBUF_PREDICT_FALSE(
(!HandleString<Cardinality_REPEATED, true, StringType_STRING>(
input, msg, arena, has_bits, presence_index, offset,
default_ptr, field_name)))) {
@@ -588,7 +590,7 @@ bool MergePartialFromCodedStreamImpl(MessageLite* msg, const ParseTable& table,
table, field_number, arena, msg, oneof_case + presence_index,
offset, default_ptr);
- if (GOOGLE_PREDICT_FALSE(
+ if (PROTOBUF_PREDICT_FALSE(
(!HandleString<Cardinality_ONEOF, true, StringType_STRING>(
input, msg, arena, has_bits, presence_index, offset,
default_ptr, field_name)))) {
@@ -598,7 +600,7 @@ bool MergePartialFromCodedStreamImpl(MessageLite* msg, const ParseTable& table,
}
#endif
case WireFormatLite::TYPE_ENUM: {
- if (GOOGLE_PREDICT_FALSE(
+ if (PROTOBUF_PREDICT_FALSE(
(!HandleEnum<UnknownFieldHandler, InternalMetadata,
Cardinality_SINGULAR>(
table, input, msg, has_bits, presence_index, offset, tag,
@@ -608,7 +610,7 @@ bool MergePartialFromCodedStreamImpl(MessageLite* msg, const ParseTable& table,
break;
}
case WireFormatLite::TYPE_ENUM | kRepeatedMask: {
- if (GOOGLE_PREDICT_FALSE(
+ if (PROTOBUF_PREDICT_FALSE(
(!HandleEnum<UnknownFieldHandler, InternalMetadata,
Cardinality_REPEATED>(
table, input, msg, has_bits, presence_index, offset, tag,
@@ -619,7 +621,7 @@ bool MergePartialFromCodedStreamImpl(MessageLite* msg, const ParseTable& table,
}
case WireFormatLite::TYPE_ENUM | kOneofMask: {
uint32* oneof_case = Raw<uint32>(msg, table.oneof_case_offset);
- if (GOOGLE_PREDICT_FALSE(
+ if (PROTOBUF_PREDICT_FALSE(
(!HandleEnum<UnknownFieldHandler, InternalMetadata,
Cardinality_ONEOF>(table, input, msg, oneof_case,
presence_index, offset, tag,
@@ -642,7 +644,7 @@ bool MergePartialFromCodedStreamImpl(MessageLite* msg, const ParseTable& table,
*submsg_holder = submsg;
}
- if (GOOGLE_PREDICT_FALSE(
+ if (PROTOBUF_PREDICT_FALSE(
!WireFormatLite::ReadGroup(field_number, input, submsg))) {
return false;
}
@@ -658,7 +660,7 @@ bool MergePartialFromCodedStreamImpl(MessageLite* msg, const ParseTable& table,
MessageLite* submsg =
MergePartialFromCodedStreamHelper::Add(field, prototype);
- if (GOOGLE_PREDICT_FALSE(
+ if (PROTOBUF_PREDICT_FALSE(
!WireFormatLite::ReadGroup(field_number, input, submsg))) {
return false;
}
@@ -682,7 +684,8 @@ bool MergePartialFromCodedStreamImpl(MessageLite* msg, const ParseTable& table,
*submsg_holder = submsg;
}
- if (GOOGLE_PREDICT_FALSE(!WireFormatLite::ReadMessage(input, submsg))) {
+ if (PROTOBUF_PREDICT_FALSE(
+ !WireFormatLite::ReadMessage(input, submsg))) {
return false;
}
@@ -701,7 +704,8 @@ bool MergePartialFromCodedStreamImpl(MessageLite* msg, const ParseTable& table,
MessageLite* submsg =
MergePartialFromCodedStreamHelper::Add(field, prototype);
- if (GOOGLE_PREDICT_FALSE(!WireFormatLite::ReadMessage(input, submsg))) {
+ if (PROTOBUF_PREDICT_FALSE(
+ !WireFormatLite::ReadMessage(input, submsg))) {
return false;
}
@@ -717,7 +721,8 @@ bool MergePartialFromCodedStreamImpl(MessageLite* msg, const ParseTable& table,
offset, NULL);
MessageLite* submsg = *submsg_holder;
- if (GOOGLE_PREDICT_FALSE(!WireFormatLite::ReadMessage(input, submsg))) {
+ if (PROTOBUF_PREDICT_FALSE(
+ !WireFormatLite::ReadMessage(input, submsg))) {
return false;
}
@@ -730,7 +735,7 @@ bool MergePartialFromCodedStreamImpl(MessageLite* msg, const ParseTable& table,
const void* default_ptr = table.aux[field_number].strings.default_ptr;
const char* field_name = table.aux[field_number].strings.field_name;
- if (GOOGLE_PREDICT_FALSE((
+ if (PROTOBUF_PREDICT_FALSE((
!HandleString<Cardinality_SINGULAR, true, StringType_INLINED>(
input, msg, arena, has_bits, presence_index, offset,
default_ptr, field_name)))) {
@@ -740,7 +745,7 @@ bool MergePartialFromCodedStreamImpl(MessageLite* msg, const ParseTable& table,
}
#endif // GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED
case TYPE_MAP: {
- if (GOOGLE_PREDICT_FALSE(!(*table.aux[field_number].maps.parse_map)(
+ if (PROTOBUF_PREDICT_FALSE(!(*table.aux[field_number].maps.parse_map)(
input, Raw<void>(msg, offset)))) {
return false;
}
@@ -771,7 +776,7 @@ bool MergePartialFromCodedStreamImpl(MessageLite* msg, const ParseTable& table,
#define HANDLE_PACKED_TYPE(TYPE, CPPTYPE, CPPTYPE_METHOD) \
case WireFormatLite::TYPE_##TYPE: { \
RepeatedField<CPPTYPE>* values = Raw<RepeatedField<CPPTYPE>>(msg, offset); \
- if (GOOGLE_PREDICT_FALSE( \
+ if (PROTOBUF_PREDICT_FALSE( \
(!WireFormatLite::ReadPackedPrimitive< \
CPPTYPE, WireFormatLite::TYPE_##TYPE>(input, values)))) { \
return false; \
@@ -802,7 +807,7 @@ bool MergePartialFromCodedStreamImpl(MessageLite* msg, const ParseTable& table,
// are valid, we implement our own parser rather than call
// WireFormat::ReadPackedEnumPreserveUnknowns.
uint32 length;
- if (GOOGLE_PREDICT_FALSE(!input->ReadVarint32(&length))) {
+ if (PROTOBUF_PREDICT_FALSE(!input->ReadVarint32(&length))) {
return false;
}
@@ -813,7 +818,7 @@ bool MergePartialFromCodedStreamImpl(MessageLite* msg, const ParseTable& table,
io::CodedInputStream::Limit limit = input->PushLimit(length);
while (input->BytesUntilLimit() > 0) {
int value;
- if (GOOGLE_PREDICT_FALSE(
+ if (PROTOBUF_PREDICT_FALSE(
(!WireFormatLite::ReadPrimitive<
int, WireFormatLite::TYPE_ENUM>(input, &value)))) {
return false;
@@ -852,7 +857,7 @@ bool MergePartialFromCodedStreamImpl(MessageLite* msg, const ParseTable& table,
}
// process unknown field.
- if (GOOGLE_PREDICT_FALSE(
+ if (PROTOBUF_PREDICT_FALSE(
!UnknownFieldHandler::Skip(msg, table, input, tag))) {
return false;
}
@@ -864,4 +869,6 @@ bool MergePartialFromCodedStreamImpl(MessageLite* msg, const ParseTable& table,
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_GENERATED_MESSAGE_TABLE_DRIVEN_LITE_H__
diff --git a/src/google/protobuf/generated_message_util.h b/src/google/protobuf/generated_message_util.h
index 23d1009e..b9bbb26b 100644
--- a/src/google/protobuf/generated_message_util.h
+++ b/src/google/protobuf/generated_message_util.h
@@ -75,38 +75,10 @@ namespace io { class CodedInputStream; }
namespace internal {
-// Returns the offset of the given field within the given aggregate type.
-// This is equivalent to the ANSI C offsetof() macro. However, according
-// to the C++ standard, offsetof() only works on POD types, and GCC
-// enforces this requirement with a warning. In practice, this rule is
-// unnecessarily strict; there is probably no compiler or platform on
-// which the offsets of the direct fields of a class are non-constant.
-// Fields inherited from superclasses *can* have non-constant offsets,
-// but that's not what this macro will be used for.
-#if defined(__clang__)
-// For Clang we use __builtin_offsetof() and suppress the warning,
-// to avoid Control Flow Integrity and UBSan vptr sanitizers from
-// crashing while trying to validate the invalid reinterpet_casts.
-#define GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TYPE, FIELD) \
- _Pragma("clang diagnostic push") \
- _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
- __builtin_offsetof(TYPE, FIELD) \
- _Pragma("clang diagnostic pop")
-#else
-// Note that we calculate relative to the pointer value 16 here since if we
-// just use zero, GCC complains about dereferencing a NULL pointer. We
-// choose 16 rather than some other number just in case the compiler would
-// be confused by an unaligned pointer.
-#define GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TYPE, FIELD) \
- static_cast< ::google::protobuf::uint32>(reinterpret_cast<const char*>( \
- &reinterpret_cast<const TYPE*>(16)->FIELD) - \
- reinterpret_cast<const char*>(16))
-#endif
-
-LIBPROTOBUF_EXPORT void InitProtobufDefaults();
+PROTOBUF_EXPORT void InitProtobufDefaults();
// This used by proto1
-LIBPROTOBUF_EXPORT inline const ::std::string& GetEmptyString() {
+PROTOBUF_EXPORT inline const ::std::string& GetEmptyString() {
InitProtobufDefaults();
return GetEmptyStringAlreadyInited();
}
@@ -139,7 +111,7 @@ bool AllAreInitializedWeak(const RepeatedPtrField<T>& t) {
return true;
}
-struct LIBPROTOBUF_EXPORT FieldMetadata {
+struct PROTOBUF_EXPORT FieldMetadata {
uint32 offset; // offset of this field in the struct
uint32 tag; // field * 8 + wire_type
// byte offset * 8 + bit_offset;
@@ -188,19 +160,23 @@ typedef void (*SpecialSerializer)(const uint8* base, uint32 offset, uint32 tag,
uint32 has_offset,
io::CodedOutputStream* output);
-LIBPROTOBUF_EXPORT void ExtensionSerializer(const uint8* base, uint32 offset, uint32 tag,
- uint32 has_offset, io::CodedOutputStream* output);
-LIBPROTOBUF_EXPORT void UnknownFieldSerializerLite(const uint8* base, uint32 offset, uint32 tag,
- uint32 has_offset,
- io::CodedOutputStream* output);
+PROTOBUF_EXPORT void ExtensionSerializer(const uint8* base, uint32 offset,
+ uint32 tag, uint32 has_offset,
+ io::CodedOutputStream* output);
+PROTOBUF_EXPORT void UnknownFieldSerializerLite(const uint8* base,
+ uint32 offset, uint32 tag,
+ uint32 has_offset,
+ io::CodedOutputStream* output);
struct SerializationTable {
int num_fields;
const FieldMetadata* field_table;
};
-LIBPROTOBUF_EXPORT void SerializeInternal(const uint8* base, const FieldMetadata* table,
- int32 num_fields, io::CodedOutputStream* output);
+PROTOBUF_EXPORT void SerializeInternal(const uint8* base,
+ const FieldMetadata* table,
+ int32 num_fields,
+ io::CodedOutputStream* output);
inline void TableSerialize(const MessageLite& msg,
const SerializationTable* table,
@@ -290,10 +266,10 @@ void MapFieldSerializer(const uint8* base, uint32 offset, uint32 tag,
}
}
-LIBPROTOBUF_EXPORT MessageLite* DuplicateIfNonNullInternal(MessageLite* message);
-LIBPROTOBUF_EXPORT MessageLite* GetOwnedMessageInternal(Arena* message_arena,
- MessageLite* submessage,
- Arena* submessage_arena);
+PROTOBUF_EXPORT MessageLite* DuplicateIfNonNullInternal(MessageLite* message);
+PROTOBUF_EXPORT MessageLite* GetOwnedMessageInternal(Arena* message_arena,
+ MessageLite* submessage,
+ Arena* submessage_arena);
template <typename T>
T* DuplicateIfNonNull(T* message) {
@@ -315,7 +291,7 @@ T* GetOwnedMessage(Arena* message_arena, T* submessage,
// Hide atomic from the public header and allow easy change to regular int
// on platforms where the atomic might have a perf impact.
-class LIBPROTOBUF_EXPORT CachedSize {
+class PROTOBUF_EXPORT CachedSize {
public:
int Get() const { return size_.load(std::memory_order_relaxed); }
void Set(int size) { size_.store(size, std::memory_order_relaxed); }
@@ -325,7 +301,7 @@ class LIBPROTOBUF_EXPORT CachedSize {
// SCCInfo represents information of a strongly connected component of
// mutual dependent messages.
-struct LIBPROTOBUF_EXPORT SCCInfoBase {
+struct PROTOBUF_EXPORT SCCInfoBase {
// We use 0 for the Initialized state, because test eax,eax, jnz is smaller
// and is subject to macro fusion.
enum {
@@ -359,15 +335,16 @@ struct SCCInfo {
SCCInfoBase* deps[N ? N : 1];
};
-LIBPROTOBUF_EXPORT void InitSCCImpl(SCCInfoBase* scc);
+PROTOBUF_EXPORT void InitSCCImpl(SCCInfoBase* scc);
inline void InitSCC(SCCInfoBase* scc) {
auto status = scc->visit_status.load(std::memory_order_acquire);
- if (GOOGLE_PREDICT_FALSE(status != SCCInfoBase::kInitialized)) InitSCCImpl(scc);
+ if (PROTOBUF_PREDICT_FALSE(status != SCCInfoBase::kInitialized))
+ InitSCCImpl(scc);
}
-LIBPROTOBUF_EXPORT void DestroyMessage(const void* message);
-LIBPROTOBUF_EXPORT void DestroyString(const void* s);
+PROTOBUF_EXPORT void DestroyMessage(const void* message);
+PROTOBUF_EXPORT void DestroyString(const void* s);
// Destroy (not delete) the message
inline void OnShutdownDestroyMessage(const void* ptr) {
OnShutdownRun(DestroyMessage, ptr);
diff --git a/src/google/protobuf/has_bits.h b/src/google/protobuf/has_bits.h
index edf4e829..d15b3f8d 100644
--- a/src/google/protobuf/has_bits.h
+++ b/src/google/protobuf/has_bits.h
@@ -47,18 +47,17 @@ namespace internal {
template<size_t doublewords>
class HasBits {
public:
- HasBits() GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE { Clear(); }
+ HasBits() PROTOBUF_ALWAYS_INLINE { Clear(); }
- void Clear() GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE {
+ void Clear() PROTOBUF_ALWAYS_INLINE {
memset(has_bits_, 0, sizeof(has_bits_));
}
- ::google::protobuf::uint32& operator[](int index) GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE {
+ ::google::protobuf::uint32& operator[](int index) PROTOBUF_ALWAYS_INLINE {
return has_bits_[index];
}
- const ::google::protobuf::uint32& operator[](int index) const
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE {
+ const ::google::protobuf::uint32& operator[](int index) const PROTOBUF_ALWAYS_INLINE {
return has_bits_[index];
}
diff --git a/src/google/protobuf/implicit_weak_message.cc b/src/google/protobuf/implicit_weak_message.cc
index 7e47cdcc..582d7084 100644
--- a/src/google/protobuf/implicit_weak_message.cc
+++ b/src/google/protobuf/implicit_weak_message.cc
@@ -31,11 +31,13 @@
#include <google/protobuf/implicit_weak_message.h>
#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
+#include <google/protobuf/stubs/once.h>
+#include <google/protobuf/wire_format_lite.h>
+
+#include <google/protobuf/port_def.inc>
#if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
#include <google/protobuf/parse_context.h>
#endif
-#include <google/protobuf/stubs/once.h>
-#include <google/protobuf/wire_format_lite.h>
namespace google {
namespace protobuf {
diff --git a/src/google/protobuf/implicit_weak_message.h b/src/google/protobuf/implicit_weak_message.h
index 29836289..5d3b479a 100644
--- a/src/google/protobuf/implicit_weak_message.h
+++ b/src/google/protobuf/implicit_weak_message.h
@@ -36,6 +36,8 @@
#include <google/protobuf/arena.h>
#include <google/protobuf/message_lite.h>
+#include <google/protobuf/port_def.inc>
+
#ifdef SWIG
#error "You cannot SWIG proto headers"
#endif
@@ -50,52 +52,52 @@ namespace internal {
// An implementation of MessageLite that treats all data as unknown. This type
// acts as a placeholder for an implicit weak field in the case where the true
// message type does not get linked into the binary.
-class LIBPROTOBUF_EXPORT ImplicitWeakMessage : public MessageLite {
+class PROTOBUF_EXPORT ImplicitWeakMessage : public MessageLite {
public:
ImplicitWeakMessage() : arena_(NULL) {}
explicit ImplicitWeakMessage(Arena* arena) : arena_(arena) {}
static const ImplicitWeakMessage* default_instance();
- string GetTypeName() const { return ""; }
+ std::string GetTypeName() const override { return ""; }
- MessageLite* New() const { return new ImplicitWeakMessage; }
- MessageLite* New(Arena* arena) const {
+ MessageLite* New() const override { return new ImplicitWeakMessage; }
+ MessageLite* New(Arena* arena) const override {
return Arena::CreateMessage<ImplicitWeakMessage>(arena);
}
- Arena* GetArena() const { return arena_; }
+ Arena* GetArena() const override { return arena_; }
- void Clear() { data_.clear(); }
+ void Clear() override { data_.clear(); }
- bool IsInitialized() const { return true; }
+ bool IsInitialized() const override { return true; }
- void CheckTypeAndMergeFrom(const MessageLite& other) {
+ void CheckTypeAndMergeFrom(const MessageLite& other) override {
data_.append(static_cast<const ImplicitWeakMessage&>(other).data_);
}
- bool MergePartialFromCodedStream(io::CodedInputStream* input);
+ bool MergePartialFromCodedStream(io::CodedInputStream* input) override;
#if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
- ParseFunc _ParseFunc() const { return _InternalParse; }
+ ParseFunc _ParseFunc() const override { return _InternalParse; }
static const char* _InternalParse(const char* begin, const char* end,
void* object, ParseContext* ctx);
#endif
- size_t ByteSizeLong() const { return data_.size(); }
+ size_t ByteSizeLong() const override { return data_.size(); }
- void SerializeWithCachedSizes(io::CodedOutputStream* output) const {
+ void SerializeWithCachedSizes(io::CodedOutputStream* output) const override {
output->WriteString(data_);
}
- int GetCachedSize() const { return static_cast<int>(data_.size()); }
+ int GetCachedSize() const override { return static_cast<int>(data_.size()); }
typedef void InternalArenaConstructable_;
private:
Arena* const arena_;
- string data_;
+ std::string data_;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImplicitWeakMessage);
};
@@ -141,4 +143,6 @@ class ImplicitWeakTypeHandler {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_IMPLICIT_WEAK_MESSAGE_H__
diff --git a/src/google/protobuf/inlined_string_field.h b/src/google/protobuf/inlined_string_field.h
index 1509193f..c5077b4b 100644
--- a/src/google/protobuf/inlined_string_field.h
+++ b/src/google/protobuf/inlined_string_field.h
@@ -58,53 +58,49 @@ namespace internal {
// default_value parameters are taken for consistency with ArenaStringPtr, but
// are not used for most methods. With inlining, these should be removed from
// the generated binary.
-class LIBPROTOBUF_EXPORT InlinedStringField {
+class PROTOBUF_EXPORT InlinedStringField {
public:
- InlinedStringField() GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE;
+ InlinedStringField() PROTOBUF_ALWAYS_INLINE;
explicit InlinedStringField(const ::std::string& default_value);
void AssignWithDefault(const ::std::string* default_value,
- const InlinedStringField& from)
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE;
+ const InlinedStringField& from) PROTOBUF_ALWAYS_INLINE;
void ClearToEmpty(const ::std::string* default_value,
- Arena* arena) GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE {
+ Arena* arena) PROTOBUF_ALWAYS_INLINE {
ClearToEmptyNoArena(default_value);
}
- void ClearNonDefaultToEmpty() GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE {
+ void ClearNonDefaultToEmpty() PROTOBUF_ALWAYS_INLINE {
ClearNonDefaultToEmptyNoArena();
}
void ClearToEmptyNoArena(const ::std::string* default_value)
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE {
+ PROTOBUF_ALWAYS_INLINE {
ClearNonDefaultToEmptyNoArena();
}
- void ClearNonDefaultToEmptyNoArena() GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE;
+ void ClearNonDefaultToEmptyNoArena() PROTOBUF_ALWAYS_INLINE;
void ClearToDefault(const ::std::string* default_value,
- Arena* arena) GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE {
+ Arena* arena) PROTOBUF_ALWAYS_INLINE {
ClearToDefaultNoArena(default_value);
}
void ClearToDefaultNoArena(const ::std::string* default_value)
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE;
+ PROTOBUF_ALWAYS_INLINE;
void Destroy(const ::std::string* default_value,
- Arena* arena) GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE {
+ Arena* arena) PROTOBUF_ALWAYS_INLINE {
DestroyNoArena(default_value);
}
- void DestroyNoArena(const ::std::string* default_value)
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE;
+ void DestroyNoArena(const ::std::string* default_value) PROTOBUF_ALWAYS_INLINE;
- const ::std::string& Get() const GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE {
- return GetNoArena();
- }
- const ::std::string& GetNoArena() const GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE;
+ const ::std::string& Get() const PROTOBUF_ALWAYS_INLINE { return GetNoArena(); }
+ const ::std::string& GetNoArena() const PROTOBUF_ALWAYS_INLINE;
::std::string* Mutable(const ::std::string* default_value,
- Arena* arena) GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE {
+ Arena* arena) PROTOBUF_ALWAYS_INLINE {
return MutableNoArena(default_value);
}
::std::string* MutableNoArena(const ::std::string* default_value)
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE;
+ PROTOBUF_ALWAYS_INLINE;
::std::string* Release(const ::std::string* default_value, Arena* arena) {
return ReleaseNoArena(default_value);
@@ -118,30 +114,30 @@ class LIBPROTOBUF_EXPORT InlinedStringField {
::std::string* ReleaseNonDefaultNoArena(const ::std::string* default_value);
void Set(const ::std::string* default_value, StringPiece value,
- Arena* arena) GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE {
+ Arena* arena) PROTOBUF_ALWAYS_INLINE {
SetNoArena(default_value, value);
}
void SetLite(const ::std::string* default_value, StringPiece value,
- Arena* arena) GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE {
+ Arena* arena) PROTOBUF_ALWAYS_INLINE {
SetNoArena(default_value, value);
}
- void SetNoArena(const ::std::string* default_value, StringPiece value)
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE;
+ void SetNoArena(const ::std::string* default_value,
+ StringPiece value) PROTOBUF_ALWAYS_INLINE;
void Set(const ::std::string* default_value, const ::std::string& value,
- Arena* arena) GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE {
+ Arena* arena) PROTOBUF_ALWAYS_INLINE {
SetNoArena(default_value, value);
}
void SetLite(const ::std::string* default_value, const ::std::string& value,
- Arena* arena) GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE {
+ Arena* arena) PROTOBUF_ALWAYS_INLINE {
SetNoArena(default_value, value);
}
- void SetNoArena(const ::std::string* default_value, const ::std::string& value)
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE;
+ void SetNoArena(const ::std::string* default_value,
+ const ::std::string& value) PROTOBUF_ALWAYS_INLINE;
#if LANG_CXX11
void SetNoArena(const ::std::string* default_value,
- ::std::string&& value) GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE;
+ ::std::string&& value) PROTOBUF_ALWAYS_INLINE;
#endif
void SetAllocated(const ::std::string* default_value,
::std::string* value,
@@ -150,7 +146,7 @@ class LIBPROTOBUF_EXPORT InlinedStringField {
}
void SetAllocatedNoArena(const ::std::string* default_value,
::std::string* value);
- void Swap(InlinedStringField* from) GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE;
+ void Swap(InlinedStringField* from) PROTOBUF_ALWAYS_INLINE;
::std::string* UnsafeMutablePointer();
void UnsafeSetDefault(const ::std::string* default_value);
::std::string* UnsafeArenaRelease(const ::std::string* default_value, Arena* arena);
diff --git a/src/google/protobuf/io/coded_stream.cc b/src/google/protobuf/io/coded_stream.cc
index 311668ce..547c5c64 100644
--- a/src/google/protobuf/io/coded_stream.cc
+++ b/src/google/protobuf/io/coded_stream.cc
@@ -123,7 +123,7 @@ CodedInputStream::Limit CodedInputStream::PushLimit(int byte_limit) {
// security: byte_limit is possibly evil, so check for negative values
// and overflow. Also check that the new requested limit is before the
// previous limit; otherwise we continue to enforce the previous limit.
- if (GOOGLE_PREDICT_TRUE(byte_limit >= 0 &&
+ if (PROTOBUF_PREDICT_TRUE(byte_limit >= 0 &&
byte_limit <= INT_MAX - current_position &&
byte_limit < current_limit_ - current_position)) {
current_limit_ = current_position + byte_limit;
@@ -314,11 +314,25 @@ bool CodedInputStream::ReadLittleEndian64Fallback(uint64* value) {
namespace {
+// Decodes varint64 with known size, N, and returns next pointer. Knowing N at
+// compile time, compiler can generate optimal code. For example, instead of
+// subtracting 0x80 at each iteration, it subtracts properly shifted mask once.
+template <size_t N>
+const uint8* DecodeVarint64KnownSize(const uint8* buffer, uint64* value) {
+ GOOGLE_DCHECK_GT(N, 0);
+ uint64 result = static_cast<uint64>(buffer[N - 1]) << (7 * (N - 1));
+ for (int i = 0, offset = 0; i < N - 1; i++, offset += 7) {
+ result += static_cast<uint64>(buffer[i] - 0x80) << offset;
+ }
+ *value = result;
+ return buffer + N;
+}
+
// Read a varint from the given buffer, write it to *value, and return a pair.
// The first part of the pair is true iff the read was successful. The second
// part is buffer + (number of bytes read). This function is always inlined,
// so returning a pair is costless.
-GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE
+PROTOBUF_ALWAYS_INLINE
::std::pair<bool, const uint8*> ReadVarint32FromArray(
uint32 first_byte, const uint8* buffer,
uint32* value);
@@ -356,47 +370,39 @@ inline ::std::pair<bool, const uint8*> ReadVarint32FromArray(
return std::make_pair(true, ptr);
}
-GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE::std::pair<bool, const uint8*>
-ReadVarint64FromArray(const uint8* buffer, uint64* value);
+PROTOBUF_ALWAYS_INLINE::std::pair<bool, const uint8*> ReadVarint64FromArray(
+ const uint8* buffer, uint64* value);
inline ::std::pair<bool, const uint8*> ReadVarint64FromArray(
const uint8* buffer, uint64* value) {
- const uint8* ptr = buffer;
- uint32 b;
-
- // Splitting into 32-bit pieces gives better performance on 32-bit
- // processors.
- uint32 part0 = 0, part1 = 0, part2 = 0;
-
- b = *(ptr++); part0 = b ; if (!(b & 0x80)) goto done;
- part0 -= 0x80;
- b = *(ptr++); part0 += b << 7; if (!(b & 0x80)) goto done;
- part0 -= 0x80 << 7;
- b = *(ptr++); part0 += b << 14; if (!(b & 0x80)) goto done;
- part0 -= 0x80 << 14;
- b = *(ptr++); part0 += b << 21; if (!(b & 0x80)) goto done;
- part0 -= 0x80 << 21;
- b = *(ptr++); part1 = b ; if (!(b & 0x80)) goto done;
- part1 -= 0x80;
- b = *(ptr++); part1 += b << 7; if (!(b & 0x80)) goto done;
- part1 -= 0x80 << 7;
- b = *(ptr++); part1 += b << 14; if (!(b & 0x80)) goto done;
- part1 -= 0x80 << 14;
- b = *(ptr++); part1 += b << 21; if (!(b & 0x80)) goto done;
- part1 -= 0x80 << 21;
- b = *(ptr++); part2 = b ; if (!(b & 0x80)) goto done;
- part2 -= 0x80;
- b = *(ptr++); part2 += b << 7; if (!(b & 0x80)) goto done;
- // "part2 -= 0x80 << 7" is irrelevant because (0x80 << 7) << 56 is 0.
-
- // We have overrun the maximum size of a varint (10 bytes). Assume
- // the data is corrupt.
- return std::make_pair(false, ptr);
+ // Assumes varint64 is at least 2 bytes.
+ GOOGLE_DCHECK_GE(buffer[0], 128);
+
+ const uint8* next;
+ if (buffer[1] < 128) {
+ next = DecodeVarint64KnownSize<2>(buffer, value);
+ } else if (buffer[2] < 128) {
+ next = DecodeVarint64KnownSize<3>(buffer, value);
+ } else if (buffer[3] < 128) {
+ next = DecodeVarint64KnownSize<4>(buffer, value);
+ } else if (buffer[4] < 128) {
+ next = DecodeVarint64KnownSize<5>(buffer, value);
+ } else if (buffer[5] < 128) {
+ next = DecodeVarint64KnownSize<6>(buffer, value);
+ } else if (buffer[6] < 128) {
+ next = DecodeVarint64KnownSize<7>(buffer, value);
+ } else if (buffer[7] < 128) {
+ next = DecodeVarint64KnownSize<8>(buffer, value);
+ } else if (buffer[8] < 128) {
+ next = DecodeVarint64KnownSize<9>(buffer, value);
+ } else if (buffer[9] < 128) {
+ next = DecodeVarint64KnownSize<10>(buffer, value);
+ } else {
+ // We have overrun the maximum size of a varint (10 bytes). Assume
+ // the data is corrupt.
+ return std::make_pair(false, buffer + 11);
+ }
- done:
- *value = (static_cast<uint64>(part0)) |
- (static_cast<uint64>(part1) << 28) |
- (static_cast<uint64>(part2) << 56);
- return std::make_pair(true, ptr);
+ return std::make_pair(true, next);
}
} // namespace
diff --git a/src/google/protobuf/io/coded_stream.h b/src/google/protobuf/io/coded_stream.h
index 71a4f5fb..63631d1f 100644
--- a/src/google/protobuf/io/coded_stream.h
+++ b/src/google/protobuf/io/coded_stream.h
@@ -161,6 +161,13 @@ class CodedOutputStream;
class ZeroCopyInputStream; // zero_copy_stream.h
class ZeroCopyOutputStream; // zero_copy_stream.h
+template <typename T>
+T UnalignedLoad(const void* p) {
+ T res;
+ memcpy(&res, p, sizeof(T));
+ return res;
+}
+
// Class which reads and decodes binary data which is composed of varint-
// encoded integers and fixed-width pieces. Wraps a ZeroCopyInputStream.
// Most users will not need to deal with CodedInputStream.
@@ -168,7 +175,7 @@ class ZeroCopyOutputStream; // zero_copy_stream.h
// Most methods of CodedInputStream that return a bool return false if an
// underlying I/O error occurs or if the data is malformed. Once such a
// failure occurs, the CodedInputStream is broken and is no longer useful.
-class LIBPROTOBUF_EXPORT CodedInputStream {
+class PROTOBUF_EXPORT CodedInputStream {
public:
// Create a CodedInputStream that reads from the given ZeroCopyInputStream.
explicit CodedInputStream(ZeroCopyInputStream* input);
@@ -204,7 +211,7 @@ class LIBPROTOBUF_EXPORT CodedInputStream {
// Like GetDirectBufferPointer, but this method is inlined, and does not
// attempt to Refresh() if the buffer is currently empty.
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE
+ PROTOBUF_ALWAYS_INLINE
void GetDirectBufferPointerInline(const void** data, int* size);
// Read raw bytes, copying them into the given buffer.
@@ -212,15 +219,15 @@ class LIBPROTOBUF_EXPORT CodedInputStream {
// Like the above, with inlined optimizations. This should only be used
// by the protobuf implementation.
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE
+ PROTOBUF_ALWAYS_INLINE
bool InternalReadRawInline(void* buffer, int size);
// Like ReadRaw, but reads into a string.
- bool ReadString(string* buffer, int size);
+ bool ReadString(std::string* buffer, int size);
// Like the above, with inlined optimizations. This should only be used
// by the protobuf implementation.
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE
- bool InternalReadStringInline(string* buffer, int size);
+ PROTOBUF_ALWAYS_INLINE
+ bool InternalReadStringInline(std::string* buffer, int size);
// Read a 32-bit little-endian integer.
@@ -263,11 +270,11 @@ class LIBPROTOBUF_EXPORT CodedInputStream {
// Always inline because this is only called in one place per parse loop
// but it is called for every iteration of said loop, so it should be fast.
// GCC doesn't want to inline this by default.
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE uint32 ReadTag() {
+ PROTOBUF_ALWAYS_INLINE uint32 ReadTag() {
return last_tag_ = ReadTagNoLastTag();
}
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE uint32 ReadTagNoLastTag();
+ PROTOBUF_ALWAYS_INLINE uint32 ReadTagNoLastTag();
// This usually a faster alternative to ReadTag() when cutoff is a manifest
// constant. It does particularly well for cutoff >= 127. The first part
@@ -277,14 +284,14 @@ class LIBPROTOBUF_EXPORT CodedInputStream {
// above cutoff or is 0. (There's intentional wiggle room when tag is 0,
// because that can arise in several ways, and for best performance we want
// to avoid an extra "is tag == 0?" check here.)
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE
+ PROTOBUF_ALWAYS_INLINE
std::pair<uint32, bool> ReadTagWithCutoff(uint32 cutoff) {
std::pair<uint32, bool> result = ReadTagWithCutoffNoLastTag(cutoff);
last_tag_ = result.first;
return result;
}
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE
+ PROTOBUF_ALWAYS_INLINE
std::pair<uint32, bool> ReadTagWithCutoffNoLastTag(uint32 cutoff);
// Usually returns true if calling ReadVarint32() now would produce the given
@@ -294,7 +301,7 @@ class LIBPROTOBUF_EXPORT CodedInputStream {
// parameter.
// Always inline because this collapses to a small number of instructions
// when given a constant parameter, but GCC doesn't want to inline by default.
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE bool ExpectTag(uint32 expected);
+ PROTOBUF_ALWAYS_INLINE bool ExpectTag(uint32 expected);
// Like above, except this reads from the specified buffer. The caller is
// responsible for ensuring that the buffer is large enough to read a varint
@@ -303,7 +310,7 @@ class LIBPROTOBUF_EXPORT CodedInputStream {
//
// Returns a pointer beyond the expected tag if it was found, or NULL if it
// was not.
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE
+ PROTOBUF_ALWAYS_INLINE
static const uint8* ExpectTagFromArray(const uint8* buffer, uint32 expected);
// Usually returns true if no more bytes can be read. Always returns false
@@ -390,7 +397,7 @@ class LIBPROTOBUF_EXPORT CodedInputStream {
// This is unrelated to PushLimit()/PopLimit().
void SetTotalBytesLimit(int total_bytes_limit);
- GOOGLE_PROTOBUF_DEPRECATED_MSG(
+ PROTOBUF_DEPRECATED_MSG(
"Please use the single parameter version of SetTotalBytesLimit(). The "
"second parameter is ignored.")
void SetTotalBytesLimit(int total_bytes_limit, int) {
@@ -409,6 +416,7 @@ class LIBPROTOBUF_EXPORT CodedInputStream {
// Sets the maximum recursion depth. The default is 100.
void SetRecursionLimit(int limit);
+ int RecursionBudget() { return recursion_budget_; }
// Increments the current recursion depth. Returns true if the depth is
@@ -627,7 +635,7 @@ class LIBPROTOBUF_EXPORT CodedInputStream {
// stream.
uint32 ReadTagFallback(uint32 first_byte_or_zero);
uint32 ReadTagSlow();
- bool ReadStringFallback(string* buffer, int size);
+ bool ReadStringFallback(std::string* buffer, int size);
// Return the size of the buffer.
int BufferSize() const;
@@ -683,7 +691,7 @@ class LIBPROTOBUF_EXPORT CodedInputStream {
// }
//
// delete coded_output;
-class LIBPROTOBUF_EXPORT CodedOutputStream {
+class PROTOBUF_EXPORT CodedOutputStream {
public:
// Create an CodedOutputStream that writes to the given ZeroCopyOutputStream.
explicit CodedOutputStream(ZeroCopyOutputStream* output);
@@ -737,11 +745,11 @@ class LIBPROTOBUF_EXPORT CodedOutputStream {
static uint8* WriteRawToArray(const void* buffer, int size, uint8* target);
// Equivalent to WriteRaw(str.data(), str.size()).
- void WriteString(const string& str);
+ void WriteString(const std::string& str);
// Like WriteString() but writing directly to the target array.
- static uint8* WriteStringToArray(const string& str, uint8* target);
+ static uint8* WriteStringToArray(const std::string& str, uint8* target);
// Write the varint-encoded size of str followed by str.
- static uint8* WriteStringWithSizeToArray(const string& str, uint8* target);
+ static uint8* WriteStringWithSizeToArray(const std::string& str, uint8* target);
// Instructs the CodedOutputStream to allow the underlying
@@ -788,7 +796,7 @@ class LIBPROTOBUF_EXPORT CodedOutputStream {
// but GCC by default doesn't want to inline this.
void WriteTag(uint32 value);
// Like WriteTag() but writing directly to the target array.
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE
+ PROTOBUF_ALWAYS_INLINE
static uint8* WriteTagToArray(uint32 value, uint8* target);
// Returns the number of bytes needed to encode the given value as a varint.
@@ -908,7 +916,7 @@ class LIBPROTOBUF_EXPORT CodedOutputStream {
inline bool CodedInputStream::ReadVarint32(uint32* value) {
uint32 v = 0;
- if (GOOGLE_PREDICT_TRUE(buffer_ < buffer_end_)) {
+ if (PROTOBUF_PREDICT_TRUE(buffer_ < buffer_end_)) {
v = *buffer_;
if (v < 0x80) {
*value = v;
@@ -922,7 +930,7 @@ inline bool CodedInputStream::ReadVarint32(uint32* value) {
}
inline bool CodedInputStream::ReadVarint64(uint64* value) {
- if (GOOGLE_PREDICT_TRUE(buffer_ < buffer_end_) && *buffer_ < 0x80) {
+ if (PROTOBUF_PREDICT_TRUE(buffer_ < buffer_end_) && *buffer_ < 0x80) {
*value = *buffer_;
Advance(1);
return true;
@@ -933,7 +941,7 @@ inline bool CodedInputStream::ReadVarint64(uint64* value) {
}
inline bool CodedInputStream::ReadVarintSizeAsInt(int* value) {
- if (GOOGLE_PREDICT_TRUE(buffer_ < buffer_end_)) {
+ if (PROTOBUF_PREDICT_TRUE(buffer_ < buffer_end_)) {
int v = *buffer_;
if (v < 0x80) {
*value = v;
@@ -984,7 +992,7 @@ inline const uint8* CodedInputStream::ReadLittleEndian64FromArray(
inline bool CodedInputStream::ReadLittleEndian32(uint32* value) {
#if defined(PROTOBUF_LITTLE_ENDIAN)
- if (GOOGLE_PREDICT_TRUE(BufferSize() >= static_cast<int>(sizeof(*value)))) {
+ if (PROTOBUF_PREDICT_TRUE(BufferSize() >= static_cast<int>(sizeof(*value)))) {
buffer_ = ReadLittleEndian32FromArray(buffer_, value);
return true;
} else {
@@ -997,7 +1005,7 @@ inline bool CodedInputStream::ReadLittleEndian32(uint32* value) {
inline bool CodedInputStream::ReadLittleEndian64(uint64* value) {
#if defined(PROTOBUF_LITTLE_ENDIAN)
- if (GOOGLE_PREDICT_TRUE(BufferSize() >= static_cast<int>(sizeof(*value)))) {
+ if (PROTOBUF_PREDICT_TRUE(BufferSize() >= static_cast<int>(sizeof(*value)))) {
buffer_ = ReadLittleEndian64FromArray(buffer_, value);
return true;
} else {
@@ -1010,7 +1018,7 @@ inline bool CodedInputStream::ReadLittleEndian64(uint64* value) {
inline uint32 CodedInputStream::ReadTagNoLastTag() {
uint32 v = 0;
- if (GOOGLE_PREDICT_TRUE(buffer_ < buffer_end_)) {
+ if (PROTOBUF_PREDICT_TRUE(buffer_ < buffer_end_)) {
v = *buffer_;
if (v < 0x80) {
Advance(1);
@@ -1027,7 +1035,7 @@ inline std::pair<uint32, bool> CodedInputStream::ReadTagWithCutoffNoLastTag(
// constant, and things like "cutoff >= kMax1ByteVarint" to be evaluated at
// compile time.
uint32 first_byte_or_zero = 0;
- if (GOOGLE_PREDICT_TRUE(buffer_ < buffer_end_)) {
+ if (PROTOBUF_PREDICT_TRUE(buffer_ < buffer_end_)) {
// Hot case: buffer_ non_empty, buffer_[0] in [1, 128).
// TODO(gpike): Is it worth rearranging this? E.g., if the number of fields
// is large enough then is it better to check for the two-byte case first?
@@ -1041,8 +1049,8 @@ inline std::pair<uint32, bool> CodedInputStream::ReadTagWithCutoffNoLastTag(
// Other hot case: cutoff >= 0x80, buffer_ has at least two bytes available,
// and tag is two bytes. The latter is tested by bitwise-and-not of the
// first byte and the second byte.
- if (cutoff >= 0x80 && GOOGLE_PREDICT_TRUE(buffer_ + 1 < buffer_end_) &&
- GOOGLE_PREDICT_TRUE((buffer_[0] & ~buffer_[1]) >= 0x80)) {
+ if (cutoff >= 0x80 && PROTOBUF_PREDICT_TRUE(buffer_ + 1 < buffer_end_) &&
+ PROTOBUF_PREDICT_TRUE((buffer_[0] & ~buffer_[1]) >= 0x80)) {
const uint32 kMax2ByteVarint = (0x7f << 7) + 0x7f;
uint32 tag = (1u << 7) * buffer_[1] + (buffer_[0] - 0x80);
Advance(2);
@@ -1071,14 +1079,14 @@ inline bool CodedInputStream::ConsumedEntireMessage() {
inline bool CodedInputStream::ExpectTag(uint32 expected) {
if (expected < (1 << 7)) {
- if (GOOGLE_PREDICT_TRUE(buffer_ < buffer_end_) && buffer_[0] == expected) {
+ if (PROTOBUF_PREDICT_TRUE(buffer_ < buffer_end_) && buffer_[0] == expected) {
Advance(1);
return true;
} else {
return false;
}
} else if (expected < (1 << 14)) {
- if (GOOGLE_PREDICT_TRUE(BufferSize() >= 2) &&
+ if (PROTOBUF_PREDICT_TRUE(BufferSize() >= 2) &&
buffer_[0] == static_cast<uint8>(expected | 0x80) &&
buffer_[1] == static_cast<uint8>(expected >> 7)) {
Advance(2);
@@ -1269,7 +1277,7 @@ inline size_t CodedOutputStream::VarintSize32SignExtended(int32 value) {
}
}
-inline void CodedOutputStream::WriteString(const string& str) {
+inline void CodedOutputStream::WriteString(const std::string& str) {
WriteRaw(str.data(), static_cast<int>(str.size()));
}
@@ -1283,7 +1291,7 @@ inline void CodedOutputStream::WriteRawMaybeAliased(
}
inline uint8* CodedOutputStream::WriteStringToArray(
- const string& str, uint8* target) {
+ const std::string& str, uint8* target) {
return WriteRawToArray(str.data(), static_cast<int>(str.size()), target);
}
diff --git a/src/google/protobuf/io/coded_stream_inl.h b/src/google/protobuf/io/coded_stream_inl.h
index d95b06e0..df66282a 100644
--- a/src/google/protobuf/io/coded_stream_inl.h
+++ b/src/google/protobuf/io/coded_stream_inl.h
@@ -47,7 +47,7 @@ namespace google {
namespace protobuf {
namespace io {
-inline bool CodedInputStream::InternalReadStringInline(string* buffer,
+inline bool CodedInputStream::InternalReadStringInline(std::string* buffer,
int size) {
if (size < 0) return false; // security: size is often user-supplied
diff --git a/src/google/protobuf/io/coded_stream_unittest.cc b/src/google/protobuf/io/coded_stream_unittest.cc
index bcda8c81..52cc7c33 100644
--- a/src/google/protobuf/io/coded_stream_unittest.cc
+++ b/src/google/protobuf/io/coded_stream_unittest.cc
@@ -49,10 +49,12 @@
#include <gtest/gtest.h>
#include <google/protobuf/stubs/casts.h>
+#include <google/protobuf/port_def.inc>
+
// This declares an unsigned long long integer literal in a portable way.
// (The original macro is way too big and ruins my formatting.)
#undef ULL
-#define ULL(x) GOOGLE_ULONGLONG(x)
+#define ULL(x) PROTOBUF_ULONGLONG(x)
namespace google {
diff --git a/src/google/protobuf/io/gzip_stream.h b/src/google/protobuf/io/gzip_stream.h
index ba1475c7..b8eadfab 100644
--- a/src/google/protobuf/io/gzip_stream.h
+++ b/src/google/protobuf/io/gzip_stream.h
@@ -48,12 +48,14 @@
#include <google/protobuf/port.h>
#include <zlib.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace io {
// A ZeroCopyInputStream that reads compressed data through zlib
-class LIBPROTOBUF_EXPORT GzipInputStream : public ZeroCopyInputStream {
+class PROTOBUF_EXPORT GzipInputStream : public ZeroCopyInputStream {
public:
// Format key for constructor
enum Format {
@@ -107,8 +109,7 @@ class LIBPROTOBUF_EXPORT GzipInputStream : public ZeroCopyInputStream {
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(GzipInputStream);
};
-
-class LIBPROTOBUF_EXPORT GzipOutputStream : public ZeroCopyOutputStream {
+class PROTOBUF_EXPORT GzipOutputStream : public ZeroCopyOutputStream {
public:
// Format key for constructor
enum Format {
@@ -119,7 +120,7 @@ class LIBPROTOBUF_EXPORT GzipOutputStream : public ZeroCopyOutputStream {
ZLIB = 2,
};
- struct LIBPROTOBUF_EXPORT Options {
+ struct PROTOBUF_EXPORT Options {
// Defaults to GZIP.
Format format;
@@ -207,4 +208,6 @@ class LIBPROTOBUF_EXPORT GzipOutputStream : public ZeroCopyOutputStream {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_IO_GZIP_STREAM_H__
diff --git a/src/google/protobuf/io/printer.h b/src/google/protobuf/io/printer.h
index 236aed43..ce693e54 100644
--- a/src/google/protobuf/io/printer.h
+++ b/src/google/protobuf/io/printer.h
@@ -42,6 +42,8 @@
#include <vector>
#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace io {
@@ -49,15 +51,15 @@ namespace io {
class ZeroCopyOutputStream; // zero_copy_stream.h
// Records annotations about a Printer's output.
-class LIBPROTOBUF_EXPORT AnnotationCollector {
+class PROTOBUF_EXPORT AnnotationCollector {
public:
// Annotation is a ofset range and a payload pair.
- typedef std::pair<std::pair<size_t, size_t>, string> Annotation;
+ typedef std::pair<std::pair<size_t, size_t>, std::string> Annotation;
// Records that the bytes in file_path beginning with begin_offset and ending
// before end_offset are associated with the SourceCodeInfo-style path.
virtual void AddAnnotation(size_t begin_offset, size_t end_offset,
- const string& file_path,
+ const std::string& file_path,
const std::vector<int>& path) = 0;
// TODO(gerbens) I don't see why we need virtuals here. Just a vector of
@@ -80,7 +82,7 @@ class AnnotationProtoCollector : public AnnotationCollector {
// Override for AnnotationCollector::AddAnnotation.
virtual void AddAnnotation(size_t begin_offset, size_t end_offset,
- const string& file_path,
+ const std::string& file_path,
const std::vector<int>& path) {
typename AnnotationProto::Annotation* annotation =
annotation_proto_->add_annotation();
@@ -176,7 +178,7 @@ class AnnotationProtoCollector : public AnnotationCollector {
// This code associates the span covering "call(bar,bar)" in the output with the
// call_ descriptor.
-class LIBPROTOBUF_EXPORT Printer {
+class PROTOBUF_EXPORT Printer {
public:
// Create a printer that writes text to the given output stream. Use the
// given character as the delimiter for variables.
@@ -217,7 +219,7 @@ class LIBPROTOBUF_EXPORT Printer {
// Link a subsitution variable emitted by the last call to Print to the file
// with path file_name.
- void Annotate(const char* varname, const string& file_name) {
+ void Annotate(const char* varname, const std::string& file_name) {
Annotate(varname, varname, file_name);
}
@@ -226,7 +228,7 @@ class LIBPROTOBUF_EXPORT Printer {
// at begin_varname's value and ends after the last character of the value
// substituted for end_varname.
void Annotate(const char* begin_varname, const char* end_varname,
- const string& file_name) {
+ const std::string& file_name) {
if (annotation_collector_ == NULL) {
// Annotations aren't turned on for this Printer.
return;
@@ -240,12 +242,12 @@ class LIBPROTOBUF_EXPORT Printer {
// substituted are identified by their names surrounded by delimiter
// characters (as given to the constructor). The variable bindings are
// defined by the given map.
- void Print(const std::map<string, string>& variables, const char* text);
+ void Print(const std::map<std::string, std::string>& variables, const char* text);
// Like the first Print(), except the substitutions are given as parameters.
template <typename... Args>
void Print(const char* text, const Args&... args) {
- std::map<string, string> vars;
+ std::map<std::string, std::string> vars;
PrintInternal(&vars, text, args...);
}
@@ -260,7 +262,7 @@ class LIBPROTOBUF_EXPORT Printer {
// Write a string to the output buffer.
// This method does not look for newlines to add indentation.
- void PrintRaw(const string& data);
+ void PrintRaw(const std::string& data);
// Write a zero-delimited string to output buffer.
// This method does not look for newlines to add indentation.
@@ -275,8 +277,8 @@ class LIBPROTOBUF_EXPORT Printer {
// formatting text using named variables (eq. "$foo$) from a lookup map (vars)
// and variables directly supplied by arguments (eq "$1$" meaning first
// argument which is the zero index element of args).
- void FormatInternal(const std::vector<string>& args,
- const std::map<string, string>& vars, const char* format);
+ void FormatInternal(const std::vector<std::string>& args,
+ const std::map<std::string, std::string>& vars, const char* format);
// True if any write to the underlying stream failed. (We don't just
// crash in this case because this is an I/O failure, not a programming
@@ -291,16 +293,16 @@ class LIBPROTOBUF_EXPORT Printer {
// substituted for end_varname. Note that begin_varname and end_varname
// may refer to the same variable.
void Annotate(const char* begin_varname, const char* end_varname,
- const string& file_path, const std::vector<int>& path);
+ const std::string& file_path, const std::vector<int>& path);
// Base case
- void PrintInternal(std::map<string, string>* vars, const char* text) {
+ void PrintInternal(std::map<std::string, std::string>* vars, const char* text) {
Print(*vars, text);
}
template <typename... Args>
- void PrintInternal(std::map<string, string>* vars, const char* text,
- const char* key, const string& value,
+ void PrintInternal(std::map<std::string, std::string>* vars, const char* text,
+ const char* key, const std::string& value,
const Args&... args) {
(*vars)[key] = value;
PrintInternal(vars, text, args...);
@@ -323,7 +325,7 @@ class LIBPROTOBUF_EXPORT Printer {
inline void IndentIfAtStart();
const char* WriteVariable(
- const std::vector<string>& args, const std::map<string, string>& vars,
+ const std::vector<std::string>& args, const std::map<std::string, std::string>& vars,
const char* format, int* arg_index,
std::vector<AnnotationCollector::Annotation>* annotations);
@@ -337,7 +339,7 @@ class LIBPROTOBUF_EXPORT Printer {
// used to calculate annotation ranges in the substitutions_ map below.
size_t offset_;
- string indent_;
+ std::string indent_;
bool at_start_of_line_;
bool failed_;
@@ -348,12 +350,12 @@ class LIBPROTOBUF_EXPORT Printer {
// start offset is the beginning of the substitution; the end offset is the
// last byte of the substitution plus one (such that (end - start) is the
// length of the substituted string).
- std::map<string, std::pair<size_t, size_t> > substitutions_;
+ std::map<std::string, std::pair<size_t, size_t> > substitutions_;
// Keeps track of the keys in substitutions_ that need to be updated when
// indents are inserted. These are keys that refer to the beginning of the
// current line.
- std::vector<string> line_start_variables_;
+ std::vector<std::string> line_start_variables_;
// Returns true and sets range to the substitution range in the output for
// varname if varname was used once in the last call to Print. If varname
@@ -373,4 +375,6 @@ class LIBPROTOBUF_EXPORT Printer {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_IO_PRINTER_H__
diff --git a/src/google/protobuf/io/tokenizer.h b/src/google/protobuf/io/tokenizer.h
index 59b67729..f6c3d273 100644
--- a/src/google/protobuf/io/tokenizer.h
+++ b/src/google/protobuf/io/tokenizer.h
@@ -42,6 +42,8 @@
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/logging.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace io {
@@ -61,7 +63,7 @@ typedef int ColumnNumber;
// Abstract interface for an object which collects the errors that occur
// during parsing. A typical implementation might simply print the errors
// to stdout.
-class LIBPROTOBUF_EXPORT ErrorCollector {
+class PROTOBUF_EXPORT ErrorCollector {
public:
inline ErrorCollector() {}
virtual ~ErrorCollector();
@@ -70,13 +72,13 @@ class LIBPROTOBUF_EXPORT ErrorCollector {
// column numbers. The numbers are zero-based, so you may want to add
// 1 to each before printing them.
virtual void AddError(int line, ColumnNumber column,
- const string& message) = 0;
+ const std::string& message) = 0;
// Indicates that there was a warning in the input at the given line and
// column numbers. The numbers are zero-based, so you may want to add
// 1 to each before printing them.
virtual void AddWarning(int line, ColumnNumber column,
- const string& message) { }
+ const std::string& message) { }
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ErrorCollector);
@@ -88,7 +90,7 @@ class LIBPROTOBUF_EXPORT ErrorCollector {
// precise descriptions. Whitespace and comments are skipped. By default,
// C- and C++-style comments are recognized, but other styles can be used by
// calling set_comment_style().
-class LIBPROTOBUF_EXPORT Tokenizer {
+class PROTOBUF_EXPORT Tokenizer {
public:
// Construct a Tokenizer that reads and tokenizes text from the given
// input stream and writes errors to the given error_collector.
@@ -124,7 +126,7 @@ class LIBPROTOBUF_EXPORT Tokenizer {
// Structure representing a token read from the token stream.
struct Token {
TokenType type;
- string text; // The exact text of the token as it appeared in
+ std::string text; // The exact text of the token as it appeared in
// the input. e.g. tokens of TYPE_STRING will still
// be escaped and in quotes.
@@ -190,31 +192,31 @@ class LIBPROTOBUF_EXPORT Tokenizer {
// /* Block comment attached to
// * grault. */
// optional int32 grault = 6;
- bool NextWithComments(string* prev_trailing_comments,
- std::vector<string>* detached_comments,
- string* next_leading_comments);
+ bool NextWithComments(std::string* prev_trailing_comments,
+ std::vector<std::string>* detached_comments,
+ std::string* next_leading_comments);
// Parse helpers ---------------------------------------------------
// Parses a TYPE_FLOAT token. This never fails, so long as the text actually
// comes from a TYPE_FLOAT token parsed by Tokenizer. If it doesn't, the
// result is undefined (possibly an assert failure).
- static double ParseFloat(const string& text);
+ static double ParseFloat(const std::string& text);
// Parses a TYPE_STRING token. This never fails, so long as the text actually
// comes from a TYPE_STRING token parsed by Tokenizer. If it doesn't, the
// result is undefined (possibly an assert failure).
- static void ParseString(const string& text, string* output);
+ static void ParseString(const std::string& text, std::string* output);
// Identical to ParseString, but appends to output.
- static void ParseStringAppend(const string& text, string* output);
+ static void ParseStringAppend(const std::string& text, std::string* output);
// Parses a TYPE_INTEGER token. Returns false if the result would be
// greater than max_value. Otherwise, returns true and sets *output to the
// result. If the text is not from a Token of type TYPE_INTEGER originally
// parsed by a Tokenizer, the result is undefined (possibly an assert
// failure).
- static bool ParseInteger(const string& text, uint64 max_value,
+ static bool ParseInteger(const std::string& text, uint64 max_value,
uint64* output);
// Options ---------------------------------------------------------
@@ -250,7 +252,7 @@ class LIBPROTOBUF_EXPORT Tokenizer {
}
// External helper: validate an identifier.
- static bool IsIdentifier(const string& text);
+ static bool IsIdentifier(const std::string& text);
// -----------------------------------------------------------------
private:
@@ -276,7 +278,7 @@ class LIBPROTOBUF_EXPORT Tokenizer {
// Call RecordTo(&str) to start recording and StopRecording() to stop.
// E.g. StartToken() calls RecordTo(&current_.text). record_start_ is the
// position within the current buffer where recording started.
- string* record_target_;
+ std::string* record_target_;
int record_start_;
// Options.
@@ -299,7 +301,7 @@ class LIBPROTOBUF_EXPORT Tokenizer {
// Read a new buffer from the input.
void Refresh();
- inline void RecordTo(string* target);
+ inline void RecordTo(std::string* target);
inline void StopRecording();
// Called when the current character is the first character of a new
@@ -311,7 +313,7 @@ class LIBPROTOBUF_EXPORT Tokenizer {
inline void EndToken();
// Convenience method to add an error at the current line and column.
- void AddError(const string& message) {
+ void AddError(const std::string& message) {
error_collector_->AddError(line_, column_, message);
}
@@ -334,9 +336,9 @@ class LIBPROTOBUF_EXPORT Tokenizer {
TokenType ConsumeNumber(bool started_with_zero, bool started_with_dot);
// Consume the rest of a line.
- void ConsumeLineComment(string* content);
+ void ConsumeLineComment(std::string* content);
// Consume until "*/".
- void ConsumeBlockComment(string* content);
+ void ConsumeBlockComment(std::string* content);
enum NextCommentStatus {
// Started a line comment.
@@ -399,7 +401,7 @@ inline const Tokenizer::Token& Tokenizer::previous() {
return previous_;
}
-inline void Tokenizer::ParseString(const string& text, string* output) {
+inline void Tokenizer::ParseString(const std::string& text, std::string* output) {
output->clear();
ParseStringAppend(text, output);
}
@@ -408,4 +410,6 @@ inline void Tokenizer::ParseString(const string& text, string* output) {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_IO_TOKENIZER_H__
diff --git a/src/google/protobuf/io/zero_copy_stream.h b/src/google/protobuf/io/zero_copy_stream.h
index f532d759..de2374b5 100644
--- a/src/google/protobuf/io/zero_copy_stream.h
+++ b/src/google/protobuf/io/zero_copy_stream.h
@@ -110,6 +110,8 @@
#include <string>
#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
@@ -121,7 +123,7 @@ class ZeroCopyOutputStream;
// Abstract interface similar to an input stream but designed to minimize
// copying.
-class LIBPROTOBUF_EXPORT ZeroCopyInputStream {
+class PROTOBUF_EXPORT ZeroCopyInputStream {
public:
ZeroCopyInputStream() {}
virtual ~ZeroCopyInputStream() {}
@@ -178,7 +180,7 @@ class LIBPROTOBUF_EXPORT ZeroCopyInputStream {
// Abstract interface similar to an output stream but designed to minimize
// copying.
-class LIBPROTOBUF_EXPORT ZeroCopyOutputStream {
+class PROTOBUF_EXPORT ZeroCopyOutputStream {
public:
ZeroCopyOutputStream() {}
virtual ~ZeroCopyOutputStream() {}
@@ -245,4 +247,6 @@ class LIBPROTOBUF_EXPORT ZeroCopyOutputStream {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_H__
diff --git a/src/google/protobuf/io/zero_copy_stream_impl.h b/src/google/protobuf/io/zero_copy_stream_impl.h
index 206fd0d4..46062a85 100644
--- a/src/google/protobuf/io/zero_copy_stream_impl.h
+++ b/src/google/protobuf/io/zero_copy_stream_impl.h
@@ -47,6 +47,8 @@
#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace io {
@@ -60,7 +62,7 @@ namespace io {
// The latter will introduce an extra layer of buffering, harming performance.
// Also, it's conceivable that FileInputStream could someday be enhanced
// to use zero-copy file descriptors on OSs which support them.
-class LIBPROTOBUF_EXPORT FileInputStream : public ZeroCopyInputStream {
+class PROTOBUF_EXPORT FileInputStream : public ZeroCopyInputStream {
public:
// Creates a stream that reads from the given Unix file descriptor.
// If a block_size is given, it specifies the number of bytes that
@@ -93,7 +95,7 @@ class LIBPROTOBUF_EXPORT FileInputStream : public ZeroCopyInputStream {
int64 ByteCount() const override;
private:
- class LIBPROTOBUF_EXPORT CopyingFileInputStream : public CopyingInputStream {
+ class PROTOBUF_EXPORT CopyingFileInputStream : public CopyingInputStream {
public:
CopyingFileInputStream(int file_descriptor);
~CopyingFileInputStream() override;
@@ -137,7 +139,7 @@ class LIBPROTOBUF_EXPORT FileInputStream : public ZeroCopyInputStream {
// harming performance. Also, it's conceivable that FileOutputStream could
// someday be enhanced to use zero-copy file descriptors on OSs which
// support them.
-class LIBPROTOBUF_EXPORT FileOutputStream : public ZeroCopyOutputStream {
+class PROTOBUF_EXPORT FileOutputStream : public ZeroCopyOutputStream {
public:
// Creates a stream that writes to the given Unix file descriptor.
// If a block_size is given, it specifies the size of the buffers
@@ -175,7 +177,7 @@ class LIBPROTOBUF_EXPORT FileOutputStream : public ZeroCopyOutputStream {
int64 ByteCount() const override;
private:
- class LIBPROTOBUF_EXPORT CopyingFileOutputStream : public CopyingOutputStream {
+ class PROTOBUF_EXPORT CopyingFileOutputStream : public CopyingOutputStream {
public:
CopyingFileOutputStream(int file_descriptor);
~CopyingFileOutputStream() override;
@@ -211,7 +213,7 @@ class LIBPROTOBUF_EXPORT FileOutputStream : public ZeroCopyOutputStream {
//
// Note that for reading files (or anything represented by a file descriptor),
// FileInputStream is more efficient.
-class LIBPROTOBUF_EXPORT IstreamInputStream : public ZeroCopyInputStream {
+class PROTOBUF_EXPORT IstreamInputStream : public ZeroCopyInputStream {
public:
// Creates a stream that reads from the given C++ istream.
// If a block_size is given, it specifies the number of bytes that
@@ -226,7 +228,7 @@ class LIBPROTOBUF_EXPORT IstreamInputStream : public ZeroCopyInputStream {
int64 ByteCount() const override;
private:
- class LIBPROTOBUF_EXPORT CopyingIstreamInputStream : public CopyingInputStream {
+ class PROTOBUF_EXPORT CopyingIstreamInputStream : public CopyingInputStream {
public:
CopyingIstreamInputStream(std::istream* input);
~CopyingIstreamInputStream() override;
@@ -254,7 +256,7 @@ class LIBPROTOBUF_EXPORT IstreamInputStream : public ZeroCopyInputStream {
//
// Note that for writing files (or anything represented by a file descriptor),
// FileOutputStream is more efficient.
-class LIBPROTOBUF_EXPORT OstreamOutputStream : public ZeroCopyOutputStream {
+class PROTOBUF_EXPORT OstreamOutputStream : public ZeroCopyOutputStream {
public:
// Creates a stream that writes to the given C++ ostream.
// If a block_size is given, it specifies the size of the buffers
@@ -269,7 +271,8 @@ class LIBPROTOBUF_EXPORT OstreamOutputStream : public ZeroCopyOutputStream {
int64 ByteCount() const override;
private:
- class LIBPROTOBUF_EXPORT CopyingOstreamOutputStream : public CopyingOutputStream {
+ class PROTOBUF_EXPORT CopyingOstreamOutputStream
+ : public CopyingOutputStream {
public:
CopyingOstreamOutputStream(std::ostream* output);
~CopyingOstreamOutputStream() override;
@@ -299,7 +302,7 @@ class LIBPROTOBUF_EXPORT OstreamOutputStream : public ZeroCopyOutputStream {
// ConcatenatingInputStream may do odd things. It is suggested that you do
// not use ConcatenatingInputStream on streams that might produce read errors
// other than end-of-stream.
-class LIBPROTOBUF_EXPORT ConcatenatingInputStream : public ZeroCopyInputStream {
+class PROTOBUF_EXPORT ConcatenatingInputStream : public ZeroCopyInputStream {
public:
// All streams passed in as well as the array itself must remain valid
// until the ConcatenatingInputStream is destroyed.
@@ -327,7 +330,7 @@ class LIBPROTOBUF_EXPORT ConcatenatingInputStream : public ZeroCopyInputStream {
// A ZeroCopyInputStream which wraps some other stream and limits it to
// a particular byte count.
-class LIBPROTOBUF_EXPORT LimitingInputStream : public ZeroCopyInputStream {
+class PROTOBUF_EXPORT LimitingInputStream : public ZeroCopyInputStream {
public:
LimitingInputStream(ZeroCopyInputStream* input, int64 limit);
~LimitingInputStream() override;
@@ -353,4 +356,6 @@ class LIBPROTOBUF_EXPORT LimitingInputStream : public ZeroCopyInputStream {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_IMPL_H__
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 da4ef455..07d18849 100644
--- a/src/google/protobuf/io/zero_copy_stream_impl_lite.h
+++ b/src/google/protobuf/io/zero_copy_stream_impl_lite.h
@@ -53,6 +53,8 @@
#include <google/protobuf/stubs/stl_util.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace io {
@@ -60,7 +62,7 @@ namespace io {
// ===================================================================
// A ZeroCopyInputStream backed by an in-memory array of bytes.
-class LIBPROTOBUF_EXPORT ArrayInputStream : public ZeroCopyInputStream {
+class PROTOBUF_EXPORT ArrayInputStream : public ZeroCopyInputStream {
public:
// Create an InputStream that returns the bytes pointed to by "data".
// "data" remains the property of the caller but must remain valid until
@@ -94,7 +96,7 @@ class LIBPROTOBUF_EXPORT ArrayInputStream : public ZeroCopyInputStream {
// ===================================================================
// A ZeroCopyOutputStream backed by an in-memory array of bytes.
-class LIBPROTOBUF_EXPORT ArrayOutputStream : public ZeroCopyOutputStream {
+class PROTOBUF_EXPORT ArrayOutputStream : public ZeroCopyOutputStream {
public:
// Create an OutputStream that writes to the bytes pointed to by "data".
// "data" remains the property of the caller but must remain valid until
@@ -126,7 +128,7 @@ class LIBPROTOBUF_EXPORT ArrayOutputStream : public ZeroCopyOutputStream {
// ===================================================================
// A ZeroCopyOutputStream which appends bytes to a string.
-class LIBPROTOBUF_EXPORT StringOutputStream : public ZeroCopyOutputStream {
+class PROTOBUF_EXPORT StringOutputStream : public ZeroCopyOutputStream {
public:
// Create a StringOutputStream which appends bytes to the given string.
// The string remains property of the caller, but it is mutated in arbitrary
@@ -137,7 +139,7 @@ class LIBPROTOBUF_EXPORT StringOutputStream : public ZeroCopyOutputStream {
// Hint: If you call target->reserve(n) before creating the stream,
// the first call to Next() will return at least n bytes of buffer
// space.
- explicit StringOutputStream(string* target);
+ explicit StringOutputStream(std::string* target);
~StringOutputStream() override = default;
// implements ZeroCopyOutputStream ---------------------------------
@@ -146,12 +148,12 @@ class LIBPROTOBUF_EXPORT StringOutputStream : public ZeroCopyOutputStream {
int64 ByteCount() const override;
protected:
- void SetString(string* target);
+ void SetString(std::string* target);
private:
static const int kMinimumSize = 16;
- string* target_;
+ std::string* target_;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(StringOutputStream);
};
@@ -173,7 +175,7 @@ class LIBPROTOBUF_EXPORT StringOutputStream : public ZeroCopyOutputStream {
// CopyingInputStream implementations should avoid buffering if possible.
// CopyingInputStreamAdaptor does its own buffering and will read data
// in large blocks.
-class LIBPROTOBUF_EXPORT CopyingInputStream {
+class PROTOBUF_EXPORT CopyingInputStream {
public:
virtual ~CopyingInputStream() {}
@@ -199,7 +201,7 @@ class LIBPROTOBUF_EXPORT CopyingInputStream {
// If you want to read from file descriptors or C++ istreams, this is
// already implemented for you: use FileInputStream or IstreamInputStream
// respectively.
-class LIBPROTOBUF_EXPORT CopyingInputStreamAdaptor : public ZeroCopyInputStream {
+class PROTOBUF_EXPORT CopyingInputStreamAdaptor : public ZeroCopyInputStream {
public:
// Creates a stream that reads from the given CopyingInputStream.
// If a block_size is given, it specifies the number of bytes that
@@ -267,7 +269,7 @@ class LIBPROTOBUF_EXPORT CopyingInputStreamAdaptor : public ZeroCopyInputStream
// CopyingOutputStream implementations should avoid buffering if possible.
// CopyingOutputStreamAdaptor does its own buffering and will write data
// in large blocks.
-class LIBPROTOBUF_EXPORT CopyingOutputStream {
+class PROTOBUF_EXPORT CopyingOutputStream {
public:
virtual ~CopyingOutputStream() {}
@@ -283,7 +285,7 @@ class LIBPROTOBUF_EXPORT CopyingOutputStream {
// If you want to write to file descriptors or C++ ostreams, this is
// already implemented for you: use FileOutputStream or OstreamOutputStream
// respectively.
-class LIBPROTOBUF_EXPORT CopyingOutputStreamAdaptor : public ZeroCopyOutputStream {
+class PROTOBUF_EXPORT CopyingOutputStreamAdaptor : public ZeroCopyOutputStream {
public:
// Creates a stream that writes to the given Unix file descriptor.
// If a block_size is given, it specifies the size of the buffers
@@ -356,7 +358,7 @@ class LIBPROTOBUF_EXPORT CopyingOutputStreamAdaptor : public ZeroCopyOutputStrea
// Return a pointer to mutable characters underlying the given string. The
// return value is valid until the next time the string is resized. We
// trust the caller to treat the return value as an array of length s->size().
-inline char* mutable_string_data(string* s) {
+inline char* mutable_string_data(std::string* s) {
#ifdef LANG_CXX11
// This should be simpler & faster than string_as_array() because the latter
// is guaranteed to return NULL when *s is empty, so it has to check for that.
@@ -370,7 +372,7 @@ inline char* mutable_string_data(string* s) {
// ({ char* p = mutable_string_data(s); make_pair(p, p != NULL); })
// Sometimes it's faster: in some scenarios p cannot be NULL, and then the
// code can avoid that check.
-inline std::pair<char*, bool> as_string_data(string* s) {
+inline std::pair<char*, bool> as_string_data(std::string* s) {
char *p = mutable_string_data(s);
#ifdef LANG_CXX11
return std::make_pair(p, true);
@@ -383,4 +385,6 @@ inline std::pair<char*, bool> as_string_data(string* s) {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_IMPL_LITE_H__
diff --git a/src/google/protobuf/lite_unittest.cc b/src/google/protobuf/lite_unittest.cc
index ee44f51b..e893316b 100644
--- a/src/google/protobuf/lite_unittest.cc
+++ b/src/google/protobuf/lite_unittest.cc
@@ -46,9 +46,10 @@
#include <google/protobuf/wire_format_lite_inl.h>
#include <gtest/gtest.h>
+// When string == std::string inside Google, we can remove this typedef.
#include <google/protobuf/stubs/strutil.h>
-using std::string;
+typedef std::string ProtoString;
namespace google {
namespace protobuf {
@@ -75,7 +76,7 @@ void SetAllTypesInEmptyMessageUnknownFields(
protobuf_unittest::TestAllTypesLite message;
TestUtilLite::ExpectClear(message);
TestUtilLite::SetAllFields(&message);
- string data = message.SerializeAsString();
+ ProtoString data = message.SerializeAsString();
empty_message->ParseFromString(data);
}
@@ -87,12 +88,12 @@ void SetSomeTypesInEmptyMessageUnknownFields(
message.set_optional_int64(102);
message.set_optional_uint32(103);
message.set_optional_uint64(104);
- string data = message.SerializeAsString();
+ ProtoString data = message.SerializeAsString();
empty_message->ParseFromString(data);
}
TEST(Lite, AllLite1) {
- string data;
+ ProtoString data;
{
protobuf_unittest::TestAllTypesLite message, message2, message3;
@@ -112,13 +113,13 @@ TEST(Lite, AllLite1) {
}
TEST(Lite, AllLite2) {
- string data;
+ ProtoString data;
{
protobuf_unittest::TestAllExtensionsLite message, message2, message3;
TestUtilLite::ExpectExtensionsClear(message);
TestUtilLite::SetAllExtensions(&message);
message2.CopyFrom(message);
- string extensions_data = message.SerializeAsString();
+ ProtoString extensions_data = message.SerializeAsString();
message3.ParseFromString(extensions_data);
TestUtilLite::ExpectAllExtensionsSet(message);
TestUtilLite::ExpectAllExtensionsSet(message2);
@@ -131,7 +132,7 @@ TEST(Lite, AllLite2) {
}
TEST(Lite, AllLite3) {
- string data, packed_data;
+ ProtoString data, packed_data;
{
protobuf_unittest::TestPackedTypesLite message, message2, message3;
@@ -154,7 +155,7 @@ TEST(Lite, AllLite3) {
TestUtilLite::ExpectPackedExtensionsClear(message);
TestUtilLite::SetPackedExtensions(&message);
message2.CopyFrom(message);
- string packed_extensions_data = message.SerializeAsString();
+ ProtoString packed_extensions_data = message.SerializeAsString();
EXPECT_EQ(packed_extensions_data, packed_data);
message3.ParseFromString(packed_extensions_data);
TestUtilLite::ExpectPackedExtensionsSet(message);
@@ -168,7 +169,7 @@ TEST(Lite, AllLite3) {
}
TEST(Lite, AllLite5) {
- string data;
+ ProtoString data;
{
// Test that if an optional or required message/group field appears multiple
@@ -202,7 +203,7 @@ TEST(Lite, AllLite5) {
#undef ASSIGN_REPEATED_GROUP
- string buffer;
+ ProtoString buffer;
generator.SerializeToString(&buffer);
unittest::TestParsingMergeLite parsing_merge;
parsing_merge.ParseFromString(buffer);
@@ -225,7 +226,7 @@ TEST(Lite, AllLite5) {
}
TEST(Lite, AllLite6) {
- string data;
+ ProtoString data;
// Test unknown fields support for lite messages.
{
@@ -246,7 +247,7 @@ TEST(Lite, AllLite6) {
}
TEST(Lite, AllLite7) {
- string data;
+ ProtoString data;
{
protobuf_unittest::TestAllExtensionsLite message, message2;
@@ -266,7 +267,7 @@ TEST(Lite, AllLite7) {
}
TEST(Lite, AllLite8) {
- string data;
+ ProtoString data;
{
protobuf_unittest::TestPackedTypesLite message, message2;
@@ -286,7 +287,7 @@ TEST(Lite, AllLite8) {
}
TEST(Lite, AllLite9) {
- string data;
+ ProtoString data;
{
protobuf_unittest::TestPackedExtensionsLite message, message2;
@@ -306,7 +307,7 @@ TEST(Lite, AllLite9) {
}
TEST(Lite, AllLite10) {
- string data;
+ ProtoString data;
{
// Test Unknown fields swap
@@ -314,7 +315,7 @@ TEST(Lite, AllLite10) {
SetAllTypesInEmptyMessageUnknownFields(&empty_message);
SetSomeTypesInEmptyMessageUnknownFields(&empty_message2);
data = empty_message.SerializeAsString();
- string data2 = empty_message2.SerializeAsString();
+ ProtoString data2 = empty_message2.SerializeAsString();
empty_message.Swap(&empty_message2);
EXPECT_EQ(data, empty_message2.SerializeAsString());
EXPECT_EQ(data2, empty_message.SerializeAsString());
@@ -322,7 +323,7 @@ TEST(Lite, AllLite10) {
}
TEST(Lite, AllLite11) {
- string data;
+ ProtoString data;
{
// Test unknown fields swap with self
@@ -335,7 +336,7 @@ TEST(Lite, AllLite11) {
}
TEST(Lite, AllLite12) {
- string data;
+ ProtoString data;
{
// Test MergeFrom with unknown fields
@@ -365,12 +366,12 @@ TEST(Lite, AllLite12) {
}
TEST(Lite, AllLite13) {
- string data;
+ ProtoString data;
{
// Test unknown enum value
protobuf_unittest::TestAllTypesLite message;
- string buffer;
+ ProtoString buffer;
{
io::StringOutputStream output_stream(&buffer);
io::CodedOutputStream coded_output(&output_stream);
@@ -390,7 +391,7 @@ TEST(Lite, AllLite13) {
}
TEST(Lite, AllLite14) {
- string data;
+ ProtoString data;
{
// Test Clear with unknown fields
@@ -404,7 +405,7 @@ TEST(Lite, AllLite14) {
// Tests for map lite =============================================
TEST(Lite, AllLite15) {
- string data;
+ ProtoString data;
{
// Accessors
@@ -419,7 +420,7 @@ TEST(Lite, AllLite15) {
}
TEST(Lite, AllLite16) {
- string data;
+ ProtoString data;
{
// SetMapFieldsInitialized
@@ -431,7 +432,7 @@ TEST(Lite, AllLite16) {
}
TEST(Lite, AllLite17) {
- string data;
+ ProtoString data;
{
// Clear
@@ -444,7 +445,7 @@ TEST(Lite, AllLite17) {
}
TEST(Lite, AllLite18) {
- string data;
+ ProtoString data;
{
// ClearMessageMap
@@ -457,7 +458,7 @@ TEST(Lite, AllLite18) {
}
TEST(Lite, AllLite19) {
- string data;
+ ProtoString data;
{
// CopyFrom
@@ -474,7 +475,7 @@ TEST(Lite, AllLite19) {
}
TEST(Lite, AllLite20) {
- string data;
+ ProtoString data;
{
// CopyFromMessageMap
@@ -492,7 +493,7 @@ TEST(Lite, AllLite20) {
}
TEST(Lite, AllLite21) {
- string data;
+ ProtoString data;
{
// SwapWithEmpty
@@ -509,7 +510,7 @@ TEST(Lite, AllLite21) {
}
TEST(Lite, AllLite22) {
- string data;
+ ProtoString data;
{
// SwapWithSelf
@@ -524,7 +525,7 @@ TEST(Lite, AllLite22) {
}
TEST(Lite, AllLite23) {
- string data;
+ ProtoString data;
{
// SwapWithOther
@@ -541,7 +542,7 @@ TEST(Lite, AllLite23) {
}
TEST(Lite, AllLite24) {
- string data;
+ ProtoString data;
{
// CopyConstructor
@@ -554,7 +555,7 @@ TEST(Lite, AllLite24) {
}
TEST(Lite, AllLite25) {
- string data;
+ ProtoString data;
{
// CopyAssignmentOperator
@@ -572,7 +573,7 @@ TEST(Lite, AllLite25) {
}
TEST(Lite, AllLite26) {
- string data;
+ ProtoString data;
{
// NonEmptyMergeFrom
@@ -594,7 +595,7 @@ TEST(Lite, AllLite26) {
}
TEST(Lite, AllLite27) {
- string data;
+ ProtoString data;
{
// MergeFromMessageMap
@@ -612,12 +613,12 @@ TEST(Lite, AllLite27) {
}
TEST(Lite, AllLite28) {
- string data;
+ ProtoString data;
{
// Test the generated SerializeWithCachedSizesToArray()
protobuf_unittest::TestMapLite message1, message2;
- string data;
+ ProtoString data;
MapLiteTestUtil::SetMapFields(&message1);
int size = message1.ByteSize();
data.resize(size);
@@ -630,14 +631,14 @@ TEST(Lite, AllLite28) {
}
TEST(Lite, AllLite29) {
- string data;
+ ProtoString data;
{
// Test the generated SerializeWithCachedSizes()
protobuf_unittest::TestMapLite message1, message2;
MapLiteTestUtil::SetMapFields(&message1);
int size = message1.ByteSize();
- string data;
+ ProtoString data;
data.resize(size);
{
// Allow the output stream to buffer only one byte at a time.
@@ -654,7 +655,7 @@ TEST(Lite, AllLite29) {
TEST(Lite, AllLite32) {
- string data;
+ ProtoString data;
{
// Proto2UnknownEnum
@@ -663,14 +664,14 @@ TEST(Lite, AllLite32) {
protobuf_unittest::E_PROTO2_MAP_ENUM_FOO_LITE;
(*from.mutable_unknown_map_field())[0] =
protobuf_unittest::E_PROTO2_MAP_ENUM_EXTRA_LITE;
- string data;
+ ProtoString data;
from.SerializeToString(&data);
protobuf_unittest::TestEnumMapLite to;
EXPECT_TRUE(to.ParseFromString(data));
EXPECT_EQ(0, to.unknown_map_field().size());
EXPECT_FALSE(to.mutable_unknown_fields()->empty());
- EXPECT_EQ(1, to.known_map_field().size());
+ ASSERT_EQ(1, to.known_map_field().size());
EXPECT_EQ(protobuf_unittest::PROTO2_MAP_ENUM_FOO_LITE,
to.known_map_field().at(0));
@@ -678,141 +679,147 @@ TEST(Lite, AllLite32) {
from.Clear();
to.SerializeToString(&data);
EXPECT_TRUE(from.ParseFromString(data));
- EXPECT_EQ(1, from.known_map_field().size());
+ ASSERT_EQ(1, from.known_map_field().size());
EXPECT_EQ(protobuf_unittest::E_PROTO2_MAP_ENUM_FOO_LITE,
from.known_map_field().at(0));
- EXPECT_EQ(1, from.unknown_map_field().size());
+ ASSERT_EQ(1, from.unknown_map_field().size());
EXPECT_EQ(protobuf_unittest::E_PROTO2_MAP_ENUM_EXTRA_LITE,
from.unknown_map_field().at(0));
}
}
TEST(Lite, AllLite33) {
- string data;
+ ProtoString data;
{
// StandardWireFormat
protobuf_unittest::TestMapLite message;
- string data = "\x0A\x04\x08\x01\x10\x01";
+ ProtoString data = "\x0A\x04\x08\x01\x10\x01";
EXPECT_TRUE(message.ParseFromString(data));
- EXPECT_EQ(1, message.map_int32_int32().size());
+ ASSERT_EQ(1, message.map_int32_int32().size());
EXPECT_EQ(1, message.map_int32_int32().at(1));
}
}
TEST(Lite, AllLite34) {
- string data;
+ ProtoString data;
{
// UnorderedWireFormat
protobuf_unittest::TestMapLite message;
// put value before key in wire format
- string data = "\x0A\x04\x10\x01\x08\x02";
+ ProtoString data = "\x0A\x04\x10\x01\x08\x02";
EXPECT_TRUE(message.ParseFromString(data));
- EXPECT_EQ(1, message.map_int32_int32().size());
+ ASSERT_EQ(1, message.map_int32_int32().size());
+ ASSERT_NE(message.map_int32_int32().find(2),
+ message.map_int32_int32().end());
EXPECT_EQ(1, message.map_int32_int32().at(2));
}
}
TEST(Lite, AllLite35) {
- string data;
+ ProtoString data;
{
// DuplicatedKeyWireFormat
protobuf_unittest::TestMapLite message;
// Two key fields in wire format
- string data = "\x0A\x06\x08\x01\x08\x02\x10\x01";
+ ProtoString data = "\x0A\x06\x08\x01\x08\x02\x10\x01";
EXPECT_TRUE(message.ParseFromString(data));
- EXPECT_EQ(1, message.map_int32_int32().size());
+ ASSERT_EQ(1, message.map_int32_int32().size());
EXPECT_EQ(1, message.map_int32_int32().at(2));
}
}
TEST(Lite, AllLite36) {
- string data;
+ ProtoString data;
{
// DuplicatedValueWireFormat
protobuf_unittest::TestMapLite message;
// Two value fields in wire format
- string data = "\x0A\x06\x08\x01\x10\x01\x10\x02";
+ ProtoString data = "\x0A\x06\x08\x01\x10\x01\x10\x02";
EXPECT_TRUE(message.ParseFromString(data));
- EXPECT_EQ(1, message.map_int32_int32().size());
+ ASSERT_EQ(1, message.map_int32_int32().size());
EXPECT_EQ(2, message.map_int32_int32().at(1));
}
}
TEST(Lite, AllLite37) {
- string data;
+ ProtoString data;
{
// MissedKeyWireFormat
protobuf_unittest::TestMapLite message;
// No key field in wire format
- string data = "\x0A\x02\x10\x01";
+ ProtoString data = "\x0A\x02\x10\x01";
EXPECT_TRUE(message.ParseFromString(data));
- EXPECT_EQ(1, message.map_int32_int32().size());
+ ASSERT_EQ(1, message.map_int32_int32().size());
+ ASSERT_NE(message.map_int32_int32().find(0),
+ message.map_int32_int32().end());
EXPECT_EQ(1, message.map_int32_int32().at(0));
}
}
TEST(Lite, AllLite38) {
- string data;
+ ProtoString data;
{
// MissedValueWireFormat
protobuf_unittest::TestMapLite message;
// No value field in wire format
- string data = "\x0A\x02\x08\x01";
+ ProtoString data = "\x0A\x02\x08\x01";
EXPECT_TRUE(message.ParseFromString(data));
- EXPECT_EQ(1, message.map_int32_int32().size());
+ ASSERT_EQ(1, message.map_int32_int32().size());
+ ASSERT_NE(message.map_int32_int32().find(1),
+ message.map_int32_int32().end());
EXPECT_EQ(0, message.map_int32_int32().at(1));
}
}
TEST(Lite, AllLite39) {
- string data;
+ ProtoString data;
{
// UnknownFieldWireFormat
protobuf_unittest::TestMapLite message;
// Unknown field in wire format
- string data = "\x0A\x06\x08\x02\x10\x03\x18\x01";
+ ProtoString data = "\x0A\x06\x08\x02\x10\x03\x18\x01";
EXPECT_TRUE(message.ParseFromString(data));
- EXPECT_EQ(1, message.map_int32_int32().size());
+ ASSERT_EQ(1, message.map_int32_int32().size());
EXPECT_EQ(3, message.map_int32_int32().at(2));
}
}
TEST(Lite, AllLite40) {
- string data;
+ ProtoString data;
{
// CorruptedWireFormat
protobuf_unittest::TestMapLite message;
// corrupted data in wire format
- string data = "\x0A\x06\x08\x02\x11\x03";
+ ProtoString data = "\x0A\x06\x08\x02\x11\x03";
EXPECT_FALSE(message.ParseFromString(data));
}
}
TEST(Lite, AllLite41) {
- string data;
+ ProtoString data;
{
// IsInitialized
@@ -831,7 +838,7 @@ TEST(Lite, AllLite41) {
}
TEST(Lite, AllLite42) {
- string data;
+ ProtoString data;
{
// Check that adding more values to enum does not corrupt message
@@ -840,7 +847,7 @@ TEST(Lite, AllLite42) {
v2_message.set_int_field(800);
// Set enum field to the value not understood by the old client.
v2_message.set_enum_field(protobuf_unittest::V2_SECOND);
- string v2_bytes = v2_message.SerializeAsString();
+ ProtoString v2_bytes = v2_message.SerializeAsString();
protobuf_unittest::V1MessageLite v1_message;
v1_message.ParseFromString(v2_bytes);
@@ -851,7 +858,7 @@ TEST(Lite, AllLite42) {
EXPECT_EQ(v1_message.enum_field(), protobuf_unittest::V1_FIRST);
// However, when re-serialized, it should preserve enum value.
- string v1_bytes = v1_message.SerializeAsString();
+ ProtoString v1_bytes = v1_message.SerializeAsString();
protobuf_unittest::V2MessageLite same_v2_message;
same_v2_message.ParseFromString(v1_bytes);
@@ -867,7 +874,7 @@ TEST(Lite, AllLite43) {
protobuf_unittest::TestOneofParsingLite message1;
message1.set_oneof_int32(17);
- string serialized;
+ ProtoString serialized;
EXPECT_TRUE(message1.SerializeToString(&serialized));
// Submessage
@@ -909,7 +916,7 @@ TEST(Lite, AllLite44) {
{
protobuf_unittest::TestOneofParsingLite original;
original.set_oneof_int32(17);
- string serialized;
+ ProtoString serialized;
EXPECT_TRUE(original.SerializeToString(&serialized));
protobuf_unittest::TestOneofParsingLite parsed;
for (int i = 0; i < 2; ++i) {
@@ -925,7 +932,7 @@ TEST(Lite, AllLite44) {
{
protobuf_unittest::TestOneofParsingLite original;
original.mutable_oneof_submessage()->set_optional_int32(5);
- string serialized;
+ ProtoString serialized;
EXPECT_TRUE(original.SerializeToString(&serialized));
protobuf_unittest::TestOneofParsingLite parsed;
for (int i = 0; i < 2; ++i) {
@@ -941,7 +948,7 @@ TEST(Lite, AllLite44) {
{
protobuf_unittest::TestOneofParsingLite original;
original.set_oneof_string("string");
- string serialized;
+ ProtoString serialized;
EXPECT_TRUE(original.SerializeToString(&serialized));
protobuf_unittest::TestOneofParsingLite parsed;
for (int i = 0; i < 2; ++i) {
@@ -957,7 +964,7 @@ TEST(Lite, AllLite44) {
{
protobuf_unittest::TestOneofParsingLite original;
original.set_oneof_bytes("bytes");
- string serialized;
+ ProtoString serialized;
EXPECT_TRUE(original.SerializeToString(&serialized));
protobuf_unittest::TestOneofParsingLite parsed;
for (int i = 0; i < 2; ++i) {
@@ -973,7 +980,7 @@ TEST(Lite, AllLite44) {
{
protobuf_unittest::TestOneofParsingLite original;
original.set_oneof_enum(protobuf_unittest::V2_SECOND);
- string serialized;
+ ProtoString serialized;
EXPECT_TRUE(original.SerializeToString(&serialized));
protobuf_unittest::TestOneofParsingLite parsed;
for (int i = 0; i < 2; ++i) {
@@ -990,7 +997,7 @@ TEST(Lite, AllLite44) {
TEST(Lite, AllLite45) {
// Test unknown fields are not discarded upon parsing.
- string data = "\20\1"; // varint 1 with field number 2
+ ProtoString data = "\20\1"; // varint 1 with field number 2
protobuf_unittest::ForeignMessageLite a;
EXPECT_TRUE(a.ParseFromString(data));
@@ -998,7 +1005,7 @@ TEST(Lite, AllLite45) {
reinterpret_cast<const ::google::protobuf::uint8*>(data.data()), data.size());
EXPECT_TRUE(a.MergePartialFromCodedStream(&input_stream));
- string serialized = a.SerializeAsString();
+ ProtoString serialized = a.SerializeAsString();
EXPECT_EQ(serialized.substr(0, 2), data);
EXPECT_EQ(serialized.substr(2), data);
}
@@ -1013,7 +1020,7 @@ TEST(Lite, AllLite45) {
TEST(Lite, AllLite46) {
protobuf_unittest::PackedInt32 packed;
packed.add_repeated_int32(42);
- string serialized;
+ ProtoString serialized;
ASSERT_TRUE(packed.SerializeToString(&serialized));
protobuf_unittest::NonPackedInt32 non_packed;
@@ -1025,7 +1032,7 @@ TEST(Lite, AllLite46) {
TEST(Lite, AllLite47) {
protobuf_unittest::NonPackedFixed32 non_packed;
non_packed.add_repeated_fixed32(42);
- string serialized;
+ ProtoString serialized;
ASSERT_TRUE(non_packed.SerializeToString(&serialized));
protobuf_unittest::PackedFixed32 packed;
@@ -1034,5 +1041,19 @@ TEST(Lite, AllLite47) {
EXPECT_EQ(42, packed.repeated_fixed32(0));
}
+TEST(Lite, MapCrash) {
+ // See b/113635730
+ Arena arena;
+ auto msg = Arena::CreateMessage<protobuf_unittest::TestMapLite>(&arena);
+ // Payload for the map<string, Enum> with a enum varint that's longer > 10
+ // bytes. This causes a parse fail and a subsequent delete.
+ // field 16 (map<int32, MapEnumLite>) tag = 128+2 = \202 \1
+ // 13 long \15
+ // int32 key = 1 (\10 \1)
+ // MapEnumLite value = too long varint (parse error)
+ EXPECT_FALSE(msg->ParseFromString(
+ "\202\1\15\10\1\200\200\200\200\200\200\200\200\200\200\1"));
+}
+
} // namespace protobuf
} // namespace google
diff --git a/src/google/protobuf/map.h b/src/google/protobuf/map.h
index c5afa200..a7126c16 100644
--- a/src/google/protobuf/map.h
+++ b/src/google/protobuf/map.h
@@ -53,6 +53,8 @@
#error "You cannot SWIG proto headers"
#endif
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
@@ -626,7 +628,7 @@ class Map {
}
DestroyNode(item);
--num_elements_;
- if (GOOGLE_PREDICT_FALSE(b == index_of_first_non_null_)) {
+ if (PROTOBUF_PREDICT_FALSE(b == index_of_first_non_null_)) {
while (index_of_first_non_null_ < num_buckets_ &&
table_[index_of_first_non_null_] == NULL) {
++index_of_first_non_null_;
@@ -683,7 +685,7 @@ class Map {
if (TableEntryIsEmpty(b)) {
result = InsertUniqueInList(b, node);
} else if (TableEntryIsNonEmptyList(b)) {
- if (GOOGLE_PREDICT_FALSE(TableEntryIsTooLong(b))) {
+ if (PROTOBUF_PREDICT_FALSE(TableEntryIsTooLong(b))) {
TreeConvert(b);
result = InsertUniqueInTree(b, node);
GOOGLE_DCHECK_EQ(result.bucket_index_, b & ~static_cast<size_type>(1));
@@ -738,13 +740,13 @@ class Map {
// We don't care how many elements are in trees. If a lot are,
// we may resize even though there are many empty buckets. In
// practice, this seems fine.
- if (GOOGLE_PREDICT_FALSE(new_size >= hi_cutoff)) {
+ if (PROTOBUF_PREDICT_FALSE(new_size >= hi_cutoff)) {
if (num_buckets_ <= max_size() / 2) {
Resize(num_buckets_ * 2);
return true;
}
- } else if (GOOGLE_PREDICT_FALSE(new_size <= lo_cutoff &&
- num_buckets_ > kMinTableSize)) {
+ } else if (PROTOBUF_PREDICT_FALSE(new_size <= lo_cutoff &&
+ num_buckets_ > kMinTableSize)) {
size_type lg2_of_size_reduction_factor = 1;
// It's possible we want to shrink a lot here... size() could even be 0.
// So, estimate how much to shrink by making sure we don't shrink so
@@ -1219,4 +1221,6 @@ class Map {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_MAP_H__
diff --git a/src/google/protobuf/map_entry.h b/src/google/protobuf/map_entry.h
index 53f35077..fbc792f3 100644
--- a/src/google/protobuf/map_entry.h
+++ b/src/google/protobuf/map_entry.h
@@ -121,7 +121,7 @@ class MapEntry
InternalMetadataWithArena _internal_metadata_;
private:
- friend class ::GOOGLE_PROTOBUF_NAMESPACE_ID::Arena;
+ friend class ::PROTOBUF_NAMESPACE_ID::Arena;
template <typename C, typename K, typename V,
WireFormatLite::FieldType k_wire_type, WireFormatLite::FieldType,
int default_enum>
diff --git a/src/google/protobuf/map_entry_lite.h b/src/google/protobuf/map_entry_lite.h
index 982f0f44..98b2acae 100644
--- a/src/google/protobuf/map_entry_lite.h
+++ b/src/google/protobuf/map_entry_lite.h
@@ -40,9 +40,13 @@
#include <google/protobuf/map.h>
#include <google/protobuf/map_type_handler.h>
#include <google/protobuf/port.h>
+#include <google/protobuf/wire_format_lite.h>
#include <google/protobuf/wire_format_lite_inl.h>
#include <google/protobuf/port_def.inc>
+#if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
+#include <google/protobuf/parse_context.h>
+#endif
#ifdef SWIG
#error "You cannot SWIG proto headers"
@@ -186,7 +190,7 @@ 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 override { return ""; }
+ std::string GetTypeName() const override { return ""; }
void CheckTypeAndMergeFrom(const MessageLite& other) override {
MergeFromInternal(*::google::protobuf::down_cast<const Derived*>(&other));
@@ -338,6 +342,9 @@ class MapEntryImpl : public Base {
class Parser {
public:
explicit Parser(MapField* mf) : mf_(mf), map_(mf->MutableMap()) {}
+ ~Parser() {
+ if (entry_ != nullptr && entry_->GetArena() == nullptr) delete entry_;
+ }
// This does what the typical MergePartialFromCodedStream() is expected to
// do, with the additional side-effect that if successful (i.e., if true is
@@ -355,11 +362,11 @@ class MapEntryImpl : public Base {
int size;
input->GetDirectBufferPointerInline(&data, &size);
// We could use memcmp here, but we don't bother. The tag is one byte.
- GOOGLE_COMPILE_ASSERT(kTagSize == 1, tag_size_error);
+ static_assert(kTagSize == 1, "tag size must be 1");
if (size > 0 && *reinterpret_cast<const char*>(data) == kValueTag) {
typename Map::size_type map_size = map_->size();
value_ptr_ = &(*map_)[key_];
- if (GOOGLE_PREDICT_TRUE(map_size != map_->size())) {
+ if (PROTOBUF_PREDICT_TRUE(map_size != map_->size())) {
// We created a new key-value pair. Fill in the value.
typedef
typename MapIf<ValueTypeHandler::kIsEnum, int*, Value*>::type T;
@@ -377,19 +384,53 @@ class MapEntryImpl : public Base {
key_ = Key();
}
- entry_.reset(mf_->NewEntry());
+ NewEntry();
*entry_->mutable_key() = key_;
const bool result = entry_->MergePartialFromCodedStream(input);
if (result) UseKeyAndValueFromEntry();
- if (entry_->GetArena() != NULL) entry_.release();
return result;
}
+#if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
+ bool ParseMap(const char* begin, const char* end) {
+ io::CodedInputStream input(reinterpret_cast<const uint8*>(begin),
+ end - begin);
+ return MergePartialFromCodedStream(&input) &&
+ input.ConsumedEntireMessage();
+ }
+ template <typename Metadata>
+ bool ParseMapEnumValidation(const char* begin, const char* end, uint32 num,
+ Metadata* metadata,
+ bool (*validate_enum)(int)) {
+ io::CodedInputStream input(reinterpret_cast<const uint8*>(begin),
+ end - begin);
+ auto entry = NewEntry();
+ // TODO(gerbens) implement _InternalParse for maps. We can't use
+ // ParseFromString as this will call _InternalParse
+ if (!(entry->MergePartialFromCodedStream(&input) &&
+ input.ConsumedEntireMessage()))
+ return false;
+ if (!validate_enum(entry->value())) {
+ auto unknown_fields = metadata->mutable_unknown_fields();
+ WriteLengthDelimited(num, StringPiece(begin, end - begin),
+ unknown_fields);
+ return true;
+ }
+ (*map_)[entry->key()] = static_cast<Value>(entry->value());
+ return true;
+ }
+#endif
+
+ MapEntryImpl* NewEntry() { return entry_ = mf_->NewEntry(); }
+
const Key& key() const { return key_; }
const Value& value() const { return *value_ptr_; }
+ const Key& entry_key() const { return entry_->key(); }
+ const Value& entry_value() const { return entry_->value(); }
+
private:
- void UseKeyAndValueFromEntry() GOOGLE_PROTOBUF_ATTRIBUTE_COLD {
+ void UseKeyAndValueFromEntry() PROTOBUF_COLD {
// Update key_ in case we need it later (because key() is called).
// This is potentially inefficient, especially if the key is
// expensive to copy (e.g., a long string), but this is a cold
@@ -406,8 +447,7 @@ class MapEntryImpl : public Base {
// After reading a key and value successfully, and inserting that data
// into map_, we are not at the end of the input. This is unusual, but
// allowed by the spec.
- bool ReadBeyondKeyValuePair(io::CodedInputStream* input)
- GOOGLE_PROTOBUF_ATTRIBUTE_COLD {
+ bool ReadBeyondKeyValuePair(io::CodedInputStream* input) PROTOBUF_COLD {
typedef MoveHelper<KeyTypeHandler::kIsEnum,
KeyTypeHandler::kIsMessage,
KeyTypeHandler::kWireType ==
@@ -418,13 +458,12 @@ class MapEntryImpl : public Base {
ValueTypeHandler::kWireType ==
WireFormatLite::WIRETYPE_LENGTH_DELIMITED,
Value> ValueMover;
- entry_.reset(mf_->NewEntry());
+ NewEntry();
ValueMover::Move(value_ptr_, entry_->mutable_value());
map_->erase(key_);
KeyMover::Move(&key_, entry_->mutable_key());
const bool result = entry_->MergePartialFromCodedStream(input);
if (result) UseKeyAndValueFromEntry();
- if (entry_->GetArena() != NULL) entry_.release();
return result;
}
@@ -432,9 +471,7 @@ class MapEntryImpl : public Base {
Map* const map_;
Key key_;
Value* value_ptr_;
- // On the fast path entry_ is not used. And, when entry_ is used, it's set
- // to mf_->NewEntry(), so in the arena case we must call entry_.release.
- std::unique_ptr<MapEntryImpl> entry_;
+ MapEntryImpl* entry_ = nullptr;
};
protected:
@@ -477,7 +514,7 @@ class MapEntryImpl : public Base {
const Key& key_;
const Value& value_;
- friend class ::GOOGLE_PROTOBUF_NAMESPACE_ID::Arena;
+ friend class ::PROTOBUF_NAMESPACE_ID::Arena;
typedef void InternalArenaConstructable_;
typedef void DestructorSkippable_;
};
@@ -507,7 +544,7 @@ class MapEntryImpl : public Base {
const KeyMapEntryAccessorType& key_;
const ValueMapEntryAccessorType value_;
- friend class ::GOOGLE_PROTOBUF_NAMESPACE_ID::Arena;
+ friend class ::PROTOBUF_NAMESPACE_ID::Arena;
typedef void DestructorSkippable_;
};
@@ -522,7 +559,7 @@ class MapEntryImpl : public Base {
uint32 _has_bits_[1];
private:
- friend class ::GOOGLE_PROTOBUF_NAMESPACE_ID::Arena;
+ friend class ::PROTOBUF_NAMESPACE_ID::Arena;
typedef void InternalArenaConstructable_;
typedef void DestructorSkippable_;
template <typename C, typename K, typename V, WireFormatLite::FieldType,
@@ -606,20 +643,20 @@ struct FromHelper {
template <>
struct FromHelper<WireFormatLite::TYPE_STRING> {
- static ArenaStringPtr From(const string& x) {
+ static ArenaStringPtr From(const std::string& x) {
ArenaStringPtr res;
TaggedPtr<::std::string> ptr;
- ptr.Set(const_cast<string*>(&x));
+ ptr.Set(const_cast<std::string*>(&x));
res.UnsafeSetTaggedPointer(ptr);
return res;
}
};
template <>
struct FromHelper<WireFormatLite::TYPE_BYTES> {
- static ArenaStringPtr From(const string& x) {
+ static ArenaStringPtr From(const std::string& x) {
ArenaStringPtr res;
TaggedPtr<::std::string> ptr;
- ptr.Set(const_cast<string*>(&x));
+ ptr.Set(const_cast<std::string*>(&x));
res.UnsafeSetTaggedPointer(ptr);
return res;
}
diff --git a/src/google/protobuf/map_field.h b/src/google/protobuf/map_field.h
index 9e60191a..38dd35d9 100644
--- a/src/google/protobuf/map_field.h
+++ b/src/google/protobuf/map_field.h
@@ -66,7 +66,7 @@ class MapFieldAccessor;
// This class provides access to map field using reflection, which is the same
// as those provided for RepeatedPtrField<Message>. It is used for internal
// reflection implentation only. Users should never use this directly.
-class LIBPROTOBUF_EXPORT MapFieldBase {
+class PROTOBUF_EXPORT MapFieldBase {
public:
MapFieldBase()
: arena_(NULL),
@@ -163,7 +163,7 @@ class LIBPROTOBUF_EXPORT MapFieldBase {
// type helper for key and value. Call these help methods to deal with
// different types. Real helper methods are implemented in
// TypeDefinedMapFieldBase.
- friend class ::GOOGLE_PROTOBUF_NAMESPACE_ID::MapIterator;
+ friend class ::PROTOBUF_NAMESPACE_ID::MapIterator;
// Allocate map<...>::iterator for MapIterator.
virtual void InitializeIterator(MapIterator* map_iter) const = 0;
@@ -300,7 +300,7 @@ class MapField : public TypeDefinedMapFieldBase<Key, T> {
void SetMapIteratorValue(MapIterator* map_iter) const override;
- friend class ::GOOGLE_PROTOBUF_NAMESPACE_ID::Arena;
+ friend class ::PROTOBUF_NAMESPACE_ID::Arena;
friend class MapFieldStateTest; // For testing, it needs raw access to impl_
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapField);
};
@@ -315,7 +315,8 @@ struct MapEntryToMapField<MapEntry<T, Key, Value, kKeyFieldType,
MapFieldType;
};
-class LIBPROTOBUF_EXPORT DynamicMapField: public TypeDefinedMapFieldBase<MapKey, MapValueRef> {
+class PROTOBUF_EXPORT DynamicMapField
+ : public TypeDefinedMapFieldBase<MapKey, MapValueRef> {
public:
explicit DynamicMapField(const Message* default_entry);
DynamicMapField(const Message* default_entry, Arena* arena);
@@ -359,7 +360,7 @@ class LIBPROTOBUF_EXPORT DynamicMapField: public TypeDefinedMapFieldBase<MapKey,
// MapKey is an union type for representing any possible
// map key.
-class LIBPROTOBUF_EXPORT MapKey {
+class PROTOBUF_EXPORT MapKey {
public:
MapKey() : type_(0) {
}
@@ -407,7 +408,7 @@ class LIBPROTOBUF_EXPORT MapKey {
SetType(FieldDescriptor::CPPTYPE_BOOL);
val_.bool_value_ = value;
}
- void SetStringValue(const string& val) {
+ void SetStringValue(const std::string& val) {
SetType(FieldDescriptor::CPPTYPE_STRING);
*val_.string_value_ = val;
}
@@ -437,7 +438,7 @@ class LIBPROTOBUF_EXPORT MapKey {
"MapKey::GetBoolValue");
return val_.bool_value_;
}
- const string& GetStringValue() const {
+ const std::string& GetStringValue() const {
TYPE_CHECK(FieldDescriptor::CPPTYPE_STRING,
"MapKey::GetStringValue");
return *val_.string_value_;
@@ -534,12 +535,12 @@ class LIBPROTOBUF_EXPORT MapKey {
private:
template <typename K, typename V>
friend class internal::TypeDefinedMapFieldBase;
- friend class ::GOOGLE_PROTOBUF_NAMESPACE_ID::MapIterator;
+ friend class ::PROTOBUF_NAMESPACE_ID::MapIterator;
friend class internal::DynamicMapField;
union KeyValue {
KeyValue() {}
- string* string_value_;
+ std::string* string_value_;
int64 int64_value_;
int32 int32_value_;
uint64 uint64_value_;
@@ -554,7 +555,7 @@ class LIBPROTOBUF_EXPORT MapKey {
}
type_ = type;
if (type_ == FieldDescriptor::CPPTYPE_STRING) {
- val_.string_value_ = new string;
+ val_.string_value_ = new std::string;
}
}
@@ -563,7 +564,7 @@ class LIBPROTOBUF_EXPORT MapKey {
};
// MapValueRef points to a map value.
-class LIBPROTOBUF_EXPORT MapValueRef {
+class PROTOBUF_EXPORT MapValueRef {
public:
MapValueRef() : data_(NULL), type_(0) {}
@@ -598,10 +599,10 @@ class LIBPROTOBUF_EXPORT MapValueRef {
"MapValueRef::SetEnumValue");
*reinterpret_cast<int*>(data_) = value;
}
- void SetStringValue(const string& value) {
+ void SetStringValue(const std::string& value) {
TYPE_CHECK(FieldDescriptor::CPPTYPE_STRING,
"MapValueRef::SetStringValue");
- *reinterpret_cast<string*>(data_) = value;
+ *reinterpret_cast<std::string*>(data_) = value;
}
void SetFloatValue(float value) {
TYPE_CHECK(FieldDescriptor::CPPTYPE_FLOAT,
@@ -644,10 +645,10 @@ class LIBPROTOBUF_EXPORT MapValueRef {
"MapValueRef::GetEnumValue");
return *reinterpret_cast<int*>(data_);
}
- const string& GetStringValue() const {
+ const std::string& GetStringValue() const {
TYPE_CHECK(FieldDescriptor::CPPTYPE_STRING,
"MapValueRef::GetStringValue");
- return *reinterpret_cast<string*>(data_);
+ return *reinterpret_cast<std::string*>(data_);
}
float GetFloatValue() const {
TYPE_CHECK(FieldDescriptor::CPPTYPE_FLOAT,
@@ -680,7 +681,7 @@ class LIBPROTOBUF_EXPORT MapValueRef {
friend class internal::MapField;
template <typename K, typename V>
friend class internal::TypeDefinedMapFieldBase;
- friend class ::GOOGLE_PROTOBUF_NAMESPACE_ID::MapIterator;
+ friend class ::PROTOBUF_NAMESPACE_ID::MapIterator;
friend class internal::GeneratedMessageReflection;
friend class internal::DynamicMapField;
@@ -718,7 +719,7 @@ class LIBPROTOBUF_EXPORT MapValueRef {
HANDLE_TYPE(DOUBLE, double);
HANDLE_TYPE(FLOAT, float);
HANDLE_TYPE(BOOL, bool);
- HANDLE_TYPE(STRING, string);
+ HANDLE_TYPE(STRING, std::string);
HANDLE_TYPE(ENUM, int32);
HANDLE_TYPE(MESSAGE, Message);
#undef HANDLE_TYPE
@@ -733,7 +734,7 @@ class LIBPROTOBUF_EXPORT MapValueRef {
#undef TYPE_CHECK
-class LIBPROTOBUF_EXPORT MapIterator {
+class PROTOBUF_EXPORT MapIterator {
public:
MapIterator(Message* message, const FieldDescriptor* field) {
const Reflection* reflection = message->GetReflection();
@@ -810,35 +811,33 @@ class LIBPROTOBUF_EXPORT MapIterator {
GOOGLE_PROTOBUF_HASH_NAMESPACE_DECLARATION_START
template <>
-struct hash<::GOOGLE_PROTOBUF_NAMESPACE_ID::MapKey> {
- size_t operator()(
- const ::GOOGLE_PROTOBUF_NAMESPACE_ID::MapKey& map_key) const {
+struct hash<::PROTOBUF_NAMESPACE_ID::MapKey> {
+ size_t operator()(const ::PROTOBUF_NAMESPACE_ID::MapKey& map_key) const {
switch (map_key.type()) {
- case ::GOOGLE_PROTOBUF_NAMESPACE_ID::FieldDescriptor::CPPTYPE_DOUBLE:
- case ::GOOGLE_PROTOBUF_NAMESPACE_ID::FieldDescriptor::CPPTYPE_FLOAT:
- case ::GOOGLE_PROTOBUF_NAMESPACE_ID::FieldDescriptor::CPPTYPE_ENUM:
- case ::GOOGLE_PROTOBUF_NAMESPACE_ID::FieldDescriptor::CPPTYPE_MESSAGE:
+ case ::PROTOBUF_NAMESPACE_ID::FieldDescriptor::CPPTYPE_DOUBLE:
+ case ::PROTOBUF_NAMESPACE_ID::FieldDescriptor::CPPTYPE_FLOAT:
+ case ::PROTOBUF_NAMESPACE_ID::FieldDescriptor::CPPTYPE_ENUM:
+ case ::PROTOBUF_NAMESPACE_ID::FieldDescriptor::CPPTYPE_MESSAGE:
GOOGLE_LOG(FATAL) << "Unsupported";
break;
- case ::GOOGLE_PROTOBUF_NAMESPACE_ID::FieldDescriptor::CPPTYPE_STRING:
- return hash<string>()(map_key.GetStringValue());
- case ::GOOGLE_PROTOBUF_NAMESPACE_ID::FieldDescriptor::CPPTYPE_INT64:
+ case ::PROTOBUF_NAMESPACE_ID::FieldDescriptor::CPPTYPE_STRING:
+ return hash<std::string>()(map_key.GetStringValue());
+ case ::PROTOBUF_NAMESPACE_ID::FieldDescriptor::CPPTYPE_INT64:
return hash<::google::protobuf::int64>()(map_key.GetInt64Value());
- case ::GOOGLE_PROTOBUF_NAMESPACE_ID::FieldDescriptor::CPPTYPE_INT32:
+ case ::PROTOBUF_NAMESPACE_ID::FieldDescriptor::CPPTYPE_INT32:
return hash<::google::protobuf::int32>()(map_key.GetInt32Value());
- case ::GOOGLE_PROTOBUF_NAMESPACE_ID::FieldDescriptor::CPPTYPE_UINT64:
+ case ::PROTOBUF_NAMESPACE_ID::FieldDescriptor::CPPTYPE_UINT64:
return hash<::google::protobuf::uint64>()(map_key.GetUInt64Value());
- case ::GOOGLE_PROTOBUF_NAMESPACE_ID::FieldDescriptor::CPPTYPE_UINT32:
+ case ::PROTOBUF_NAMESPACE_ID::FieldDescriptor::CPPTYPE_UINT32:
return hash<::google::protobuf::uint32>()(map_key.GetUInt32Value());
- case ::GOOGLE_PROTOBUF_NAMESPACE_ID::FieldDescriptor::CPPTYPE_BOOL:
+ case ::PROTOBUF_NAMESPACE_ID::FieldDescriptor::CPPTYPE_BOOL:
return hash<bool>()(map_key.GetBoolValue());
}
GOOGLE_LOG(FATAL) << "Can't get here.";
return 0;
}
- bool operator()(
- const ::GOOGLE_PROTOBUF_NAMESPACE_ID::MapKey& map_key1,
- const ::GOOGLE_PROTOBUF_NAMESPACE_ID::MapKey& map_key2) const {
+ bool operator()(const ::PROTOBUF_NAMESPACE_ID::MapKey& map_key1,
+ const ::PROTOBUF_NAMESPACE_ID::MapKey& map_key2) const {
return map_key1 < map_key2;
}
};
diff --git a/src/google/protobuf/map_field_inl.h b/src/google/protobuf/map_field_inl.h
index 169b3e2b..0e78342c 100644
--- a/src/google/protobuf/map_field_inl.h
+++ b/src/google/protobuf/map_field_inl.h
@@ -69,7 +69,7 @@ inline bool UnwrapMapKey<bool>(const MapKey& map_key) {
return map_key.GetBoolValue();
}
template<>
-inline string UnwrapMapKey<string>(const MapKey& map_key) {
+inline std::string UnwrapMapKey<std::string>(const MapKey& map_key) {
return map_key.GetStringValue();
}
@@ -97,7 +97,7 @@ inline void SetMapKey<bool>(MapKey* map_key, const bool& value) {
map_key->SetBoolValue(value);
}
template<>
-inline void SetMapKey<string>(MapKey* map_key, const string& value) {
+inline void SetMapKey<std::string>(MapKey* map_key, const std::string& value) {
map_key->SetStringValue(value);
}
diff --git a/src/google/protobuf/map_field_lite.h b/src/google/protobuf/map_field_lite.h
index 36b5b80d..5b8d2e48 100644
--- a/src/google/protobuf/map_field_lite.h
+++ b/src/google/protobuf/map_field_lite.h
@@ -31,6 +31,8 @@
#ifndef GOOGLE_PROTOBUF_MAP_FIELD_LITE_H__
#define GOOGLE_PROTOBUF_MAP_FIELD_LITE_H__
+#include <type_traits>
+#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/map.h>
#include <google/protobuf/map_entry_lite.h>
#include <google/protobuf/port.h>
@@ -112,7 +114,7 @@ class MapFieldLite {
Arena* arena_;
Map<Key, T> map_;
- friend class ::GOOGLE_PROTOBUF_NAMESPACE_ID::Arena;
+ friend class ::PROTOBUF_NAMESPACE_ID::Arena;
};
// True if IsInitialized() is true for value field in all elements of t. T is
diff --git a/src/google/protobuf/map_test.cc b/src/google/protobuf/map_test.cc
index beaacc47..080b9dfc 100644
--- a/src/google/protobuf/map_test.cc
+++ b/src/google/protobuf/map_test.cc
@@ -79,6 +79,8 @@
#include <google/protobuf/stubs/casts.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
@@ -1977,7 +1979,7 @@ TEST(GeneratedMapFieldTest, CopyAssignmentOperator) {
MapTestUtil::ExpectMapFieldsSet(message2);
}
-#if !defined(PROTOBUF_TEST_NO_DESCRIPTORS) || GOOGLE_PROTOBUF_RTTI
+#if !defined(PROTOBUF_TEST_NO_DESCRIPTORS) || PROTOBUF_RTTI
TEST(GeneratedMapFieldTest, UpcastCopyFrom) {
// Test the CopyFrom method that takes in the generic const Message&
// parameter.
@@ -2205,6 +2207,7 @@ TEST(GeneratedMapFieldTest, UnorderedWireFormat) {
EXPECT_TRUE(message.ParseFromString(data));
EXPECT_EQ(1, message.map_int32_int32().size());
+ ASSERT_NE(message.map_int32_int32().find(2), message.map_int32_int32().end());
EXPECT_EQ(1, message.map_int32_int32().at(2));
}
@@ -2280,10 +2283,21 @@ TEST(GeneratedMapFieldTest, KeysValuesUnknownsWireFormat) {
wire_format.push_back(c);
if (is_key) expected_key = static_cast<int>(c);
if (is_value) expected_value = static_cast<int>(c);
- ASSERT_TRUE(message.ParseFromString(wire_format));
- ASSERT_EQ(1, message.map_int32_int32().size());
- ASSERT_EQ(expected_key, message.map_int32_int32().begin()->first);
- ASSERT_EQ(expected_value, message.map_int32_int32().begin()->second);
+ bool res = message.ParseFromString(wire_format);
+ bool expect_success = true;
+#if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
+ // Unfortunately the old map parser accepts malformed input, the new
+ // parser accepts only correct input.
+ if (j != items - 1) expect_success = false;
+#endif
+ if (expect_success) {
+ ASSERT_TRUE(res);
+ ASSERT_EQ(1, message.map_int32_int32().size());
+ ASSERT_EQ(expected_key, message.map_int32_int32().begin()->first);
+ ASSERT_EQ(expected_value, message.map_int32_int32().begin()->second);
+ } else {
+ ASSERT_FALSE(res);
+ }
}
}
}
@@ -2308,6 +2322,7 @@ TEST(GeneratedMapFieldTest, MissedKeyWireFormat) {
EXPECT_TRUE(message.ParseFromString(data));
EXPECT_EQ(1, message.map_int32_int32().size());
+ ASSERT_NE(message.map_int32_int32().find(0), message.map_int32_int32().end());
EXPECT_EQ(1, message.map_int32_int32().at(0));
}
@@ -2319,6 +2334,7 @@ TEST(GeneratedMapFieldTest, MissedValueWireFormat) {
EXPECT_TRUE(message.ParseFromString(data));
EXPECT_EQ(1, message.map_int32_int32().size());
+ ASSERT_NE(message.map_int32_int32().find(1), message.map_int32_int32().end());
EXPECT_EQ(0, message.map_int32_int32().at(1));
}
@@ -3178,6 +3194,23 @@ TEST(TextFormatMapTest, SerializeAndParse) {
MapTestUtil::ExpectMapFieldsSet(dest);
}
+TEST(TextFormatMapTest, DynamicMessage) {
+ TestMap prototype;
+ DynamicMessageFactory factory;
+ std::unique_ptr<Message> message(
+ factory.GetPrototype(prototype.GetDescriptor())->New());
+ MapReflectionTester tester(message->GetDescriptor());
+ tester.SetMapFieldsViaReflection(message.get());
+
+ string expected_text;
+ GOOGLE_CHECK_OK(File::GetContents(
+ TestUtil::GetTestDataPath("net/proto2/internal/"
+ "testdata/map_test_data.txt"),
+ &expected_text, true));
+
+ EXPECT_EQ(message->DebugString(), expected_text);
+}
+
TEST(TextFormatMapTest, Sorted) {
unittest::TestMap message;
MapReflectionTester tester(message.GetDescriptor());
@@ -3211,6 +3244,78 @@ TEST(TextFormatMapTest, ParseCorruptedString) {
TestParseCorruptedString<protobuf_unittest::TestMaps, false>(message);
}
+// Previously, serializing to text format will disable iterator from generated
+// API. Now, the iterator can be still used even after serializing to text
+// format.
+TEST(TextFormatMapTest, NoDisableIterator) {
+ unittest::TestMap source;
+ (*source.mutable_map_int32_int32())[1] = 1;
+
+ // Get iterator.
+ Map<int32, int32>::iterator iter =
+ source.mutable_map_int32_int32()->find(1);
+
+ // Serialize message to text format, which will invalidate the previous
+ // iterator previously.
+ string output;
+ TextFormat::Printer printer;
+ printer.PrintToString(source, &output);
+
+ // Modify map via the iterator (invalidated in prvious implementation.).
+ iter->second = 2;
+
+ // In previous implementation, the new change won't be reflected in text
+ // format, because the previous iterator has been invalidated.
+ output.clear();
+ printer.PrintToString(source, &output);
+ string expected =
+ "map_int32_int32 {\n"
+ " key: 1\n"
+ " value: 2\n"
+ "}\n";
+ EXPECT_EQ(output, expected);
+}
+
+// Previously, serializing to text format will disable iterator from reflection
+// API.
+TEST(TextFormatMapTest, NoDisableReflectionIterator) {
+ unittest::TestMap source;
+ (*source.mutable_map_int32_int32())[1] = 1;
+
+ // Get iterator. This will also sync internal repeated field with map inside
+ // of MapField.
+ const Reflection* reflection = source.GetReflection();
+ const FieldDescriptor* field_desc =
+ source.GetDescriptor()->FindFieldByName("map_int32_int32");
+ RepeatedPtrField<Message>* map_field =
+ reflection->MutableRepeatedPtrField<Message>(&source, field_desc);
+ RepeatedPtrField<Message>::iterator iter = map_field->begin();
+
+ // Serialize message to text format, which will invalidate the prvious
+ // iterator previously.
+ string output;
+ TextFormat::Printer printer;
+ printer.PrintToString(source, &output);
+
+ // Modify map via the iterator (invalidated in prvious implementation.).
+ const Reflection* map_entry_reflection = iter->GetReflection();
+ const FieldDescriptor* value_field_desc =
+ iter->GetDescriptor()->FindFieldByName("value");
+ map_entry_reflection->SetInt32(&(*iter), value_field_desc, 2);
+ GOOGLE_LOG(INFO) << iter->DebugString();
+
+ // In previous implementation, the new change won't be reflected in text
+ // format, because the previous iterator has been invalidated.
+ output.clear();
+ printer.PrintToString(source, &output);
+ string expected =
+ "map_int32_int32 {\n"
+ " key: 1\n"
+ " value: 2\n"
+ "}\n";
+ EXPECT_EQ(output, expected);
+}
+
// arena support =================================================
TEST(ArenaTest, ParsingAndSerializingNoHeapAllocation) {
diff --git a/src/google/protobuf/map_test_util.h b/src/google/protobuf/map_test_util.h
index 53d15756..105313d4 100644
--- a/src/google/protobuf/map_test_util.h
+++ b/src/google/protobuf/map_test_util.h
@@ -107,15 +107,15 @@ class MapReflectionTester {
void ExpectClearViaReflectionIterator(Message* message);
void ExpectMapEntryClearViaReflection(Message* message);
void GetMapValueViaMapReflection(Message* message,
- const string& field_name,
+ const std::string& field_name,
const MapKey& map_key, MapValueRef* map_val);
- Message* GetMapEntryViaReflection(Message* message, const string& field_name,
+ Message* GetMapEntryViaReflection(Message* message, const std::string& field_name,
int index);
- MapIterator MapBegin(Message* message, const string& field_name);
- MapIterator MapEnd(Message* message, const string& field_name);
+ MapIterator MapBegin(Message* message, const std::string& field_name);
+ MapIterator MapEnd(Message* message, const std::string& field_name);
private:
- const FieldDescriptor* F(const string& name);
+ const FieldDescriptor* F(const std::string& name);
const Descriptor* base_descriptor_;
diff --git a/src/google/protobuf/map_type_handler.h b/src/google/protobuf/map_type_handler.h
index 0489851e..2db3dc6c 100644
--- a/src/google/protobuf/map_type_handler.h
+++ b/src/google/protobuf/map_type_handler.h
@@ -245,7 +245,7 @@ class MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type> {
int default_enum); \
static inline size_t SpaceUsedInMapEntryLong(const TypeOnMemory& value); \
static inline size_t SpaceUsedInMapLong(const TypeOnMemory& value); \
- static inline size_t SpaceUsedInMapLong(const string& value); \
+ static inline size_t SpaceUsedInMapLong(const std::string& value); \
static inline void AssignDefaultValue(TypeOnMemory* value); \
static inline const MapEntryAccessorType& DefaultIfNotInitialized( \
const TypeOnMemory& value, const TypeOnMemory& default_value); \
@@ -575,7 +575,7 @@ inline bool MapTypeHandler<WireFormatLite::TYPE_MESSAGE,
template <typename Type> \
inline size_t \
MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::SpaceUsedInMapLong( \
- const string& value) { \
+ const std::string& value) { \
return sizeof(value); \
} \
template <typename Type> \
diff --git a/src/google/protobuf/message.cc b/src/google/protobuf/message.cc
index b5a624b7..5a9acaf6 100644
--- a/src/google/protobuf/message.cc
+++ b/src/google/protobuf/message.cc
@@ -36,6 +36,7 @@
#include <stack>
#include <unordered_map>
+#include <google/protobuf/generated_message_reflection.h>
#include <google/protobuf/message.h>
#include <google/protobuf/stubs/casts.h>
@@ -51,6 +52,7 @@
#include <google/protobuf/map_field_inl.h>
#include <google/protobuf/reflection_ops.h>
#include <google/protobuf/wire_format.h>
+#include <google/protobuf/wire_format_lite.h>
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/map_util.h>
@@ -72,9 +74,12 @@ using internal::WireFormatLite;
void Message::MergeFrom(const Message& from) {
const Descriptor* descriptor = GetDescriptor();
GOOGLE_CHECK_EQ(from.GetDescriptor(), descriptor)
- << ": Tried to merge from a message with a different type. "
- "to: " << descriptor->full_name() << ", "
- "from: " << from.GetDescriptor()->full_name();
+ << ": Tried to merge from a message with a different type. "
+ "to: "
+ << descriptor->full_name()
+ << ", "
+ "from: "
+ << from.GetDescriptor()->full_name();
ReflectionOps::Merge(from, this);
}
@@ -85,19 +90,18 @@ void Message::CheckTypeAndMergeFrom(const MessageLite& other) {
void Message::CopyFrom(const Message& from) {
const Descriptor* descriptor = GetDescriptor();
GOOGLE_CHECK_EQ(from.GetDescriptor(), descriptor)
- << ": Tried to copy from a message with a different type. "
- "to: " << descriptor->full_name() << ", "
- "from: " << from.GetDescriptor()->full_name();
+ << ": Tried to copy from a message with a different type. "
+ "to: "
+ << descriptor->full_name()
+ << ", "
+ "from: "
+ << from.GetDescriptor()->full_name();
ReflectionOps::Copy(from, this);
}
-string Message::GetTypeName() const {
- return GetDescriptor()->full_name();
-}
+string Message::GetTypeName() const { return GetDescriptor()->full_name(); }
-void Message::Clear() {
- ReflectionOps::Clear(this);
-}
+void Message::Clear() { ReflectionOps::Clear(this); }
bool Message::IsInitialized() const {
return ReflectionOps::IsInitialized(*this);
@@ -114,9 +118,9 @@ string Message::InitializationErrorString() const {
}
void Message::CheckInitialized() const {
- GOOGLE_CHECK(IsInitialized())
- << "Message of type \"" << GetDescriptor()->full_name()
- << "\" is missing required fields: " << InitializationErrorString();
+ GOOGLE_CHECK(IsInitialized()) << "Message of type \"" << GetDescriptor()->full_name()
+ << "\" is missing required fields: "
+ << InitializationErrorString();
}
void Message::DiscardUnknownFields() {
@@ -156,27 +160,30 @@ class ReflectionAccessor {
public:
static void* GetOffset(void* msg, const google::protobuf::FieldDescriptor* f,
const google::protobuf::Reflection* r) {
- auto gr =
- dynamic_cast<const google::protobuf::internal::GeneratedMessageReflection*>(r);
- GOOGLE_CHECK(gr != nullptr);
- return static_cast<char*>(msg) + gr->schema_.GetFieldOffset(f);
+ return static_cast<char*>(msg) + CheckedCast(r)->schema_.GetFieldOffset(f);
}
- static google::protobuf::internal::ExtensionSet* GetExtensionSet(
- void* msg, const google::protobuf::Reflection* r) {
- auto gr =
- dynamic_cast<const google::protobuf::internal::GeneratedMessageReflection*>(r);
- GOOGLE_CHECK(gr != nullptr);
- return reinterpret_cast<google::protobuf::internal::ExtensionSet*>(
- static_cast<char*>(msg) + gr->schema_.GetExtensionSetOffset());
+ static ExtensionSet* GetExtensionSet(void* msg, const google::protobuf::Reflection* r) {
+ return reinterpret_cast<ExtensionSet*>(
+ static_cast<char*>(msg) +
+ CheckedCast(r)->schema_.GetExtensionSetOffset());
+ }
+ static InternalMetadataWithArena* GetMetadata(void* msg,
+ const google::protobuf::Reflection* r) {
+ return reinterpret_cast<InternalMetadataWithArena*>(
+ static_cast<char*>(msg) + CheckedCast(r)->schema_.GetMetadataOffset());
}
- static google::protobuf::internal::InternalMetadataWithArena* GetMetadata(
- void* msg, const google::protobuf::Reflection* r) {
- auto gr =
- dynamic_cast<const google::protobuf::internal::GeneratedMessageReflection*>(r);
+ static void* GetRepeatedEnum(const Reflection* reflection,
+ const FieldDescriptor* field, Message* msg) {
+ return reflection->MutableRawRepeatedField(
+ msg, field, FieldDescriptor::CPPTYPE_ENUM, 0, nullptr);
+ }
+
+ private:
+ static const GeneratedMessageReflection* CheckedCast(const Reflection* r) {
+ auto gr = dynamic_cast<const GeneratedMessageReflection*>(r);
GOOGLE_CHECK(gr != nullptr);
- return reinterpret_cast<google::protobuf::internal::InternalMetadataWithArena*>(
- static_cast<char*>(msg) + gr->schema_.GetMetadataOffset());
+ return gr;
}
};
@@ -276,16 +283,15 @@ ParseClosure GetPackedField(const FieldDescriptor* field, Message* msg,
HANDLE_PACKED_TYPE(UINT64, uint64, UInt64);
HANDLE_PACKED_TYPE(BOOL, bool, Bool);
case FieldDescriptor::TYPE_ENUM: {
+ auto object =
+ internal::ReflectionAccessor::GetRepeatedEnum(reflection, field, msg);
if (field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3) {
- auto object =
- internal::ReflectionAccessor::GetOffset(msg, field, reflection);
return {internal::PackedEnumParser, object};
} else {
+ GOOGLE_CHECK_EQ(field->file()->options().cc_api_version(), 2);
ctx->extra_parse_data().SetEnumValidatorArg(
ReflectiveValidator, field->enum_type(),
reflection->MutableUnknownFields(msg), field->number());
- auto object =
- internal::ReflectionAccessor::GetOffset(msg, field, reflection);
return {internal::PackedValidEnumParserArg, object};
}
}
@@ -334,7 +340,7 @@ ParseClosure GetLenDelim(int field_number, const FieldDescriptor* field,
ctx->extra_parse_data().SetFieldName(field->full_name().c_str());
utf8_level = kVerify;
}
- GOOGLE_FALLTHROUGH_INTENDED;
+ FALLTHROUGH_INTENDED;
case FieldDescriptor::TYPE_BYTES: {
if (field->is_repeated()) {
int index = reflection->FieldSize(*msg, field);
@@ -383,10 +389,11 @@ ParseClosure GetLenDelim(int field_number, const FieldDescriptor* field,
}
case FieldDescriptor::TYPE_MESSAGE: {
Message* object;
+ auto factory = ctx->extra_parse_data().factory;
if (field->is_repeated()) {
- object = reflection->AddMessage(msg, field, nullptr);
+ object = reflection->AddMessage(msg, field, factory);
} else {
- object = reflection->MutableMessage(msg, field, nullptr);
+ object = reflection->MutableMessage(msg, field, factory);
}
return {object->_ParseFunc(), object};
}
@@ -493,6 +500,10 @@ const char* Message::_InternalParse(const char* begin, const char* end,
while (ptr < end) {
ptr = Varint::Parse32Inline(ptr, &tag);
if (ptr == nullptr) return nullptr;
+ if (tag == 0) {
+ if (ctx->ValidEndGroup(0)) return ptr;
+ return nullptr;
+ }
if ((tag >> 3) == 0) return nullptr;
const FieldDescriptor* field = nullptr;
@@ -501,11 +512,14 @@ const char* Message::_InternalParse(const char* begin, const char* end,
// If that failed, check if the field is an extension.
if (field == nullptr && descriptor->IsExtensionNumber(field_number)) {
- field = reflection->FindKnownExtensionByNumber(field_number);
+ auto pool = ctx->extra_parse_data().pool;
+ if (pool == NULL) {
+ field = reflection->FindKnownExtensionByNumber(field_number);
+ } else {
+ field = pool->FindExtensionByNumber(descriptor, field_number);
+ }
}
- // if (field) GOOGLE_LOG(ERROR) << "Encountered field " << field->name();
-
switch (tag & 7) {
case 0: {
uint64 val;
@@ -565,7 +579,7 @@ const char* Message::_InternalParse(const char* begin, const char* end,
ptr = ptr + 4;
if (field == nullptr ||
WireFormat::WireTypeForFieldType(field->type()) != 5) {
- unknown->AddFixed64(field_number, val);
+ unknown->AddFixed32(field_number, val);
break;
}
SetField(val, field, msg, reflection);
@@ -593,8 +607,7 @@ group_continues:
#endif // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
-void Message::SerializeWithCachedSizes(
- io::CodedOutputStream* output) const {
+void Message::SerializeWithCachedSizes(io::CodedOutputStream* output) const {
const internal::SerializationTable* table =
static_cast<const internal::SerializationTable*>(InternalGetTable());
if (table == 0) {
@@ -653,51 +666,50 @@ void Reflection::AddAllocatedMessage(Message* /* message */,
const FieldDescriptor* /*field */,
Message* /* new_entry */) const {}
-#define HANDLE_TYPE(TYPE, CPPTYPE, CTYPE) \
-template<> \
-const RepeatedField<TYPE>& Reflection::GetRepeatedField<TYPE>( \
- const Message& message, const FieldDescriptor* field) const { \
- return *static_cast<RepeatedField<TYPE>* >( \
- MutableRawRepeatedField(const_cast<Message*>(&message), \
- field, CPPTYPE, CTYPE, NULL)); \
-} \
- \
-template<> \
-RepeatedField<TYPE>* Reflection::MutableRepeatedField<TYPE>( \
- Message* message, const FieldDescriptor* field) const { \
- return static_cast<RepeatedField<TYPE>* >( \
- MutableRawRepeatedField(message, field, CPPTYPE, CTYPE, NULL)); \
-}
-
-HANDLE_TYPE(int32, FieldDescriptor::CPPTYPE_INT32, -1);
-HANDLE_TYPE(int64, FieldDescriptor::CPPTYPE_INT64, -1);
+#define HANDLE_TYPE(TYPE, CPPTYPE, CTYPE) \
+ template <> \
+ const RepeatedField<TYPE>& Reflection::GetRepeatedField<TYPE>( \
+ const Message& message, const FieldDescriptor* field) const { \
+ return *static_cast<RepeatedField<TYPE>*>(MutableRawRepeatedField( \
+ const_cast<Message*>(&message), field, CPPTYPE, CTYPE, NULL)); \
+ } \
+ \
+ template <> \
+ RepeatedField<TYPE>* Reflection::MutableRepeatedField<TYPE>( \
+ Message * message, const FieldDescriptor* field) const { \
+ return static_cast<RepeatedField<TYPE>*>( \
+ MutableRawRepeatedField(message, field, CPPTYPE, CTYPE, NULL)); \
+ }
+
+HANDLE_TYPE(int32, FieldDescriptor::CPPTYPE_INT32, -1);
+HANDLE_TYPE(int64, FieldDescriptor::CPPTYPE_INT64, -1);
HANDLE_TYPE(uint32, FieldDescriptor::CPPTYPE_UINT32, -1);
HANDLE_TYPE(uint64, FieldDescriptor::CPPTYPE_UINT64, -1);
-HANDLE_TYPE(float, FieldDescriptor::CPPTYPE_FLOAT, -1);
+HANDLE_TYPE(float, FieldDescriptor::CPPTYPE_FLOAT, -1);
HANDLE_TYPE(double, FieldDescriptor::CPPTYPE_DOUBLE, -1);
-HANDLE_TYPE(bool, FieldDescriptor::CPPTYPE_BOOL, -1);
+HANDLE_TYPE(bool, FieldDescriptor::CPPTYPE_BOOL, -1);
#undef HANDLE_TYPE
-void* Reflection::MutableRawRepeatedString(
- Message* message, const FieldDescriptor* field, bool is_string) const {
+void* Reflection::MutableRawRepeatedString(Message* message,
+ const FieldDescriptor* field,
+ bool is_string) const {
return MutableRawRepeatedField(message, field,
- FieldDescriptor::CPPTYPE_STRING, FieldOptions::STRING, NULL);
+ FieldDescriptor::CPPTYPE_STRING,
+ FieldOptions::STRING, NULL);
}
-MapIterator Reflection::MapBegin(
- Message* message,
- const FieldDescriptor* field) const {
+MapIterator Reflection::MapBegin(Message* message,
+ const FieldDescriptor* field) const {
GOOGLE_LOG(FATAL) << "Unimplemented Map Reflection API.";
MapIterator iter(message, field);
return iter;
}
-MapIterator Reflection::MapEnd(
- Message* message,
- const FieldDescriptor* field) const {
+MapIterator Reflection::MapEnd(Message* message,
+ const FieldDescriptor* field) const {
GOOGLE_LOG(FATAL) << "Unimplemented Map Reflection API.";
MapIterator iter(message, field);
return iter;
@@ -766,8 +778,8 @@ void GeneratedMessageFactory::RegisterFile(const char* file,
void GeneratedMessageFactory::RegisterType(const Descriptor* descriptor,
const Message* prototype) {
GOOGLE_DCHECK_EQ(descriptor->file()->pool(), DescriptorPool::generated_pool())
- << "Tried to register a non-generated type with the generated "
- "type registry.";
+ << "Tried to register a non-generated type with the generated "
+ "type registry.";
// This should only be called as a result of calling a file registration
// function during GetPrototype(), in which case we already have locked
@@ -795,7 +807,8 @@ const Message* GeneratedMessageFactory::GetPrototype(const Descriptor* type) {
FindPtrOrNull(file_map_, type->file()->name().c_str());
if (registration_data == NULL) {
GOOGLE_LOG(DFATAL) << "File appears to be in generated pool but wasn't "
- "registered: " << type->file()->name();
+ "registered: "
+ << type->file()->name();
return NULL;
}
@@ -841,10 +854,10 @@ MessageFactory* Reflection::GetMessageFactory() const {
return NULL;
}
-void* Reflection::RepeatedFieldData(
- Message* message, const FieldDescriptor* field,
- FieldDescriptor::CppType cpp_type,
- const Descriptor* message_type) const {
+void* Reflection::RepeatedFieldData(Message* message,
+ const FieldDescriptor* field,
+ FieldDescriptor::CppType cpp_type,
+ const Descriptor* message_type) const {
GOOGLE_LOG(FATAL) << "Not implemented.";
return NULL;
}
@@ -896,7 +909,7 @@ template <>
#if defined(_MSC_VER) && (_MSC_VER >= 1800)
// Note: force noinline to workaround MSVC compiler bug with /Zc:inline, issue
// #240
-GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE
+PROTOBUF_NOINLINE
#endif
Message*
GenericTypeHandler<Message>::NewFromPrototype(const Message* prototype,
@@ -907,7 +920,7 @@ template <>
#if defined(_MSC_VER) && (_MSC_VER >= 1800)
// Note: force noinline to workaround MSVC compiler bug with /Zc:inline, issue
// #240
-GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE
+PROTOBUF_NOINLINE
#endif
Arena*
GenericTypeHandler<Message>::GetArena(Message* value) {
@@ -917,7 +930,7 @@ template <>
#if defined(_MSC_VER) && (_MSC_VER >= 1800)
// Note: force noinline to workaround MSVC compiler bug with /Zc:inline, issue
// #240
-GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE
+PROTOBUF_NOINLINE
#endif
void*
GenericTypeHandler<Message>::GetMaybeArenaPointer(Message* value) {
diff --git a/src/google/protobuf/message.h b/src/google/protobuf/message.h
index 007dafa2..9f44132b 100644
--- a/src/google/protobuf/message.h
+++ b/src/google/protobuf/message.h
@@ -163,8 +163,13 @@ namespace expr {
class CelMapReflectionFriend; // field_backed_map_impl.cc
}
+namespace internal {
+class MapFieldPrinterHelper; // text_format.cc
+}
+
namespace internal {
+class ReflectionAccessor; // message.cc
class ReflectionOps; // reflection_ops.h
class MapKeySorter; // wire_format.cc
class WireFormat; // wire_format.h
@@ -193,7 +198,7 @@ struct Metadata {
// optimized for speed will want to override these with faster implementations,
// but classes optimized for code size may be happy with keeping them. See
// the optimize_for option in descriptor.proto.
-class LIBPROTOBUF_EXPORT Message : public MessageLite {
+class PROTOBUF_EXPORT Message : public MessageLite {
public:
inline Message() {}
virtual ~Message() {}
@@ -236,11 +241,11 @@ class LIBPROTOBUF_EXPORT Message : public MessageLite {
// This is much, much slower than IsInitialized() as it is implemented
// purely via reflection. Generally, you should not call this unless you
// have already determined that an error exists by calling IsInitialized().
- void FindInitializationErrors(std::vector<string>* errors) const;
+ void FindInitializationErrors(std::vector<std::string>* errors) const;
// Like FindInitializationErrors, but joins all the strings, delimited by
// commas, and returns them.
- string InitializationErrorString() const override;
+ std::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,
@@ -264,18 +269,18 @@ class LIBPROTOBUF_EXPORT Message : public MessageLite {
// fields defined for the proto.
virtual size_t SpaceUsedLong() const;
- GOOGLE_PROTOBUF_DEPRECATED_MSG("Please use SpaceUsedLong() instead")
+ PROTOBUF_DEPRECATED_MSG("Please use SpaceUsedLong() instead")
int SpaceUsed() const { return internal::ToIntSize(SpaceUsedLong()); }
// Debugging & Testing----------------------------------------------
// Generates a human readable form of this message, useful for debugging
// and other purposes.
- string DebugString() const;
+ std::string DebugString() const;
// Like DebugString(), but with less whitespace.
- string ShortDebugString() const;
+ std::string ShortDebugString() const;
// Like DebugString(), but do not escape UTF-8 byte sequences.
- string Utf8DebugString() const;
+ std::string Utf8DebugString() const;
// Convenience function useful in GDB. Prints DebugString() to stdout.
void PrintDebugString() const;
@@ -312,7 +317,7 @@ class LIBPROTOBUF_EXPORT Message : public MessageLite {
// These methods are pure-virtual in MessageLite, but Message provides
// reflection-based default implementations.
- string GetTypeName() const override;
+ std::string GetTypeName() const override;
void Clear() override;
bool IsInitialized() const override;
void CheckTypeAndMergeFrom(const MessageLite& other) override;
@@ -424,7 +429,7 @@ class MutableRepeatedFieldRef;
// double the message's memory footprint, probably worse. Allocating the
// objects on-demand, on the other hand, would be expensive and prone to
// memory leaks. So, instead we ended up with this flat interface.
-class LIBPROTOBUF_EXPORT Reflection {
+class PROTOBUF_EXPORT Reflection {
public:
inline Reflection() {}
virtual ~Reflection();
@@ -445,7 +450,7 @@ class LIBPROTOBUF_EXPORT Reflection {
// Estimate the amount of memory used by the message object.
virtual size_t SpaceUsedLong(const Message& message) const = 0;
- GOOGLE_PROTOBUF_DEPRECATED_MSG("Please use SpaceUsedLong() instead")
+ PROTOBUF_DEPRECATED_MSG("Please use SpaceUsedLong() instead")
int SpaceUsed(const Message& message) const {
return internal::ToIntSize(SpaceUsedLong(message));
}
@@ -542,7 +547,7 @@ class LIBPROTOBUF_EXPORT Reflection {
const FieldDescriptor* field) const = 0;
virtual bool GetBool (const Message& message,
const FieldDescriptor* field) const = 0;
- virtual string GetString(const Message& message,
+ virtual std::string GetString(const Message& message,
const FieldDescriptor* field) const = 0;
virtual const EnumValueDescriptor* GetEnum(
const Message& message, const FieldDescriptor* field) const = 0;
@@ -575,9 +580,9 @@ class LIBPROTOBUF_EXPORT Reflection {
// a newly-constructed string, though, it's just as fast and more readable
// to use code like:
// string str = reflection->GetString(message, field);
- virtual const string& GetStringReference(const Message& message,
+ virtual const std::string& GetStringReference(const Message& message,
const FieldDescriptor* field,
- string* scratch) const = 0;
+ std::string* scratch) const = 0;
// Singular field mutators -----------------------------------------
@@ -599,7 +604,7 @@ class LIBPROTOBUF_EXPORT Reflection {
const FieldDescriptor* field, bool value) const = 0;
virtual void SetString(Message* message,
const FieldDescriptor* field,
- const string& value) const = 0;
+ const std::string& value) const = 0;
virtual void SetEnum (Message* message,
const FieldDescriptor* field,
const EnumValueDescriptor* value) const = 0;
@@ -670,7 +675,7 @@ class LIBPROTOBUF_EXPORT Reflection {
virtual bool GetRepeatedBool (const Message& message,
const FieldDescriptor* field,
int index) const = 0;
- virtual string GetRepeatedString(const Message& message,
+ virtual std::string GetRepeatedString(const Message& message,
const FieldDescriptor* field,
int index) const = 0;
virtual const EnumValueDescriptor* GetRepeatedEnum(
@@ -689,9 +694,9 @@ class LIBPROTOBUF_EXPORT Reflection {
const FieldDescriptor* field, int index) const = 0;
// See GetStringReference(), above.
- virtual const string& GetRepeatedStringReference(
+ virtual const std::string& GetRepeatedStringReference(
const Message& message, const FieldDescriptor* field,
- int index, string* scratch) const = 0;
+ int index, std::string* scratch) const = 0;
// Repeated field mutators -----------------------------------------
@@ -720,7 +725,7 @@ class LIBPROTOBUF_EXPORT Reflection {
int index, bool value) const = 0;
virtual void SetRepeatedString(Message* message,
const FieldDescriptor* field,
- int index, const string& value) const = 0;
+ int index, const std::string& value) const = 0;
virtual void SetRepeatedEnum(Message* message,
const FieldDescriptor* field, int index,
const EnumValueDescriptor* value) const = 0;
@@ -759,7 +764,7 @@ class LIBPROTOBUF_EXPORT Reflection {
const FieldDescriptor* field, bool value) const = 0;
virtual void AddString(Message* message,
const FieldDescriptor* field,
- const string& value) const = 0;
+ const std::string& value) const = 0;
virtual void AddEnum (Message* message,
const FieldDescriptor* field,
const EnumValueDescriptor* value) const = 0;
@@ -839,8 +844,7 @@ class LIBPROTOBUF_EXPORT Reflection {
//
// for T = Cord and all protobuf scalar types except enums.
template <typename T>
- GOOGLE_PROTOBUF_DEPRECATED_MSG(
- "Please use GetRepeatedFieldRef() instead")
+ PROTOBUF_DEPRECATED_MSG("Please use GetRepeatedFieldRef() instead")
const RepeatedField<T>& GetRepeatedField(const Message&,
const FieldDescriptor*) const;
@@ -848,8 +852,7 @@ class LIBPROTOBUF_EXPORT Reflection {
//
// for T = Cord and all protobuf scalar types except enums.
template <typename T>
- GOOGLE_PROTOBUF_DEPRECATED_MSG(
- "Please use GetMutableRepeatedFieldRef() instead")
+ PROTOBUF_DEPRECATED_MSG("Please use GetMutableRepeatedFieldRef() instead")
RepeatedField<T>* MutableRepeatedField(Message*,
const FieldDescriptor*) const;
@@ -858,8 +861,7 @@ class LIBPROTOBUF_EXPORT Reflection {
// for T = string, google::protobuf::internal::StringPieceField
// google::protobuf::Message & descendants.
template <typename T>
- GOOGLE_PROTOBUF_DEPRECATED_MSG(
- "Please use GetRepeatedFieldRef() instead")
+ PROTOBUF_DEPRECATED_MSG("Please use GetRepeatedFieldRef() instead")
const RepeatedPtrField<T>& GetRepeatedPtrField(const Message&,
const FieldDescriptor*) const;
@@ -868,8 +870,7 @@ class LIBPROTOBUF_EXPORT Reflection {
// for T = string, google::protobuf::internal::StringPieceField
// google::protobuf::Message & descendants.
template <typename T>
- GOOGLE_PROTOBUF_DEPRECATED_MSG(
- "Please use GetMutableRepeatedFieldRef() instead")
+ PROTOBUF_DEPRECATED_MSG("Please use GetMutableRepeatedFieldRef() instead")
RepeatedPtrField<T>* MutableRepeatedPtrField(Message*,
const FieldDescriptor*) const;
@@ -878,7 +879,7 @@ class LIBPROTOBUF_EXPORT Reflection {
// Try to find an extension of this message type by fully-qualified field
// name. Returns NULL if no extension is known for this name or number.
virtual const FieldDescriptor* FindKnownExtensionByName(
- const string& name) const = 0;
+ const std::string& name) const = 0;
// Try to find an extension of this message type by field number.
// Returns NULL if no extension is known for this name or number.
@@ -987,6 +988,9 @@ class LIBPROTOBUF_EXPORT Reflection {
friend class internal::MapKeySorter;
friend class internal::WireFormat;
friend class internal::ReflectionOps;
+ // Needed for implementing text format for map.
+ friend class internal::MapFieldPrinterHelper;
+ friend class internal::ReflectionAccessor;
// Special version for specialized implementations of string. We can't call
// MutableRawRepeatedField directly here because we don't have access to
@@ -1057,7 +1061,7 @@ class LIBPROTOBUF_EXPORT Reflection {
};
// Abstract interface for a factory for message objects.
-class LIBPROTOBUF_EXPORT MessageFactory {
+class PROTOBUF_EXPORT MessageFactory {
public:
inline MessageFactory() {}
virtual ~MessageFactory();
@@ -1120,16 +1124,15 @@ class LIBPROTOBUF_EXPORT MessageFactory {
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageFactory);
};
-#define DECLARE_GET_REPEATED_FIELD(TYPE) \
-template<> \
-LIBPROTOBUF_EXPORT \
-const RepeatedField<TYPE>& Reflection::GetRepeatedField<TYPE>( \
- const Message& message, const FieldDescriptor* field) const; \
- \
-template<> \
-LIBPROTOBUF_EXPORT \
-RepeatedField<TYPE>* Reflection::MutableRepeatedField<TYPE>( \
- Message* message, const FieldDescriptor* field) const;
+#define DECLARE_GET_REPEATED_FIELD(TYPE) \
+ template <> \
+ PROTOBUF_EXPORT const RepeatedField<TYPE>& \
+ Reflection::GetRepeatedField<TYPE>(const Message& message, \
+ const FieldDescriptor* field) const; \
+ \
+ template <> \
+ PROTOBUF_EXPORT RepeatedField<TYPE>* Reflection::MutableRepeatedField<TYPE>( \
+ Message * message, const FieldDescriptor* field) const;
DECLARE_GET_REPEATED_FIELD(int32)
DECLARE_GET_REPEATED_FIELD(int64)
@@ -1196,16 +1199,16 @@ T dynamic_cast_if_available(Message* from) {
// Such a type presumably is a descendant of google::protobuf::Message.
template<>
-inline const RepeatedPtrField<string>& Reflection::GetRepeatedPtrField<string>(
+inline const RepeatedPtrField<std::string>& Reflection::GetRepeatedPtrField<std::string>(
const Message& message, const FieldDescriptor* field) const {
- return *static_cast<RepeatedPtrField<string>* >(
+ return *static_cast<RepeatedPtrField<std::string>* >(
MutableRawRepeatedString(const_cast<Message*>(&message), field, true));
}
template<>
-inline RepeatedPtrField<string>* Reflection::MutableRepeatedPtrField<string>(
+inline RepeatedPtrField<std::string>* Reflection::MutableRepeatedPtrField<std::string>(
Message* message, const FieldDescriptor* field) const {
- return static_cast<RepeatedPtrField<string>* >(
+ return static_cast<RepeatedPtrField<std::string>* >(
MutableRawRepeatedString(message, field, true));
}
diff --git a/src/google/protobuf/message_lite.cc b/src/google/protobuf/message_lite.cc
index 33ee6323..01bb0d39 100644
--- a/src/google/protobuf/message_lite.cc
+++ b/src/google/protobuf/message_lite.cc
@@ -80,7 +80,8 @@ void ByteSizeConsistencyError(size_t byte_size_before_serialization,
GOOGLE_CHECK_EQ(bytes_produced_by_serialization, byte_size_before_serialization)
<< "Byte size calculation and serialization were inconsistent. This "
"may indicate a bug in protocol buffers or it may be caused by "
- "concurrent modification of " << message.GetTypeName() << ".";
+ "concurrent modification of "
+ << message.GetTypeName() << ".";
GOOGLE_LOG(FATAL) << "This shouldn't be called if all the sizes are equal.";
}
@@ -108,12 +109,16 @@ string InitializationErrorMessage(const char* action,
#if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
// This is wrapper to turn a ZeroCopyInputStream (ZCIS) into a
// InputStreamWithOverlap. This is done by copying data around the seams,
-// pictorially if ZCIS presents a stream in chunks like so
+// hence the name EpsCopyInputStream, pictorially if ZCIS presents a stream
+// in chunks like so
// [---------------------------------------------------------------]
// [---------------------] chunk 1
// [----------------------------] chunk 2
// chunk 3 [--------------]
-// this class will convert this into chunks
+// where '-' depicts bytes of the stream or chunks vertically alligned with the
+// corresponding bytes between stream and chunk.
+//
+// This class will convert this into chunks
// [-----------------....] chunk 1
// [----....] patch
// [------------------------....] chunk 2
@@ -121,17 +126,58 @@ string InitializationErrorMessage(const char* action,
// chunk 3 [----------....]
// patch [----****]
// by using a fixed size buffer to patch over the seams. This requires
-// copying of an "epsilon" neighboorhood around the seams.
-
+// copying of an "epsilon" neighboorhood around the seams. In the picture above
+// dots mean bytes beyond the end of the new chunks. Each chunk is kSlopBytes
+// smalller as its original chunk (above depicted as 4 dots) and the number of
+// of chunks is doubled because each seam in the original stream introduces a
+// new patch.
+//
+// The algorithm is simple but not entirely trivial. Two complications arise
+// 1) The original chunk could be less than kSlopBytes. Hence we can't simply
+// chop the last kSlopBytes of a chunk.
+// 2) We need to leave the underlying CodedInputStream (CIS) precisely at the
+// last byte read in the parse. In most cases a parse ends on a limit or end of
+// the ZeroCopyInputStream, which is not problematic because CIS will never give
+// us data beyond that. But the parse can end on a 0 end tag or an end group.
+// If that happens in the first kSlopBytes of the patch (which are copied
+// from the previous buffer) the CIS has already moved to the next chunk to
+// copy the remaining bytes of the patch buffer. There exist no API to rollback
+// to a previous buffer.
+//
+// We model this as a state machine. A call to get the next chunk either returns
+// an original chunk except the last kSlopBytes or it has to copy the last
+// kSlopBytes of the current chunk to the patch buffer and copy the first
+// kSlopBytes of the next chunk to the end of the patch buffer.
+//
+// In order to deal with problem 1, we need to deal with the case that a new
+// chunk can be less or equal than kSlopBytes big. We can just copy the chunk
+// to the end and return (buffer, chunk->size). Pictorially
+// [--------] chunk 1
+// [--] chunk 2
+// [---] chunk 3
+// will become
+// [----....] chunk 1
+// [--....] patch (not full range of the buffer, only two hyphens)
+// [--] chunk 2 (too small so never returned as buffer)
+// [---....] patch (not full range of the buffer, only three hyphens)
+// [---] chunk 3 (too small so never returned as buffer)
+// [----****] patch (full range, last bytes are garbage)
+// Because of this the source (the dots in above) can overlap with the
+// destination buffer and so we have to use memmove.
+//
+// To solve problem 2, we verify after copying the last kSlopBytes the parse
+// won't end before we continue to get the next chunk.
template <int kSlopBytes>
class EpsCopyInputStream {
public:
EpsCopyInputStream(io::CodedInputStream* input) : input_(input) {}
~EpsCopyInputStream() {
- if (skip_) input_->Skip(skip_);
+ ABSL_ASSERT(skip_ >= 0);
+ input_->Skip(skip_);
}
- StringPiece NextWithOverlap() {
+ template <typename EnsureNotEnd>
+ StringPiece SafeNextWithOverlap(const EnsureNotEnd& ensure_not_end) {
switch (next_state_) {
case kEOS:
// End of stream
@@ -141,140 +187,118 @@ class EpsCopyInputStream {
// To parse the last kSlopBytes we need to copy the bytes into the
// buffer. Hence we set,
next_state_ = kBuffer;
+ skip_ = chunk_.size() - kSlopBytes;
return {chunk_.begin(), chunk_.size() - kSlopBytes};
- case kBuffer:
+ case kBuffer: {
// We have to parse the last kSlopBytes of chunk_, which could alias
// buffer_ so we have to memmove.
std::memmove(buffer_, chunk_.end() - kSlopBytes, kSlopBytes);
- chunk_ = GetChunk();
- if (chunk_.size() > kSlopBytes) {
- next_state_ = kChunk;
- std::memcpy(buffer_ + kSlopBytes, chunk_.begin(), kSlopBytes);
- return {buffer_, kSlopBytes};
- } else if (chunk_.empty()) {
+ skip_ += kSlopBytes;
+ // We need to fill in the other half of buffer_ with the start of the
+ // next chunk. So we need to continue to the next buffer in the ZCIS,
+ // which makes it impossible to rollback to the current buffer :(
+ // We need to verify this won't happen.
+ if (!ensure_not_end(buffer_, kSlopBytes)) {
+ // We are guaranteed to exit in this interval.
next_state_ = kEOS;
return {buffer_, kSlopBytes};
- } else {
- auto size = chunk_.size();
- // The next chunk is not big enough. So we copy it in the current
- // after the current buffer. Resulting in a buffer with
- // size + kSlopBytes bytes.
- std::memcpy(buffer_ + kSlopBytes, chunk_.begin(), size);
- chunk_ = {buffer_, size + kSlopBytes};
- return {buffer_, size};
- }
- case kStart: {
- size_t i = 0;
- do {
- chunk_ = GetChunk();
- if (chunk_.size() > kSlopBytes) {
- if (i == 0) {
- next_state_ = kBuffer;
- return {chunk_.begin(), chunk_.size() - kSlopBytes};
- }
- std::memcpy(buffer_ + i, chunk_.begin(), kSlopBytes);
- next_state_ = kChunk;
- return {buffer_, i};
- }
- if (chunk_.empty()) {
- next_state_ = kEOS;
- return {buffer_, i};
- }
- std::memcpy(buffer_ + i, chunk_.begin(), chunk_.size());
- i += chunk_.size();
- } while (i <= kSlopBytes);
- chunk_ = {buffer_, i};
- next_state_ = kBuffer;
- return {buffer_, i - kSlopBytes};
- }
- }
- }
-
- StringPiece NextWithOverlapEndingSafe(const char* ptr, int nesting) {
- switch (next_state_) {
- case kEOS:
- // End of stream
- return nullptr;
- case kChunk:
- // chunk_ contains a buffer of sufficient size (> kSlopBytes).
- // To parse the last kSlopBytes we need to copy the bytes into the
- // buffer. Hence we set,
- next_state_ = kBuffer;
- return {chunk_.begin(), chunk_.size() - kSlopBytes};
- case kBuffer:
- // We have to parse the last kSlopBytes of chunk_, which could alias
- // buffer_ so we have to memmove.
- if (!SafeCopy(buffer_, chunk_.end() - kSlopBytes, nesting)) {
- // We will terminate
}
chunk_ = GetChunk();
- if (chunk_.size() > kSlopBytes) {
+ auto size = chunk_.size();
+ if (size > kSlopBytes) {
next_state_ = kChunk;
std::memcpy(buffer_ + kSlopBytes, chunk_.begin(), kSlopBytes);
return {buffer_, kSlopBytes};
- } else if (chunk_.empty()) {
+ } else if (size == 0) {
next_state_ = kEOS;
return {buffer_, kSlopBytes};
} else {
- auto size = chunk_.size();
+ // next_state_ = kBuffer, but this is unnecessary
+
// The next chunk is not big enough. So we copy it in the current
// after the current buffer. Resulting in a buffer with
// size + kSlopBytes bytes.
std::memcpy(buffer_ + kSlopBytes, chunk_.begin(), size);
+ // skip_ becomes negative here.
+ skip_ += size - kSlopBytes;
chunk_ = {buffer_, size + kSlopBytes};
return {buffer_, size};
}
+ }
case kStart: {
+ chunk_ = GetChunk();
+ auto size = chunk_.size();
+ if (PROTOBUF_PREDICT_TRUE(size > kSlopBytes)) {
+ next_state_ = kBuffer;
+ skip_ = size - kSlopBytes;
+ return {chunk_.begin(), size - kSlopBytes};
+ }
size_t i = 0;
do {
- chunk_ = GetChunk();
- if (chunk_.size() > kSlopBytes) {
- if (i == 0) {
- next_state_ = kBuffer;
- return {chunk_.begin(), chunk_.size() - kSlopBytes};
- }
- std::memcpy(buffer_ + i, chunk_.begin(), kSlopBytes);
- next_state_ = kChunk;
+ if (size == 0) {
+ next_state_ = kEOS;
return {buffer_, i};
}
- if (chunk_.empty()) {
+ std::memcpy(buffer_ + i, chunk_.begin(), size);
+ ABSL_ASSERT(skip_ == 0);
+ skip_ = size;
+ i += size;
+ if (i > kSlopBytes) {
+ skip_ -= kSlopBytes;
+ chunk_ = {buffer_, i};
+ next_state_ = kBuffer;
+ return {buffer_, i - kSlopBytes};
+ }
+ if (!ensure_not_end(buffer_, i)) {
next_state_ = kEOS;
return {buffer_, i};
}
- std::memcpy(buffer_ + i, chunk_.begin(), chunk_.size());
- i += chunk_.size();
- } while (i <= kSlopBytes);
- chunk_ = {buffer_, i};
- next_state_ = kBuffer;
- return {buffer_, i - kSlopBytes};
+ chunk_ = GetChunk();
+ size = chunk_.size();
+ } while (size <= kSlopBytes);
+ std::memcpy(buffer_ + i, chunk_.begin(), kSlopBytes);
+ next_state_ = kChunk;
+ return {buffer_, i};
}
}
}
- void Backup(const char* ptr) { skip_ = ptr - chunk_.data(); }
+ StringPiece NextWithOverlap() {
+ return SafeNextWithOverlap([](const char*, size_t) { return true; });
+ }
+
+ void AdjustPos(int delta) {
+ ABSL_ASSERT(delta <= kSlopBytes);
+ skip_ += delta;
+ }
+
+ void SetError() { skip_ = 0; }
private:
io::CodedInputStream* input_;
StringPiece chunk_;
- char buffer_[2 * kSlopBytes];
+ char buffer_[2 * kSlopBytes] = {};
enum State {
- kEOS = 0, // -> end of stream.
- kChunk = 1, // -> chunk_ contains the data for Next.
- kBuffer = 2, // -> We need to copy the left over from previous chunk_ and
- // load and patch the start of the next chunk in the
- // local buffer.
- kStart = 3,
+ kStart,
+ kEOS, // -> end of stream.
+ kChunk, // -> chunk_ contains the data for Next.
+ kBuffer, // -> We need to copy the left over from previous chunk_ and
+ // load and patch the start of the next chunk in the
+ // local buffer.
};
State next_state_ = kStart;
- int skip_ = 0;
+ int skip_ = 0; // how much bytes to skip to current position in the stream.
StringPiece GetChunk() {
const void* ptr;
- if (skip_) input_->Skip(skip_);
- if (!input_->GetDirectBufferPointer(&ptr, &skip_)) {
+ ABSL_ASSERT(skip_ >= 0);
+ input_->Skip(skip_);
+ skip_ = 0;
+ int size;
+ if (!input_->GetDirectBufferPointer(&ptr, &size)) {
return nullptr;
}
- return StringPiece(static_cast<const char*>(ptr), skip_);
+ return StringPiece(static_cast<const char*>(ptr), size);
}
};
#endif
@@ -287,29 +311,71 @@ class EpsCopyInputStream {
// messages, every function call introduces significant overhead. To avoid
// this without reproducing code, we use these forced-inline helpers.
-inline bool InlineMergePartialFromCodedStream(io::CodedInputStream* input,
+inline bool InlineMergeFromCodedStream(io::CodedInputStream* input,
+ MessageLite* message) {
+ if (!message->MergePartialFromCodedStream(input)) return false;
+ if (!message->IsInitialized()) {
+ GOOGLE_LOG(ERROR) << InitializationErrorMessage("parse", *message);
+ return false;
+ }
+ return true;
+}
+
+inline bool InlineParsePartialFromCodedStream(io::CodedInputStream* input,
MessageLite* message) {
+ message->Clear();
+ return message->MergePartialFromCodedStream(input);
+}
+
+inline bool InlineParseFromCodedStream(io::CodedInputStream* input,
+ MessageLite* message) {
+ message->Clear();
+ return InlineMergeFromCodedStream(input, message);
+}
+
#if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
- EpsCopyInputStream<internal::ParseContext::kSlopBytes> eps_input(input);
+template <template <int> class Input>
+inline bool InlineMergePartialEntireInput(
+ Input<internal::ParseContext::kSlopBytes>* input, MessageLite* message) {
internal::ParseContext ctx;
- auto res = ctx.ParseNoLimit({message->_ParseFunc(), message}, &eps_input);
- if (res == 1) {
- input->SetConsumed();
+
+ auto chunk = input->NextWithOverlap();
+ if (chunk.empty()) {
return true;
- } else if (res == 2) {
- return false;
- } else {
- input->SetLastTag(res);
+ }
+ auto res = ctx.StartParse({message->_ParseFunc(), message}, chunk);
+ while (res.first == internal::ParseContext::kContinue) {
+ int overrun = res.second;
+ chunk = input->NextWithOverlap();
+ if (chunk.empty()) {
+ if (!ctx.ValidEnd(overrun)) return false;
+ return true;
+ }
+ res = ctx.ResumeParse(chunk, overrun);
+ }
+ // Either failure or ended on a zero or end-group tag
+ return false;
+}
+#endif
+
+inline bool InlineMergePartialEntireStream(io::CodedInputStream* cis,
+ MessageLite* message) {
+#if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
+ EpsCopyInputStream<internal::ParseContext::kSlopBytes> input(cis);
+ if (InlineMergePartialEntireInput(&input, message)) {
+ cis->SetConsumed();
return true;
}
+ return false;
#else
- return message->MergePartialFromCodedStream(input);
+ return message->MergePartialFromCodedStream(cis) &&
+ cis->ConsumedEntireMessage();
#endif
}
-inline bool InlineMergeFromCodedStream(io::CodedInputStream* input,
- MessageLite* message) {
- if (!InlineMergePartialFromCodedStream(input, message)) return false;
+inline bool InlineMergeEntireStream(io::CodedInputStream* input,
+ MessageLite* message) {
+ if (!InlineMergePartialEntireStream(input, message)) return false;
if (!message->IsInitialized()) {
GOOGLE_LOG(ERROR) << InitializationErrorMessage("parse", *message);
return false;
@@ -317,16 +383,16 @@ inline bool InlineMergeFromCodedStream(io::CodedInputStream* input,
return true;
}
-inline bool InlineParsePartialFromCodedStream(io::CodedInputStream* input,
- MessageLite* message) {
+inline bool InlineParsePartialEntireStream(io::CodedInputStream* input,
+ MessageLite* message) {
message->Clear();
- return InlineMergePartialFromCodedStream(input, message);
+ return InlineMergePartialEntireStream(input, message);
}
-inline bool InlineParseFromCodedStream(io::CodedInputStream* input,
- MessageLite* message) {
+inline bool InlineParseEntireStream(io::CodedInputStream* input,
+ MessageLite* message) {
message->Clear();
- return InlineMergeFromCodedStream(input, message);
+ return InlineMergeEntireStream(input, message);
}
#if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
@@ -334,30 +400,49 @@ template <int kSlopBytes>
class ArrayInput {
public:
ArrayInput(StringPiece chunk) : chunk_(chunk) {}
+
StringPiece NextWithOverlap() {
- auto res = chunk_;
- chunk_ = nullptr;
- return res;
+ auto s = chunk_.size();
+ if (s > 16) {
+ auto res = chunk_.substr(0, s - 16);
+ chunk_ = chunk_.substr(s - 16);
+ return res;
+ } else if (s == 0) {
+ return nullptr;
+ } else {
+ std::memcpy(buffer_, chunk_.begin(), s);
+ chunk_ = nullptr;
+ return {buffer_, s};
+ }
}
- void Backup(const char*) { GOOGLE_CHECK(false) << "Can't backup arrayinput"; }
+ void SetError() {}
private:
StringPiece chunk_;
+ char buffer_[32] = {};
+ int state_ = 0;
};
#endif
inline bool InlineMergePartialFromArray(const void* data, int size,
- MessageLite* message,
+ MessageLite* msg,
bool aliasing = false) {
#if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
- internal::ParseContext ctx;
+ auto begin = static_cast<const char*>(data);
+ if (aliasing) {
+ // TODO(gerbens) make this safe against corruption buffer overflow.
+ // Short cut to allow aliasing string_piece
+ internal::ParseContext ctx;
+ ctx.extra_parse_data().aliasing = true;
+ return ctx.ParseExactRange({msg->_ParseFunc(), msg}, begin, begin + size);
+ }
ArrayInput<internal::ParseContext::kSlopBytes> input(
- StringPiece(static_cast<const char*>(data), size));
- return ctx.Parse({message->_ParseFunc(), message}, size, &input);
+ StringPiece(begin, size));
+ return InlineMergePartialEntireInput(&input, msg);
#else
io::CodedInputStream input(static_cast<const uint8*>(data), size);
- return message->MergePartialFromCodedStream(&input) &&
+ return msg->MergePartialFromCodedStream(&input) &&
input.ConsumedEntireMessage();
#endif
}
@@ -400,8 +485,44 @@ MessageLite* MessageLite::New(Arena* arena) const {
}
#if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
-bool MessageLite::MergePartialFromCodedStream(io::CodedInputStream* input) {
- return InlineMergePartialFromCodedStream(input, this);
+bool MessageLite::MergePartialFromCodedStream(io::CodedInputStream* cis) {
+ EpsCopyInputStream<internal::ParseContext::kSlopBytes> input(cis);
+ internal::ParseContext ctx(cis->RecursionBudget());
+ ctx.extra_parse_data().pool = cis->GetExtensionPool();
+ ctx.extra_parse_data().factory = cis->GetExtensionFactory();
+
+ auto chunk = input.SafeNextWithOverlap(
+ [&ctx](const char* ptr, int n) { return ctx.EnsureNoEnd(ptr, n, 0); });
+ if (chunk.empty()) {
+ cis->SetConsumed();
+ return true;
+ }
+ auto res = ctx.StartParse({_ParseFunc(), this}, chunk);
+ while (res.first == internal::ParseContext::kContinue) {
+ int overrun = res.second;
+ chunk = input.SafeNextWithOverlap([&ctx, overrun](const char* ptr, int n) {
+ return ctx.EnsureNoEnd(ptr, n, overrun);
+ });
+ if (chunk.empty()) {
+ if (!ctx.ValidEnd(overrun)) goto error;
+ cis->SetConsumed();
+ return true;
+ }
+ res = ctx.ResumeParse(chunk, overrun);
+ }
+ // Either failure or ended on a zero or end-group tag
+ if (res.first != internal::ParseContext::kFailure) {
+ cis->SetLastTag(res.first);
+ input.AdjustPos(res.second);
+ return true;
+ }
+error:
+ // Error can happen at a spot from which we can't back up. But in this case
+ // the user can't resume the stream as the error could be in an arbitrary
+ // location in the stream, so just leave the stream alone. This prevents
+ // triggering assertion fail.
+ input.SetError();
+ return false;
}
#endif
@@ -419,22 +540,20 @@ bool MessageLite::ParsePartialFromCodedStream(io::CodedInputStream* input) {
bool MessageLite::ParseFromZeroCopyStream(io::ZeroCopyInputStream* input) {
io::CodedInputStream decoder(input);
- return ParseFromCodedStream(&decoder) && decoder.ConsumedEntireMessage();
+ return InlineParseEntireStream(&decoder, this);
}
bool MessageLite::ParsePartialFromZeroCopyStream(
io::ZeroCopyInputStream* input) {
io::CodedInputStream decoder(input);
- return ParsePartialFromCodedStream(&decoder) &&
- decoder.ConsumedEntireMessage();
+ return InlineParsePartialEntireStream(&decoder, this);
}
-bool MessageLite::ParseFromBoundedZeroCopyStream(
- io::ZeroCopyInputStream* input, int size) {
+bool MessageLite::ParseFromBoundedZeroCopyStream(io::ZeroCopyInputStream* input,
+ int size) {
io::CodedInputStream decoder(input);
decoder.PushLimit(size);
- return ParseFromCodedStream(&decoder) &&
- decoder.ConsumedEntireMessage() &&
+ return InlineParseEntireStream(&decoder, this) &&
decoder.BytesUntilLimit() == 0;
}
@@ -442,8 +561,7 @@ bool MessageLite::ParsePartialFromBoundedZeroCopyStream(
io::ZeroCopyInputStream* input, int size) {
io::CodedInputStream decoder(input);
decoder.PushLimit(size);
- return ParsePartialFromCodedStream(&decoder) &&
- decoder.ConsumedEntireMessage() &&
+ return InlineParsePartialEntireStream(&decoder, this) &&
decoder.BytesUntilLimit() == 0;
}
@@ -480,8 +598,8 @@ bool MessageLite::SerializePartialToCodedStream(
io::CodedOutputStream* output) const {
const size_t size = ByteSizeLong(); // Force size to be cached.
if (size > INT_MAX) {
- GOOGLE_LOG(ERROR) << GetTypeName() << " exceeded maximum protobuf size of 2GB: "
- << size;
+ GOOGLE_LOG(ERROR) << GetTypeName()
+ << " exceeded maximum protobuf size of 2GB: " << size;
return false;
}
@@ -531,8 +649,8 @@ bool MessageLite::AppendPartialToString(string* output) const {
size_t old_size = output->size();
size_t byte_size = ByteSizeLong();
if (byte_size > INT_MAX) {
- GOOGLE_LOG(ERROR) << GetTypeName() << " exceeded maximum protobuf size of 2GB: "
- << byte_size;
+ GOOGLE_LOG(ERROR) << GetTypeName()
+ << " exceeded maximum protobuf size of 2GB: " << byte_size;
return false;
}
@@ -564,8 +682,8 @@ bool MessageLite::SerializeToArray(void* data, int size) const {
bool MessageLite::SerializePartialToArray(void* data, int size) const {
const size_t byte_size = ByteSizeLong();
if (byte_size > INT_MAX) {
- GOOGLE_LOG(ERROR) << GetTypeName() << " exceeded maximum protobuf size of 2GB: "
- << byte_size;
+ GOOGLE_LOG(ERROR) << GetTypeName()
+ << " exceeded maximum protobuf size of 2GB: " << byte_size;
return false;
}
if (size < byte_size) return false;
@@ -583,15 +701,13 @@ string MessageLite::SerializeAsString() const {
// of this function, but will be overlaid with the object that the
// caller supplied for the return value to be constructed in.
string output;
- if (!AppendToString(&output))
- output.clear();
+ if (!AppendToString(&output)) output.clear();
return output;
}
string MessageLite::SerializePartialAsString() const {
string output;
- if (!AppendPartialToString(&output))
- output.clear();
+ if (!AppendPartialToString(&output)) output.clear();
return output;
}
@@ -640,9 +756,8 @@ void GenericTypeHandler<MessageLite>::Merge(const MessageLite& from,
MessageLite* to) {
to->CheckTypeAndMergeFrom(from);
}
-template<>
-void GenericTypeHandler<string>::Merge(const string& from,
- string* to) {
+template <>
+void GenericTypeHandler<string>::Merge(const string& from, string* to) {
*to = from;
}
diff --git a/src/google/protobuf/message_lite.h b/src/google/protobuf/message_lite.h
index 21d54915..0e8c3475 100644
--- a/src/google/protobuf/message_lite.h
+++ b/src/google/protobuf/message_lite.h
@@ -146,15 +146,15 @@ class ExplicitlyConstructed {
// Default empty string object. Don't use this directly. Instead, call
// GetEmptyString() to get the reference.
-LIBPROTOBUF_EXPORT extern ExplicitlyConstructed<::std::string>
+PROTOBUF_EXPORT extern ExplicitlyConstructed<::std::string>
fixed_address_empty_string;
-LIBPROTOBUF_EXPORT inline const ::std::string& GetEmptyStringAlreadyInited() {
+PROTOBUF_EXPORT inline const ::std::string& GetEmptyStringAlreadyInited() {
return fixed_address_empty_string.get();
}
-LIBPROTOBUF_EXPORT size_t StringSpaceUsedExcludingSelfLong(const string& str);
+PROTOBUF_EXPORT size_t StringSpaceUsedExcludingSelfLong(const std::string& str);
} // namespace internal
@@ -181,7 +181,7 @@ LIBPROTOBUF_EXPORT size_t StringSpaceUsedExcludingSelfLong(const string& str);
// is best when you only have a small number of message types linked
// into your binary, in which case the size of the protocol buffers
// runtime itself is the biggest problem.
-class LIBPROTOBUF_EXPORT MessageLite {
+class PROTOBUF_EXPORT MessageLite {
public:
inline MessageLite() {}
virtual ~MessageLite() {}
@@ -189,7 +189,7 @@ class LIBPROTOBUF_EXPORT MessageLite {
// Basic Operations ------------------------------------------------
// Get the name of this message type, e.g. "foo.bar.BazProto".
- virtual string GetTypeName() const = 0;
+ virtual std::string GetTypeName() const = 0;
// Construct a new instance of the same type. Ownership is passed to the
// caller.
@@ -230,7 +230,7 @@ class LIBPROTOBUF_EXPORT MessageLite {
// This is not implemented for Lite messages -- it just returns "(cannot
// determine missing fields for lite message)". However, it is implemented
// for full messages. See message.h.
- virtual string InitializationErrorString() const;
+ virtual std::string InitializationErrorString() const;
// If |other| is the exact same class as this, calls MergeFrom(). Otherwise,
// results are undefined (probably crash).
@@ -269,10 +269,10 @@ class LIBPROTOBUF_EXPORT MessageLite {
// format, matching the encoding output by MessageLite::SerializeToString().
// If you'd like to convert a human-readable string into a protocol buffer
// object, see google::protobuf::TextFormat::ParseFromString().
- bool ParseFromString(const string& data);
+ bool ParseFromString(const std::string& data);
// Like ParseFromString(), but accepts messages that are missing
// required fields.
- bool ParsePartialFromString(const string& data);
+ bool ParsePartialFromString(const std::string& data);
// Parse a protocol buffer contained in an array of bytes.
bool ParseFromArray(const void* data, int size);
// Like ParseFromArray(), but accepts messages that are missing
@@ -305,7 +305,7 @@ class LIBPROTOBUF_EXPORT MessageLite {
#endif // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
// Merge a protocol buffer contained in a string.
- bool MergeFromString(const string& data);
+ bool MergeFromString(const std::string& data);
// Serialization ---------------------------------------------------
@@ -325,9 +325,9 @@ class LIBPROTOBUF_EXPORT MessageLite {
bool SerializePartialToZeroCopyStream(io::ZeroCopyOutputStream* output) const;
// Serialize the message and store it in the given string. All required
// fields must be set.
- bool SerializeToString(string* output) const;
+ bool SerializeToString(std::string* output) const;
// Like SerializeToString(), but allows missing required fields.
- bool SerializePartialToString(string* output) const;
+ bool SerializePartialToString(std::string* output) const;
// Serialize the message and store it in the given byte array. All required
// fields must be set.
bool SerializeToArray(void* data, int size) const;
@@ -340,15 +340,15 @@ class LIBPROTOBUF_EXPORT MessageLite {
// Note: If you intend to generate many such strings, you may
// reduce heap fragmentation by instead re-using the same string
// object with calls to SerializeToString().
- string SerializeAsString() const;
+ std::string SerializeAsString() const;
// Like SerializeAsString(), but allows missing required fields.
- string SerializePartialAsString() const;
+ std::string SerializePartialAsString() const;
// Like SerializeToString(), but appends to the data to the string's existing
// contents. All required fields must be set.
- bool AppendToString(string* output) const;
+ bool AppendToString(std::string* output) const;
// Like AppendToString(), but allows missing required fields.
- bool AppendPartialToString(string* output) const;
+ bool AppendPartialToString(std::string* output) const;
// Computes the serialized size of the message. This recursively calls
// ByteSizeLong() on all embedded messages.
@@ -358,7 +358,7 @@ class LIBPROTOBUF_EXPORT MessageLite {
virtual size_t ByteSizeLong() const = 0;
// Legacy ByteSize() API.
- GOOGLE_PROTOBUF_DEPRECATED_MSG("Please use ByteSizeLong() instead")
+ PROTOBUF_DEPRECATED_MSG("Please use ByteSizeLong() instead")
int ByteSize() const {
return internal::ToIntSize(ByteSizeLong());
}
@@ -399,6 +399,8 @@ class LIBPROTOBUF_EXPORT MessageLite {
#if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
virtual internal::ParseFunc _ParseFunc() const {
+ GOOGLE_LOG(FATAL) << "Type " << typeid(*this).name()
+ << " doesn't implement _InternalParse";
return nullptr;
}
#endif // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
diff --git a/src/google/protobuf/message_unittest.inc b/src/google/protobuf/message_unittest.inc
index 0b9d565f..23deaa25 100644
--- a/src/google/protobuf/message_unittest.inc
+++ b/src/google/protobuf/message_unittest.inc
@@ -567,6 +567,68 @@ TEST(MESSAGE_FACTORY_TEST_NAME, GeneratedFactoryUnknownType) {
nullptr);
}
+TEST(MESSAGE_TEST_NAME, MOMIParserEdgeCases) {
+ {
+ UNITTEST::TestAllTypes msg;
+ // Parser ends in last 16 bytes of buffer due to a 0.
+ string data;
+ // 12 bytes of data
+ for (int i = 0; i < 4; i++) data += "\370\1\1";
+ // 13 byte is terminator
+ data += '\0'; // Terminator
+ // followed by the rest of the stream
+ // space is ascii 32 so no end group
+ data += string(30, ' ');
+ io::ArrayInputStream zcis(data.data(), data.size(), 17);
+ io::CodedInputStream cis(&zcis);
+ EXPECT_TRUE(msg.MergePartialFromCodedStream(&cis));
+ EXPECT_EQ(cis.CurrentPosition(), 3 * 4 + 1);
+ }
+ {
+ // Parser ends in last 16 bytes of buffer due to a end-group.
+ // Must use a message that is a group. Otherwise ending on a group end is
+ // a failure.
+ UNITTEST::TestAllTypes::OptionalGroup msg;
+ string data;
+ for (int i = 0; i < 3; i++) data += "\370\1\1";
+ data += '\14'; // Octal end-group tag 12 (1 * 8 + 4(
+ data += string(30, ' ');
+ io::ArrayInputStream zcis(data.data(), data.size(), 17);
+ io::CodedInputStream cis(&zcis);
+ EXPECT_TRUE(msg.MergePartialFromCodedStream(&cis));
+ EXPECT_EQ(cis.CurrentPosition(), 3 * 3 + 1);
+ EXPECT_TRUE(cis.LastTagWas(12));
+ }
+ {
+ // Parser ends in last 16 bytes of buffer due to a end-group. But is inside
+ // a length delimited field.
+ // a failure.
+ UNITTEST::TestAllTypes::OptionalGroup msg;
+ string data;
+ data += "\22\3foo";
+ data += '\14'; // Octal end-group tag 12 (1 * 8 + 4(
+ data += string(30, ' ');
+ io::ArrayInputStream zcis(data.data(), data.size(), 17);
+ io::CodedInputStream cis(&zcis);
+ EXPECT_TRUE(msg.MergePartialFromCodedStream(&cis));
+ EXPECT_EQ(cis.CurrentPosition(), 6);
+ EXPECT_TRUE(cis.LastTagWas(12));
+ }
+ {
+ // Parser fails when ending on 0 if from ZeroCopyInputStream
+ UNITTEST::TestAllTypes msg;
+ string data;
+ // 12 bytes of data
+ for (int i = 0; i < 4; i++) data += "\370\1\1";
+ // 13 byte is terminator
+ data += '\0'; // Terminator
+ data += string(30, ' ');
+ io::ArrayInputStream zcis(data.data(), data.size(), 17);
+ EXPECT_FALSE(msg.ParsePartialFromZeroCopyStream(&zcis));
+ }
+}
+
+
} // namespace protobuf
} // namespace google
diff --git a/src/google/protobuf/metadata_lite.h b/src/google/protobuf/metadata_lite.h
index 3c36a553..a0e101df 100644
--- a/src/google/protobuf/metadata_lite.h
+++ b/src/google/protobuf/metadata_lite.h
@@ -34,6 +34,7 @@
#include <string>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/arena.h>
+#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/message_lite.h>
#include <google/protobuf/port.h>
@@ -70,35 +71,35 @@ class InternalMetadataWithArenaBase {
ptr_ = NULL;
}
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE const T& unknown_fields() const {
- if (GOOGLE_PREDICT_FALSE(have_unknown_fields())) {
+ PROTOBUF_ALWAYS_INLINE const T& unknown_fields() const {
+ if (PROTOBUF_PREDICT_FALSE(have_unknown_fields())) {
return PtrValue<Container>()->unknown_fields;
} else {
return Derived::default_instance();
}
}
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE T* mutable_unknown_fields() {
- if (GOOGLE_PREDICT_TRUE(have_unknown_fields())) {
+ PROTOBUF_ALWAYS_INLINE T* mutable_unknown_fields() {
+ if (PROTOBUF_PREDICT_TRUE(have_unknown_fields())) {
return &PtrValue<Container>()->unknown_fields;
} else {
return mutable_unknown_fields_slow();
}
}
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE Arena* arena() const {
- if (GOOGLE_PREDICT_FALSE(have_unknown_fields())) {
+ PROTOBUF_ALWAYS_INLINE Arena* arena() const {
+ if (PROTOBUF_PREDICT_FALSE(have_unknown_fields())) {
return PtrValue<Container>()->arena;
} else {
return PtrValue<Arena>();
}
}
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE bool have_unknown_fields() const {
+ PROTOBUF_ALWAYS_INLINE bool have_unknown_fields() const {
return PtrTag() == kTagContainer;
}
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE void Swap(Derived* other) {
+ PROTOBUF_ALWAYS_INLINE void Swap(Derived* other) {
// Semantics here are that we swap only the unknown fields, not the arena
// pointer. We cannot simply swap ptr_ with other->ptr_ because we need to
// maintain our own arena ptr. Also, our ptr_ and other's ptr_ may be in
@@ -110,22 +111,19 @@ class InternalMetadataWithArenaBase {
}
}
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE void MergeFrom(
- const Derived& other) {
+ PROTOBUF_ALWAYS_INLINE void MergeFrom(const Derived& other) {
if (other.have_unknown_fields()) {
static_cast<Derived*>(this)->DoMergeFrom(other.unknown_fields());
}
}
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE void Clear() {
+ PROTOBUF_ALWAYS_INLINE void Clear() {
if (have_unknown_fields()) {
static_cast<Derived*>(this)->DoClear();
}
}
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE void* raw_arena_ptr() const {
- return ptr_;
- }
+ PROTOBUF_ALWAYS_INLINE void* raw_arena_ptr() const { return ptr_; }
private:
void* ptr_;
@@ -141,7 +139,7 @@ class InternalMetadataWithArenaBase {
static const intptr_t kPtrValueMask = ~kPtrTagMask;
// Accessors for pointer tag and pointer value.
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE int PtrTag() const {
+ PROTOBUF_ALWAYS_INLINE int PtrTag() const {
return reinterpret_cast<intptr_t>(ptr_) & kPtrTagMask;
}
@@ -156,7 +154,7 @@ class InternalMetadataWithArenaBase {
Arena* arena;
};
- GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE T* mutable_unknown_fields_slow() {
+ PROTOBUF_NOINLINE T* mutable_unknown_fields_slow() {
Arena* my_arena = arena();
Container* container = Arena::Create<Container>(my_arena);
// Two-step assignment works around a bug in clang's static analyzer:
@@ -173,20 +171,20 @@ class InternalMetadataWithArenaBase {
// good interface for reading unknown fields into an ArenaString. We may want
// to revisit this to allow unknown fields to be parsed onto the Arena.
class InternalMetadataWithArenaLite
- : public InternalMetadataWithArenaBase<string,
+ : public InternalMetadataWithArenaBase<std::string,
InternalMetadataWithArenaLite> {
public:
InternalMetadataWithArenaLite() {}
explicit InternalMetadataWithArenaLite(Arena* arena)
- : InternalMetadataWithArenaBase<string,
+ : InternalMetadataWithArenaBase<std::string,
InternalMetadataWithArenaLite>(arena) {}
- void DoSwap(string* other) {
+ void DoSwap(std::string* other) {
mutable_unknown_fields()->swap(*other);
}
- void DoMergeFrom(const string& other) {
+ void DoMergeFrom(const std::string& other) {
mutable_unknown_fields()->append(other);
}
@@ -194,8 +192,13 @@ class InternalMetadataWithArenaLite
mutable_unknown_fields()->clear();
}
- static const string& default_instance() {
- return GetEmptyStringAlreadyInited();
+ static const std::string& default_instance() {
+ // Can't use GetEmptyStringAlreadyInited() here because empty string may
+ // not have been initalized yet. This happens when protocol compiler
+ // statically determines the user can't access defaults and omits init code
+ // from proto constructors. However unknown fields are always part of a
+ // proto so it needs to be lazily initailzed. See b/112613846.
+ return GetEmptyString();
}
};
@@ -207,7 +210,7 @@ class InternalMetadataWithArenaLite
// LiteUnknownFieldSetter setter(&_internal_metadata_);
// StringOutputStream stream(setter.buffer());
// guarantees that the string is only swapped after stream is destroyed.
-class LIBPROTOBUF_EXPORT LiteUnknownFieldSetter {
+class PROTOBUF_EXPORT LiteUnknownFieldSetter {
public:
explicit LiteUnknownFieldSetter(InternalMetadataWithArenaLite* metadata)
: metadata_(metadata) {
@@ -218,11 +221,11 @@ class LIBPROTOBUF_EXPORT LiteUnknownFieldSetter {
~LiteUnknownFieldSetter() {
if (!buffer_.empty()) metadata_->mutable_unknown_fields()->swap(buffer_);
}
- string* buffer() { return &buffer_; }
+ std::string* buffer() { return &buffer_; }
private:
InternalMetadataWithArenaLite* metadata_;
- string buffer_;
+ std::string buffer_;
};
} // namespace internal
diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc
index 3c119c1e..113605f6 100644
--- a/src/google/protobuf/port_def.inc
+++ b/src/google/protobuf/port_def.inc
@@ -1,15 +1,308 @@
+// 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.
+
+// This file defines common macros that are used in protobuf.
+//
+// To hide these definitions from the outside world (and to prevent collisions
+// if more than one version of protobuf is #included in the same project) you
+// must follow this pattern when #including port_def.inc in a header file:
+//
+// #include "other_header.h"
+// #include "message.h"
+// // etc.
+//
+// #include "port_def.inc" // MUST be last header included
+//
+// // Definitions for this header.
+//
+// #include "port_undef.inc"
+//
+// This is a textual header with no include guard, because we want to
+// detect/prohibit anytime it is #included twice without a corresponding
+// #undef.
+
+// These macros are private and should always be #undef'd from headers.
+// If any of these errors fire, you should either properly #include
+// port_undef.h at the end of your header that #includes port.h, or
+// don't #include port.h twice in a .cc file.
+#ifdef PROTOBUF_NAMESPACE
+#error PROTOBUF_NAMESPACE was previously defined
+#endif
+#ifdef PROTOBUF_NAMESPACE_ID
+#error PROTOBUF_NAMESPACE_ID was previously defined
+#endif
+#ifdef PROTOBUF_ALWAYS_INLINE
+#error PROTOBUF_ALWAYS_INLINE was previously defined
+#endif
+#ifdef PROTOBUF_COLD
+#error PROTOBUF_COLD was previously defined
+#endif
+#ifdef PROTOBUF_NOINLINE
+#error PROTOBUF_NOINLINE was previously defined
+#endif
+#ifdef PROTOBUF_SECTION_VARIABLE
+#error PROTOBUF_SECTION_VARIABLE was previously defined
+#endif
+#ifdef PROTOBUF_DEPRECATED
+#error PROTOBUF_DEPRECATED was previously defined
+#endif
+#ifdef PROTOBUF_DEPRECATED_MSG
+#error PROTOBUF_DEPRECATED_MSG was previously defined
+#endif
+#ifdef PROTOBUF_FUNC_ALIGN
+#error PROTOBUF_FUNC_ALIGN was previously defined
+#endif
+#ifdef PROTOBUF_RETURNS_NONNULL
+#error PROTOBUF_RETURNS_NONNULL was previously defined
+#endif
+#ifdef PROTOBUF_RTTI
+#error PROTOBUF_RTTI was previously defined
+#endif
+#ifdef PROTOBUF_VERSION
+#error PROTOBUF_VERSION was previously defined
+#endif
+#ifdef PROTOBUF_VERSION_SUFFIX
+#error PROTOBUF_VERSION_SUFFIX was previously defined
+#endif
+#ifdef PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC
+#error PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC was previously defined
+#endif
+#ifdef PROTOBUF_PREDICT_TRUE
+#error PROTOBUF_PREDICT_TRUE was previously defined
+#endif
+#ifdef PROTOBUF_PREDICT_FALSE
+#error PROTOBUF_PREDICT_FALSE was previously defined
+#endif
+#ifdef PROTOBUF_FIELD_OFFSET
+#error PROTOBUF_FIELD_OFFSET was previously defined
+#endif
+#ifdef PROTOBUF_LL_FORMAT
+#error PROTOBUF_LL_FORMAT was previously defined
+#endif
+#ifdef PROTOBUF_GUARDED_BY
+#error PROTOBUF_GUARDED_BY was previously defined
+#endif
+#ifdef PROTOBUF_LONGLONG
+#error PROTOBUF_LONGLONG was previously defined
+#endif
+#ifdef PROTOBUF_ULONGLONG
+#error PROTOBUF_ULONGLONG was previously defined
+#endif
+#ifdef PROTOBUF_FALLTHROUGH_INTENDED
+#error PROTOBUF_FALLTHROUGH_INTENDED was previously defined
+#endif
+#ifdef PROTOBUF_EXPORT
+#error PROTOBUF_EXPORT was previously defined
+#endif
+#ifdef PROTOC_EXPORT
+#error PROTOC_EXPORT was previously defined
+#endif
+
+
+#define PROTOBUF_NAMESPACE "google::protobuf"
+#define PROTOBUF_NAMESPACE_ID google::protobuf
+#define PROTOBUF_DEPRECATED
+#define PROTOBUF_DEPRECATED_MSG(x)
+#define PROTOBUF_SECTION_VARIABLE(x)
+
+// ----------------------------------------------------------------------------
+// Annotations: Some parts of the code have been annotated in ways that might
+// be useful to some compilers or tools, but are not supported universally.
+// You can #define these annotations yourself if the default implementation
+// is not right for you.
+
+#ifdef GOOGLE_ATTRIBUTE_ALWAYS_INLINE
+#define PROTOBUF_ALWAYS_INLINE GOOGLE_ATTRIBUTE_ALWAYS_INLINE
+#else
+#if defined(__GNUC__) && (__GNUC__ > 3 ||(__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
+// For functions we want to force inline.
+// Introduced in gcc 3.1.
+#define PROTOBUF_ALWAYS_INLINE __attribute__ ((always_inline))
+#else
+// Other compilers will have to figure it out for themselves.
+#define PROTOBUF_ALWAYS_INLINE
+#endif
+#endif
+
+#ifdef GOOGLE_ATTRIBUTE_NOINLINE
+#define PROTOBUF_NOINLINE GOOGLE_ATTRIBUTE_NOINLINE
+#else
+#if defined(__GNUC__) && (__GNUC__ > 3 ||(__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
+// For functions we want to force not inline.
+// Introduced in gcc 3.1.
+#define PROTOBUF_NOINLINE __attribute__ ((noinline))
+#elif defined(_MSC_VER) && (_MSC_VER >= 1400)
+// Seems to have been around since at least Visual Studio 2005
+#define PROTOBUF_NOINLINE __declspec(noinline)
+#else
+// Other compilers will have to figure it out for themselves.
+#define PROTOBUF_NOINLINE
+#endif
+#endif
+
+#ifdef GOOGLE_ATTRIBUTE_FUNC_ALIGN
+#define PROTOBUF_FUNC_ALIGN GOOGLE_ATTRIBUTE_FUNC_ALIGN
+#else
+#if defined(__clang__) || \
+ defined(__GNUC__) && (__GNUC__ > 4 ||(__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
+// Function alignment attribute introduced in gcc 4.3
+#define PROTOBUF_FUNC_ALIGN(bytes) __attribute__ ((aligned(bytes)))
+#else
+#define PROTOBUF_FUNC_ALIGN(bytes)
+#endif
+#endif
+
+#ifdef GOOGLE_PREDICT_TRUE
+#define PROTOBUF_PREDICT_TRUE GOOGLE_PREDICT_TRUE
+#else
+#ifdef __GNUC__
+// Provided at least since GCC 3.0.
+#define PROTOBUF_PREDICT_TRUE(x) (__builtin_expect(!!(x), 1))
+#else
+#define PROTOBUF_PREDICT_TRUE(x) (x)
+#endif
+#endif
+
+#ifdef GOOGLE_PREDICT_FALSE
+#define PROTOBUF_PREDICT_FALSE GOOGLE_PREDICT_FALSE
+#else
+#ifdef __GNUC__
+// Provided at least since GCC 3.0.
+#define PROTOBUF_PREDICT_FALSE(x) (__builtin_expect(x, 0))
+#else
+#define PROTOBUF_PREDICT_FALSE(x) (x)
+#endif
+#endif
+
+#ifdef GOOGLE_PROTOBUF_ATTRIBUTE_RETURNS_NONNULL
+#define PROTOBUF_RETURNS_NONNULL GOOGLE_PROTOBUF_ATTRIBUTE_RETURNS_NONNULL
+#else
+#ifdef __GNUC__
+#define PROTOBUF_RETURNS_NONNULL __attribute__((returns_nonnull))
+#endif
+#endif
+
+#define PROTOBUF_GUARDED_BY(x)
+#define PROTOBUF_COLD
+
+// Copied from ABSL.
+#if defined(__clang__) && defined(__has_warning)
+#if __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough")
+#define PROTOBUF_FALLTHROUGH_INTENDED [[clang::fallthrough]]
+#endif
+#elif defined(__GNUC__) && __GNUC__ >= 7
+#define PROTOBUF_FALLTHROUGH_INTENDED [[gnu::fallthrough]]
+#endif
+
+#ifndef PROTOBUF_FALLTHROUGH_INTENDED
+#define PROTOBUF_FALLTHROUGH_INTENDED
+#endif
+
+#ifdef _MSC_VER
+#define PROTOBUF_LONGLONG(x) x##I64
+#define PROTOBUF_ULONGLONG(x) x##UI64
+#define PROTOBUF_LL_FORMAT "I64" // As in printf("%I64d", ...)
+#else
+// By long long, we actually mean int64.
+#define PROTOBUF_LONGLONG(x) x##LL
+#define PROTOBUF_ULONGLONG(x) x##ULL
+// Used to format real long long integers.
+#define PROTOBUF_LL_FORMAT \
+ "ll" // As in "%lld". Note that "q" is poor form also.
+#endif
+
+
+// Shared google3/opensource definitions. //////////////////////////////////////
+
+#define PROTOBUF_VERSION 3006001
+#define PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC 3006001
+#define PROTOBUF_VERSION_SUFFIX ""
+
+// The minimum library version which works with the current version of the
+// headers.
+#define GOOGLE_PROTOBUF_MIN_LIBRARY_VERSION 3006001
+
#if defined(GOOGLE_PROTOBUF_NO_RTTI) && GOOGLE_PROTOBUF_NO_RTTI
-#define GOOGLE_PROTOBUF_RTTI 0
+#define PROTOBUF_RTTI 0
+#else
+#define PROTOBUF_RTTI 1
+#endif
+
+// Returns the offset of the given field within the given aggregate type.
+// This is equivalent to the ANSI C offsetof() macro. However, according
+// to the C++ standard, offsetof() only works on POD types, and GCC
+// enforces this requirement with a warning. In practice, this rule is
+// unnecessarily strict; there is probably no compiler or platform on
+// which the offsets of the direct fields of a class are non-constant.
+// Fields inherited from superclasses *can* have non-constant offsets,
+// but that's not what this macro will be used for.
+#if defined(__clang__)
+// For Clang we use __builtin_offsetof() and suppress the warning,
+// to avoid Control Flow Integrity and UBSan vptr sanitizers from
+// crashing while trying to validate the invalid reinterpet_casts.
+#define PROTOBUF_FIELD_OFFSET(TYPE, FIELD) \
+ _Pragma("clang diagnostic push") \
+ _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
+ __builtin_offsetof(TYPE, FIELD) \
+ _Pragma("clang diagnostic pop")
#else
-#define GOOGLE_PROTOBUF_RTTI 1
+// Note that we calculate relative to the pointer value 16 here since if we
+// just use zero, GCC complains about dereferencing a NULL pointer. We
+// choose 16 rather than some other number just in case the compiler would
+// be confused by an unaligned pointer.
+#define PROTOBUF_FIELD_OFFSET(TYPE, FIELD) \
+ static_cast< ::google::protobuf::uint32>(reinterpret_cast<const char*>( \
+ &reinterpret_cast<const TYPE*>(16)->FIELD) - \
+ reinterpret_cast<const char*>(16))
#endif
-#define GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER 0
-#define GOOGLE_PROTOBUF_PREDICT_TRUE(x) GOOGLE_PREDICT_TRUE(x)
-#define GOOGLE_PROTOBUF_PREDICT_FALSE(x) GOOGLE_PREDICT_FALSE(x)
-#define GOOGLE_PROTOBUF_DEPRECATED
-#define GOOGLE_PROTOBUF_DEPRECATED_MSG(x)
-#define GOOGLE_PROTOBUF_LONGLONG(x) GOOGLE_LONGLONG(x)
-#define GOOGLE_PROTOBUF_ULONGLONG(x) GOOGLE_ULONGLONG(x)
-#define GOOGLE_PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC 3006000
+#if defined(_MSC_VER) && defined(PROTOBUF_USE_DLLS)
+#ifdef LIBPROTOBUF_EXPORTS
+#define PROTOBUF_EXPORT __declspec(dllexport)
+#else
+#define PROTOBUF_EXPORT __declspec(dllimport)
+#endif
+#ifdef LIBPROTOC_EXPORTS
+#define PROTOC_EXPORT __declspec(dllexport)
+#else
+#define PROTOC_EXPORT __declspec(dllimport)
+#endif
+#else
+#define PROTOBUF_EXPORT
+#define PROTOC_EXPORT
+#endif
+
+// Windows declares several inconvenient macro names. We #undef them and then
+// restore them in port_undef.inc.
+#ifdef _MSC_VER
+#pragma push_macro("GetMessage")
+#undef GetMessage
+#endif
diff --git a/src/google/protobuf/port_undef.inc b/src/google/protobuf/port_undef.inc
index 721241cf..84eecf5b 100644
--- a/src/google/protobuf/port_undef.inc
+++ b/src/google/protobuf/port_undef.inc
@@ -1,9 +1,62 @@
-#undef GOOGLE_PROTOBUF_RTTI
-#undef GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
-#undef GOOGLE_PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC
-#undef GOOGLE_PROTOBUF_PREDICT_TRUE
-#undef GOOGLE_PROTOBUF_PREDICT_FALSE
-#undef GOOGLE_PROTOBUF_DEPRECATED
-#undef GOOGLE_PROTOBUF_DEPRECATED_MSG
-#undef GOOGLE_PROTOBUF_LONGLONG
-#undef GOOGLE_PROTOBUF_ULONGLONG
+// 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.
+
+// #undefs all macros defined in port_def.inc. See comments in port_def.inc
+// for more info.
+
+#undef PROTOBUF_NAMESPACE
+#undef PROTOBUF_NAMESPACE_ID
+#undef PROTOBUF_ALWAYS_INLINE
+#undef PROTOBUF_COLD
+#undef PROTOBUF_NOINLINE
+#undef PROTOBUF_SECTION_VARIABLE
+#undef PROTOBUF_DEPRECATED
+#undef PROTOBUF_DEPRECATED_MSG
+#undef PROTOBUF_FUNC_ALIGN
+#undef PROTOBUF_RETURNS_NONNULL
+#undef PROTOBUF_RTTI
+#undef PROTOBUF_VERSION
+#undef PROTOBUF_VERSION_SUFFIX
+#undef PROTOBUF_FIELD_OFFSET
+#undef PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC
+#undef PROTOBUF_PREDICT_TRUE
+#undef PROTOBUF_PREDICT_FALSE
+#undef PROTOBUF_LONGLONG
+#undef PROTOBUF_ULONGLONG
+#undef PROTOBUF_LL_FORMAT
+#undef PROTOBUF_GUARDED_BY
+#undef PROTOBUF_FALLTHROUGH_INTENDED
+#undef PROTOBUF_EXPORT
+#undef PROTOC_EXPORT
+
+// Restore macro that may have been #undef'd in port_def.inc.
+#ifdef _MSC_VER
+#pragma pop_macro("GetMessage")
+#endif
diff --git a/src/google/protobuf/reflection.h b/src/google/protobuf/reflection.h
index c14a896c..094701f7 100644
--- a/src/google/protobuf/reflection.h
+++ b/src/google/protobuf/reflection.h
@@ -42,6 +42,8 @@
#error "You cannot SWIG proto headers"
#endif
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace internal {
@@ -344,7 +346,7 @@ namespace internal {
//
// You can map from T to the actual type using RefTypeTraits:
// typedef RefTypeTraits<T>::AccessorValueType ActualType;
-class LIBPROTOBUF_EXPORT RepeatedFieldAccessor {
+class PROTOBUF_EXPORT RepeatedFieldAccessor {
public:
// Typedefs for clarity.
typedef void Field;
@@ -573,12 +575,12 @@ struct RefTypeTraits<
template<typename T>
struct RefTypeTraits<
- T, typename std::enable_if<std::is_same<string, T>::value>::type> {
+ T, typename std::enable_if<std::is_same<std::string, T>::value>::type> {
typedef RepeatedFieldRefIterator<T> iterator;
typedef RepeatedFieldAccessor AccessorType;
- typedef string AccessorValueType;
- typedef const string IteratorValueType;
- typedef const string* IteratorPointerType;
+ typedef std::string AccessorValueType;
+ typedef const std::string IteratorValueType;
+ typedef const std::string* IteratorPointerType;
static const FieldDescriptor::CppType cpp_type =
FieldDescriptor::CPPTYPE_STRING;
static const Descriptor* GetMessageFieldDescriptor() {
@@ -617,4 +619,6 @@ struct RefTypeTraits<
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_REFLECTION_H__
diff --git a/src/google/protobuf/reflection_internal.h b/src/google/protobuf/reflection_internal.h
index f664d8e2..ff62d58d 100644
--- a/src/google/protobuf/reflection_internal.h
+++ b/src/google/protobuf/reflection_internal.h
@@ -293,7 +293,7 @@ class RepeatedFieldPrimitiveAccessor final : public RepeatedFieldWrapper<T> {
// Default implementation of RepeatedFieldAccessor for string fields with
// ctype=STRING.
class RepeatedPtrFieldStringAccessor final
- : public RepeatedPtrFieldWrapper<string> {
+ : public RepeatedPtrFieldWrapper<std::string> {
typedef void Field;
typedef void Value;
using RepeatedFieldAccessor::Add;
@@ -305,26 +305,26 @@ class RepeatedPtrFieldStringAccessor final
if (this == other_mutator) {
MutableRepeatedField(data)->Swap(MutableRepeatedField(other_data));
} else {
- RepeatedPtrField<string> tmp;
+ RepeatedPtrField<std::string> tmp;
tmp.Swap(MutableRepeatedField(data));
int other_size = other_mutator->Size(other_data);
for (int i = 0; i < other_size; ++i) {
- Add<string>(data, other_mutator->Get<string>(other_data, i));
+ Add<std::string>(data, other_mutator->Get<std::string>(other_data, i));
}
int size = Size(data);
other_mutator->Clear(other_data);
for (int i = 0; i < size; ++i) {
- other_mutator->Add<string>(other_data, tmp.Get(i));
+ other_mutator->Add<std::string>(other_data, tmp.Get(i));
}
}
}
protected:
- string* New(const Value*) const override { return new string(); }
- void ConvertToT(const Value* value, string* result) const override {
- *result = *static_cast<const string*>(value);
+ std::string* New(const Value*) const override { return new std::string(); }
+ void ConvertToT(const Value* value, std::string* result) const override {
+ *result = *static_cast<const std::string*>(value);
}
- const Value* ConvertFromT(const string& value,
+ const Value* ConvertFromT(const std::string& value,
Value* scratch_space) const override {
return static_cast<const Value*>(&value);
}
diff --git a/src/google/protobuf/reflection_ops.h b/src/google/protobuf/reflection_ops.h
index 78666f30..b30c050a 100644
--- a/src/google/protobuf/reflection_ops.h
+++ b/src/google/protobuf/reflection_ops.h
@@ -45,6 +45,8 @@
#error "You cannot SWIG proto headers"
#endif
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace internal {
@@ -58,7 +60,7 @@ namespace internal {
// the Message interface.
//
// This class is really a namespace that contains only static methods.
-class LIBPROTOBUF_EXPORT ReflectionOps {
+class PROTOBUF_EXPORT ReflectionOps {
public:
static void Copy(const Message& from, Message* to);
static void Merge(const Message& from, Message* to);
@@ -70,8 +72,8 @@ class LIBPROTOBUF_EXPORT ReflectionOps {
// paths (e.g. "foo.bar[5].baz") to *names. "prefix" will be attached to
// the front of each name.
static void FindInitializationErrors(const Message& message,
- const string& prefix,
- std::vector<string>* errors);
+ const std::string& prefix,
+ std::vector<std::string>* errors);
private:
// All methods are static. No need to construct.
@@ -82,4 +84,6 @@ class LIBPROTOBUF_EXPORT ReflectionOps {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_REFLECTION_OPS_H__
diff --git a/src/google/protobuf/repeated_field.cc b/src/google/protobuf/repeated_field.cc
index 89d70a71..e09f3e6a 100644
--- a/src/google/protobuf/repeated_field.cc
+++ b/src/google/protobuf/repeated_field.cc
@@ -38,6 +38,8 @@
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
@@ -120,14 +122,14 @@ MessageLite* RepeatedPtrFieldBase::AddWeak(const MessageLite* prototype) {
} // namespace internal
-template class LIBPROTOBUF_EXPORT RepeatedField<bool>;
-template class LIBPROTOBUF_EXPORT RepeatedField<int32>;
-template class LIBPROTOBUF_EXPORT RepeatedField<uint32>;
-template class LIBPROTOBUF_EXPORT RepeatedField<int64>;
-template class LIBPROTOBUF_EXPORT RepeatedField<uint64>;
-template class LIBPROTOBUF_EXPORT RepeatedField<float>;
-template class LIBPROTOBUF_EXPORT RepeatedField<double>;
-template class LIBPROTOBUF_EXPORT RepeatedPtrField<string>;
+template class PROTOBUF_EXPORT RepeatedField<bool>;
+template class PROTOBUF_EXPORT RepeatedField<int32>;
+template class PROTOBUF_EXPORT RepeatedField<uint32>;
+template class PROTOBUF_EXPORT RepeatedField<int64>;
+template class PROTOBUF_EXPORT RepeatedField<uint64>;
+template class PROTOBUF_EXPORT RepeatedField<float>;
+template class PROTOBUF_EXPORT RepeatedField<double>;
+template class PROTOBUF_EXPORT RepeatedPtrField<string>;
} // namespace protobuf
} // namespace google
diff --git a/src/google/protobuf/repeated_field.h b/src/google/protobuf/repeated_field.h
index 63062c10..42144222 100644
--- a/src/google/protobuf/repeated_field.h
+++ b/src/google/protobuf/repeated_field.h
@@ -433,7 +433,7 @@ struct TypeImplementsMergeBehavior< ::std::string> {
// // Only needs to be implemented if SpaceUsedExcludingSelf() is called.
// static int SpaceUsedLong(const Type&);
// };
-class LIBPROTOBUF_EXPORT RepeatedPtrFieldBase {
+class PROTOBUF_EXPORT RepeatedPtrFieldBase {
protected:
RepeatedPtrFieldBase();
explicit RepeatedPtrFieldBase(Arena* arena);
@@ -501,8 +501,7 @@ class LIBPROTOBUF_EXPORT RepeatedPtrFieldBase {
const typename TypeHandler::Type* const* data() const;
template <typename TypeHandler>
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE void Swap(
- RepeatedPtrFieldBase* other);
+ PROTOBUF_ALWAYS_INLINE void Swap(RepeatedPtrFieldBase* other);
void SwapElements(int index1, int index2);
@@ -547,10 +546,10 @@ class LIBPROTOBUF_EXPORT RepeatedPtrFieldBase {
void AddAllocatedInternal(typename TypeHandler::Type* value, std::false_type);
template <typename TypeHandler>
- GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE void AddAllocatedSlowWithCopy(
+ PROTOBUF_NOINLINE void AddAllocatedSlowWithCopy(
typename TypeHandler::Type* value, Arena* value_arena, Arena* my_arena);
template <typename TypeHandler>
- GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE void AddAllocatedSlowWithoutCopy(
+ PROTOBUF_NOINLINE void AddAllocatedSlowWithoutCopy(
typename TypeHandler::Type* value);
template <typename TypeHandler>
@@ -559,7 +558,7 @@ class LIBPROTOBUF_EXPORT RepeatedPtrFieldBase {
typename TypeHandler::Type* ReleaseLastInternal(std::false_type);
template <typename TypeHandler>
- GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE void SwapFallback(
+ PROTOBUF_NOINLINE void SwapFallback(
RepeatedPtrFieldBase* other);
inline Arena* GetArenaNoVirtual() const {
@@ -671,7 +670,7 @@ class GenericTypeHandler {
}
static inline void Clear(GenericType* value) { value->Clear(); }
- GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE
+ PROTOBUF_NOINLINE
static void Merge(const GenericType& from, GenericType* to);
static inline size_t SpaceUsedLong(const GenericType& value) {
return value.SpaceUsedLong();
@@ -708,23 +707,25 @@ template <>
void GenericTypeHandler<MessageLite>::Merge(const MessageLite& from,
MessageLite* to);
template<>
-inline void GenericTypeHandler<string>::Clear(string* value) {
+inline void GenericTypeHandler<std::string>::Clear(std::string* value) {
value->clear();
}
template<>
-void GenericTypeHandler<string>::Merge(const string& from,
- string* to);
+void GenericTypeHandler<std::string>::Merge(const std::string& from,
+ std::string* to);
// 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 <> LIBPROTOBUF_EXPORT \
- TypeName* GenericTypeHandler<TypeName>::NewFromPrototype( \
- const TypeName* prototype, Arena* arena); \
- template <> LIBPROTOBUF_EXPORT \
- Arena* GenericTypeHandler<TypeName>::GetArena(TypeName* value); \
- template <> LIBPROTOBUF_EXPORT \
- void* GenericTypeHandler<TypeName>::GetMaybeArenaPointer(TypeName* value);
+#define DECLARE_SPECIALIZATIONS_FOR_BASE_PROTO_TYPES(TypeName) \
+ template <> \
+ PROTOBUF_EXPORT TypeName* GenericTypeHandler<TypeName>::NewFromPrototype( \
+ const TypeName* prototype, Arena* arena); \
+ template <> \
+ PROTOBUF_EXPORT Arena* GenericTypeHandler<TypeName>::GetArena( \
+ TypeName* value); \
+ template <> \
+ PROTOBUF_EXPORT void* GenericTypeHandler<TypeName>::GetMaybeArenaPointer( \
+ TypeName* value);
// Message specialization bodies defined in message.cc. This split is necessary
// to allow proto2-lite (which includes this header) to be independent of
@@ -736,32 +737,32 @@ DECLARE_SPECIALIZATIONS_FOR_BASE_PROTO_TYPES(Message)
class StringTypeHandler {
public:
- typedef string Type;
- typedef string WeakType;
+ typedef std::string Type;
+ typedef std::string WeakType;
static const bool Moveable = std::is_move_constructible<Type>::value &&
std::is_move_assignable<Type>::value;
- static inline string* New(Arena* arena) {
- return Arena::Create<string>(arena);
+ static inline std::string* New(Arena* arena) {
+ return Arena::Create<std::string>(arena);
}
- static inline string* New(Arena* arena, string&& value) {
- return Arena::Create<string>(arena, std::move(value));
+ static inline std::string* New(Arena* arena, std::string&& value) {
+ return Arena::Create<std::string>(arena, std::move(value));
}
- static inline string* NewFromPrototype(const string*, Arena* arena) {
+ static inline std::string* NewFromPrototype(const std::string*, Arena* arena) {
return New(arena);
}
- static inline Arena* GetArena(string*) { return NULL; }
- static inline void* GetMaybeArenaPointer(string* /* value */) {
+ static inline Arena* GetArena(std::string*) { return NULL; }
+ static inline void* GetMaybeArenaPointer(std::string* /* value */) {
return NULL;
}
- static inline void Delete(string* value, Arena* arena) {
+ static inline void Delete(std::string* value, Arena* arena) {
if (arena == NULL) {
delete value;
}
}
- static inline void Clear(string* value) { value->clear(); }
- static inline void Merge(const string& from, string* to) { *to = from; }
- static size_t SpaceUsedLong(const string& value) {
+ static inline void Clear(std::string* value) { value->clear(); }
+ static inline void Merge(const std::string& from, std::string* to) { *to = from; }
+ static size_t SpaceUsedLong(const std::string& value) {
return sizeof(value) + StringSpaceUsedExcludingSelfLong(value);
}
};
@@ -1885,7 +1886,7 @@ class RepeatedPtrField<Element>::TypeHandler
};
template <>
-class RepeatedPtrField<string>::TypeHandler
+class RepeatedPtrField<std::string>::TypeHandler
: public internal::StringTypeHandler {
};
@@ -2630,14 +2631,14 @@ UnsafeArenaAllocatedRepeatedPtrFieldBackInserter(
}
// Extern declarations of common instantiations to reduce libray bloat.
-extern template class LIBPROTOBUF_EXPORT RepeatedField<bool>;
-extern template class LIBPROTOBUF_EXPORT RepeatedField<int32>;
-extern template class LIBPROTOBUF_EXPORT RepeatedField<uint32>;
-extern template class LIBPROTOBUF_EXPORT RepeatedField<int64>;
-extern template class LIBPROTOBUF_EXPORT RepeatedField<uint64>;
-extern template class LIBPROTOBUF_EXPORT RepeatedField<float>;
-extern template class LIBPROTOBUF_EXPORT RepeatedField<double>;
-extern template class LIBPROTOBUF_EXPORT RepeatedPtrField<string>;
+extern template class PROTOBUF_EXPORT RepeatedField<bool>;
+extern template class PROTOBUF_EXPORT RepeatedField<int32>;
+extern template class PROTOBUF_EXPORT RepeatedField<uint32>;
+extern template class PROTOBUF_EXPORT RepeatedField<int64>;
+extern template class PROTOBUF_EXPORT RepeatedField<uint64>;
+extern template class PROTOBUF_EXPORT RepeatedField<float>;
+extern template class PROTOBUF_EXPORT RepeatedField<double>;
+extern template class PROTOBUF_EXPORT RepeatedPtrField<std::string>;
} // namespace protobuf
} // namespace google
diff --git a/src/google/protobuf/service.h b/src/google/protobuf/service.h
index 5c6d068f..0792817a 100644
--- a/src/google/protobuf/service.h
+++ b/src/google/protobuf/service.h
@@ -108,6 +108,8 @@
#error "You cannot SWIG proto headers"
#endif
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
@@ -127,7 +129,7 @@ class Message; // message.h
// stubs), but they subclass this base interface. The methods of this
// interface can be used to call the methods of the Service without knowing
// its exact type at compile time (analogous to Reflection).
-class LIBPROTOBUF_EXPORT Service {
+class PROTOBUF_EXPORT Service {
public:
inline Service() {}
virtual ~Service();
@@ -204,7 +206,7 @@ class LIBPROTOBUF_EXPORT Service {
// "least common denominator" set of features which we expect all
// implementations to support. Specific implementations may provide more
// advanced features (e.g. deadline propagation).
-class LIBPROTOBUF_EXPORT RpcController {
+class PROTOBUF_EXPORT RpcController {
public:
inline RpcController() {}
virtual ~RpcController();
@@ -224,7 +226,7 @@ class LIBPROTOBUF_EXPORT RpcController {
virtual bool Failed() const = 0;
// If Failed() is true, returns a human-readable description of the error.
- virtual string ErrorText() const = 0;
+ virtual std::string ErrorText() const = 0;
// Advises the RPC system that the caller desires that the RPC call be
// canceled. The RPC system may cancel it immediately, may wait awhile and
@@ -242,7 +244,7 @@ class LIBPROTOBUF_EXPORT RpcController {
// you need to return machine-readable information about failures, you
// should incorporate it into your response protocol buffer and should
// NOT call SetFailed().
- virtual void SetFailed(const string& reason) = 0;
+ virtual void SetFailed(const std::string& reason) = 0;
// If true, indicates that the client canceled the RPC, so the server may
// as well give up on replying to it. The server should still call the
@@ -270,7 +272,7 @@ class LIBPROTOBUF_EXPORT RpcController {
// RpcChannel* channel = new MyRpcChannel("remotehost.example.com:1234");
// MyService* service = new MyService::Stub(channel);
// service->MyMethod(request, &response, callback);
-class LIBPROTOBUF_EXPORT RpcChannel {
+class PROTOBUF_EXPORT RpcChannel {
public:
inline RpcChannel() {}
virtual ~RpcChannel();
@@ -293,4 +295,6 @@ class LIBPROTOBUF_EXPORT RpcChannel {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_SERVICE_H__
diff --git a/src/google/protobuf/source_context.pb.cc b/src/google/protobuf/source_context.pb.cc
index 067fcae0..a3dd41d4 100644
--- a/src/google/protobuf/source_context.pb.cc
+++ b/src/google/protobuf/source_context.pb.cc
@@ -13,10 +13,6 @@
#include <google/protobuf/generated_message_reflection.h>
#include <google/protobuf/reflection_ops.h>
#include <google/protobuf/wire_format.h>
-// This is a temporary google only hack
-#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
-#include "third_party/protobuf/version.h"
-#endif
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>
@@ -39,7 +35,7 @@ static void InitDefaultsSourceContext_google_2fprotobuf_2fsource_5fcontext_2epro
::google::protobuf::SourceContext::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_SourceContext_google_2fprotobuf_2fsource_5fcontext_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_SourceContext_google_2fprotobuf_2fsource_5fcontext_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsSourceContext_google_2fprotobuf_2fsource_5fcontext_2eproto}, {}};
void InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto() {
@@ -50,15 +46,15 @@ void InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto() {
constexpr ::google::protobuf::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2fsource_5fcontext_2eproto = nullptr;
constexpr ::google::protobuf::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fsource_5fcontext_2eproto = nullptr;
-const ::google::protobuf::uint32 TableStruct_google_2fprotobuf_2fsource_5fcontext_2eproto::offsets[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
+const ::google::protobuf::uint32 TableStruct_google_2fprotobuf_2fsource_5fcontext_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
~0u, // no _has_bits_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::SourceContext, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::SourceContext, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::SourceContext, file_name_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::SourceContext, file_name_),
};
-static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
+static const ::google::protobuf::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
{ 0, -1, sizeof(::google::protobuf::SourceContext)},
};
@@ -170,14 +166,13 @@ const char* SourceContext::_InternalParse(const char* begin, const char* end, vo
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// string file_name = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 10) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.SourceContext.file_name");
parser_till_end = ::google::protobuf::internal::StringParserUTF8;
::std::string* str = msg->mutable_file_name();
@@ -185,14 +180,15 @@ const char* SourceContext::_InternalParse(const char* begin, const char* end, vo
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
@@ -203,8 +199,6 @@ const char* SourceContext::_InternalParse(const char* begin, const char* end, vo
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -216,7 +210,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool SourceContext::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.SourceContext)
for (;;) {
@@ -402,10 +396,11 @@ void SourceContext::InternalSwap(SourceContext* other) {
} // namespace google
namespace google {
namespace protobuf {
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::SourceContext* Arena::CreateMaybeMessage< ::google::protobuf::SourceContext >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::SourceContext* Arena::CreateMaybeMessage< ::google::protobuf::SourceContext >(Arena* arena) {
return Arena::CreateInternal< ::google::protobuf::SourceContext >(arena);
}
} // namespace protobuf
} // namespace google
// @@protoc_insertion_point(global_scope)
+#include <google/protobuf/port_undef.inc>
diff --git a/src/google/protobuf/source_context.pb.h b/src/google/protobuf/source_context.pb.h
index 5355e1c0..b6fed22c 100644
--- a/src/google/protobuf/source_context.pb.h
+++ b/src/google/protobuf/source_context.pb.h
@@ -7,18 +7,19 @@
#include <limits>
#include <string>
-#include <google/protobuf/stubs/common.h>
-#if GOOGLE_PROTOBUF_VERSION < 3006000
+#include <google/protobuf/port_def.inc>
+#if PROTOBUF_VERSION < 3006001
#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 3006001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 3006001 < 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.
#endif
+#include <google/protobuf/port_undef.inc>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
@@ -32,27 +33,27 @@
#include <google/protobuf/unknown_field_set.h>
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>
-#define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fsource_5fcontext_2eproto LIBPROTOBUF_EXPORT
+#define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fsource_5fcontext_2eproto PROTOBUF_EXPORT
// Internal implementation detail -- do not use these members.
-struct LIBPROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fsource_5fcontext_2eproto {
+struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fsource_5fcontext_2eproto {
static const ::google::protobuf::internal::ParseTableField entries[]
- GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold);
+ PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::google::protobuf::internal::AuxillaryParseTableField aux[]
- GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold);
+ PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::google::protobuf::internal::ParseTable schema[1]
- GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold);
+ PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::google::protobuf::internal::FieldMetadata field_metadata[];
static const ::google::protobuf::internal::SerializationTable serialization_table[];
static const ::google::protobuf::uint32 offsets[];
};
-void LIBPROTOBUF_EXPORT AddDescriptors_google_2fprotobuf_2fsource_5fcontext_2eproto();
+void PROTOBUF_EXPORT AddDescriptors_google_2fprotobuf_2fsource_5fcontext_2eproto();
namespace google {
namespace protobuf {
class SourceContext;
class SourceContextDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern SourceContextDefaultTypeInternal _SourceContext_default_instance_;
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::SourceContext* Arena::CreateMaybeMessage<::google::protobuf::SourceContext>(Arena*);
+PROTOBUF_EXPORT extern SourceContextDefaultTypeInternal _SourceContext_default_instance_;
+template<> PROTOBUF_EXPORT ::google::protobuf::SourceContext* Arena::CreateMaybeMessage<::google::protobuf::SourceContext>(Arena*);
} // namespace protobuf
} // namespace google
namespace google {
@@ -60,7 +61,7 @@ namespace protobuf {
// ===================================================================
-class LIBPROTOBUF_EXPORT SourceContext : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.SourceContext) */ {
+class PROTOBUF_EXPORT SourceContext : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.SourceContext) */ {
public:
SourceContext();
virtual ~SourceContext();
diff --git a/src/google/protobuf/struct.pb.cc b/src/google/protobuf/struct.pb.cc
index 4294f407..10e33ca2 100644
--- a/src/google/protobuf/struct.pb.cc
+++ b/src/google/protobuf/struct.pb.cc
@@ -13,10 +13,6 @@
#include <google/protobuf/generated_message_reflection.h>
#include <google/protobuf/reflection_ops.h>
#include <google/protobuf/wire_format.h>
-// This is a temporary google only hack
-#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
-#include "third_party/protobuf/version.h"
-#endif
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>
@@ -75,7 +71,7 @@ static void InitDefaultsListValue_google_2fprotobuf_2fstruct_2eproto() {
::google::protobuf::ListValue::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_ListValue_google_2fprotobuf_2fstruct_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_ListValue_google_2fprotobuf_2fstruct_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsListValue_google_2fprotobuf_2fstruct_2eproto}, {}};
void InitDefaults_google_2fprotobuf_2fstruct_2eproto() {
@@ -86,26 +82,26 @@ void InitDefaults_google_2fprotobuf_2fstruct_2eproto() {
const ::google::protobuf::EnumDescriptor* file_level_enum_descriptors_google_2fprotobuf_2fstruct_2eproto[1];
constexpr ::google::protobuf::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fstruct_2eproto = nullptr;
-const ::google::protobuf::uint32 TableStruct_google_2fprotobuf_2fstruct_2eproto::offsets[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Struct_FieldsEntry_DoNotUse, _has_bits_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Struct_FieldsEntry_DoNotUse, _internal_metadata_),
+const ::google::protobuf::uint32 TableStruct_google_2fprotobuf_2fstruct_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Struct_FieldsEntry_DoNotUse, _has_bits_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Struct_FieldsEntry_DoNotUse, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Struct_FieldsEntry_DoNotUse, key_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Struct_FieldsEntry_DoNotUse, value_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Struct_FieldsEntry_DoNotUse, key_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Struct_FieldsEntry_DoNotUse, value_),
0,
1,
~0u, // no _has_bits_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Struct, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Struct, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Struct, fields_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Struct, fields_),
~0u, // no _has_bits_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Value, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Value, _internal_metadata_),
~0u, // no _extensions_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Value, _oneof_case_[0]),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Value, _oneof_case_[0]),
~0u, // no _weak_field_map_
offsetof(::google::protobuf::ValueDefaultTypeInternal, null_value_),
offsetof(::google::protobuf::ValueDefaultTypeInternal, number_value_),
@@ -113,15 +109,15 @@ const ::google::protobuf::uint32 TableStruct_google_2fprotobuf_2fstruct_2eproto:
offsetof(::google::protobuf::ValueDefaultTypeInternal, bool_value_),
offsetof(::google::protobuf::ValueDefaultTypeInternal, struct_value_),
offsetof(::google::protobuf::ValueDefaultTypeInternal, list_value_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Value, kind_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Value, kind_),
~0u, // no _has_bits_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::ListValue, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::ListValue, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::ListValue, values_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::ListValue, values_),
};
-static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
+static const ::google::protobuf::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
{ 0, 7, sizeof(::google::protobuf::Struct_FieldsEntry_DoNotUse)},
{ 9, -1, sizeof(::google::protobuf::Struct)},
{ 15, -1, sizeof(::google::protobuf::Value)},
@@ -207,7 +203,22 @@ void Struct_FieldsEntry_DoNotUse::MergeFrom(
}
#if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
-const char* Struct_FieldsEntry_DoNotUse::_InternalParse(const char* begin, const char* end, void* object, ::google::protobuf::internal::ParseContext* ctx) { return end; }
+bool Struct_FieldsEntry_DoNotUse::_ParseMap(const char* begin, const char* end, void* object, ::google::protobuf::internal::ParseContext* ctx) {
+ using MF = ::google::protobuf::internal::MapField<
+ Struct_FieldsEntry_DoNotUse, EntryKeyType, EntryValueType,
+ kEntryKeyFieldType, kEntryValueFieldType,
+ kEntryDefaultEnumValue>;
+ auto mf = static_cast<MF*>(object);
+ Parser<MF, ::google::protobuf::Map<EntryKeyType, EntryValueType>> parser(mf);
+#define DO_(x) if (!(x)) return false
+ DO_(parser.ParseMap(begin, end));
+ DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
+ parser.key().data(), static_cast<int>(parser.key().length()),
+ ::google::protobuf::internal::WireFormatLite::PARSE,
+ "google.protobuf.Struct.FieldsEntry.key"));
+#undef DO_
+ return true;
+}
#endif // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
@@ -294,29 +305,32 @@ const char* Struct::_InternalParse(const char* begin, const char* end, void* obj
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// map<string, .google.protobuf.Value> fields = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 10) goto handle_unusual;
do {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
- parser_till_end = ::google::protobuf::Struct_FieldsEntry_DoNotUse::_InternalParse;
- object = msg->mutable_fields();
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
+ parser_till_end = ::google::protobuf::internal::SlowMapEntryParser;
+ auto parse_map = ::google::protobuf::Struct_FieldsEntry_DoNotUse::_ParseMap;
+ ctx->extra_parse_data().payload.clear();
+ ctx->extra_parse_data().parse_map = parse_map;
+ object = &msg->fields_;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(parse_map(ptr, newend, object, ctx));
ptr = newend;
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 255) == 10 && (ptr += 1));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 10 && (ptr += 1));
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
@@ -327,8 +341,6 @@ const char* Struct::_InternalParse(const char* begin, const char* end, void* obj
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -340,7 +352,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool Struct::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.Struct)
for (;;) {
@@ -842,15 +854,14 @@ const char* Value::_InternalParse(const char* begin, const char* end, void* obje
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// .google.protobuf.NullValue null_value = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 8) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
::google::protobuf::NullValue value = static_cast<::google::protobuf::NullValue>(val);
msg->set_null_value(value);
break;
@@ -868,7 +879,7 @@ const char* Value::_InternalParse(const char* begin, const char* end, void* obje
case 3: {
if (static_cast<::google::protobuf::uint8>(tag) != 26) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.Value.string_value");
parser_till_end = ::google::protobuf::internal::StringParserUTF8;
::std::string* str = msg->mutable_string_value();
@@ -876,8 +887,8 @@ const char* Value::_InternalParse(const char* begin, const char* end, void* obje
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// bool bool_value = 4;
@@ -885,7 +896,7 @@ const char* Value::_InternalParse(const char* begin, const char* end, void* obje
if (static_cast<::google::protobuf::uint8>(tag) != 32) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
bool value = val;
msg->set_bool_value(value);
break;
@@ -894,12 +905,14 @@ const char* Value::_InternalParse(const char* begin, const char* end, void* obje
case 5: {
if (static_cast<::google::protobuf::uint8>(tag) != 42) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::Struct::_InternalParse;
object = msg->mutable_struct_value();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
break;
}
@@ -907,19 +920,22 @@ const char* Value::_InternalParse(const char* begin, const char* end, void* obje
case 6: {
if (static_cast<::google::protobuf::uint8>(tag) != 50) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::ListValue::_InternalParse;
object = msg->mutable_list_value();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
@@ -930,8 +946,6 @@ const char* Value::_InternalParse(const char* begin, const char* end, void* obje
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -943,7 +957,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool Value::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.Value)
for (;;) {
@@ -1404,29 +1418,31 @@ const char* ListValue::_InternalParse(const char* begin, const char* end, void*
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// repeated .google.protobuf.Value values = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 10) goto handle_unusual;
do {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::Value::_InternalParse;
object = msg->add_values();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 255) == 10 && (ptr += 1));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 10 && (ptr += 1));
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
@@ -1437,8 +1453,6 @@ const char* ListValue::_InternalParse(const char* begin, const char* end, void*
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -1450,7 +1464,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool ListValue::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.ListValue)
for (;;) {
@@ -1643,19 +1657,20 @@ void ListValue::InternalSwap(ListValue* other) {
} // namespace google
namespace google {
namespace protobuf {
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Struct_FieldsEntry_DoNotUse* Arena::CreateMaybeMessage< ::google::protobuf::Struct_FieldsEntry_DoNotUse >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::Struct_FieldsEntry_DoNotUse* Arena::CreateMaybeMessage< ::google::protobuf::Struct_FieldsEntry_DoNotUse >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::Struct_FieldsEntry_DoNotUse >(arena);
}
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Struct* Arena::CreateMaybeMessage< ::google::protobuf::Struct >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::Struct* Arena::CreateMaybeMessage< ::google::protobuf::Struct >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::Struct >(arena);
}
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Value* Arena::CreateMaybeMessage< ::google::protobuf::Value >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::Value* Arena::CreateMaybeMessage< ::google::protobuf::Value >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::Value >(arena);
}
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::ListValue* Arena::CreateMaybeMessage< ::google::protobuf::ListValue >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::ListValue* Arena::CreateMaybeMessage< ::google::protobuf::ListValue >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::ListValue >(arena);
}
} // namespace protobuf
} // namespace google
// @@protoc_insertion_point(global_scope)
+#include <google/protobuf/port_undef.inc>
diff --git a/src/google/protobuf/struct.pb.h b/src/google/protobuf/struct.pb.h
index fa1f568d..224fe81a 100644
--- a/src/google/protobuf/struct.pb.h
+++ b/src/google/protobuf/struct.pb.h
@@ -7,18 +7,19 @@
#include <limits>
#include <string>
-#include <google/protobuf/stubs/common.h>
-#if GOOGLE_PROTOBUF_VERSION < 3006000
+#include <google/protobuf/port_def.inc>
+#if PROTOBUF_VERSION < 3006001
#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 3006001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 3006001 < 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.
#endif
+#include <google/protobuf/port_undef.inc>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
@@ -36,39 +37,39 @@
#include <google/protobuf/unknown_field_set.h>
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>
-#define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fstruct_2eproto LIBPROTOBUF_EXPORT
+#define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fstruct_2eproto PROTOBUF_EXPORT
// Internal implementation detail -- do not use these members.
-struct LIBPROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fstruct_2eproto {
+struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fstruct_2eproto {
static const ::google::protobuf::internal::ParseTableField entries[]
- GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold);
+ PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::google::protobuf::internal::AuxillaryParseTableField aux[]
- GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold);
+ PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::google::protobuf::internal::ParseTable schema[4]
- GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold);
+ PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::google::protobuf::internal::FieldMetadata field_metadata[];
static const ::google::protobuf::internal::SerializationTable serialization_table[];
static const ::google::protobuf::uint32 offsets[];
};
-void LIBPROTOBUF_EXPORT AddDescriptors_google_2fprotobuf_2fstruct_2eproto();
+void PROTOBUF_EXPORT AddDescriptors_google_2fprotobuf_2fstruct_2eproto();
namespace google {
namespace protobuf {
class ListValue;
class ListValueDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern ListValueDefaultTypeInternal _ListValue_default_instance_;
+PROTOBUF_EXPORT extern ListValueDefaultTypeInternal _ListValue_default_instance_;
class Struct;
class StructDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern StructDefaultTypeInternal _Struct_default_instance_;
+PROTOBUF_EXPORT extern StructDefaultTypeInternal _Struct_default_instance_;
class Struct_FieldsEntry_DoNotUse;
class Struct_FieldsEntry_DoNotUseDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern Struct_FieldsEntry_DoNotUseDefaultTypeInternal _Struct_FieldsEntry_DoNotUse_default_instance_;
+PROTOBUF_EXPORT extern Struct_FieldsEntry_DoNotUseDefaultTypeInternal _Struct_FieldsEntry_DoNotUse_default_instance_;
class Value;
class ValueDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern ValueDefaultTypeInternal _Value_default_instance_;
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::ListValue* Arena::CreateMaybeMessage<::google::protobuf::ListValue>(Arena*);
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::Struct* Arena::CreateMaybeMessage<::google::protobuf::Struct>(Arena*);
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::Struct_FieldsEntry_DoNotUse* Arena::CreateMaybeMessage<::google::protobuf::Struct_FieldsEntry_DoNotUse>(Arena*);
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::Value* Arena::CreateMaybeMessage<::google::protobuf::Value>(Arena*);
+PROTOBUF_EXPORT extern ValueDefaultTypeInternal _Value_default_instance_;
+template<> PROTOBUF_EXPORT ::google::protobuf::ListValue* Arena::CreateMaybeMessage<::google::protobuf::ListValue>(Arena*);
+template<> PROTOBUF_EXPORT ::google::protobuf::Struct* Arena::CreateMaybeMessage<::google::protobuf::Struct>(Arena*);
+template<> PROTOBUF_EXPORT ::google::protobuf::Struct_FieldsEntry_DoNotUse* Arena::CreateMaybeMessage<::google::protobuf::Struct_FieldsEntry_DoNotUse>(Arena*);
+template<> PROTOBUF_EXPORT ::google::protobuf::Value* Arena::CreateMaybeMessage<::google::protobuf::Value>(Arena*);
} // namespace protobuf
} // namespace google
namespace google {
@@ -79,12 +80,12 @@ enum NullValue {
NullValue_INT_MIN_SENTINEL_DO_NOT_USE_ = std::numeric_limits<::google::protobuf::int32>::min(),
NullValue_INT_MAX_SENTINEL_DO_NOT_USE_ = std::numeric_limits<::google::protobuf::int32>::max()
};
-LIBPROTOBUF_EXPORT bool NullValue_IsValid(int value);
+PROTOBUF_EXPORT bool NullValue_IsValid(int value);
const NullValue NullValue_MIN = NULL_VALUE;
const NullValue NullValue_MAX = NULL_VALUE;
const int NullValue_ARRAYSIZE = NullValue_MAX + 1;
-LIBPROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* NullValue_descriptor();
+PROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* NullValue_descriptor();
inline const ::std::string& NullValue_Name(NullValue value) {
return ::google::protobuf::internal::NameOfEnum(
NullValue_descriptor(), value);
@@ -103,7 +104,7 @@ class Struct_FieldsEntry_DoNotUse : public ::google::protobuf::internal::MapEntr
0 > {
public:
#if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
- static const char* _InternalParse(const char* begin, const char* end, void* object, ::google::protobuf::internal::ParseContext* ctx);
+static bool _ParseMap(const char* begin, const char* end, void* object, ::google::protobuf::internal::ParseContext* ctx);
#endif // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
typedef ::google::protobuf::internal::MapEntry<Struct_FieldsEntry_DoNotUse,
::std::string, ::google::protobuf::Value,
@@ -120,7 +121,7 @@ public:
// -------------------------------------------------------------------
-class LIBPROTOBUF_EXPORT Struct : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Struct) */ {
+class PROTOBUF_EXPORT Struct : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Struct) */ {
public:
Struct();
virtual ~Struct();
@@ -255,7 +256,7 @@ class LIBPROTOBUF_EXPORT Struct : public ::google::protobuf::Message /* @@protoc
};
// -------------------------------------------------------------------
-class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Value) */ {
+class PROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Value) */ {
public:
Value();
virtual ~Value();
@@ -483,7 +484,7 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_
};
// -------------------------------------------------------------------
-class LIBPROTOBUF_EXPORT ListValue : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.ListValue) */ {
+class PROTOBUF_EXPORT ListValue : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.ListValue) */ {
public:
ListValue();
virtual ~ListValue();
diff --git a/src/google/protobuf/stubs/bytestream.h b/src/google/protobuf/stubs/bytestream.h
index cfa19f29..29a9fbe7 100644
--- a/src/google/protobuf/stubs/bytestream.h
+++ b/src/google/protobuf/stubs/bytestream.h
@@ -56,6 +56,8 @@
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/stringpiece.h>
+#include <google/protobuf/port_def.inc>
+
class CordByteSink;
namespace google {
@@ -73,7 +75,7 @@ namespace strings {
// sink->Append(my_data.data(), my_data.size());
// sink->Flush();
//
-class LIBPROTOBUF_EXPORT ByteSink {
+class PROTOBUF_EXPORT ByteSink {
public:
ByteSink() {}
virtual ~ByteSink() {}
@@ -102,7 +104,7 @@ class LIBPROTOBUF_EXPORT ByteSink {
// source->Skip(data.length());
// }
//
-class LIBPROTOBUF_EXPORT ByteSource {
+class PROTOBUF_EXPORT ByteSource {
public:
ByteSource() {}
virtual ~ByteSource() {}
@@ -158,7 +160,7 @@ class LIBPROTOBUF_EXPORT ByteSource {
// sink.Append("hi", 2); // OK
// sink.Append(data, 100); // WOOPS! Overflows buf[10].
//
-class LIBPROTOBUF_EXPORT UncheckedArrayByteSink : public ByteSink {
+class PROTOBUF_EXPORT UncheckedArrayByteSink : public ByteSink {
public:
explicit UncheckedArrayByteSink(char* dest) : dest_(dest) {}
virtual void Append(const char* data, size_t n) override;
@@ -186,7 +188,7 @@ class LIBPROTOBUF_EXPORT UncheckedArrayByteSink : public ByteSink {
// sink.Append("hi", 2); // OK
// sink.Append(data, 100); // Will only write 8 more bytes
//
-class LIBPROTOBUF_EXPORT CheckedArrayByteSink : public ByteSink {
+class PROTOBUF_EXPORT CheckedArrayByteSink : public ByteSink {
public:
CheckedArrayByteSink(char* outbuf, size_t capacity);
virtual void Append(const char* bytes, size_t n) override;
@@ -222,7 +224,7 @@ class LIBPROTOBUF_EXPORT CheckedArrayByteSink : public ByteSink {
// const char* buf = sink.GetBuffer(); // Ownership transferred
// delete[] buf;
//
-class LIBPROTOBUF_EXPORT GrowingArrayByteSink : public strings::ByteSink {
+class PROTOBUF_EXPORT GrowingArrayByteSink : public strings::ByteSink {
public:
explicit GrowingArrayByteSink(size_t estimated_size);
virtual ~GrowingArrayByteSink();
@@ -252,7 +254,7 @@ class LIBPROTOBUF_EXPORT GrowingArrayByteSink : public strings::ByteSink {
// sink.Append("World", 5);
// assert(dest == "Hello World");
//
-class LIBPROTOBUF_EXPORT StringByteSink : public ByteSink {
+class PROTOBUF_EXPORT StringByteSink : public ByteSink {
public:
explicit StringByteSink(string* dest) : dest_(dest) {}
virtual void Append(const char* data, size_t n) override;
@@ -269,7 +271,7 @@ class LIBPROTOBUF_EXPORT StringByteSink : public ByteSink {
// NullByteSink sink;
// sink.Append(data, data.size()); // All data ignored.
//
-class LIBPROTOBUF_EXPORT NullByteSink : public ByteSink {
+class PROTOBUF_EXPORT NullByteSink : public ByteSink {
public:
NullByteSink() {}
virtual void Append(const char *data, size_t n) override {}
@@ -291,7 +293,7 @@ class LIBPROTOBUF_EXPORT NullByteSink : public ByteSink {
// assert(source.Available() == 5);
// assert(source.Peek() == "Hello");
//
-class LIBPROTOBUF_EXPORT ArrayByteSource : public ByteSource {
+class PROTOBUF_EXPORT ArrayByteSource : public ByteSource {
public:
explicit ArrayByteSource(StringPiece s) : input_(s) {}
@@ -322,7 +324,7 @@ class LIBPROTOBUF_EXPORT ArrayByteSource : public ByteSource {
// assert(limit.Available() == 5);
// assert(limit.Peek() == "Hello");
//
-class LIBPROTOBUF_EXPORT LimitByteSource : public ByteSource {
+class PROTOBUF_EXPORT LimitByteSource : public ByteSource {
public:
// Returns at most "limit" bytes from "source".
LimitByteSource(ByteSource* source, size_t limit);
@@ -344,4 +346,6 @@ class LIBPROTOBUF_EXPORT LimitByteSource : public ByteSource {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_STUBS_BYTESTREAM_H_
diff --git a/src/google/protobuf/stubs/callback.h b/src/google/protobuf/stubs/callback.h
index dae972f2..7cce4426 100644
--- a/src/google/protobuf/stubs/callback.h
+++ b/src/google/protobuf/stubs/callback.h
@@ -5,6 +5,8 @@
#include <google/protobuf/stubs/macros.h>
+#include <google/protobuf/port_def.inc>
+
// ===================================================================
// emulates google3/base/callback.h
@@ -68,7 +70,7 @@ namespace protobuf {
// string my_str;
// NewCallback(&Foo, my_str); // WON'T WORK: Can't use referecnes.
// However, correctly-typed pointers will work just fine.
-class LIBPROTOBUF_EXPORT Closure {
+class PROTOBUF_EXPORT Closure {
public:
Closure() {}
virtual ~Closure();
@@ -91,8 +93,8 @@ class ResultCallback {
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ResultCallback);
};
-template<typename R, typename A1>
-class LIBPROTOBUF_EXPORT ResultCallback1 {
+template <typename R, typename A1>
+class PROTOBUF_EXPORT ResultCallback1 {
public:
ResultCallback1() {}
virtual ~ResultCallback1() {}
@@ -103,8 +105,8 @@ class LIBPROTOBUF_EXPORT ResultCallback1 {
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ResultCallback1);
};
-template<typename R, typename A1, typename A2>
-class LIBPROTOBUF_EXPORT ResultCallback2 {
+template <typename R, typename A1, typename A2>
+class PROTOBUF_EXPORT ResultCallback2 {
public:
ResultCallback2() {}
virtual ~ResultCallback2() {}
@@ -117,7 +119,7 @@ class LIBPROTOBUF_EXPORT ResultCallback2 {
namespace internal {
-class LIBPROTOBUF_EXPORT FunctionClosure0 : public Closure {
+class PROTOBUF_EXPORT FunctionClosure0 : public Closure {
public:
typedef void (*FunctionType)();
@@ -568,10 +570,11 @@ inline ResultCallback2<R, A1, A2>* NewPermanentCallback(
// A function which does nothing. Useful for creating no-op callbacks, e.g.:
// Closure* nothing = NewCallback(&DoNothing);
-void LIBPROTOBUF_EXPORT DoNothing();
-
+void PROTOBUF_EXPORT DoNothing();
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_STUBS_CALLBACK_H_
diff --git a/src/google/protobuf/stubs/common.cc b/src/google/protobuf/stubs/common.cc
index 4b65eb89..38153321 100644
--- a/src/google/protobuf/stubs/common.cc
+++ b/src/google/protobuf/stubs/common.cc
@@ -54,6 +54,8 @@
#include <android/log.h>
#endif
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
@@ -242,8 +244,8 @@ DECLARE_STREAM_OPERATOR(long , "%ld")
DECLARE_STREAM_OPERATOR(unsigned long, "%lu")
DECLARE_STREAM_OPERATOR(double , "%g" )
DECLARE_STREAM_OPERATOR(void* , "%p" )
-DECLARE_STREAM_OPERATOR(long long , "%" GOOGLE_LL_FORMAT "d")
-DECLARE_STREAM_OPERATOR(unsigned long long, "%" GOOGLE_LL_FORMAT "u")
+DECLARE_STREAM_OPERATOR(long long , "%" PROTOBUF_LL_FORMAT "d")
+DECLARE_STREAM_OPERATOR(unsigned long long, "%" PROTOBUF_LL_FORMAT "u")
#undef DECLARE_STREAM_OPERATOR
LogMessage::LogMessage(LogLevel level, const char* filename, int line)
diff --git a/src/google/protobuf/stubs/common.h b/src/google/protobuf/stubs/common.h
index 585e0128..b3cb882d 100644
--- a/src/google/protobuf/stubs/common.h
+++ b/src/google/protobuf/stubs/common.h
@@ -73,22 +73,7 @@
#include <pthread.h>
#endif
-#if defined(_WIN32) && defined(GetMessage)
-// Allow GetMessage to be used as a valid method name in protobuf classes.
-// windows.h defines GetMessage() as a macro. Let's re-define it as an inline
-// function. The inline function should be equivalent for C++ users.
-inline BOOL GetMessage_Win32(
- LPMSG lpMsg, HWND hWnd,
- UINT wMsgFilterMin, UINT wMsgFilterMax) {
- return GetMessage(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax);
-}
-#undef GetMessage
-inline BOOL GetMessage(
- LPMSG lpMsg, HWND hWnd,
- UINT wMsgFilterMin, UINT wMsgFilterMax) {
- return GetMessage_Win32(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax);
-}
-#endif
+#include <google/protobuf/port_def.inc>
namespace std {}
@@ -125,11 +110,11 @@ static const int kMinHeaderVersionForProtoc = 3006001;
// Verifies that the headers and libraries are compatible. Use the macro
// below to call this.
-void LIBPROTOBUF_EXPORT VerifyVersion(int headerVersion, int minLibraryVersion,
- const char* filename);
+void PROTOBUF_EXPORT VerifyVersion(int headerVersion, int minLibraryVersion,
+ const char* filename);
// Converts a numeric version number to a string.
-std::string LIBPROTOBUF_EXPORT VersionString(int version);
+std::string PROTOBUF_EXPORT VersionString(int version);
} // namespace internal
@@ -151,14 +136,14 @@ namespace internal {
// Checks if the buffer contains structurally-valid UTF-8. Implemented in
// structurally_valid.cc.
-LIBPROTOBUF_EXPORT bool IsStructurallyValidUTF8(const char* buf, int len);
+PROTOBUF_EXPORT bool IsStructurallyValidUTF8(const char* buf, int len);
inline bool IsStructurallyValidUTF8(const std::string& str) {
return IsStructurallyValidUTF8(str.data(), static_cast<int>(str.length()));
}
// Returns initial number of bytes of structually valid UTF-8.
-LIBPROTOBUF_EXPORT int UTF8SpnStructurallyValid(const StringPiece& str);
+PROTOBUF_EXPORT int UTF8SpnStructurallyValid(const StringPiece& str);
// Coerce UTF-8 byte string in src_str to be
// a structurally-valid equal-length string by selectively
@@ -172,8 +157,9 @@ LIBPROTOBUF_EXPORT int UTF8SpnStructurallyValid(const StringPiece& str);
//
// Optimized for: all structurally valid and no byte copying is done.
//
-LIBPROTOBUF_EXPORT char* UTF8CoerceToStructurallyValid(
- const StringPiece& str, char* dst, char replace_char);
+PROTOBUF_EXPORT char* UTF8CoerceToStructurallyValid(const StringPiece& str,
+ char* dst,
+ char replace_char);
} // namespace internal
@@ -195,14 +181,14 @@ LIBPROTOBUF_EXPORT char* UTF8CoerceToStructurallyValid(
// any other part of the protocol buffers library after
// ShutdownProtobufLibrary() has been called. Furthermore this call is not
// thread safe, user needs to synchronize multiple calls.
-LIBPROTOBUF_EXPORT void ShutdownProtobufLibrary();
+PROTOBUF_EXPORT void ShutdownProtobufLibrary();
namespace internal {
// Register a function to be called when ShutdownProtocolBuffers() is called.
-LIBPROTOBUF_EXPORT void OnShutdown(void (*func)());
+PROTOBUF_EXPORT void OnShutdown(void (*func)());
// Run an arbitrary function on an arg
-LIBPROTOBUF_EXPORT void OnShutdownRun(void (*f)(const void*), const void* arg);
+PROTOBUF_EXPORT void OnShutdownRun(void (*f)(const void*), const void* arg);
template <typename T>
T* OnShutdownDelete(T* p) {
@@ -239,4 +225,6 @@ using std::string;
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_COMMON_H__
diff --git a/src/google/protobuf/stubs/fastmem.h b/src/google/protobuf/stubs/fastmem.h
index 1f1f6ed3..76c8a3ae 100644
--- a/src/google/protobuf/stubs/fastmem.h
+++ b/src/google/protobuf/stubs/fastmem.h
@@ -51,6 +51,8 @@
#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace internal {
@@ -64,7 +66,7 @@ namespace internal {
// if it makes sense to do so.:w
inline bool memeq(const char* a, const char* b, size_t n) {
size_t n_rounded_down = n & ~static_cast<size_t>(7);
- if (GOOGLE_PREDICT_FALSE(n_rounded_down == 0)) { // n <= 7
+ if (PROTOBUF_PREDICT_FALSE(n_rounded_down == 0)) { // n <= 7
return memcmp(a, b, n) == 0;
}
// n >= 8
@@ -150,4 +152,6 @@ inline void memcpy_inlined(char *dst, const char *src, size_t size) {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_STUBS_FASTMEM_H_
diff --git a/src/google/protobuf/stubs/int128.cc b/src/google/protobuf/stubs/int128.cc
index 7b993e8f..f86ac4a0 100644
--- a/src/google/protobuf/stubs/int128.cc
+++ b/src/google/protobuf/stubs/int128.cc
@@ -34,12 +34,14 @@
#include <ostream> // NOLINT(readability/streams)
#include <sstream>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
const uint128_pod kuint128max = {
- static_cast<uint64>(GOOGLE_LONGLONG(0xFFFFFFFFFFFFFFFF)),
- static_cast<uint64>(GOOGLE_LONGLONG(0xFFFFFFFFFFFFFFFF))
+ static_cast<uint64>(PROTOBUF_LONGLONG(0xFFFFFFFFFFFFFFFF)),
+ static_cast<uint64>(PROTOBUF_LONGLONG(0xFFFFFFFFFFFFFFFF))
};
// Returns the 0-based position of the last set bit (i.e., most significant bit)
@@ -63,7 +65,7 @@ static inline int Fls64(uint64 n) {
STEP(uint32, n32, pos, 0x10);
STEP(uint32, n32, pos, 0x08);
STEP(uint32, n32, pos, 0x04);
- return pos + ((GOOGLE_ULONGLONG(0x3333333322221100) >> (n32 << 2)) & 0x3);
+ return pos + ((PROTOBUF_ULONGLONG(0x3333333322221100) >> (n32 << 2)) & 0x3);
}
#undef STEP
@@ -129,15 +131,18 @@ std::ostream& operator<<(std::ostream& o, const uint128& b) {
std::streamsize div_base_log;
switch (flags & std::ios::basefield) {
case std::ios::hex:
- div = static_cast<uint64>(GOOGLE_ULONGLONG(0x1000000000000000)); // 16^15
+ div =
+ static_cast<uint64>(PROTOBUF_ULONGLONG(0x1000000000000000)); // 16^15
div_base_log = 15;
break;
case std::ios::oct:
- div = static_cast<uint64>(GOOGLE_ULONGLONG(01000000000000000000000)); // 8^21
+ div = static_cast<uint64>(
+ PROTOBUF_ULONGLONG(01000000000000000000000)); // 8^21
div_base_log = 21;
break;
default: // std::ios::dec
- div = static_cast<uint64>(GOOGLE_ULONGLONG(10000000000000000000)); // 10^19
+ div = static_cast<uint64>(
+ PROTOBUF_ULONGLONG(10000000000000000000)); // 10^19
div_base_log = 19;
break;
}
diff --git a/src/google/protobuf/stubs/int128.h b/src/google/protobuf/stubs/int128.h
index 1499bb76..dc70d96e 100644
--- a/src/google/protobuf/stubs/int128.h
+++ b/src/google/protobuf/stubs/int128.h
@@ -34,6 +34,8 @@
#include <iosfwd>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
@@ -48,7 +50,7 @@ struct uint128_pod;
#endif
// An unsigned 128-bit integer type. Thread-compatible.
-class LIBPROTOBUF_EXPORT uint128 {
+class PROTOBUF_EXPORT uint128 {
public:
UINT128_CONSTEXPR uint128(); // Sets to 0, but don't trust on this behavior.
UINT128_CONSTEXPR uint128(uint64 top, uint64 bottom);
@@ -84,8 +86,8 @@ class LIBPROTOBUF_EXPORT uint128 {
friend uint64 Uint128High64(const uint128& v);
// We add "std::" to avoid including all of port.h.
- LIBPROTOBUF_EXPORT friend std::ostream& operator<<(std::ostream& o,
- const uint128& b);
+ PROTOBUF_EXPORT friend std::ostream& operator<<(std::ostream& o,
+ const uint128& b);
private:
static void DivModImpl(uint128 dividend, uint128 divisor,
@@ -116,11 +118,11 @@ struct uint128_pod {
uint64 lo;
};
-LIBPROTOBUF_EXPORT extern const uint128_pod kuint128max;
+PROTOBUF_EXPORT extern const uint128_pod kuint128max;
// allow uint128 to be logged
-LIBPROTOBUF_EXPORT extern std::ostream& operator<<(std::ostream& o,
- const uint128& b);
+PROTOBUF_EXPORT extern std::ostream& operator<<(std::ostream& o,
+ const uint128& b);
// Methods to access low and high pieces of 128-bit value.
// Defined externally from uint128 to facilitate conversion
@@ -380,4 +382,6 @@ inline uint128& uint128::operator--() {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_STUBS_INT128_H_
diff --git a/src/google/protobuf/stubs/int128_unittest.cc b/src/google/protobuf/stubs/int128_unittest.cc
index 1ec899ad..9a8125d4 100644
--- a/src/google/protobuf/stubs/int128_unittest.cc
+++ b/src/google/protobuf/stubs/int128_unittest.cc
@@ -37,6 +37,8 @@
#include <google/protobuf/testing/googletest.h>
#include <gtest/gtest.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
@@ -291,24 +293,26 @@ TEST(Int128, Multiply) {
}
// Verified with dc.
- a = uint128(GOOGLE_ULONGLONG(0xffffeeeeddddcccc),
- GOOGLE_ULONGLONG(0xbbbbaaaa99998888));
- b = uint128(GOOGLE_ULONGLONG(0x7777666655554444),
- GOOGLE_ULONGLONG(0x3333222211110000));
+ a = uint128(PROTOBUF_ULONGLONG(0xffffeeeeddddcccc),
+ PROTOBUF_ULONGLONG(0xbbbbaaaa99998888));
+ b = uint128(PROTOBUF_ULONGLONG(0x7777666655554444),
+ PROTOBUF_ULONGLONG(0x3333222211110000));
c = a * b;
- EXPECT_EQ(uint128(GOOGLE_ULONGLONG(0x530EDA741C71D4C3),
- GOOGLE_ULONGLONG(0xBF25975319080000)), c);
+ EXPECT_EQ(uint128(PROTOBUF_ULONGLONG(0x530EDA741C71D4C3),
+ PROTOBUF_ULONGLONG(0xBF25975319080000)),
+ c);
EXPECT_EQ(0, c - b * a);
- EXPECT_EQ(a*a - b*b, (a+b) * (a-b));
+ EXPECT_EQ(a * a - b * b, (a + b) * (a - b));
// Verified with dc.
- a = uint128(GOOGLE_ULONGLONG(0x0123456789abcdef),
- GOOGLE_ULONGLONG(0xfedcba9876543210));
- b = uint128(GOOGLE_ULONGLONG(0x02468ace13579bdf),
- GOOGLE_ULONGLONG(0xfdb97531eca86420));
+ a = uint128(PROTOBUF_ULONGLONG(0x0123456789abcdef),
+ PROTOBUF_ULONGLONG(0xfedcba9876543210));
+ b = uint128(PROTOBUF_ULONGLONG(0x02468ace13579bdf),
+ PROTOBUF_ULONGLONG(0xfdb97531eca86420));
c = a * b;
- EXPECT_EQ(uint128(GOOGLE_ULONGLONG(0x97a87f4f261ba3f2),
- GOOGLE_ULONGLONG(0x342d0bbf48948200)), c);
+ EXPECT_EQ(uint128(PROTOBUF_ULONGLONG(0x97a87f4f261ba3f2),
+ PROTOBUF_ULONGLONG(0x342d0bbf48948200)),
+ c);
EXPECT_EQ(0, c - b * a);
EXPECT_EQ(a*a - b*b, (a+b) * (a-b));
}
@@ -355,10 +359,10 @@ TEST(Int128, DivideAndMod) {
EXPECT_EQ(0, q);
EXPECT_EQ(0, r);
- a = uint128(GOOGLE_ULONGLONG(0x530eda741c71d4c3),
- GOOGLE_ULONGLONG(0xbf25975319080000));
- q = uint128(GOOGLE_ULONGLONG(0x4de2cab081),
- GOOGLE_ULONGLONG(0x14c34ab4676e4bab));
+ a = uint128(PROTOBUF_ULONGLONG(0x530eda741c71d4c3),
+ PROTOBUF_ULONGLONG(0xbf25975319080000));
+ q = uint128(PROTOBUF_ULONGLONG(0x4de2cab081),
+ PROTOBUF_ULONGLONG(0x14c34ab4676e4bab));
b = uint128(0x1110001);
r = uint128(0x3eb455);
ASSERT_EQ(a, q * b + r); // Sanity-check.
@@ -396,8 +400,8 @@ TEST(Int128, DivideAndMod) {
// Try a large remainder.
b = a / 2 + 1;
- uint128 expected_r(GOOGLE_ULONGLONG(0x29876d3a0e38ea61),
- GOOGLE_ULONGLONG(0xdf92cba98c83ffff));
+ uint128 expected_r(PROTOBUF_ULONGLONG(0x29876d3a0e38ea61),
+ PROTOBUF_ULONGLONG(0xdf92cba98c83ffff));
// Sanity checks.
ASSERT_EQ(a / 2 - 1, expected_r);
ASSERT_EQ(a, b + expected_r);
@@ -455,50 +459,50 @@ TEST(Int128, OStream) {
char fill;
const char* rep;
} cases[] = {
- // zero with different bases
- {uint128(0), std::ios::dec, 0, '_', "0"},
- {uint128(0), std::ios::oct, 0, '_', "0"},
- {uint128(0), std::ios::hex, 0, '_', "0"},
- // crossover between lo_ and hi_
- {uint128(0, -1), std::ios::dec, 0, '_', "18446744073709551615"},
- {uint128(0, -1), std::ios::oct, 0, '_', "1777777777777777777777"},
- {uint128(0, -1), std::ios::hex, 0, '_', "ffffffffffffffff"},
- {uint128(1, 0), std::ios::dec, 0, '_', "18446744073709551616"},
- {uint128(1, 0), std::ios::oct, 0, '_', "2000000000000000000000"},
- {uint128(1, 0), std::ios::hex, 0, '_', "10000000000000000"},
- // just the top bit
- {uint128(GOOGLE_ULONGLONG(0x8000000000000000), 0), std::ios::dec, 0, '_',
- "170141183460469231731687303715884105728"},
- {uint128(GOOGLE_ULONGLONG(0x8000000000000000), 0), std::ios::oct, 0, '_',
- "2000000000000000000000000000000000000000000"},
- {uint128(GOOGLE_ULONGLONG(0x8000000000000000), 0), std::ios::hex, 0, '_',
- "80000000000000000000000000000000"},
- // maximum uint128 value
- {uint128(-1, -1), std::ios::dec, 0, '_',
- "340282366920938463463374607431768211455"},
- {uint128(-1, -1), std::ios::oct, 0, '_',
- "3777777777777777777777777777777777777777777"},
- {uint128(-1, -1), std::ios::hex, 0, '_',
- "ffffffffffffffffffffffffffffffff"},
- // uppercase
- {uint128(-1, -1), std::ios::hex | std::ios::uppercase, 0, '_',
- "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"},
- // showbase
- {uint128(1), std::ios::dec | std::ios::showbase, 0, '_', "1"},
- {uint128(1), std::ios::oct | std::ios::showbase, 0, '_', "01"},
- {uint128(1), std::ios::hex | std::ios::showbase, 0, '_', "0x1"},
- // showbase does nothing on zero
- {uint128(0), std::ios::dec | std::ios::showbase, 0, '_', "0"},
- {uint128(0), std::ios::oct | std::ios::showbase, 0, '_', "0"},
- {uint128(0), std::ios::hex | std::ios::showbase, 0, '_', "0"},
- // showpos does nothing on unsigned types
- {uint128(1), std::ios::dec | std::ios::showpos, 0, '_', "1"},
- // padding
- {uint128(9), std::ios::dec, 6, '_', "_____9"},
- {uint128(12345), std::ios::dec, 6, '_', "_12345"},
- // left adjustment
- {uint128(9), std::ios::dec | std::ios::left, 6, '_', "9_____"},
- {uint128(12345), std::ios::dec | std::ios::left, 6, '_', "12345_"},
+ // zero with different bases
+ {uint128(0), std::ios::dec, 0, '_', "0"},
+ {uint128(0), std::ios::oct, 0, '_', "0"},
+ {uint128(0), std::ios::hex, 0, '_', "0"},
+ // crossover between lo_ and hi_
+ {uint128(0, -1), std::ios::dec, 0, '_', "18446744073709551615"},
+ {uint128(0, -1), std::ios::oct, 0, '_', "1777777777777777777777"},
+ {uint128(0, -1), std::ios::hex, 0, '_', "ffffffffffffffff"},
+ {uint128(1, 0), std::ios::dec, 0, '_', "18446744073709551616"},
+ {uint128(1, 0), std::ios::oct, 0, '_', "2000000000000000000000"},
+ {uint128(1, 0), std::ios::hex, 0, '_', "10000000000000000"},
+ // just the top bit
+ {uint128(PROTOBUF_ULONGLONG(0x8000000000000000), 0), std::ios::dec, 0,
+ '_', "170141183460469231731687303715884105728"},
+ {uint128(PROTOBUF_ULONGLONG(0x8000000000000000), 0), std::ios::oct, 0,
+ '_', "2000000000000000000000000000000000000000000"},
+ {uint128(PROTOBUF_ULONGLONG(0x8000000000000000), 0), std::ios::hex, 0,
+ '_', "80000000000000000000000000000000"},
+ // maximum uint128 value
+ {uint128(-1, -1), std::ios::dec, 0, '_',
+ "340282366920938463463374607431768211455"},
+ {uint128(-1, -1), std::ios::oct, 0, '_',
+ "3777777777777777777777777777777777777777777"},
+ {uint128(-1, -1), std::ios::hex, 0, '_',
+ "ffffffffffffffffffffffffffffffff"},
+ // uppercase
+ {uint128(-1, -1), std::ios::hex | std::ios::uppercase, 0, '_',
+ "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"},
+ // showbase
+ {uint128(1), std::ios::dec | std::ios::showbase, 0, '_', "1"},
+ {uint128(1), std::ios::oct | std::ios::showbase, 0, '_', "01"},
+ {uint128(1), std::ios::hex | std::ios::showbase, 0, '_', "0x1"},
+ // showbase does nothing on zero
+ {uint128(0), std::ios::dec | std::ios::showbase, 0, '_', "0"},
+ {uint128(0), std::ios::oct | std::ios::showbase, 0, '_', "0"},
+ {uint128(0), std::ios::hex | std::ios::showbase, 0, '_', "0"},
+ // showpos does nothing on unsigned types
+ {uint128(1), std::ios::dec | std::ios::showpos, 0, '_', "1"},
+ // padding
+ {uint128(9), std::ios::dec, 6, '_', "_____9"},
+ {uint128(12345), std::ios::dec, 6, '_', "_12345"},
+ // left adjustment
+ {uint128(9), std::ios::dec | std::ios::left, 6, '_', "9_____"},
+ {uint128(12345), std::ios::dec | std::ios::left, 6, '_', "12345_"},
};
for (size_t i = 0; i < GOOGLE_ARRAYSIZE(cases); ++i) {
std::ostringstream os;
diff --git a/src/google/protobuf/stubs/io_win32.h b/src/google/protobuf/stubs/io_win32.h
index 9e17d253..afa5de35 100644
--- a/src/google/protobuf/stubs/io_win32.h
+++ b/src/google/protobuf/stubs/io_win32.h
@@ -50,6 +50,8 @@
#include <string>
#include <google/protobuf/stubs/port.h>
+#include <google/protobuf/port_def.inc>
+
// Compilers on Windows other than MSVC (e.g. Cygwin, MinGW32) define the
// following functions already, except for mkdir.
namespace google {
@@ -57,35 +59,34 @@ namespace protobuf {
namespace internal {
namespace win32 {
-LIBPROTOBUF_EXPORT FILE* fopen(const char* path, const char* mode);
-LIBPROTOBUF_EXPORT int access(const char* path, int mode);
-LIBPROTOBUF_EXPORT int chdir(const char* path);
-LIBPROTOBUF_EXPORT int close(int fd);
-LIBPROTOBUF_EXPORT int dup(int fd);
-LIBPROTOBUF_EXPORT int dup2(int fd1, int fd2);
-LIBPROTOBUF_EXPORT int mkdir(const char* path, int _mode);
-LIBPROTOBUF_EXPORT int open(const char* path, int flags, int mode = 0);
-LIBPROTOBUF_EXPORT int read(int fd, void* buffer, size_t size);
-LIBPROTOBUF_EXPORT int setmode(int fd, int mode);
-LIBPROTOBUF_EXPORT int stat(const char* path, struct _stat* buffer);
-LIBPROTOBUF_EXPORT int write(int fd, const void* buffer, size_t size);
-LIBPROTOBUF_EXPORT std::wstring testonly_utf8_to_winpath(const char* path);
+PROTOBUF_EXPORT FILE* fopen(const char* path, const char* mode);
+PROTOBUF_EXPORT int access(const char* path, int mode);
+PROTOBUF_EXPORT int chdir(const char* path);
+PROTOBUF_EXPORT int close(int fd);
+PROTOBUF_EXPORT int dup(int fd);
+PROTOBUF_EXPORT int dup2(int fd1, int fd2);
+PROTOBUF_EXPORT int mkdir(const char* path, int _mode);
+PROTOBUF_EXPORT int open(const char* path, int flags, int mode = 0);
+PROTOBUF_EXPORT int read(int fd, void* buffer, size_t size);
+PROTOBUF_EXPORT int setmode(int fd, int mode);
+PROTOBUF_EXPORT int stat(const char* path, struct _stat* buffer);
+PROTOBUF_EXPORT int write(int fd, const void* buffer, size_t size);
+PROTOBUF_EXPORT std::wstring testonly_utf8_to_winpath(const char* path);
namespace strings {
// Convert from UTF-16 to Active-Code-Page-encoded or to UTF-8-encoded text.
-LIBPROTOBUF_EXPORT bool wcs_to_mbs(
- const wchar_t* s, std::string* out, bool outUtf8);
+PROTOBUF_EXPORT bool wcs_to_mbs(const wchar_t* s, std::string* out,
+ bool outUtf8);
// Convert from Active-Code-Page-encoded or UTF-8-encoded text to UTF-16.
-LIBPROTOBUF_EXPORT bool mbs_to_wcs(
- const char* s, std::wstring* out, bool inUtf8);
+PROTOBUF_EXPORT bool mbs_to_wcs(const char* s, std::wstring* out, bool inUtf8);
// Convert from UTF-8-encoded text to UTF-16.
-LIBPROTOBUF_EXPORT bool utf8_to_wcs(const char* input, std::wstring* out);
+PROTOBUF_EXPORT bool utf8_to_wcs(const char* input, std::wstring* out);
// Convert from UTF-16-encoded text to UTF-8.
-LIBPROTOBUF_EXPORT bool wcs_to_utf8(const wchar_t* input, std::string* out);
+PROTOBUF_EXPORT bool wcs_to_utf8(const wchar_t* input, std::string* out);
} // namespace strings
@@ -112,4 +113,6 @@ LIBPROTOBUF_EXPORT bool wcs_to_utf8(const wchar_t* input, std::string* out);
#endif // defined(_WIN32)
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_STUBS_IO_WIN32_H__
diff --git a/src/google/protobuf/stubs/logging.h b/src/google/protobuf/stubs/logging.h
index f7c6d6a8..8d7e6401 100644
--- a/src/google/protobuf/stubs/logging.h
+++ b/src/google/protobuf/stubs/logging.h
@@ -34,6 +34,8 @@
#include <google/protobuf/stubs/macros.h>
#include <google/protobuf/stubs/port.h>
+#include <google/protobuf/port_def.inc>
+
// ===================================================================
// emulates google3/base/logging.h
@@ -70,7 +72,7 @@ namespace internal {
class LogFinisher;
-class LIBPROTOBUF_EXPORT LogMessage {
+class PROTOBUF_EXPORT LogMessage {
public:
LogMessage(LogLevel level, const char* filename, int line);
~LogMessage();
@@ -102,7 +104,7 @@ class LIBPROTOBUF_EXPORT LogMessage {
// Used to make the entire "LOG(BLAH) << etc." expression have a void return
// type and print a newline after each message.
-class LIBPROTOBUF_EXPORT LogFinisher {
+class PROTOBUF_EXPORT LogFinisher {
public:
void operator=(LogMessage& other);
};
@@ -216,7 +218,7 @@ typedef void LogHandler(LogLevel level, const char* filename, int line,
// have some code that tends to trigger them frequently and you know
// the warnings are not important to you), use the LogSilencer class
// below.
-LIBPROTOBUF_EXPORT LogHandler* SetLogHandler(LogHandler* new_func);
+PROTOBUF_EXPORT LogHandler* SetLogHandler(LogHandler* new_func);
// Create a LogSilencer if you want to temporarily suppress all log
// messages. As long as any LogSilencer objects exist, non-fatal
@@ -225,7 +227,7 @@ LIBPROTOBUF_EXPORT LogHandler* SetLogHandler(LogHandler* new_func);
// accidentally suppress log messages occurring in another thread, but
// since messages are generally for debugging purposes only, this isn't
// a big deal. If you want to intercept log messages, use SetLogHandler().
-class LIBPROTOBUF_EXPORT LogSilencer {
+class PROTOBUF_EXPORT LogSilencer {
public:
LogSilencer();
~LogSilencer();
@@ -234,4 +236,6 @@ class LIBPROTOBUF_EXPORT LogSilencer {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_STUBS_LOGGING_H_
diff --git a/src/google/protobuf/stubs/mathlimits.h b/src/google/protobuf/stubs/mathlimits.h
index 9c9d0e9a..e603947a 100644
--- a/src/google/protobuf/stubs/mathlimits.h
+++ b/src/google/protobuf/stubs/mathlimits.h
@@ -66,6 +66,8 @@
#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/port_def.inc>
+
// ========================================================================= //
// Useful integer and floating point limits and type traits.
@@ -173,43 +175,43 @@ template<typename T> struct MathLimits {
static bool IsPosInf(const Type /*x*/) { return false; } \
static bool IsNegInf(const Type /*x*/) { return false; }
-#define DECL_SIGNED_INT_LIMITS(IntType, UnsignedIntType) \
-template<> \
-struct LIBPROTOBUF_EXPORT MathLimits<IntType> { \
- typedef IntType Type; \
- typedef UnsignedIntType UnsignedType; \
- static const bool kIsSigned = true; \
- static const bool kIsInteger = true; \
- static const Type kPosMin = 1; \
- static const Type kPosMax = SIGNED_INT_MAX(Type); \
- static const Type kMin = SIGNED_INT_MIN(Type); \
- static const Type kMax = kPosMax; \
- static const Type kNegMin = -1; \
- static const Type kNegMax = kMin; \
- static const int kMin10Exp = 0; \
- static const int kMax10Exp = SIGNED_MAX_10_EXP(Type); \
- static const Type kEpsilon = 1; \
- static const Type kStdError = 0; \
- DECL_INT_LIMIT_FUNCS \
-};
+#define DECL_SIGNED_INT_LIMITS(IntType, UnsignedIntType) \
+ template <> \
+ struct PROTOBUF_EXPORT MathLimits<IntType> { \
+ typedef IntType Type; \
+ typedef UnsignedIntType UnsignedType; \
+ static const bool kIsSigned = true; \
+ static const bool kIsInteger = true; \
+ static const Type kPosMin = 1; \
+ static const Type kPosMax = SIGNED_INT_MAX(Type); \
+ static const Type kMin = SIGNED_INT_MIN(Type); \
+ static const Type kMax = kPosMax; \
+ static const Type kNegMin = -1; \
+ static const Type kNegMax = kMin; \
+ static const int kMin10Exp = 0; \
+ static const int kMax10Exp = SIGNED_MAX_10_EXP(Type); \
+ static const Type kEpsilon = 1; \
+ static const Type kStdError = 0; \
+ DECL_INT_LIMIT_FUNCS \
+ };
-#define DECL_UNSIGNED_INT_LIMITS(IntType) \
-template<> \
-struct LIBPROTOBUF_EXPORT MathLimits<IntType> { \
- typedef IntType Type; \
- typedef IntType UnsignedType; \
- static const bool kIsSigned = false; \
- static const bool kIsInteger = true; \
- static const Type kPosMin = 1; \
- static const Type kPosMax = UNSIGNED_INT_MAX(Type); \
- static const Type kMin = 0; \
- static const Type kMax = kPosMax; \
- static const int kMin10Exp = 0; \
- static const int kMax10Exp = UNSIGNED_MAX_10_EXP(Type); \
- static const Type kEpsilon = 1; \
- static const Type kStdError = 0; \
- DECL_INT_LIMIT_FUNCS \
-};
+#define DECL_UNSIGNED_INT_LIMITS(IntType) \
+ template <> \
+ struct PROTOBUF_EXPORT MathLimits<IntType> { \
+ typedef IntType Type; \
+ typedef IntType UnsignedType; \
+ static const bool kIsSigned = false; \
+ static const bool kIsInteger = true; \
+ static const Type kPosMin = 1; \
+ static const Type kPosMax = UNSIGNED_INT_MAX(Type); \
+ static const Type kMin = 0; \
+ static const Type kMax = kPosMax; \
+ static const int kMin10Exp = 0; \
+ static const int kMax10Exp = UNSIGNED_MAX_10_EXP(Type); \
+ static const Type kEpsilon = 1; \
+ static const Type kStdError = 0; \
+ DECL_INT_LIMIT_FUNCS \
+ };
DECL_SIGNED_INT_LIMITS(signed char, unsigned char)
DECL_SIGNED_INT_LIMITS(signed short int, unsigned short int)
@@ -263,29 +265,29 @@ DECL_UNSIGNED_INT_LIMITS(unsigned long long int)
// such constants are not considered to be primitive-type constants by gcc.
// CAVEAT: Hence, they are going to be initialized only during
// the global objects construction time.
-#define DECL_FP_LIMITS(FP_Type, PREFIX) \
-template<> \
-struct LIBPROTOBUF_EXPORT MathLimits<FP_Type> { \
- typedef FP_Type Type; \
- typedef FP_Type UnsignedType; \
- static const bool kIsSigned = true; \
- static const bool kIsInteger = false; \
- static const Type kPosMin; \
- static const Type kPosMax; \
- static const Type kMin; \
- static const Type kMax; \
- static const Type kNegMin; \
- static const Type kNegMax; \
- static const int kMin10Exp = PREFIX##_MIN_10_EXP; \
- static const int kMax10Exp = PREFIX##_MAX_10_EXP; \
- static const Type kEpsilon; \
- static const Type kStdError; \
- static const int kPrecisionDigits = PREFIX##_DIG; \
- static const Type kNaN; \
- static const Type kPosInf; \
- static const Type kNegInf; \
- DECL_FP_LIMIT_FUNCS \
-};
+#define DECL_FP_LIMITS(FP_Type, PREFIX) \
+ template <> \
+ struct PROTOBUF_EXPORT MathLimits<FP_Type> { \
+ typedef FP_Type Type; \
+ typedef FP_Type UnsignedType; \
+ static const bool kIsSigned = true; \
+ static const bool kIsInteger = false; \
+ static const Type kPosMin; \
+ static const Type kPosMax; \
+ static const Type kMin; \
+ static const Type kMax; \
+ static const Type kNegMin; \
+ static const Type kNegMax; \
+ static const int kMin10Exp = PREFIX##_MIN_10_EXP; \
+ static const int kMax10Exp = PREFIX##_MAX_10_EXP; \
+ static const Type kEpsilon; \
+ static const Type kStdError; \
+ static const int kPrecisionDigits = PREFIX##_DIG; \
+ static const Type kNaN; \
+ static const Type kPosInf; \
+ static const Type kNegInf; \
+ DECL_FP_LIMIT_FUNCS \
+ };
DECL_FP_LIMITS(float, FLT)
DECL_FP_LIMITS(double, DBL)
@@ -300,4 +302,6 @@ DECL_FP_LIMITS(long double, LDBL)
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // UTIL_MATH_MATHLIMITS_H__
diff --git a/src/google/protobuf/stubs/mutex.h b/src/google/protobuf/stubs/mutex.h
index 2b1aab87..8c997363 100644
--- a/src/google/protobuf/stubs/mutex.h
+++ b/src/google/protobuf/stubs/mutex.h
@@ -46,6 +46,8 @@
#define GOOGLE_PROTOBUF_RELEASE(...)
#endif
+#include <google/protobuf/port_def.inc>
+
// ===================================================================
// emulates google3/base/mutex.h
namespace google {
@@ -57,7 +59,7 @@ namespace internal {
// Mutex is a natural type to wrap. As both google and other organization have
// specialized mutexes. gRPC also provides an injection mechanism for custom
// mutexes.
-class LIBPROTOBUF_EXPORT WrappedMutex {
+class PROTOBUF_EXPORT WrappedMutex {
public:
WrappedMutex() = default;
void Lock() GOOGLE_PROTOBUF_ACQUIRE() { mu_.lock(); }
@@ -73,7 +75,7 @@ class LIBPROTOBUF_EXPORT WrappedMutex {
using Mutex = WrappedMutex;
// MutexLock(mu) acquires mu when constructed and releases it when destroyed.
-class LIBPROTOBUF_EXPORT MutexLock {
+class PROTOBUF_EXPORT MutexLock {
public:
explicit MutexLock(Mutex *mu) : mu_(mu) { this->mu_->Lock(); }
~MutexLock() { this->mu_->Unlock(); }
@@ -87,7 +89,7 @@ typedef MutexLock ReaderMutexLock;
typedef MutexLock WriterMutexLock;
// MutexLockMaybe is like MutexLock, but is a no-op when mu is nullptr.
-class LIBPROTOBUF_EXPORT MutexLockMaybe {
+class PROTOBUF_EXPORT MutexLockMaybe {
public:
explicit MutexLockMaybe(Mutex *mu) :
mu_(mu) { if (this->mu_ != nullptr) { this->mu_->Lock(); } }
@@ -141,4 +143,6 @@ using internal::MutexLockMaybe;
#undef GOOGLE_PROTOBUF_ACQUIRE
#undef GOOGLE_PROTOBUF_RELEASE
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_STUBS_MUTEX_H_
diff --git a/src/google/protobuf/stubs/port.h b/src/google/protobuf/stubs/port.h
index 4d3d0008..4884a277 100644
--- a/src/google/protobuf/stubs/port.h
+++ b/src/google/protobuf/stubs/port.h
@@ -46,6 +46,8 @@
#include <google/protobuf/stubs/platform_macros.h>
+#include <google/protobuf/port_def.inc>
+
#undef PROTOBUF_LITTLE_ENDIAN
#ifdef _WIN32
// Assuming windows is always little-endian.
@@ -72,6 +74,19 @@
#define PROTOBUF_LITTLE_ENDIAN 1
#endif
#endif
+
+// These #includes are for the byte swap functions declared later on.
+#ifdef _MSC_VER
+#include <stdlib.h> // NOLINT(build/include)
+#include <intrin.h>
+#elif defined(__APPLE__)
+#include <libkern/OSByteOrder.h>
+#elif defined(__GLIBC__) || defined(__BIONIC__) || defined(__CYGWIN__)
+#include <byteswap.h> // IWYU pragma: export
+#endif
+
+// Legacy: some users reference these (internal-only) macros even though we
+// don't need them any more.
#if defined(_MSC_VER) && defined(PROTOBUF_USE_DLLS)
#ifdef LIBPROTOBUF_EXPORTS
#define LIBPROTOBUF_EXPORT __declspec(dllexport)
@@ -88,16 +103,6 @@
#define LIBPROTOC_EXPORT
#endif
-// These #includes are for the byte swap functions declared later on.
-#ifdef _MSC_VER
-#include <stdlib.h> // NOLINT(build/include)
-#include <intrin.h>
-#elif defined(__APPLE__)
-#include <libkern/OSByteOrder.h>
-#elif defined(__GLIBC__) || defined(__BIONIC__) || defined(__CYGWIN__)
-#include <byteswap.h> // IWYU pragma: export
-#endif
-
#define PROTOBUF_RUNTIME_DEPRECATED(message)
#define GOOGLE_PROTOBUF_RUNTIME_DEPRECATED(message)
@@ -151,131 +156,12 @@ typedef uint32_t uint32;
typedef uint64_t uint64;
#endif
-// long long macros to be used because gcc and vc++ use different suffixes,
-// and different size specifiers in format strings
-#undef GOOGLE_LONGLONG
-#undef GOOGLE_ULONGLONG
-#undef GOOGLE_LL_FORMAT
-
-#ifdef _MSC_VER
-#define GOOGLE_LONGLONG(x) x##I64
-#define GOOGLE_ULONGLONG(x) x##UI64
-#define GOOGLE_LL_FORMAT "I64" // As in printf("%I64d", ...)
-#else
-// By long long, we actually mean int64.
-#define GOOGLE_LONGLONG(x) x##LL
-#define GOOGLE_ULONGLONG(x) x##ULL
-// Used to format real long long integers.
-#define GOOGLE_LL_FORMAT "ll" // As in "%lld". Note that "q" is poor form also.
-#endif
-
static const int32 kint32max = 0x7FFFFFFF;
static const int32 kint32min = -kint32max - 1;
-static const int64 kint64max = GOOGLE_LONGLONG(0x7FFFFFFFFFFFFFFF);
+static const int64 kint64max = PROTOBUF_LONGLONG(0x7FFFFFFFFFFFFFFF);
static const int64 kint64min = -kint64max - 1;
static const uint32 kuint32max = 0xFFFFFFFFu;
-static const uint64 kuint64max = GOOGLE_ULONGLONG(0xFFFFFFFFFFFFFFFF);
-
-#define GOOGLE_PROTOBUF_NAMESPACE "google::protobuf"
-#define GOOGLE_PROTOBUF_NAMESPACE_ID google::protobuf
-
-// -------------------------------------------------------------------
-// Annotations: Some parts of the code have been annotated in ways that might
-// be useful to some compilers or tools, but are not supported universally.
-// You can #define these annotations yourself if the default implementation
-// is not right for you.
-
-#ifndef GOOGLE_ATTRIBUTE_ALWAYS_INLINE
-#if defined(__GNUC__) && (__GNUC__ > 3 ||(__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
-// For functions we want to force inline.
-// Introduced in gcc 3.1.
-#define GOOGLE_ATTRIBUTE_ALWAYS_INLINE __attribute__ ((always_inline))
-#else
-// Other compilers will have to figure it out for themselves.
-#define GOOGLE_ATTRIBUTE_ALWAYS_INLINE
-#endif
-#endif
-
-#define GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE GOOGLE_ATTRIBUTE_ALWAYS_INLINE
-
-#ifndef GOOGLE_ATTRIBUTE_NOINLINE
-#if defined(__GNUC__) && (__GNUC__ > 3 ||(__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
-// For functions we want to force not inline.
-// Introduced in gcc 3.1.
-#define GOOGLE_ATTRIBUTE_NOINLINE __attribute__ ((noinline))
-#elif defined(_MSC_VER) && (_MSC_VER >= 1400)
-// Seems to have been around since at least Visual Studio 2005
-#define GOOGLE_ATTRIBUTE_NOINLINE __declspec(noinline)
-#else
-// Other compilers will have to figure it out for themselves.
-#define GOOGLE_ATTRIBUTE_NOINLINE
-#endif
-#endif
-
-#define GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE GOOGLE_ATTRIBUTE_NOINLINE
-
-#ifndef GOOGLE_ATTRIBUTE_FUNC_ALIGN
-#if defined(__clang__) || \
- defined(__GNUC__) && (__GNUC__ > 4 ||(__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
-// Function alignment attribute introduced in gcc 4.3
-#define GOOGLE_ATTRIBUTE_FUNC_ALIGN(bytes) __attribute__ ((aligned(bytes)))
-#else
-#define GOOGLE_ATTRIBUTE_FUNC_ALIGN(bytes)
-#endif
-#endif
-
-#define GOOGLE_PROTOBUF_ATTRIBUTE_FUNC_ALIGN(bytes) \
- GOOGLE_ATTRIBUTE_FUNC_ALIGN(bytes)
-
-#ifndef GOOGLE_PREDICT_TRUE
-#ifdef __GNUC__
-// Provided at least since GCC 3.0.
-#define GOOGLE_PREDICT_TRUE(x) (__builtin_expect(!!(x), 1))
-#else
-#define GOOGLE_PREDICT_TRUE(x) (x)
-#endif
-#endif
-
-#ifndef GOOGLE_PREDICT_FALSE
-#ifdef __GNUC__
-// Provided at least since GCC 3.0.
-#define GOOGLE_PREDICT_FALSE(x) (__builtin_expect(x, 0))
-#else
-#define GOOGLE_PREDICT_FALSE(x) (x)
-#endif
-#endif
-
-#ifndef GOOGLE_PROTOBUF_ATTRIBUTE_RETURNS_NONNULL
-#ifdef __GNUC__
-#define GOOGLE_PROTOBUF_ATTRIBUTE_RETURNS_NONNULL \
- __attribute__((returns_nonnull))
-#endif
-#endif
-
-// Delimits a block of code which may write to memory which is simultaneously
-// written by other threads, but which has been determined to be thread-safe
-// (e.g. because it is an idempotent write).
-#ifndef GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN
-#define GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN()
-#endif
-#ifndef GOOGLE_SAFE_CONCURRENT_WRITES_END
-#define GOOGLE_SAFE_CONCURRENT_WRITES_END()
-#endif
-
-#define GOOGLE_GUARDED_BY(x)
-#define GOOGLE_ATTRIBUTE_COLD
-
-#ifdef GOOGLE_PROTOBUF_DONT_USE_UNALIGNED
-# define GOOGLE_PROTOBUF_USE_UNALIGNED 0
-#else
-# if defined(_M_X64) || defined(__x86_64__) || defined(_M_IX86) || defined(__i386__)
-# define GOOGLE_PROTOBUF_USE_UNALIGNED 1
-# else
-# define GOOGLE_PROTOBUF_USE_UNALIGNED 0
-# endif
-#endif
-
-#define GOOGLE_PROTOBUF_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_COLD
+static const uint64 kuint64max = PROTOBUF_ULONGLONG(0xFFFFFFFFFFFFFFFF);
#if defined(ADDRESS_SANITIZER) || defined(THREAD_SANITIZER) ||\
defined(MEMORY_SANITIZER)
@@ -405,14 +291,14 @@ static inline uint32 bswap_32(uint32 x) {
#ifndef bswap_64
static inline uint64 bswap_64(uint64 x) {
- return (((x & GOOGLE_ULONGLONG(0xFF)) << 56) |
- ((x & GOOGLE_ULONGLONG(0xFF00)) << 40) |
- ((x & GOOGLE_ULONGLONG(0xFF0000)) << 24) |
- ((x & GOOGLE_ULONGLONG(0xFF000000)) << 8) |
- ((x & GOOGLE_ULONGLONG(0xFF00000000)) >> 8) |
- ((x & GOOGLE_ULONGLONG(0xFF0000000000)) >> 24) |
- ((x & GOOGLE_ULONGLONG(0xFF000000000000)) >> 40) |
- ((x & GOOGLE_ULONGLONG(0xFF00000000000000)) >> 56));
+ return (((x & PROTOBUF_ULONGLONG(0xFF)) << 56) |
+ ((x & PROTOBUF_ULONGLONG(0xFF00)) << 40) |
+ ((x & PROTOBUF_ULONGLONG(0xFF0000)) << 24) |
+ ((x & PROTOBUF_ULONGLONG(0xFF000000)) << 8) |
+ ((x & PROTOBUF_ULONGLONG(0xFF00000000)) >> 8) |
+ ((x & PROTOBUF_ULONGLONG(0xFF0000000000)) >> 24) |
+ ((x & PROTOBUF_ULONGLONG(0xFF000000000000)) >> 40) |
+ ((x & PROTOBUF_ULONGLONG(0xFF00000000000000)) >> 56));
}
#define bswap_64(x) bswap_64(x)
#endif
@@ -484,7 +370,7 @@ class Bits {
// ===================================================================
// from google3/util/endian/endian.h
-LIBPROTOBUF_EXPORT uint32 ghtonl(uint32 x);
+PROTOBUF_EXPORT uint32 ghtonl(uint32 x);
class BigEndian {
public:
@@ -542,13 +428,11 @@ class BigEndian {
}
};
-#ifndef GOOGLE_ATTRIBUTE_SECTION_VARIABLE
-#define GOOGLE_ATTRIBUTE_SECTION_VARIABLE(name)
-#endif
-
-#define GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(name)
-
} // namespace protobuf
} // namespace google
+#define GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER 0
+
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_STUBS_PORT_H_
diff --git a/src/google/protobuf/stubs/status.h b/src/google/protobuf/stubs/status.h
index c5d38f0b..008416ef 100644
--- a/src/google/protobuf/stubs/status.h
+++ b/src/google/protobuf/stubs/status.h
@@ -36,6 +36,8 @@
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/stringpiece.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace util {
@@ -62,7 +64,7 @@ enum Code {
};
} // namespace error
-class LIBPROTOBUF_EXPORT Status {
+class PROTOBUF_EXPORT Status {
public:
// Creates a "successful" status.
Status();
@@ -106,11 +108,14 @@ class LIBPROTOBUF_EXPORT Status {
};
// Prints a human-readable representation of 'x' to 'os'.
-LIBPROTOBUF_EXPORT std::ostream& operator<<(std::ostream& os, const Status& x);
+PROTOBUF_EXPORT std::ostream& operator<<(std::ostream& os, const Status& x);
#define EXPECT_OK(value) EXPECT_TRUE((value).ok())
} // namespace util
} // namespace protobuf
} // namespace google
+
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_STUBS_STATUS_H_
diff --git a/src/google/protobuf/stubs/status_macros.h b/src/google/protobuf/stubs/status_macros.h
index 743e79a7..b3af0dcd 100644
--- a/src/google/protobuf/stubs/status_macros.h
+++ b/src/google/protobuf/stubs/status_macros.h
@@ -46,11 +46,11 @@ namespace util {
//
// Example:
// RETURN_IF_ERROR(DoThings(4));
-#define RETURN_IF_ERROR(expr) \
- do { \
+#define RETURN_IF_ERROR(expr) \
+ do { \
/* Using _status below to avoid capture problems if expr is "status". */ \
- const ::google::protobuf::util::Status _status = (expr); \
- if (GOOGLE_PREDICT_FALSE(!_status.ok())) return _status; \
+ const ::google::protobuf::util::Status _status = (expr); \
+ if (PROTOBUF_PREDICT_FALSE(!_status.ok())) return _status; \
} while (0)
// Internal helper for concatenating macro values.
@@ -67,7 +67,7 @@ Status DoAssignOrReturn(T& lhs, StatusOr<T> result) {
#define ASSIGN_OR_RETURN_IMPL(status, lhs, rexpr) \
Status status = DoAssignOrReturn(lhs, (rexpr)); \
- if (GOOGLE_PREDICT_FALSE(!status.ok())) return status;
+ if (PROTOBUF_PREDICT_FALSE(!status.ok())) return status;
// Executes an expression that returns a util::StatusOr, extracting its value
// into the variable defined by lhs (or returning on error).
diff --git a/src/google/protobuf/stubs/statusor.h b/src/google/protobuf/stubs/statusor.h
index b1c1e6b4..90fd5f0d 100644
--- a/src/google/protobuf/stubs/statusor.h
+++ b/src/google/protobuf/stubs/statusor.h
@@ -89,6 +89,8 @@
#include <google/protobuf/stubs/status.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace util {
@@ -162,7 +164,7 @@ class StatusOr {
namespace internal {
-class LIBPROTOBUF_EXPORT StatusOrHelper {
+class PROTOBUF_EXPORT StatusOrHelper {
public:
// Move type-agnostic error handling to the .cc.
static void Crash(const util::Status& status);
@@ -256,4 +258,6 @@ inline const T& StatusOr<T>::ValueOrDie() const {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_STUBS_STATUSOR_H_
diff --git a/src/google/protobuf/stubs/stringpiece.h b/src/google/protobuf/stubs/stringpiece.h
index 6ab985cc..bb5aeed9 100644
--- a/src/google/protobuf/stubs/stringpiece.h
+++ b/src/google/protobuf/stubs/stringpiece.h
@@ -151,6 +151,8 @@
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/hash.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
// StringPiece has *two* size types.
@@ -175,7 +177,7 @@ typedef string::difference_type stringpiece_ssize_type;
#define STRINGPIECE_CHECK_SIZE 0
#endif
-class LIBPROTOBUF_EXPORT StringPiece {
+class PROTOBUF_EXPORT StringPiece {
private:
const char* ptr_;
stringpiece_ssize_type length_;
@@ -487,4 +489,6 @@ template<> struct hash<StringPiece> {
};
GOOGLE_PROTOBUF_HASH_NAMESPACE_DECLARATION_END
+#include <google/protobuf/port_undef.inc>
+
#endif // STRINGS_STRINGPIECE_H_
diff --git a/src/google/protobuf/stubs/stringprintf.h b/src/google/protobuf/stubs/stringprintf.h
index 7183ec6a..253d736a 100644
--- a/src/google/protobuf/stubs/stringprintf.h
+++ b/src/google/protobuf/stubs/stringprintf.h
@@ -46,31 +46,38 @@
#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
// Return a C++ string
-LIBPROTOBUF_EXPORT extern string StringPrintf(const char* format, ...);
+PROTOBUF_EXPORT extern string StringPrintf(const char* format, ...);
// Store result into a supplied string and return it
-LIBPROTOBUF_EXPORT extern const string& SStringPrintf(string* dst, const char* format, ...);
+PROTOBUF_EXPORT extern const string& SStringPrintf(string* dst,
+ const char* format, ...);
// Append result to a supplied string
-LIBPROTOBUF_EXPORT extern void StringAppendF(string* dst, const char* format, ...);
+PROTOBUF_EXPORT extern void StringAppendF(string* dst, const char* format, ...);
// Lower-level routine that takes a va_list and appends to a specified
// string. All other routines are just convenience wrappers around it.
-LIBPROTOBUF_EXPORT extern void StringAppendV(string* dst, const char* format, va_list ap);
+PROTOBUF_EXPORT extern void StringAppendV(string* dst, const char* format,
+ va_list ap);
// The max arguments supported by StringPrintfVector
-LIBPROTOBUF_EXPORT extern const int kStringPrintfVectorMaxArgs;
+PROTOBUF_EXPORT extern const int kStringPrintfVectorMaxArgs;
// You can use this version when all your arguments are strings, but
// you don't know how many arguments you'll have at compile time.
// StringPrintfVector will LOG(FATAL) if v.size() > kStringPrintfVectorMaxArgs
-LIBPROTOBUF_EXPORT extern string StringPrintfVector(const char* format, const std::vector<string>& v);
+PROTOBUF_EXPORT extern string StringPrintfVector(const char* format,
+ const std::vector<string>& v);
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_STUBS_STRINGPRINTF_H
diff --git a/src/google/protobuf/stubs/strutil.h b/src/google/protobuf/stubs/strutil.h
index ec5512d6..e567ba7f 100644
--- a/src/google/protobuf/stubs/strutil.h
+++ b/src/google/protobuf/stubs/strutil.h
@@ -38,6 +38,8 @@
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/stringpiece.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
@@ -155,13 +157,12 @@ inline string StripSuffixString(const string& str, const string& suffix) {
// StripWhitespace
// Removes whitespaces from both ends of the given string.
// ----------------------------------------------------------------------
-LIBPROTOBUF_EXPORT void ReplaceCharacters(string* s, const char* remove,
- char replacewith);
-LIBPROTOBUF_EXPORT void StripString(string* s, const char* remove,
- char replacewith);
-
-LIBPROTOBUF_EXPORT void StripWhitespace(string* s);
+PROTOBUF_EXPORT void ReplaceCharacters(string* s, const char* remove,
+ char replacewith);
+PROTOBUF_EXPORT void StripString(string* s, const char* remove,
+ char replacewith);
+PROTOBUF_EXPORT void StripWhitespace(string* s);
// ----------------------------------------------------------------------
// LowerString()
@@ -203,8 +204,8 @@ inline string ToUpper(const string& s) {
// happened or not.
// ----------------------------------------------------------------------
-LIBPROTOBUF_EXPORT string StringReplace(const string& s, const string& oldsub,
- const string& newsub, bool replace_all);
+PROTOBUF_EXPORT string StringReplace(const string& s, const string& oldsub,
+ const string& newsub, bool replace_all);
// ----------------------------------------------------------------------
// SplitStringUsing()
@@ -212,8 +213,8 @@ LIBPROTOBUF_EXPORT string StringReplace(const string& s, const string& oldsub,
// to 'result'. If there are consecutive delimiters, this function skips
// over all of them.
// ----------------------------------------------------------------------
-LIBPROTOBUF_EXPORT void SplitStringUsing(const string& full, const char* delim,
- std::vector<string>* res);
+PROTOBUF_EXPORT void SplitStringUsing(const string& full, const char* delim,
+ std::vector<string>* res);
// Split a string using one or more byte delimiters, presented
// as a nul-terminated c string. Append the components to 'result'.
@@ -223,9 +224,9 @@ LIBPROTOBUF_EXPORT void SplitStringUsing(const string& full, const char* delim,
//
// If "full" is the empty string, yields an empty string as the only value.
// ----------------------------------------------------------------------
-LIBPROTOBUF_EXPORT void SplitStringAllowEmpty(const string& full,
- const char* delim,
- std::vector<string>* result);
+PROTOBUF_EXPORT void SplitStringAllowEmpty(const string& full,
+ const char* delim,
+ std::vector<string>* result);
// ----------------------------------------------------------------------
// Split()
@@ -250,8 +251,8 @@ inline std::vector<string> Split(
// another takes a pointer to the target string. In the latter case the
// target string is cleared and overwritten.
// ----------------------------------------------------------------------
-LIBPROTOBUF_EXPORT void JoinStrings(const std::vector<string>& components,
- const char* delim, string* result);
+PROTOBUF_EXPORT void JoinStrings(const std::vector<string>& components,
+ const char* delim, string* result);
inline string JoinStrings(const std::vector<string>& components,
const char* delim) {
@@ -291,9 +292,9 @@ inline string JoinStrings(const std::vector<string>& components,
// processed.
// ----------------------------------------------------------------------
-LIBPROTOBUF_EXPORT int UnescapeCEscapeSequences(const char* source, char* dest);
-LIBPROTOBUF_EXPORT int UnescapeCEscapeSequences(const char* source, char* dest,
- std::vector<string> *errors);
+PROTOBUF_EXPORT int UnescapeCEscapeSequences(const char* source, char* dest);
+PROTOBUF_EXPORT int UnescapeCEscapeSequences(const char* source, char* dest,
+ std::vector<string>* errors);
// ----------------------------------------------------------------------
// UnescapeCEscapeString()
@@ -310,10 +311,10 @@ LIBPROTOBUF_EXPORT int UnescapeCEscapeSequences(const char* source, char* dest,
// the third call, the new string is returned.
// ----------------------------------------------------------------------
-LIBPROTOBUF_EXPORT int UnescapeCEscapeString(const string& src, string* dest);
-LIBPROTOBUF_EXPORT int UnescapeCEscapeString(const string& src, string* dest,
- std::vector<string> *errors);
-LIBPROTOBUF_EXPORT string UnescapeCEscapeString(const string& src);
+PROTOBUF_EXPORT int UnescapeCEscapeString(const string& src, string* dest);
+PROTOBUF_EXPORT int UnescapeCEscapeString(const string& src, string* dest,
+ std::vector<string>* errors);
+PROTOBUF_EXPORT string UnescapeCEscapeString(const string& src);
// ----------------------------------------------------------------------
// CEscape()
@@ -322,21 +323,21 @@ LIBPROTOBUF_EXPORT string UnescapeCEscapeString(const string& src);
//
// Escaped chars: \n, \r, \t, ", ', \, and !isprint().
// ----------------------------------------------------------------------
-LIBPROTOBUF_EXPORT string CEscape(const string& src);
+PROTOBUF_EXPORT string CEscape(const string& src);
// ----------------------------------------------------------------------
// CEscapeAndAppend()
// Escapes 'src' using C-style escape sequences, and appends the escaped
// string to 'dest'.
// ----------------------------------------------------------------------
-LIBPROTOBUF_EXPORT void CEscapeAndAppend(StringPiece src, string* dest);
+PROTOBUF_EXPORT void CEscapeAndAppend(StringPiece src, string* dest);
namespace strings {
// Like CEscape() but does not escape bytes with the upper bit set.
-LIBPROTOBUF_EXPORT string Utf8SafeCEscape(const string& src);
+PROTOBUF_EXPORT string Utf8SafeCEscape(const string& src);
// Like CEscape() but uses hex (\x) escapes instead of octals.
-LIBPROTOBUF_EXPORT string CHexEscape(const string& src);
+PROTOBUF_EXPORT string CHexEscape(const string& src);
} // namespace strings
// ----------------------------------------------------------------------
@@ -349,10 +350,10 @@ LIBPROTOBUF_EXPORT string CHexEscape(const string& src);
// platforms, so using these is safer, from the point of view of
// overflow behavior, than using the standard libc functions.
// ----------------------------------------------------------------------
-LIBPROTOBUF_EXPORT int32 strto32_adaptor(const char *nptr, char **endptr,
- int base);
-LIBPROTOBUF_EXPORT uint32 strtou32_adaptor(const char *nptr, char **endptr,
- int base);
+PROTOBUF_EXPORT int32 strto32_adaptor(const char* nptr, char** endptr,
+ int base);
+PROTOBUF_EXPORT uint32 strtou32_adaptor(const char* nptr, char** endptr,
+ int base);
inline int32 strto32(const char *nptr, char **endptr, int base) {
if (sizeof(int32) == sizeof(long))
@@ -391,10 +392,10 @@ inline uint64 strtou64(const char *nptr, char **endptr, int base) {
// safe_strtof()
// safe_strtod()
// ----------------------------------------------------------------------
-LIBPROTOBUF_EXPORT bool safe_strtob(StringPiece str, bool* value);
+PROTOBUF_EXPORT bool safe_strtob(StringPiece str, bool* value);
-LIBPROTOBUF_EXPORT bool safe_strto32(const string& str, int32* value);
-LIBPROTOBUF_EXPORT bool safe_strtou32(const string& str, uint32* value);
+PROTOBUF_EXPORT bool safe_strto32(const string& str, int32* value);
+PROTOBUF_EXPORT bool safe_strtou32(const string& str, uint32* value);
inline bool safe_strto32(const char* str, int32* value) {
return safe_strto32(string(str), value);
}
@@ -408,8 +409,8 @@ inline bool safe_strtou32(StringPiece str, uint32* value) {
return safe_strtou32(str.ToString(), value);
}
-LIBPROTOBUF_EXPORT bool safe_strto64(const string& str, int64* value);
-LIBPROTOBUF_EXPORT bool safe_strtou64(const string& str, uint64* value);
+PROTOBUF_EXPORT bool safe_strto64(const string& str, int64* value);
+PROTOBUF_EXPORT bool safe_strtou64(const string& str, uint64* value);
inline bool safe_strto64(const char* str, int64* value) {
return safe_strto64(string(str), value);
}
@@ -423,8 +424,8 @@ inline bool safe_strtou64(StringPiece str, uint64* value) {
return safe_strtou64(str.ToString(), value);
}
-LIBPROTOBUF_EXPORT bool safe_strtof(const char* str, float* value);
-LIBPROTOBUF_EXPORT bool safe_strtod(const char* str, double* value);
+PROTOBUF_EXPORT bool safe_strtof(const char* str, float* value);
+PROTOBUF_EXPORT bool safe_strtod(const char* str, double* value);
inline bool safe_strtof(const string& str, float* value) {
return safe_strtof(str.c_str(), value);
}
@@ -464,13 +465,13 @@ inline bool safe_strtod(StringPiece str, double* value) {
// DoubleToBuffer() and FloatToBuffer().
static const int kFastToBufferSize = 32;
-LIBPROTOBUF_EXPORT char* FastInt32ToBuffer(int32 i, char* buffer);
-LIBPROTOBUF_EXPORT char* FastInt64ToBuffer(int64 i, char* buffer);
+PROTOBUF_EXPORT char* FastInt32ToBuffer(int32 i, char* buffer);
+PROTOBUF_EXPORT char* FastInt64ToBuffer(int64 i, char* buffer);
char* FastUInt32ToBuffer(uint32 i, char* buffer); // inline below
char* FastUInt64ToBuffer(uint64 i, char* buffer); // inline below
-LIBPROTOBUF_EXPORT char* FastHexToBuffer(int i, char* buffer);
-LIBPROTOBUF_EXPORT char* FastHex64ToBuffer(uint64 i, char* buffer);
-LIBPROTOBUF_EXPORT char* FastHex32ToBuffer(uint32 i, char* buffer);
+PROTOBUF_EXPORT char* FastHexToBuffer(int i, char* buffer);
+PROTOBUF_EXPORT char* FastHex64ToBuffer(uint64 i, char* buffer);
+PROTOBUF_EXPORT char* FastHex32ToBuffer(uint32 i, char* buffer);
// at least 22 bytes long
inline char* FastIntToBuffer(int i, char* buffer) {
@@ -506,10 +507,10 @@ inline char* FastULongToBuffer(unsigned long i, char* buffer) {
// terminating the string).
// ----------------------------------------------------------------------
-LIBPROTOBUF_EXPORT char* FastInt32ToBufferLeft(int32 i, char* buffer);
-LIBPROTOBUF_EXPORT char* FastUInt32ToBufferLeft(uint32 i, char* buffer);
-LIBPROTOBUF_EXPORT char* FastInt64ToBufferLeft(int64 i, char* buffer);
-LIBPROTOBUF_EXPORT char* FastUInt64ToBufferLeft(uint64 i, char* buffer);
+PROTOBUF_EXPORT char* FastInt32ToBufferLeft(int32 i, char* buffer);
+PROTOBUF_EXPORT char* FastUInt32ToBufferLeft(uint32 i, char* buffer);
+PROTOBUF_EXPORT char* FastInt64ToBufferLeft(int64 i, char* buffer);
+PROTOBUF_EXPORT char* FastUInt64ToBufferLeft(uint64 i, char* buffer);
// Just define these in terms of the above.
inline char* FastUInt32ToBuffer(uint32 i, char* buffer) {
@@ -531,12 +532,12 @@ inline string SimpleBtoa(bool value) {
//
// Return value: string
// ----------------------------------------------------------------------
-LIBPROTOBUF_EXPORT string SimpleItoa(int i);
-LIBPROTOBUF_EXPORT string SimpleItoa(unsigned int i);
-LIBPROTOBUF_EXPORT string SimpleItoa(long i);
-LIBPROTOBUF_EXPORT string SimpleItoa(unsigned long i);
-LIBPROTOBUF_EXPORT string SimpleItoa(long long i);
-LIBPROTOBUF_EXPORT string SimpleItoa(unsigned long long i);
+PROTOBUF_EXPORT string SimpleItoa(int i);
+PROTOBUF_EXPORT string SimpleItoa(unsigned int i);
+PROTOBUF_EXPORT string SimpleItoa(long i);
+PROTOBUF_EXPORT string SimpleItoa(unsigned long i);
+PROTOBUF_EXPORT string SimpleItoa(long long i);
+PROTOBUF_EXPORT string SimpleItoa(unsigned long long i);
// ----------------------------------------------------------------------
// SimpleDtoa()
@@ -557,11 +558,11 @@ LIBPROTOBUF_EXPORT string SimpleItoa(unsigned long long i);
//
// Return value: string
// ----------------------------------------------------------------------
-LIBPROTOBUF_EXPORT string SimpleDtoa(double value);
-LIBPROTOBUF_EXPORT string SimpleFtoa(float value);
+PROTOBUF_EXPORT string SimpleDtoa(double value);
+PROTOBUF_EXPORT string SimpleFtoa(float value);
-LIBPROTOBUF_EXPORT char* DoubleToBuffer(double i, char* buffer);
-LIBPROTOBUF_EXPORT char* FloatToBuffer(float i, char* buffer);
+PROTOBUF_EXPORT char* DoubleToBuffer(double i, char* buffer);
+PROTOBUF_EXPORT char* FloatToBuffer(float i, char* buffer);
// In practice, doubles should never need more than 24 bytes and floats
// should never need more than 14 (including null terminators), but we
@@ -610,7 +611,7 @@ struct Hex {
}
};
-struct LIBPROTOBUF_EXPORT AlphaNum {
+struct PROTOBUF_EXPORT AlphaNum {
const char *piece_data_; // move these to string_ref eventually
size_t piece_size_; // move these to string_ref eventually
@@ -692,30 +693,30 @@ using strings::AlphaNum;
// be a reference into str.
// ----------------------------------------------------------------------
-LIBPROTOBUF_EXPORT string StrCat(const AlphaNum& a, const AlphaNum& b);
-LIBPROTOBUF_EXPORT string StrCat(const AlphaNum& a, const AlphaNum& b,
- const AlphaNum& c);
-LIBPROTOBUF_EXPORT string StrCat(const AlphaNum& a, const AlphaNum& b,
- const AlphaNum& c, const AlphaNum& d);
-LIBPROTOBUF_EXPORT string StrCat(const AlphaNum& a, const AlphaNum& b,
- const AlphaNum& c, const AlphaNum& d,
- const AlphaNum& e);
-LIBPROTOBUF_EXPORT string StrCat(const AlphaNum& a, const AlphaNum& b,
- const AlphaNum& c, const AlphaNum& d,
- const AlphaNum& e, const AlphaNum& f);
-LIBPROTOBUF_EXPORT string StrCat(const AlphaNum& a, const AlphaNum& b,
- const AlphaNum& c, const AlphaNum& d,
- const AlphaNum& e, const AlphaNum& f,
- const AlphaNum& g);
-LIBPROTOBUF_EXPORT string StrCat(const AlphaNum& a, const AlphaNum& b,
- const AlphaNum& c, const AlphaNum& d,
- const AlphaNum& e, const AlphaNum& f,
- const AlphaNum& g, const AlphaNum& h);
-LIBPROTOBUF_EXPORT string StrCat(const AlphaNum& a, const AlphaNum& b,
- const AlphaNum& c, const AlphaNum& d,
- const AlphaNum& e, const AlphaNum& f,
- const AlphaNum& g, const AlphaNum& h,
- const AlphaNum& i);
+PROTOBUF_EXPORT string StrCat(const AlphaNum& a, const AlphaNum& b);
+PROTOBUF_EXPORT string StrCat(const AlphaNum& a, const AlphaNum& b,
+ const AlphaNum& c);
+PROTOBUF_EXPORT string StrCat(const AlphaNum& a, const AlphaNum& b,
+ const AlphaNum& c, const AlphaNum& d);
+PROTOBUF_EXPORT string StrCat(const AlphaNum& a, const AlphaNum& b,
+ const AlphaNum& c, const AlphaNum& d,
+ const AlphaNum& e);
+PROTOBUF_EXPORT string StrCat(const AlphaNum& a, const AlphaNum& b,
+ const AlphaNum& c, const AlphaNum& d,
+ const AlphaNum& e, const AlphaNum& f);
+PROTOBUF_EXPORT string StrCat(const AlphaNum& a, const AlphaNum& b,
+ const AlphaNum& c, const AlphaNum& d,
+ const AlphaNum& e, const AlphaNum& f,
+ const AlphaNum& g);
+PROTOBUF_EXPORT string StrCat(const AlphaNum& a, const AlphaNum& b,
+ const AlphaNum& c, const AlphaNum& d,
+ const AlphaNum& e, const AlphaNum& f,
+ const AlphaNum& g, const AlphaNum& h);
+PROTOBUF_EXPORT string StrCat(const AlphaNum& a, const AlphaNum& b,
+ const AlphaNum& c, const AlphaNum& d,
+ const AlphaNum& e, const AlphaNum& f,
+ const AlphaNum& g, const AlphaNum& h,
+ const AlphaNum& i);
inline string StrCat(const AlphaNum& a) { return string(a.data(), a.size()); }
@@ -740,14 +741,14 @@ inline string StrCat(const AlphaNum& a) { return string(a.data(), a.size()); }
// worked around as consecutive calls to StrAppend are quite efficient.
// ----------------------------------------------------------------------
-LIBPROTOBUF_EXPORT void StrAppend(string* dest, const AlphaNum& a);
-LIBPROTOBUF_EXPORT void StrAppend(string* dest, const AlphaNum& a,
- const AlphaNum& b);
-LIBPROTOBUF_EXPORT void StrAppend(string* dest, const AlphaNum& a,
- const AlphaNum& b, const AlphaNum& c);
-LIBPROTOBUF_EXPORT void StrAppend(string* dest, const AlphaNum& a,
- const AlphaNum& b, const AlphaNum& c,
- const AlphaNum& d);
+PROTOBUF_EXPORT void StrAppend(string* dest, const AlphaNum& a);
+PROTOBUF_EXPORT void StrAppend(string* dest, const AlphaNum& a,
+ const AlphaNum& b);
+PROTOBUF_EXPORT void StrAppend(string* dest, const AlphaNum& a,
+ const AlphaNum& b, const AlphaNum& c);
+PROTOBUF_EXPORT void StrAppend(string* dest, const AlphaNum& a,
+ const AlphaNum& b, const AlphaNum& c,
+ const AlphaNum& d);
// ----------------------------------------------------------------------
// Join()
@@ -777,7 +778,7 @@ string Join(const Range& components,
// ToHex()
// Return a lower-case hex string representation of the given integer.
// ----------------------------------------------------------------------
-LIBPROTOBUF_EXPORT string ToHex(uint64 num);
+PROTOBUF_EXPORT string ToHex(uint64 num);
// ----------------------------------------------------------------------
// GlobalReplaceSubstring()
@@ -786,9 +787,9 @@ LIBPROTOBUF_EXPORT string ToHex(uint64 num);
//
// NOTE: The string pieces must not overlap s.
// ----------------------------------------------------------------------
-LIBPROTOBUF_EXPORT int GlobalReplaceSubstring(const string& substring,
- const string& replacement,
- string* s);
+PROTOBUF_EXPORT int GlobalReplaceSubstring(const string& substring,
+ const string& replacement,
+ string* s);
// ----------------------------------------------------------------------
// Base64Unescape()
@@ -796,7 +797,7 @@ LIBPROTOBUF_EXPORT int GlobalReplaceSubstring(const string& substring,
// writes it to "dest". If src contains invalid characters, dest is cleared
// and the function returns false. Returns true on success.
// ----------------------------------------------------------------------
-LIBPROTOBUF_EXPORT bool Base64Unescape(StringPiece src, string* dest);
+PROTOBUF_EXPORT bool Base64Unescape(StringPiece src, string* dest);
// ----------------------------------------------------------------------
// WebSafeBase64Unescape()
@@ -809,18 +810,17 @@ LIBPROTOBUF_EXPORT bool Base64Unescape(StringPiece src, string* dest);
// returns false (with dest empty) if src contains invalid chars; for
// this version src and dest must be different strings.
// ----------------------------------------------------------------------
-LIBPROTOBUF_EXPORT int WebSafeBase64Unescape(const char* src, int slen,
- char* dest, int szdest);
-LIBPROTOBUF_EXPORT bool WebSafeBase64Unescape(StringPiece src, string* dest);
+PROTOBUF_EXPORT int WebSafeBase64Unescape(const char* src, int slen, char* dest,
+ int szdest);
+PROTOBUF_EXPORT bool WebSafeBase64Unescape(StringPiece src, string* dest);
// Return the length to use for the output buffer given to the base64 escape
// routines. Make sure to use the same value for do_padding in both.
// This function may return incorrect results if given input_len values that
// are extremely high, which should happen rarely.
-LIBPROTOBUF_EXPORT int CalculateBase64EscapedLen(int input_len,
- bool do_padding);
+PROTOBUF_EXPORT int CalculateBase64EscapedLen(int input_len, bool do_padding);
// Use this version when calling Base64Escape without a do_padding arg.
-LIBPROTOBUF_EXPORT int CalculateBase64EscapedLen(int input_len);
+PROTOBUF_EXPORT int CalculateBase64EscapedLen(int input_len);
// ----------------------------------------------------------------------
// Base64Escape()
@@ -834,23 +834,23 @@ LIBPROTOBUF_EXPORT int CalculateBase64EscapedLen(int input_len);
// to escape them. It also has an extra parameter "do_padding",
// which when set to false will prevent padding with "=".
// ----------------------------------------------------------------------
-LIBPROTOBUF_EXPORT int Base64Escape(const unsigned char* src, int slen,
- char* dest, int szdest);
-LIBPROTOBUF_EXPORT int WebSafeBase64Escape(
- const unsigned char* src, int slen, char* dest,
- int szdest, bool do_padding);
+PROTOBUF_EXPORT int Base64Escape(const unsigned char* src, int slen, char* dest,
+ int szdest);
+PROTOBUF_EXPORT int WebSafeBase64Escape(const unsigned char* src, int slen,
+ char* dest, int szdest,
+ bool do_padding);
// Encode src into dest with padding.
-LIBPROTOBUF_EXPORT void Base64Escape(StringPiece src, string* dest);
+PROTOBUF_EXPORT void Base64Escape(StringPiece src, string* dest);
// Encode src into dest web-safely without padding.
-LIBPROTOBUF_EXPORT void WebSafeBase64Escape(StringPiece src, string* dest);
+PROTOBUF_EXPORT void WebSafeBase64Escape(StringPiece src, string* dest);
// Encode src into dest web-safely with padding.
-LIBPROTOBUF_EXPORT void WebSafeBase64EscapeWithPadding(StringPiece src,
- string* dest);
+PROTOBUF_EXPORT void WebSafeBase64EscapeWithPadding(StringPiece src,
+ string* dest);
-LIBPROTOBUF_EXPORT void Base64Escape(const unsigned char* src, int szsrc,
- string* dest, bool do_padding);
-LIBPROTOBUF_EXPORT void WebSafeBase64Escape(const unsigned char* src, int szsrc,
- string* dest, bool do_padding);
+PROTOBUF_EXPORT void Base64Escape(const unsigned char* src, int szsrc,
+ string* dest, bool do_padding);
+PROTOBUF_EXPORT void WebSafeBase64Escape(const unsigned char* src, int szsrc,
+ string* dest, bool do_padding);
inline bool IsValidCodePoint(uint32 code_point) {
return code_point < 0xD800 ||
@@ -864,13 +864,13 @@ static const int UTFmax = 4;
// in any external dependencies. The output buffer must be as least 4 bytes
// large.
// ----------------------------------------------------------------------
-LIBPROTOBUF_EXPORT int EncodeAsUTF8Char(uint32 code_point, char* output);
+PROTOBUF_EXPORT int EncodeAsUTF8Char(uint32 code_point, char* output);
// ----------------------------------------------------------------------
// UTF8FirstLetterNumBytes()
// Length of the first UTF-8 character.
// ----------------------------------------------------------------------
-LIBPROTOBUF_EXPORT int UTF8FirstLetterNumBytes(const char* src, int len);
+PROTOBUF_EXPORT int UTF8FirstLetterNumBytes(const char* src, int len);
// From google3/third_party/absl/strings/escaping.h
@@ -906,12 +906,12 @@ LIBPROTOBUF_EXPORT int UTF8FirstLetterNumBytes(const char* src, int len);
//
// (1) determines the presence of LF (first one is ok)
// (2) if yes, removes any CR, else convert every CR to LF
-LIBPROTOBUF_EXPORT void CleanStringLineEndings(const string& src, string* dst,
- bool auto_end_last_line);
+PROTOBUF_EXPORT void CleanStringLineEndings(const string& src, string* dst,
+ bool auto_end_last_line);
// Same as above, but transforms the argument in place.
-LIBPROTOBUF_EXPORT void CleanStringLineEndings(string* str,
- bool auto_end_last_line);
+PROTOBUF_EXPORT void CleanStringLineEndings(string* str,
+ bool auto_end_last_line);
namespace strings {
inline bool EndsWith(StringPiece text, StringPiece suffix) {
@@ -925,4 +925,6 @@ inline bool EndsWith(StringPiece text, StringPiece suffix) {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_STUBS_STRUTIL_H__
diff --git a/src/google/protobuf/stubs/substitute.h b/src/google/protobuf/stubs/substitute.h
index e05ca8d8..267dead2 100644
--- a/src/google/protobuf/stubs/substitute.h
+++ b/src/google/protobuf/stubs/substitute.h
@@ -38,6 +38,8 @@
#ifndef GOOGLE_PROTOBUF_STUBS_SUBSTITUTE_H_
#define GOOGLE_PROTOBUF_STUBS_SUBSTITUTE_H_
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace strings {
@@ -137,34 +139,36 @@ class SubstituteArg {
} // namespace internal
-LIBPROTOBUF_EXPORT string Substitute(
- const char* format,
- const internal::SubstituteArg& arg0 = internal::SubstituteArg(),
- const internal::SubstituteArg& arg1 = internal::SubstituteArg(),
- const internal::SubstituteArg& arg2 = internal::SubstituteArg(),
- const internal::SubstituteArg& arg3 = internal::SubstituteArg(),
- const internal::SubstituteArg& arg4 = internal::SubstituteArg(),
- const internal::SubstituteArg& arg5 = internal::SubstituteArg(),
- const internal::SubstituteArg& arg6 = internal::SubstituteArg(),
- const internal::SubstituteArg& arg7 = internal::SubstituteArg(),
- const internal::SubstituteArg& arg8 = internal::SubstituteArg(),
- const internal::SubstituteArg& arg9 = internal::SubstituteArg());
-
-LIBPROTOBUF_EXPORT void SubstituteAndAppend(
- string* output, const char* format,
- const internal::SubstituteArg& arg0 = internal::SubstituteArg(),
- const internal::SubstituteArg& arg1 = internal::SubstituteArg(),
- const internal::SubstituteArg& arg2 = internal::SubstituteArg(),
- const internal::SubstituteArg& arg3 = internal::SubstituteArg(),
- const internal::SubstituteArg& arg4 = internal::SubstituteArg(),
- const internal::SubstituteArg& arg5 = internal::SubstituteArg(),
- const internal::SubstituteArg& arg6 = internal::SubstituteArg(),
- const internal::SubstituteArg& arg7 = internal::SubstituteArg(),
- const internal::SubstituteArg& arg8 = internal::SubstituteArg(),
- const internal::SubstituteArg& arg9 = internal::SubstituteArg());
+PROTOBUF_EXPORT string
+Substitute(const char* format,
+ const internal::SubstituteArg& arg0 = internal::SubstituteArg(),
+ const internal::SubstituteArg& arg1 = internal::SubstituteArg(),
+ const internal::SubstituteArg& arg2 = internal::SubstituteArg(),
+ const internal::SubstituteArg& arg3 = internal::SubstituteArg(),
+ const internal::SubstituteArg& arg4 = internal::SubstituteArg(),
+ const internal::SubstituteArg& arg5 = internal::SubstituteArg(),
+ const internal::SubstituteArg& arg6 = internal::SubstituteArg(),
+ const internal::SubstituteArg& arg7 = internal::SubstituteArg(),
+ const internal::SubstituteArg& arg8 = internal::SubstituteArg(),
+ const internal::SubstituteArg& arg9 = internal::SubstituteArg());
+
+PROTOBUF_EXPORT void SubstituteAndAppend(
+ string* output, const char* format,
+ const internal::SubstituteArg& arg0 = internal::SubstituteArg(),
+ const internal::SubstituteArg& arg1 = internal::SubstituteArg(),
+ const internal::SubstituteArg& arg2 = internal::SubstituteArg(),
+ const internal::SubstituteArg& arg3 = internal::SubstituteArg(),
+ const internal::SubstituteArg& arg4 = internal::SubstituteArg(),
+ const internal::SubstituteArg& arg5 = internal::SubstituteArg(),
+ const internal::SubstituteArg& arg6 = internal::SubstituteArg(),
+ const internal::SubstituteArg& arg7 = internal::SubstituteArg(),
+ const internal::SubstituteArg& arg8 = internal::SubstituteArg(),
+ const internal::SubstituteArg& arg9 = internal::SubstituteArg());
} // namespace strings
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_STUBS_SUBSTITUTE_H_
diff --git a/src/google/protobuf/stubs/time.h b/src/google/protobuf/stubs/time.h
index 45607ca9..12091de3 100644
--- a/src/google/protobuf/stubs/time.h
+++ b/src/google/protobuf/stubs/time.h
@@ -32,6 +32,8 @@
#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace internal {
@@ -49,12 +51,12 @@ struct DateTime {
// negative to represent time before 1970-01-01) to DateTime. Returns false
// if the timestamp is not in the range between 0001-01-01T00:00:00 and
// 9999-12-31T23:59:59.
-bool LIBPROTOBUF_EXPORT SecondsToDateTime(int64 seconds, DateTime* time);
+bool PROTOBUF_EXPORT SecondsToDateTime(int64 seconds, DateTime* time);
// Converts DateTime to a timestamp (seconds since 1970-01-01T00:00:00).
// Returns false if the DateTime is not valid or is not in the valid range.
-bool LIBPROTOBUF_EXPORT DateTimeToSeconds(const DateTime& time, int64* seconds);
+bool PROTOBUF_EXPORT DateTimeToSeconds(const DateTime& time, int64* seconds);
-void LIBPROTOBUF_EXPORT GetCurrentTime(int64* seconds, int32* nanos);
+void PROTOBUF_EXPORT GetCurrentTime(int64* seconds, int32* nanos);
// Formats a time string in RFC3339 fromat.
//
@@ -63,13 +65,16 @@ void LIBPROTOBUF_EXPORT GetCurrentTime(int64* seconds, int32* nanos);
// value.
//
// Note that "nanos" must in the range of [0, 999999999].
-string LIBPROTOBUF_EXPORT FormatTime(int64 seconds, int32 nanos);
+string PROTOBUF_EXPORT FormatTime(int64 seconds, int32 nanos);
// Parses a time string. This method accepts RFC3339 date/time string with UTC
// offset. For example, "2015-05-20T13:29:35.120-08:00".
-bool LIBPROTOBUF_EXPORT ParseTime(const string& value, int64* seconds, int32* nanos);
+bool PROTOBUF_EXPORT ParseTime(const string& value, int64* seconds,
+ int32* nanos);
} // namespace internal
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_STUBS_TIME_H_
diff --git a/src/google/protobuf/test_util.h b/src/google/protobuf/test_util.h
index 0308eb12..5d22a763 100644
--- a/src/google/protobuf/test_util.h
+++ b/src/google/protobuf/test_util.h
@@ -44,6 +44,7 @@
#undef UNITTEST
#undef UNITTEST_IMPORT
+#include <google/protobuf/port_def.inc>
namespace google {
namespace protobuf {
@@ -94,7 +95,7 @@ class ReflectionTester {
static void ExpectOneofSetViaReflection(const Message& message);
private:
- const FieldDescriptor* F(const string& name);
+ const FieldDescriptor* F(const std::string& name);
const Descriptor* base_descriptor_;
@@ -128,10 +129,10 @@ inline TestUtil::ReflectionTester::ReflectionTester(
const Descriptor* base_descriptor)
: base_descriptor_(base_descriptor) {
const DescriptorPool* pool = base_descriptor->file()->pool();
- string package = base_descriptor->file()->package();
+ std::string package = base_descriptor->file()->package();
const FieldDescriptor* import_descriptor =
pool->FindFieldByName(package + ".TestAllTypes.optional_import_message");
- string import_package = import_descriptor->message_type()->file()->package();
+ std::string import_package = import_descriptor->message_type()->file()->package();
nested_b_ = pool->FindFieldByName(package + ".TestAllTypes.NestedMessage.bb");
foreign_c_ = pool->FindFieldByName(package + ".ForeignMessage.c");
@@ -176,7 +177,7 @@ inline TestUtil::ReflectionTester::ReflectionTester(
// Shorthand to get a FieldDescriptor for a field of TestAllTypes.
inline const FieldDescriptor* TestUtil::ReflectionTester::F(
- const string& name) {
+ const std::string& name) {
const FieldDescriptor* result = nullptr;
if (base_descriptor_->name() == "TestAllExtensions" ||
base_descriptor_->name() == "TestPackedExtensions") {
@@ -361,7 +362,7 @@ inline void TestUtil::ReflectionTester::ExpectOneofSetViaReflection(
const Message& message) {
const Descriptor* descriptor = message.GetDescriptor();
const Reflection* reflection = message.GetReflection();
- string scratch;
+ std::string scratch;
EXPECT_TRUE(reflection->HasField(
message, descriptor->FindFieldByName("foo_lazy_message")));
EXPECT_TRUE(
@@ -441,7 +442,7 @@ inline void TestUtil::ReflectionTester::ExpectAllFieldsSetViaReflection(
inline void TestUtil::ReflectionTester::ExpectAllFieldsSetViaReflection1(
const Message& message) {
const Reflection* reflection = message.GetReflection();
- string scratch;
+ std::string scratch;
const Message* sub_message;
EXPECT_TRUE(reflection->HasField(message, F("optional_int32")));
@@ -565,7 +566,7 @@ inline void TestUtil::ReflectionTester::ExpectAllFieldsSetViaReflection1(
inline void TestUtil::ReflectionTester::ExpectAllFieldsSetViaReflection2(
const Message& message) {
const Reflection* reflection = message.GetReflection();
- string scratch;
+ std::string scratch;
const Message* sub_message;
// -----------------------------------------------------------------
@@ -740,7 +741,7 @@ inline void TestUtil::ReflectionTester::ExpectAllFieldsSetViaReflection2(
inline void TestUtil::ReflectionTester::ExpectAllFieldsSetViaReflection3(
const Message& message) {
const Reflection* reflection = message.GetReflection();
- string scratch;
+ std::string scratch;
// -----------------------------------------------------------------
@@ -869,7 +870,7 @@ inline void TestUtil::ReflectionTester::ExpectPackedFieldsSetViaReflection(
inline void TestUtil::ReflectionTester::ExpectClearViaReflection(
const Message& message) {
const Reflection* reflection = message.GetReflection();
- string scratch;
+ std::string scratch;
const Message* sub_message;
// has_blah() should initially be false for all optional fields.
@@ -1269,10 +1270,10 @@ inline void TestUtil::ReflectionTester::ExpectMessagesReleasedViaReflection(
// expect for a TestFieldOrderings message filled in by
// SetAllFieldsAndExtensions().
inline void ExpectAllFieldsAndExtensionsInOrder(
- const string& serialized) {
+ const std::string& serialized) {
// We set each field individually, serialize separately, and concatenate all
// the strings in canonical order to determine the expected serialization.
- string expected;
+ std::string expected;
unittest::TestFieldOrderings message;
message.set_my_int(1); // Field 1.
message.AppendToString(&expected);
@@ -1298,4 +1299,6 @@ inline void ExpectAllFieldsAndExtensionsInOrder(
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_TEST_UTIL_H__
diff --git a/src/google/protobuf/test_util2.h b/src/google/protobuf/test_util2.h
index b1c03772..d729808d 100644
--- a/src/google/protobuf/test_util2.h
+++ b/src/google/protobuf/test_util2.h
@@ -53,7 +53,7 @@ inline ::std::string TranslatePathToOpensource(const ::std::string& google3_path
}
inline ::std::string MaybeTranslatePath(const ::std::string& google3_path) {
- string path = google3_path;
+ std::string path = google3_path;
path = TranslatePathToOpensource(path);
return path;
}
diff --git a/src/google/protobuf/text_format.cc b/src/google/protobuf/text_format.cc
index 93c24b23..c8de875d 100644
--- a/src/google/protobuf/text_format.cc
+++ b/src/google/protobuf/text_format.cc
@@ -53,6 +53,7 @@
#include <google/protobuf/io/zero_copy_stream_impl.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/dynamic_message.h>
+#include <google/protobuf/map_field.h>
#include <google/protobuf/repeated_field.h>
#include <google/protobuf/unknown_field_set.h>
#include <google/protobuf/wire_format_lite.h>
@@ -1356,9 +1357,9 @@ bool CheckParseInputSize(StringPiece input,
io::ErrorCollector* error_collector) {
if (input.size() > INT_MAX) {
error_collector->AddError(
- -1, 0, StrCat("Input size too large: ",
- static_cast<int64>(input.size()), " bytes",
- " > ", INT_MAX, " bytes."));
+ -1, 0,
+ StrCat("Input size too large: ", static_cast<int64>(input.size()),
+ " bytes", " > ", INT_MAX, " bytes."));
return false;
}
return true;
@@ -1714,9 +1715,9 @@ class FieldValuePrinterWrapper : public TextFormat::FastFieldValuePrinter {
void PrintFieldName(const Message& message, int field_index, int field_count,
const Reflection* reflection,
const FieldDescriptor* field,
- TextFormat::BaseTextGenerator* generator) const {
- generator->PrintString(delegate_->PrintFieldName(
- message, reflection, field));
+ TextFormat::BaseTextGenerator* generator) const override {
+ generator->PrintString(
+ delegate_->PrintFieldName(message, reflection, field));
}
void PrintFieldName(const Message& message, const Reflection* reflection,
const FieldDescriptor* field,
@@ -1947,7 +1948,13 @@ void TextFormat::Printer::Print(const Message& message,
return;
}
std::vector<const FieldDescriptor*> fields;
- reflection->ListFields(message, &fields);
+ if (descriptor->options().map_entry()) {
+ fields.push_back(descriptor->field(0));
+ fields.push_back(descriptor->field(1));
+ } else {
+ reflection->ListFields(message, &fields);
+ }
+
if (print_message_fields_in_index_order_) {
std::sort(fields.begin(), fields.end(), FieldIndexSorter());
}
@@ -1973,6 +1980,181 @@ void TextFormat::Printer::PrintFieldValueToString(
PrintFieldValue(message, message.GetReflection(), field, index, &generator);
}
+class MapEntryMessageComparator {
+ public:
+ explicit MapEntryMessageComparator(const Descriptor* descriptor)
+ : field_(descriptor->field(0)) {}
+
+ bool operator()(const Message* a, const Message* b) {
+ const Reflection* reflection = a->GetReflection();
+ switch (field_->cpp_type()) {
+ case FieldDescriptor::CPPTYPE_BOOL: {
+ bool first = reflection->GetBool(*a, field_);
+ bool second = reflection->GetBool(*b, field_);
+ return first < second;
+ }
+ case FieldDescriptor::CPPTYPE_INT32: {
+ int32 first = reflection->GetInt32(*a, field_);
+ int32 second = reflection->GetInt32(*b, field_);
+ return first < second;
+ }
+ case FieldDescriptor::CPPTYPE_INT64: {
+ int64 first = reflection->GetInt64(*a, field_);
+ int64 second = reflection->GetInt64(*b, field_);
+ return first < second;
+ }
+ case FieldDescriptor::CPPTYPE_UINT32: {
+ uint32 first = reflection->GetUInt32(*a, field_);
+ uint32 second = reflection->GetUInt32(*b, field_);
+ return first < second;
+ }
+ case FieldDescriptor::CPPTYPE_UINT64: {
+ uint64 first = reflection->GetUInt64(*a, field_);
+ uint64 second = reflection->GetUInt64(*b, field_);
+ return first < second;
+ }
+ case FieldDescriptor::CPPTYPE_STRING: {
+ string first = reflection->GetString(*a, field_);
+ string second = reflection->GetString(*b, field_);
+ return first < second;
+ }
+ default:
+ GOOGLE_LOG(DFATAL) << "Invalid key for map field.";
+ return true;
+ }
+ }
+
+ private:
+ const FieldDescriptor* field_;
+};
+
+namespace internal {
+class MapFieldPrinterHelper {
+ public:
+ // DynamicMapSorter::Sort cannot be used because it enfores syncing with
+ // repeated field.
+ static bool SortMap(const Message& message, const Reflection* reflection,
+ const FieldDescriptor* field, MessageFactory* factory,
+ std::vector<const Message*>* sorted_map_field);
+ static void CopyKey(const MapKey& key, Message* message,
+ const FieldDescriptor* field_desc);
+ static void CopyValue(const MapValueRef& value, Message* message,
+ const FieldDescriptor* field_desc);
+};
+
+// Returns true if elements contained in sorted_map_field need to be released.
+bool MapFieldPrinterHelper::SortMap(
+ const Message& message, const Reflection* reflection,
+ const FieldDescriptor* field, MessageFactory* factory,
+ std::vector<const Message*>* sorted_map_field) {
+ bool need_release = false;
+ const MapFieldBase& base =
+ *reflection->MapData(const_cast<Message*>(&message), field);
+
+ if (base.IsRepeatedFieldValid()) {
+ const RepeatedPtrField<Message>& map_field =
+ reflection->GetRepeatedPtrField<Message>(message, field);
+ for (int i = 0; i < map_field.size(); ++i) {
+ sorted_map_field->push_back(
+ const_cast<RepeatedPtrField<Message>*>(&map_field)->Mutable(i));
+ }
+ } else {
+ // TODO(teboring): For performance, instead of creating map entry message
+ // for each element, just store map keys and sort them.
+ const Descriptor* map_entry_desc = field->message_type();
+ const Message* prototype = factory->GetPrototype(map_entry_desc);
+ for (MapIterator iter =
+ reflection->MapBegin(const_cast<Message*>(&message), field);
+ iter != reflection->MapEnd(const_cast<Message*>(&message), field);
+ ++iter) {
+ Message* map_entry_message = prototype->New();
+ CopyKey(iter.GetKey(), map_entry_message, map_entry_desc->field(0));
+ CopyValue(iter.GetValueRef(), map_entry_message,
+ map_entry_desc->field(1));
+ sorted_map_field->push_back(map_entry_message);
+ }
+ need_release = true;
+ }
+
+ MapEntryMessageComparator comparator(field->message_type());
+ std::stable_sort(sorted_map_field->begin(), sorted_map_field->end(),
+ comparator);
+ return need_release;
+}
+
+void MapFieldPrinterHelper::CopyKey(const MapKey& key, Message* message,
+ const FieldDescriptor* field_desc) {
+ const Reflection* reflection = message->GetReflection();
+ switch (field_desc->cpp_type()) {
+ case FieldDescriptor::CPPTYPE_DOUBLE:
+ case FieldDescriptor::CPPTYPE_FLOAT:
+ case FieldDescriptor::CPPTYPE_ENUM:
+ case FieldDescriptor::CPPTYPE_MESSAGE:
+ GOOGLE_LOG(ERROR) << "Not supported.";
+ break;
+ case FieldDescriptor::CPPTYPE_STRING:
+ reflection->SetString(message, field_desc, key.GetStringValue());
+ return;
+ case FieldDescriptor::CPPTYPE_INT64:
+ reflection->SetInt64(message, field_desc, key.GetInt64Value());
+ return;
+ case FieldDescriptor::CPPTYPE_INT32:
+ reflection->SetInt32(message, field_desc, key.GetInt32Value());
+ return;
+ case FieldDescriptor::CPPTYPE_UINT64:
+ reflection->SetUInt64(message, field_desc, key.GetUInt64Value());
+ return;
+ case FieldDescriptor::CPPTYPE_UINT32:
+ reflection->SetUInt32(message, field_desc, key.GetUInt32Value());
+ return;
+ case FieldDescriptor::CPPTYPE_BOOL:
+ reflection->SetBool(message, field_desc, key.GetBoolValue());
+ return;
+ }
+}
+
+void MapFieldPrinterHelper::CopyValue(const MapValueRef& value,
+ Message* message,
+ const FieldDescriptor* field_desc) {
+ const Reflection* reflection = message->GetReflection();
+ switch (field_desc->cpp_type()) {
+ case FieldDescriptor::CPPTYPE_DOUBLE:
+ reflection->SetDouble(message, field_desc, value.GetDoubleValue());
+ return;
+ case FieldDescriptor::CPPTYPE_FLOAT:
+ reflection->SetFloat(message, field_desc, value.GetFloatValue());
+ return;
+ case FieldDescriptor::CPPTYPE_ENUM:
+ reflection->SetEnumValue(message, field_desc, value.GetEnumValue());
+ return;
+ case FieldDescriptor::CPPTYPE_MESSAGE: {
+ Message* sub_message = value.GetMessageValue().New();
+ sub_message->CopyFrom(value.GetMessageValue());
+ reflection->SetAllocatedMessage(message, sub_message, field_desc);
+ return;
+ }
+ case FieldDescriptor::CPPTYPE_STRING:
+ reflection->SetString(message, field_desc, value.GetStringValue());
+ return;
+ case FieldDescriptor::CPPTYPE_INT64:
+ reflection->SetInt64(message, field_desc, value.GetInt64Value());
+ return;
+ case FieldDescriptor::CPPTYPE_INT32:
+ reflection->SetInt32(message, field_desc, value.GetInt32Value());
+ return;
+ case FieldDescriptor::CPPTYPE_UINT64:
+ reflection->SetUInt64(message, field_desc, value.GetUInt64Value());
+ return;
+ case FieldDescriptor::CPPTYPE_UINT32:
+ reflection->SetUInt32(message, field_desc, value.GetUInt32Value());
+ return;
+ case FieldDescriptor::CPPTYPE_BOOL:
+ reflection->SetBool(message, field_desc, value.GetBoolValue());
+ return;
+ }
+}
+} // namespace internal
+
void TextFormat::Printer::PrintField(const Message& message,
const Reflection* reflection,
const FieldDescriptor* field,
@@ -1989,14 +2171,18 @@ void TextFormat::Printer::PrintField(const Message& message,
if (field->is_repeated()) {
count = reflection->FieldSize(message, field);
- } else if (reflection->HasField(message, field)) {
+ } else if (reflection->HasField(message, field) ||
+ field->containing_type()->options().map_entry()) {
count = 1;
}
- std::vector<const Message*> map_entries;
- const bool is_map = field->is_map();
+ DynamicMessageFactory factory;
+ std::vector<const Message*> sorted_map_field;
+ bool need_release = false;
+ bool is_map = field->is_map();
if (is_map) {
- map_entries = DynamicMapSorter::Sort(message, count, reflection, field);
+ need_release = internal::MapFieldPrinterHelper::SortMap(
+ message, reflection, field, &factory, &sorted_map_field);
}
for (int j = 0; j < count; ++j) {
@@ -2009,7 +2195,7 @@ void TextFormat::Printer::PrintField(const Message& message,
custom_printers_, field, default_field_value_printer_.get());
const Message& sub_message =
field->is_repeated()
- ? (is_map ? *map_entries[j]
+ ? (is_map ? *sorted_map_field[j]
: reflection->GetRepeatedMessage(message, field, j))
: reflection->GetMessage(message, field);
printer->PrintMessageStart(sub_message, field_index, count,
@@ -2030,6 +2216,12 @@ void TextFormat::Printer::PrintField(const Message& message,
}
}
}
+
+ if (need_release) {
+ for (int j = 0; j < sorted_map_field.size(); ++j) {
+ delete sorted_map_field[j];
+ }
+ }
}
void TextFormat::Printer::PrintShortRepeatedField(
diff --git a/src/google/protobuf/text_format.h b/src/google/protobuf/text_format.h
index df12f13d..d185bfd9 100644
--- a/src/google/protobuf/text_format.h
+++ b/src/google/protobuf/text_format.h
@@ -67,7 +67,7 @@ namespace io {
// of messages.
//
// This class is really a namespace that contains only static methods.
-class LIBPROTOBUF_EXPORT TextFormat {
+class PROTOBUF_EXPORT TextFormat {
public:
// Outputs a textual representation of the given message to the given
// output stream. Returns false if printing fails.
@@ -82,12 +82,12 @@ class LIBPROTOBUF_EXPORT TextFormat {
// Like Print(), but outputs directly to a string.
// Note: output will be cleared prior to printing, and will be left empty
// even if printing fails. Returns false if printing fails.
- static bool PrintToString(const Message& message, string* output);
+ static bool PrintToString(const Message& message, std::string* output);
// Like PrintUnknownFields(), but outputs directly to a string. Returns false
// if printing fails.
static bool PrintUnknownFieldsToString(const UnknownFieldSet& unknown_fields,
- string* output);
+ std::string* output);
// Outputs a textual representation of the value of the field supplied on
// the message supplied. For non-repeated fields, an index of -1 must
@@ -96,9 +96,9 @@ class LIBPROTOBUF_EXPORT TextFormat {
static void PrintFieldValueToString(const Message& message,
const FieldDescriptor* field,
int index,
- string* output);
+ std::string* output);
- class LIBPROTOBUF_EXPORT BaseTextGenerator {
+ class PROTOBUF_EXPORT BaseTextGenerator {
public:
virtual ~BaseTextGenerator();
@@ -108,7 +108,7 @@ class LIBPROTOBUF_EXPORT TextFormat {
// Print text to the output stream.
virtual void Print(const char* text, size_t size) = 0;
- void PrintString(const string& str) { Print(str.data(), str.size()); }
+ void PrintString(const std::string& str) { Print(str.data(), str.size()); }
template <size_t n>
void PrintLiteral(const char (&text)[n]) {
@@ -120,7 +120,7 @@ class LIBPROTOBUF_EXPORT TextFormat {
// string representation.
// You can derive from this FastFieldValuePrinter if you want to have fields
// to be printed in a different way and register it at the Printer.
- class LIBPROTOBUF_EXPORT FastFieldValuePrinter {
+ class PROTOBUF_EXPORT FastFieldValuePrinter {
public:
FastFieldValuePrinter();
virtual ~FastFieldValuePrinter();
@@ -131,11 +131,11 @@ class LIBPROTOBUF_EXPORT TextFormat {
virtual void PrintUInt64(uint64 val, BaseTextGenerator* generator) const;
virtual void PrintFloat(float val, BaseTextGenerator* generator) const;
virtual void PrintDouble(double val, BaseTextGenerator* generator) const;
- virtual void PrintString(const string& val,
+ virtual void PrintString(const std::string& val,
BaseTextGenerator* generator) const;
- virtual void PrintBytes(const string& val,
+ virtual void PrintBytes(const std::string& val,
BaseTextGenerator* generator) const;
- virtual void PrintEnum(int32 val, const string& name,
+ virtual void PrintEnum(int32 val, const std::string& name,
BaseTextGenerator* generator) const;
virtual void PrintFieldName(const Message& message, int field_index,
int field_count, const Reflection* reflection,
@@ -156,29 +156,29 @@ class LIBPROTOBUF_EXPORT TextFormat {
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FastFieldValuePrinter);
};
- class LIBPROTOBUF_EXPORT GOOGLE_PROTOBUF_DEPRECATED_MSG(
+ class PROTOBUF_EXPORT PROTOBUF_DEPRECATED_MSG(
"Please use FastFieldValuePrinter") FieldValuePrinter {
public:
FieldValuePrinter();
virtual ~FieldValuePrinter();
- virtual string PrintBool(bool val) const;
- virtual string PrintInt32(int32 val) const;
- virtual string PrintUInt32(uint32 val) const;
- virtual string PrintInt64(int64 val) const;
- virtual string PrintUInt64(uint64 val) const;
- virtual string PrintFloat(float val) const;
- virtual string PrintDouble(double val) const;
- virtual string PrintString(const string& val) const;
- virtual string PrintBytes(const string& val) const;
- virtual string PrintEnum(int32 val, const string& name) const;
- virtual string PrintFieldName(const Message& message,
+ virtual std::string PrintBool(bool val) const;
+ virtual std::string PrintInt32(int32 val) const;
+ virtual std::string PrintUInt32(uint32 val) const;
+ virtual std::string PrintInt64(int64 val) const;
+ virtual std::string PrintUInt64(uint64 val) const;
+ virtual std::string PrintFloat(float val) const;
+ virtual std::string PrintDouble(double val) const;
+ virtual std::string PrintString(const std::string& val) const;
+ virtual std::string PrintBytes(const std::string& val) const;
+ virtual std::string PrintEnum(int32 val, const std::string& name) const;
+ virtual std::string PrintFieldName(const Message& message,
const Reflection* reflection,
const FieldDescriptor* field) const;
- virtual string PrintMessageStart(const Message& message,
+ virtual std::string PrintMessageStart(const Message& message,
int field_index,
int field_count,
bool single_line_mode) const;
- virtual string PrintMessageEnd(const Message& message,
+ virtual std::string PrintMessageEnd(const Message& message,
int field_index,
int field_count,
bool single_line_mode) const;
@@ -188,7 +188,7 @@ class LIBPROTOBUF_EXPORT TextFormat {
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldValuePrinter);
};
- class LIBPROTOBUF_EXPORT MessagePrinter {
+ class PROTOBUF_EXPORT MessagePrinter {
public:
MessagePrinter() {}
virtual ~MessagePrinter() {}
@@ -201,7 +201,7 @@ class LIBPROTOBUF_EXPORT TextFormat {
// Interface that Printers or Parsers can use to find extensions, or types
// referenced in Any messages.
- class LIBPROTOBUF_EXPORT Finder {
+ class PROTOBUF_EXPORT Finder {
public:
virtual ~Finder();
@@ -210,7 +210,7 @@ class LIBPROTOBUF_EXPORT TextFormat {
// The base implementation uses the extensions already known by the message.
virtual const FieldDescriptor* FindExtension(
Message* message,
- const string& name) const;
+ const std::string& name) const;
// Find the message type for an Any proto.
// Returns NULL if no message is known for this name.
@@ -218,13 +218,13 @@ class LIBPROTOBUF_EXPORT TextFormat {
// type.googleapis.com/, and searches the DescriptorPool of the parent
// message.
virtual const Descriptor* FindAnyType(const Message& message,
- const string& prefix,
- const string& name) const;
+ const std::string& prefix,
+ const std::string& name) const;
};
// Class for those users which require more fine-grained control over how
// a protobuffer message is printed out.
- class LIBPROTOBUF_EXPORT Printer {
+ class PROTOBUF_EXPORT Printer {
public:
Printer();
~Printer();
@@ -235,15 +235,15 @@ class LIBPROTOBUF_EXPORT TextFormat {
bool PrintUnknownFields(const UnknownFieldSet& unknown_fields,
io::ZeroCopyOutputStream* output) const;
// Like TextFormat::PrintToString
- bool PrintToString(const Message& message, string* output) const;
+ bool PrintToString(const Message& message, std::string* output) const;
// Like TextFormat::PrintUnknownFieldsToString
bool PrintUnknownFieldsToString(const UnknownFieldSet& unknown_fields,
- string* output) const;
+ std::string* output) const;
// Like TextFormat::PrintFieldValueToString
void PrintFieldValueToString(const Message& message,
const FieldDescriptor* field,
int index,
- string* output) const;
+ std::string* output) const;
// Adjust the initial indent level of all output. Each indent level is
// equal to two spaces.
@@ -320,9 +320,7 @@ class LIBPROTOBUF_EXPORT TextFormat {
}
// Set how parser finds message for Any payloads.
- void SetFinder(Finder* finder) {
- finder_ = finder;
- }
+ void SetFinder(const Finder* finder) { finder_ = finder; }
// If non-zero, we truncate all string fields that are longer than this
// threshold. This is useful when the proto message has very long strings,
@@ -439,18 +437,18 @@ class LIBPROTOBUF_EXPORT TextFormat {
// google::protobuf::MessageLite::ParseFromString().
static bool Parse(io::ZeroCopyInputStream* input, Message* output);
// Like Parse(), but reads directly from a string.
- static bool ParseFromString(const string& input, Message* output);
+ static bool ParseFromString(const std::string& input, Message* output);
// Like Parse(), but the data is merged into the given message, as if
// using Message::MergeFrom().
static bool Merge(io::ZeroCopyInputStream* input, Message* output);
// Like Merge(), but reads directly from a string.
- static bool MergeFromString(const string& input, Message* output);
+ static bool MergeFromString(const std::string& input, Message* output);
// Parse the given text as a single field value and store it into the
// given field of the given message. If the field is a repeated field,
// the new value will be added to the end
- static bool ParseFieldValueFromString(const string& input,
+ static bool ParseFieldValueFromString(const std::string& input,
const FieldDescriptor* field,
Message* message);
@@ -466,7 +464,7 @@ class LIBPROTOBUF_EXPORT TextFormat {
// Data structure which is populated with the locations of each field
// value parsed from the text.
- class LIBPROTOBUF_EXPORT ParseInfoTree {
+ class PROTOBUF_EXPORT ParseInfoTree {
public:
ParseInfoTree();
~ParseInfoTree();
@@ -508,7 +506,7 @@ class LIBPROTOBUF_EXPORT TextFormat {
};
// For more control over parsing, use this class.
- class LIBPROTOBUF_EXPORT Parser {
+ class PROTOBUF_EXPORT Parser {
public:
Parser();
~Parser();
@@ -516,11 +514,11 @@ class LIBPROTOBUF_EXPORT TextFormat {
// Like TextFormat::Parse().
bool Parse(io::ZeroCopyInputStream* input, Message* output);
// Like TextFormat::ParseFromString().
- bool ParseFromString(const string& input, Message* output);
+ bool ParseFromString(const std::string& input, Message* output);
// Like TextFormat::Merge().
bool Merge(io::ZeroCopyInputStream* input, Message* output);
// Like TextFormat::MergeFromString().
- bool MergeFromString(const string& input, Message* output);
+ bool MergeFromString(const std::string& input, Message* output);
// Set where to report parse errors. If NULL (the default), errors will
// be printed to stderr.
@@ -531,9 +529,7 @@ class LIBPROTOBUF_EXPORT TextFormat {
// Set how parser finds extensions. If NULL (the default), the
// parser will use the standard Reflection object associated with
// the message being parsed.
- void SetFinder(Finder* finder) {
- finder_ = finder;
- }
+ void SetFinder(const Finder* finder) { finder_ = finder; }
// Sets where location information about the parse will be written. If NULL
// (the default), then no location will be written.
@@ -556,7 +552,7 @@ class LIBPROTOBUF_EXPORT TextFormat {
}
// Like TextFormat::ParseFieldValueFromString
- bool ParseFieldValueFromString(const string& input,
+ bool ParseFieldValueFromString(const std::string& input,
const FieldDescriptor* field,
Message* output);
diff --git a/src/google/protobuf/text_format_unittest.cc b/src/google/protobuf/text_format_unittest.cc
index 8df2fe3f..d64cd2eb 100644
--- a/src/google/protobuf/text_format_unittest.cc
+++ b/src/google/protobuf/text_format_unittest.cc
@@ -44,6 +44,7 @@
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/testing/file.h>
#include <google/protobuf/testing/file.h>
+#include <google/protobuf/map_unittest.pb.h>
#include <google/protobuf/test_util.h>
#include <google/protobuf/test_util2.h>
#include <google/protobuf/unittest.pb.h>
@@ -59,6 +60,8 @@
#include <google/protobuf/stubs/mathlimits.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
@@ -963,8 +966,8 @@ TEST_F(TextFormatTest, PrintExotic) {
// 9223372036854775808 is outside the range of int64. However, it is not
// outside the range of uint64. Confusingly, this means that everything
// works if we make the literal unsigned, even though we are negating it.
- message.add_repeated_int64(-GOOGLE_ULONGLONG(9223372036854775808));
- message.add_repeated_uint64(GOOGLE_ULONGLONG(18446744073709551615));
+ message.add_repeated_int64(-PROTOBUF_ULONGLONG(9223372036854775808));
+ message.add_repeated_uint64(PROTOBUF_ULONGLONG(18446744073709551615));
message.add_repeated_double(123.456);
message.add_repeated_double(1.23e21);
message.add_repeated_double(1.23e-18);
@@ -1137,15 +1140,18 @@ TEST_F(TextFormatTest, ParseExotic) {
// 9223372036854775808 is outside the range of int64. However, it is not
// outside the range of uint64. Confusingly, this means that everything
// works if we make the literal unsigned, even though we are negating it.
- EXPECT_EQ(-GOOGLE_ULONGLONG(9223372036854775808), message.repeated_int64(1));
+ EXPECT_EQ(-PROTOBUF_ULONGLONG(9223372036854775808),
+ message.repeated_int64(1));
ASSERT_EQ(2, message.repeated_uint32_size());
EXPECT_EQ(4294967295u, message.repeated_uint32(0));
EXPECT_EQ(2147483648u, message.repeated_uint32(1));
ASSERT_EQ(2, message.repeated_uint64_size());
- EXPECT_EQ(GOOGLE_ULONGLONG(18446744073709551615), message.repeated_uint64(0));
- EXPECT_EQ(GOOGLE_ULONGLONG(9223372036854775808), message.repeated_uint64(1));
+ EXPECT_EQ(PROTOBUF_ULONGLONG(18446744073709551615),
+ message.repeated_uint64(0));
+ EXPECT_EQ(PROTOBUF_ULONGLONG(9223372036854775808),
+ message.repeated_uint64(1));
ASSERT_EQ(13, message.repeated_double_size());
EXPECT_EQ(123.0 , message.repeated_double(0));
diff --git a/src/google/protobuf/timestamp.pb.cc b/src/google/protobuf/timestamp.pb.cc
index 10857919..4a962e3b 100644
--- a/src/google/protobuf/timestamp.pb.cc
+++ b/src/google/protobuf/timestamp.pb.cc
@@ -13,10 +13,6 @@
#include <google/protobuf/generated_message_reflection.h>
#include <google/protobuf/reflection_ops.h>
#include <google/protobuf/wire_format.h>
-// This is a temporary google only hack
-#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
-#include "third_party/protobuf/version.h"
-#endif
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>
@@ -39,7 +35,7 @@ static void InitDefaultsTimestamp_google_2fprotobuf_2ftimestamp_2eproto() {
::google::protobuf::Timestamp::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_Timestamp_google_2fprotobuf_2ftimestamp_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_Timestamp_google_2fprotobuf_2ftimestamp_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsTimestamp_google_2fprotobuf_2ftimestamp_2eproto}, {}};
void InitDefaults_google_2fprotobuf_2ftimestamp_2eproto() {
@@ -50,16 +46,16 @@ void InitDefaults_google_2fprotobuf_2ftimestamp_2eproto() {
constexpr ::google::protobuf::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2ftimestamp_2eproto = nullptr;
constexpr ::google::protobuf::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2ftimestamp_2eproto = nullptr;
-const ::google::protobuf::uint32 TableStruct_google_2fprotobuf_2ftimestamp_2eproto::offsets[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
+const ::google::protobuf::uint32 TableStruct_google_2fprotobuf_2ftimestamp_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
~0u, // no _has_bits_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Timestamp, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Timestamp, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Timestamp, seconds_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Timestamp, nanos_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Timestamp, seconds_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Timestamp, nanos_),
};
-static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
+static const ::google::protobuf::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
{ 0, -1, sizeof(::google::protobuf::Timestamp)},
};
@@ -185,15 +181,14 @@ const char* Timestamp::_InternalParse(const char* begin, const char* end, void*
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// int64 seconds = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 8) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
::google::protobuf::int64 value = val;
msg->set_seconds(value);
break;
@@ -203,15 +198,16 @@ const char* Timestamp::_InternalParse(const char* begin, const char* end, void*
if (static_cast<::google::protobuf::uint8>(tag) != 16) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
::google::protobuf::int32 value = val;
msg->set_nanos(value);
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
@@ -222,8 +218,6 @@ const char* Timestamp::_InternalParse(const char* begin, const char* end, void*
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -235,7 +229,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool Timestamp::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.Timestamp)
for (;;) {
@@ -455,10 +449,11 @@ void Timestamp::InternalSwap(Timestamp* other) {
} // namespace google
namespace google {
namespace protobuf {
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Timestamp* Arena::CreateMaybeMessage< ::google::protobuf::Timestamp >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::Timestamp* Arena::CreateMaybeMessage< ::google::protobuf::Timestamp >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::Timestamp >(arena);
}
} // namespace protobuf
} // namespace google
// @@protoc_insertion_point(global_scope)
+#include <google/protobuf/port_undef.inc>
diff --git a/src/google/protobuf/timestamp.pb.h b/src/google/protobuf/timestamp.pb.h
index e77adbe0..9839e92a 100644
--- a/src/google/protobuf/timestamp.pb.h
+++ b/src/google/protobuf/timestamp.pb.h
@@ -7,18 +7,19 @@
#include <limits>
#include <string>
-#include <google/protobuf/stubs/common.h>
-#if GOOGLE_PROTOBUF_VERSION < 3006000
+#include <google/protobuf/port_def.inc>
+#if PROTOBUF_VERSION < 3006001
#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 3006001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 3006001 < 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.
#endif
+#include <google/protobuf/port_undef.inc>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
@@ -32,27 +33,27 @@
#include <google/protobuf/unknown_field_set.h>
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>
-#define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2ftimestamp_2eproto LIBPROTOBUF_EXPORT
+#define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2ftimestamp_2eproto PROTOBUF_EXPORT
// Internal implementation detail -- do not use these members.
-struct LIBPROTOBUF_EXPORT TableStruct_google_2fprotobuf_2ftimestamp_2eproto {
+struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2ftimestamp_2eproto {
static const ::google::protobuf::internal::ParseTableField entries[]
- GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold);
+ PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::google::protobuf::internal::AuxillaryParseTableField aux[]
- GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold);
+ PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::google::protobuf::internal::ParseTable schema[1]
- GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold);
+ PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::google::protobuf::internal::FieldMetadata field_metadata[];
static const ::google::protobuf::internal::SerializationTable serialization_table[];
static const ::google::protobuf::uint32 offsets[];
};
-void LIBPROTOBUF_EXPORT AddDescriptors_google_2fprotobuf_2ftimestamp_2eproto();
+void PROTOBUF_EXPORT AddDescriptors_google_2fprotobuf_2ftimestamp_2eproto();
namespace google {
namespace protobuf {
class Timestamp;
class TimestampDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern TimestampDefaultTypeInternal _Timestamp_default_instance_;
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::Timestamp* Arena::CreateMaybeMessage<::google::protobuf::Timestamp>(Arena*);
+PROTOBUF_EXPORT extern TimestampDefaultTypeInternal _Timestamp_default_instance_;
+template<> PROTOBUF_EXPORT ::google::protobuf::Timestamp* Arena::CreateMaybeMessage<::google::protobuf::Timestamp>(Arena*);
} // namespace protobuf
} // namespace google
namespace google {
@@ -60,7 +61,7 @@ namespace protobuf {
// ===================================================================
-class LIBPROTOBUF_EXPORT Timestamp : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Timestamp) */ {
+class PROTOBUF_EXPORT Timestamp : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Timestamp) */ {
public:
Timestamp();
virtual ~Timestamp();
@@ -204,7 +205,7 @@ class LIBPROTOBUF_EXPORT Timestamp : public ::google::protobuf::Message /* @@pro
// int64 seconds = 1;
inline void Timestamp::clear_seconds() {
- seconds_ = GOOGLE_PROTOBUF_LONGLONG(0);
+ seconds_ = PROTOBUF_LONGLONG(0);
}
inline ::google::protobuf::int64 Timestamp::seconds() const {
// @@protoc_insertion_point(field_get:google.protobuf.Timestamp.seconds)
diff --git a/src/google/protobuf/timestamp.proto b/src/google/protobuf/timestamp.proto
index eafb3fa0..3faa3ab7 100644
--- a/src/google/protobuf/timestamp.proto
+++ b/src/google/protobuf/timestamp.proto
@@ -116,7 +116,7 @@ option objc_class_prefix = "GPB";
// to this format using [`strftime`](https://docs.python.org/2/library/time.html#time.strftime)
// with the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one
// can use the Joda Time's [`ISODateTimeFormat.dateTime()`](
-// http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime--
+// http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D
// ) to obtain a formatter capable of generating timestamps in this format.
//
//
diff --git a/src/google/protobuf/type.pb.cc b/src/google/protobuf/type.pb.cc
index de1bd6c9..2d00a8ff 100644
--- a/src/google/protobuf/type.pb.cc
+++ b/src/google/protobuf/type.pb.cc
@@ -13,10 +13,6 @@
#include <google/protobuf/generated_message_reflection.h>
#include <google/protobuf/reflection_ops.h>
#include <google/protobuf/wire_format.h>
-// This is a temporary google only hack
-#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
-#include "third_party/protobuf/version.h"
-#endif
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>
@@ -60,7 +56,7 @@ static void InitDefaultsType_google_2fprotobuf_2ftype_2eproto() {
::google::protobuf::Type::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<3> scc_info_Type_google_2fprotobuf_2ftype_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<3> scc_info_Type_google_2fprotobuf_2ftype_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 3, InitDefaultsType_google_2fprotobuf_2ftype_2eproto}, {
&scc_info_Field_google_2fprotobuf_2ftype_2eproto.base,
&scc_info_Option_google_2fprotobuf_2ftype_2eproto.base,
@@ -77,7 +73,7 @@ static void InitDefaultsField_google_2fprotobuf_2ftype_2eproto() {
::google::protobuf::Field::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<1> scc_info_Field_google_2fprotobuf_2ftype_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<1> scc_info_Field_google_2fprotobuf_2ftype_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsField_google_2fprotobuf_2ftype_2eproto}, {
&scc_info_Option_google_2fprotobuf_2ftype_2eproto.base,}};
@@ -92,7 +88,7 @@ static void InitDefaultsEnum_google_2fprotobuf_2ftype_2eproto() {
::google::protobuf::Enum::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<3> scc_info_Enum_google_2fprotobuf_2ftype_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<3> scc_info_Enum_google_2fprotobuf_2ftype_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 3, InitDefaultsEnum_google_2fprotobuf_2ftype_2eproto}, {
&scc_info_EnumValue_google_2fprotobuf_2ftype_2eproto.base,
&scc_info_Option_google_2fprotobuf_2ftype_2eproto.base,
@@ -109,7 +105,7 @@ static void InitDefaultsEnumValue_google_2fprotobuf_2ftype_2eproto() {
::google::protobuf::EnumValue::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<1> scc_info_EnumValue_google_2fprotobuf_2ftype_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<1> scc_info_EnumValue_google_2fprotobuf_2ftype_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsEnumValue_google_2fprotobuf_2ftype_2eproto}, {
&scc_info_Option_google_2fprotobuf_2ftype_2eproto.base,}};
@@ -124,7 +120,7 @@ static void InitDefaultsOption_google_2fprotobuf_2ftype_2eproto() {
::google::protobuf::Option::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<1> scc_info_Option_google_2fprotobuf_2ftype_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<1> scc_info_Option_google_2fprotobuf_2ftype_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsOption_google_2fprotobuf_2ftype_2eproto}, {
&scc_info_Any_google_2fprotobuf_2fany_2eproto.base,}};
@@ -140,60 +136,60 @@ void InitDefaults_google_2fprotobuf_2ftype_2eproto() {
const ::google::protobuf::EnumDescriptor* file_level_enum_descriptors_google_2fprotobuf_2ftype_2eproto[3];
constexpr ::google::protobuf::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2ftype_2eproto = nullptr;
-const ::google::protobuf::uint32 TableStruct_google_2fprotobuf_2ftype_2eproto::offsets[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
+const ::google::protobuf::uint32 TableStruct_google_2fprotobuf_2ftype_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
~0u, // no _has_bits_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Type, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Type, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Type, name_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Type, fields_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Type, oneofs_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Type, options_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Type, source_context_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Type, syntax_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Type, name_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Type, fields_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Type, oneofs_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Type, options_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Type, source_context_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Type, syntax_),
~0u, // no _has_bits_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Field, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Field, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Field, kind_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Field, cardinality_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Field, number_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Field, name_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Field, type_url_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Field, oneof_index_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Field, packed_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Field, options_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Field, json_name_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Field, default_value_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Field, kind_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Field, cardinality_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Field, number_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Field, name_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Field, type_url_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Field, oneof_index_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Field, packed_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Field, options_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Field, json_name_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Field, default_value_),
~0u, // no _has_bits_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Enum, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Enum, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Enum, name_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Enum, enumvalue_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Enum, options_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Enum, source_context_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Enum, syntax_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Enum, name_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Enum, enumvalue_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Enum, options_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Enum, source_context_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Enum, syntax_),
~0u, // no _has_bits_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumValue, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::EnumValue, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumValue, name_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumValue, number_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::EnumValue, options_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::EnumValue, name_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::EnumValue, number_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::EnumValue, options_),
~0u, // no _has_bits_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Option, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Option, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Option, name_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Option, value_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Option, name_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Option, value_),
};
-static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
+static const ::google::protobuf::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
{ 0, -1, sizeof(::google::protobuf::Type)},
{ 11, -1, sizeof(::google::protobuf::Field)},
{ 26, -1, sizeof(::google::protobuf::Enum)},
@@ -512,14 +508,13 @@ const char* Type::_InternalParse(const char* begin, const char* end, void* objec
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// string name = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 10) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.Type.name");
parser_till_end = ::google::protobuf::internal::StringParserUTF8;
::std::string* str = msg->mutable_name();
@@ -527,8 +522,8 @@ const char* Type::_InternalParse(const char* begin, const char* end, void* objec
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// repeated .google.protobuf.Field fields = 2;
@@ -536,15 +531,17 @@ const char* Type::_InternalParse(const char* begin, const char* end, void* objec
if (static_cast<::google::protobuf::uint8>(tag) != 18) goto handle_unusual;
do {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::Field::_InternalParse;
object = msg->add_fields();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 255) == 18 && (ptr += 1));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 18 && (ptr += 1));
break;
}
// repeated string oneofs = 3;
@@ -552,7 +549,7 @@ const char* Type::_InternalParse(const char* begin, const char* end, void* objec
if (static_cast<::google::protobuf::uint8>(tag) != 26) goto handle_unusual;
do {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.Type.oneofs");
parser_till_end = ::google::protobuf::internal::StringParserUTF8;
::std::string* str = msg->add_oneofs();
@@ -560,10 +557,10 @@ const char* Type::_InternalParse(const char* begin, const char* end, void* objec
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 255) == 26 && (ptr += 1));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 26 && (ptr += 1));
break;
}
// repeated .google.protobuf.Option options = 4;
@@ -571,27 +568,31 @@ const char* Type::_InternalParse(const char* begin, const char* end, void* objec
if (static_cast<::google::protobuf::uint8>(tag) != 34) goto handle_unusual;
do {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::Option::_InternalParse;
object = msg->add_options();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 255) == 34 && (ptr += 1));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 34 && (ptr += 1));
break;
}
// .google.protobuf.SourceContext source_context = 5;
case 5: {
if (static_cast<::google::protobuf::uint8>(tag) != 42) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::SourceContext::_InternalParse;
object = msg->mutable_source_context();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
break;
}
@@ -600,15 +601,16 @@ const char* Type::_InternalParse(const char* begin, const char* end, void* objec
if (static_cast<::google::protobuf::uint8>(tag) != 48) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
::google::protobuf::Syntax value = static_cast<::google::protobuf::Syntax>(val);
msg->set_syntax(value);
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
@@ -619,8 +621,6 @@ const char* Type::_InternalParse(const char* begin, const char* end, void* objec
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -632,7 +632,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool Type::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.Type)
for (;;) {
@@ -1159,15 +1159,14 @@ const char* Field::_InternalParse(const char* begin, const char* end, void* obje
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// .google.protobuf.Field.Kind kind = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 8) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
::google::protobuf::Field_Kind value = static_cast<::google::protobuf::Field_Kind>(val);
msg->set_kind(value);
break;
@@ -1177,7 +1176,7 @@ const char* Field::_InternalParse(const char* begin, const char* end, void* obje
if (static_cast<::google::protobuf::uint8>(tag) != 16) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
::google::protobuf::Field_Cardinality value = static_cast<::google::protobuf::Field_Cardinality>(val);
msg->set_cardinality(value);
break;
@@ -1187,7 +1186,7 @@ const char* Field::_InternalParse(const char* begin, const char* end, void* obje
if (static_cast<::google::protobuf::uint8>(tag) != 24) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
::google::protobuf::int32 value = val;
msg->set_number(value);
break;
@@ -1196,7 +1195,7 @@ const char* Field::_InternalParse(const char* begin, const char* end, void* obje
case 4: {
if (static_cast<::google::protobuf::uint8>(tag) != 34) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.Field.name");
parser_till_end = ::google::protobuf::internal::StringParserUTF8;
::std::string* str = msg->mutable_name();
@@ -1204,15 +1203,15 @@ const char* Field::_InternalParse(const char* begin, const char* end, void* obje
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// string type_url = 6;
case 6: {
if (static_cast<::google::protobuf::uint8>(tag) != 50) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.Field.type_url");
parser_till_end = ::google::protobuf::internal::StringParserUTF8;
::std::string* str = msg->mutable_type_url();
@@ -1220,8 +1219,8 @@ const char* Field::_InternalParse(const char* begin, const char* end, void* obje
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// int32 oneof_index = 7;
@@ -1229,7 +1228,7 @@ const char* Field::_InternalParse(const char* begin, const char* end, void* obje
if (static_cast<::google::protobuf::uint8>(tag) != 56) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
::google::protobuf::int32 value = val;
msg->set_oneof_index(value);
break;
@@ -1239,7 +1238,7 @@ const char* Field::_InternalParse(const char* begin, const char* end, void* obje
if (static_cast<::google::protobuf::uint8>(tag) != 64) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
bool value = val;
msg->set_packed(value);
break;
@@ -1249,22 +1248,24 @@ const char* Field::_InternalParse(const char* begin, const char* end, void* obje
if (static_cast<::google::protobuf::uint8>(tag) != 74) goto handle_unusual;
do {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::Option::_InternalParse;
object = msg->add_options();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 255) == 74 && (ptr += 1));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 74 && (ptr += 1));
break;
}
// string json_name = 10;
case 10: {
if (static_cast<::google::protobuf::uint8>(tag) != 82) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.Field.json_name");
parser_till_end = ::google::protobuf::internal::StringParserUTF8;
::std::string* str = msg->mutable_json_name();
@@ -1272,15 +1273,15 @@ const char* Field::_InternalParse(const char* begin, const char* end, void* obje
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// string default_value = 11;
case 11: {
if (static_cast<::google::protobuf::uint8>(tag) != 90) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.Field.default_value");
parser_till_end = ::google::protobuf::internal::StringParserUTF8;
::std::string* str = msg->mutable_default_value();
@@ -1288,14 +1289,15 @@ const char* Field::_InternalParse(const char* begin, const char* end, void* obje
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
@@ -1306,8 +1308,6 @@ const char* Field::_InternalParse(const char* begin, const char* end, void* obje
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -1319,7 +1319,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool Field::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.Field)
for (;;) {
@@ -2010,14 +2010,13 @@ const char* Enum::_InternalParse(const char* begin, const char* end, void* objec
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// string name = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 10) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.Enum.name");
parser_till_end = ::google::protobuf::internal::StringParserUTF8;
::std::string* str = msg->mutable_name();
@@ -2025,8 +2024,8 @@ const char* Enum::_InternalParse(const char* begin, const char* end, void* objec
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// repeated .google.protobuf.EnumValue enumvalue = 2;
@@ -2034,15 +2033,17 @@ const char* Enum::_InternalParse(const char* begin, const char* end, void* objec
if (static_cast<::google::protobuf::uint8>(tag) != 18) goto handle_unusual;
do {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::EnumValue::_InternalParse;
object = msg->add_enumvalue();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 255) == 18 && (ptr += 1));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 18 && (ptr += 1));
break;
}
// repeated .google.protobuf.Option options = 3;
@@ -2050,27 +2051,31 @@ const char* Enum::_InternalParse(const char* begin, const char* end, void* objec
if (static_cast<::google::protobuf::uint8>(tag) != 26) goto handle_unusual;
do {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::Option::_InternalParse;
object = msg->add_options();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 255) == 26 && (ptr += 1));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 26 && (ptr += 1));
break;
}
// .google.protobuf.SourceContext source_context = 4;
case 4: {
if (static_cast<::google::protobuf::uint8>(tag) != 34) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::SourceContext::_InternalParse;
object = msg->mutable_source_context();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
break;
}
@@ -2079,15 +2084,16 @@ const char* Enum::_InternalParse(const char* begin, const char* end, void* objec
if (static_cast<::google::protobuf::uint8>(tag) != 40) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
::google::protobuf::Syntax value = static_cast<::google::protobuf::Syntax>(val);
msg->set_syntax(value);
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
@@ -2098,8 +2104,6 @@ const char* Enum::_InternalParse(const char* begin, const char* end, void* objec
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -2111,7 +2115,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool Enum::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.Enum)
for (;;) {
@@ -2555,14 +2559,13 @@ const char* EnumValue::_InternalParse(const char* begin, const char* end, void*
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// string name = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 10) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.EnumValue.name");
parser_till_end = ::google::protobuf::internal::StringParserUTF8;
::std::string* str = msg->mutable_name();
@@ -2570,8 +2573,8 @@ const char* EnumValue::_InternalParse(const char* begin, const char* end, void*
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// int32 number = 2;
@@ -2579,7 +2582,7 @@ const char* EnumValue::_InternalParse(const char* begin, const char* end, void*
if (static_cast<::google::protobuf::uint8>(tag) != 16) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
::google::protobuf::int32 value = val;
msg->set_number(value);
break;
@@ -2589,21 +2592,24 @@ const char* EnumValue::_InternalParse(const char* begin, const char* end, void*
if (static_cast<::google::protobuf::uint8>(tag) != 26) goto handle_unusual;
do {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::Option::_InternalParse;
object = msg->add_options();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
if (ptr >= end) break;
- } while((*reinterpret_cast<const ::google::protobuf::uint64*>(ptr) & 255) == 26 && (ptr += 1));
+ } while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 26 && (ptr += 1));
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
@@ -2614,8 +2620,6 @@ const char* EnumValue::_InternalParse(const char* begin, const char* end, void*
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -2627,7 +2631,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool EnumValue::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.EnumValue)
for (;;) {
@@ -3023,14 +3027,13 @@ const char* Option::_InternalParse(const char* begin, const char* end, void* obj
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// string name = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 10) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.Option.name");
parser_till_end = ::google::protobuf::internal::StringParserUTF8;
::std::string* str = msg->mutable_name();
@@ -3038,27 +3041,30 @@ const char* Option::_InternalParse(const char* begin, const char* end, void* obj
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
// .google.protobuf.Any value = 2;
case 2: {
if (static_cast<::google::protobuf::uint8>(tag) != 18) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::Any::_InternalParse;
object = msg->mutable_value();
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
+ bool ok = ctx->ParseExactRange({parser_till_end, object},
+ ptr, newend);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
ptr = newend;
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
@@ -3069,8 +3075,6 @@ const char* Option::_InternalParse(const char* begin, const char* end, void* obj
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -3082,7 +3086,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool Option::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.Option)
for (;;) {
@@ -3317,22 +3321,23 @@ void Option::InternalSwap(Option* other) {
} // namespace google
namespace google {
namespace protobuf {
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Type* Arena::CreateMaybeMessage< ::google::protobuf::Type >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::Type* Arena::CreateMaybeMessage< ::google::protobuf::Type >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::Type >(arena);
}
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Field* Arena::CreateMaybeMessage< ::google::protobuf::Field >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::Field* Arena::CreateMaybeMessage< ::google::protobuf::Field >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::Field >(arena);
}
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Enum* Arena::CreateMaybeMessage< ::google::protobuf::Enum >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::Enum* Arena::CreateMaybeMessage< ::google::protobuf::Enum >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::Enum >(arena);
}
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::EnumValue* Arena::CreateMaybeMessage< ::google::protobuf::EnumValue >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::EnumValue* Arena::CreateMaybeMessage< ::google::protobuf::EnumValue >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::EnumValue >(arena);
}
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Option* Arena::CreateMaybeMessage< ::google::protobuf::Option >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::Option* Arena::CreateMaybeMessage< ::google::protobuf::Option >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::Option >(arena);
}
} // namespace protobuf
} // namespace google
// @@protoc_insertion_point(global_scope)
+#include <google/protobuf/port_undef.inc>
diff --git a/src/google/protobuf/type.pb.h b/src/google/protobuf/type.pb.h
index 5ae22bbd..63d71e6b 100644
--- a/src/google/protobuf/type.pb.h
+++ b/src/google/protobuf/type.pb.h
@@ -7,18 +7,19 @@
#include <limits>
#include <string>
-#include <google/protobuf/stubs/common.h>
-#if GOOGLE_PROTOBUF_VERSION < 3006000
+#include <google/protobuf/port_def.inc>
+#if PROTOBUF_VERSION < 3006001
#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 3006001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 3006001 < 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.
#endif
+#include <google/protobuf/port_undef.inc>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
@@ -35,43 +36,43 @@
#include <google/protobuf/source_context.pb.h>
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>
-#define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2ftype_2eproto LIBPROTOBUF_EXPORT
+#define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2ftype_2eproto PROTOBUF_EXPORT
// Internal implementation detail -- do not use these members.
-struct LIBPROTOBUF_EXPORT TableStruct_google_2fprotobuf_2ftype_2eproto {
+struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2ftype_2eproto {
static const ::google::protobuf::internal::ParseTableField entries[]
- GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold);
+ PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::google::protobuf::internal::AuxillaryParseTableField aux[]
- GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold);
+ PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::google::protobuf::internal::ParseTable schema[5]
- GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold);
+ PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::google::protobuf::internal::FieldMetadata field_metadata[];
static const ::google::protobuf::internal::SerializationTable serialization_table[];
static const ::google::protobuf::uint32 offsets[];
};
-void LIBPROTOBUF_EXPORT AddDescriptors_google_2fprotobuf_2ftype_2eproto();
+void PROTOBUF_EXPORT AddDescriptors_google_2fprotobuf_2ftype_2eproto();
namespace google {
namespace protobuf {
class Enum;
class EnumDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern EnumDefaultTypeInternal _Enum_default_instance_;
+PROTOBUF_EXPORT extern EnumDefaultTypeInternal _Enum_default_instance_;
class EnumValue;
class EnumValueDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern EnumValueDefaultTypeInternal _EnumValue_default_instance_;
+PROTOBUF_EXPORT extern EnumValueDefaultTypeInternal _EnumValue_default_instance_;
class Field;
class FieldDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern FieldDefaultTypeInternal _Field_default_instance_;
+PROTOBUF_EXPORT extern FieldDefaultTypeInternal _Field_default_instance_;
class Option;
class OptionDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern OptionDefaultTypeInternal _Option_default_instance_;
+PROTOBUF_EXPORT extern OptionDefaultTypeInternal _Option_default_instance_;
class Type;
class TypeDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern TypeDefaultTypeInternal _Type_default_instance_;
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::Enum* Arena::CreateMaybeMessage<::google::protobuf::Enum>(Arena*);
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::EnumValue* Arena::CreateMaybeMessage<::google::protobuf::EnumValue>(Arena*);
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::Field* Arena::CreateMaybeMessage<::google::protobuf::Field>(Arena*);
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::Option* Arena::CreateMaybeMessage<::google::protobuf::Option>(Arena*);
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::Type* Arena::CreateMaybeMessage<::google::protobuf::Type>(Arena*);
+PROTOBUF_EXPORT extern TypeDefaultTypeInternal _Type_default_instance_;
+template<> PROTOBUF_EXPORT ::google::protobuf::Enum* Arena::CreateMaybeMessage<::google::protobuf::Enum>(Arena*);
+template<> PROTOBUF_EXPORT ::google::protobuf::EnumValue* Arena::CreateMaybeMessage<::google::protobuf::EnumValue>(Arena*);
+template<> PROTOBUF_EXPORT ::google::protobuf::Field* Arena::CreateMaybeMessage<::google::protobuf::Field>(Arena*);
+template<> PROTOBUF_EXPORT ::google::protobuf::Option* Arena::CreateMaybeMessage<::google::protobuf::Option>(Arena*);
+template<> PROTOBUF_EXPORT ::google::protobuf::Type* Arena::CreateMaybeMessage<::google::protobuf::Type>(Arena*);
} // namespace protobuf
} // namespace google
namespace google {
@@ -100,12 +101,12 @@ enum Field_Kind {
Field_Kind_Field_Kind_INT_MIN_SENTINEL_DO_NOT_USE_ = std::numeric_limits<::google::protobuf::int32>::min(),
Field_Kind_Field_Kind_INT_MAX_SENTINEL_DO_NOT_USE_ = std::numeric_limits<::google::protobuf::int32>::max()
};
-LIBPROTOBUF_EXPORT bool Field_Kind_IsValid(int value);
+PROTOBUF_EXPORT bool Field_Kind_IsValid(int value);
const Field_Kind Field_Kind_Kind_MIN = Field_Kind_TYPE_UNKNOWN;
const Field_Kind Field_Kind_Kind_MAX = Field_Kind_TYPE_SINT64;
const int Field_Kind_Kind_ARRAYSIZE = Field_Kind_Kind_MAX + 1;
-LIBPROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* Field_Kind_descriptor();
+PROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* Field_Kind_descriptor();
inline const ::std::string& Field_Kind_Name(Field_Kind value) {
return ::google::protobuf::internal::NameOfEnum(
Field_Kind_descriptor(), value);
@@ -123,12 +124,12 @@ enum Field_Cardinality {
Field_Cardinality_Field_Cardinality_INT_MIN_SENTINEL_DO_NOT_USE_ = std::numeric_limits<::google::protobuf::int32>::min(),
Field_Cardinality_Field_Cardinality_INT_MAX_SENTINEL_DO_NOT_USE_ = std::numeric_limits<::google::protobuf::int32>::max()
};
-LIBPROTOBUF_EXPORT bool Field_Cardinality_IsValid(int value);
+PROTOBUF_EXPORT bool Field_Cardinality_IsValid(int value);
const Field_Cardinality Field_Cardinality_Cardinality_MIN = Field_Cardinality_CARDINALITY_UNKNOWN;
const Field_Cardinality Field_Cardinality_Cardinality_MAX = Field_Cardinality_CARDINALITY_REPEATED;
const int Field_Cardinality_Cardinality_ARRAYSIZE = Field_Cardinality_Cardinality_MAX + 1;
-LIBPROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* Field_Cardinality_descriptor();
+PROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* Field_Cardinality_descriptor();
inline const ::std::string& Field_Cardinality_Name(Field_Cardinality value) {
return ::google::protobuf::internal::NameOfEnum(
Field_Cardinality_descriptor(), value);
@@ -144,12 +145,12 @@ enum Syntax {
Syntax_INT_MIN_SENTINEL_DO_NOT_USE_ = std::numeric_limits<::google::protobuf::int32>::min(),
Syntax_INT_MAX_SENTINEL_DO_NOT_USE_ = std::numeric_limits<::google::protobuf::int32>::max()
};
-LIBPROTOBUF_EXPORT bool Syntax_IsValid(int value);
+PROTOBUF_EXPORT bool Syntax_IsValid(int value);
const Syntax Syntax_MIN = SYNTAX_PROTO2;
const Syntax Syntax_MAX = SYNTAX_PROTO3;
const int Syntax_ARRAYSIZE = Syntax_MAX + 1;
-LIBPROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* Syntax_descriptor();
+PROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* Syntax_descriptor();
inline const ::std::string& Syntax_Name(Syntax value) {
return ::google::protobuf::internal::NameOfEnum(
Syntax_descriptor(), value);
@@ -161,7 +162,7 @@ inline bool Syntax_Parse(
}
// ===================================================================
-class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Type) */ {
+class PROTOBUF_EXPORT Type : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Type) */ {
public:
Type();
virtual ~Type();
@@ -373,7 +374,7 @@ class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message /* @@protoc_i
};
// -------------------------------------------------------------------
-class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Field) */ {
+class PROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Field) */ {
public:
Field();
virtual ~Field();
@@ -726,7 +727,7 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_
};
// -------------------------------------------------------------------
-class LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Enum) */ {
+class PROTOBUF_EXPORT Enum : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Enum) */ {
public:
Enum();
virtual ~Enum();
@@ -915,7 +916,7 @@ class LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message /* @@protoc_i
};
// -------------------------------------------------------------------
-class LIBPROTOBUF_EXPORT EnumValue : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumValue) */ {
+class PROTOBUF_EXPORT EnumValue : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumValue) */ {
public:
EnumValue();
virtual ~EnumValue();
@@ -1078,7 +1079,7 @@ class LIBPROTOBUF_EXPORT EnumValue : public ::google::protobuf::Message /* @@pro
};
// -------------------------------------------------------------------
-class LIBPROTOBUF_EXPORT Option : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Option) */ {
+class PROTOBUF_EXPORT Option : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Option) */ {
public:
Option();
virtual ~Option();
diff --git a/src/google/protobuf/unknown_field_set.cc b/src/google/protobuf/unknown_field_set.cc
index dc53016b..0226c76b 100644
--- a/src/google/protobuf/unknown_field_set.cc
+++ b/src/google/protobuf/unknown_field_set.cc
@@ -329,6 +329,7 @@ const char* PackedValidEnumParser(const char* begin, const char* end,
while (ptr < end) {
uint64 varint;
ptr = Varint::Parse64(ptr, &varint);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
int val = varint;
if (ctx->extra_parse_data().ValidateEnum<UnknownFieldSet>(val))
repeated_field->Add(val);
@@ -343,6 +344,7 @@ const char* PackedValidEnumParserArg(const char* begin, const char* end,
while (ptr < end) {
uint64 varint;
ptr = Varint::Parse64(ptr, &varint);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
int val = varint;
if (ctx->extra_parse_data().ValidateEnumArg<UnknownFieldSet>(val))
repeated_field->Add(val);
@@ -358,7 +360,8 @@ const char* UnknownGroupParse(const char* begin, const char* end, void* object,
while (ptr < end) {
uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if ((tag >> 3) == 0) return nullptr;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
+ GOOGLE_PROTOBUF_PARSER_ASSERT((tag >> 3) != 0);
auto res = UnknownFieldParse(tag, {UnknownGroupParse, unknown}, ptr, end,
unknown, ctx);
@@ -368,7 +371,7 @@ const char* UnknownGroupParse(const char* begin, const char* end, void* object,
return ptr;
}
-std::pair<const char*, bool> UnknownFieldParse(uint32 tag, ParseClosure parent,
+std::pair<const char*, bool> UnknownFieldParse(uint64 tag, ParseClosure parent,
const char* begin,
const char* end,
UnknownFieldSet* unknown,
@@ -378,14 +381,13 @@ std::pair<const char*, bool> UnknownFieldParse(uint32 tag, ParseClosure parent,
void* object;
auto ptr = begin;
- GOOGLE_DCHECK(tag >> 3);
-
uint32 field_num = tag >> 3;
+ GOOGLE_PROTOBUF_ASSERT_RETURN(field_num != 0, std::make_pair(nullptr, true));
switch (tag & 7) {
case 0: {
uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_ASSERT_RETURN(ptr, std::make_pair(nullptr, true));
unknown->AddVarint(field_num, val);
break;
}
@@ -397,26 +399,27 @@ std::pair<const char*, bool> UnknownFieldParse(uint32 tag, ParseClosure parent,
}
case 2: {
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_ASSERT_RETURN(ptr, std::make_pair(nullptr, true));
object = unknown->AddLengthDelimited(field_num);
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({StringParser, object}, ptr, newend)) {
- goto error;
- }
+ bool ok = ctx->ParseExactRange({StringParser, object}, ptr, newend);
+ GOOGLE_PROTOBUF_ASSERT_RETURN(ok, std::make_pair(nullptr, true));
ptr = newend;
break;
}
case 3: {
object = unknown->AddGroup(field_num);
- if (!ctx->PrepareGroup(tag, &depth)) goto error;
+ bool ok = ctx->PrepareGroup(tag, &depth);
+ GOOGLE_PROTOBUF_ASSERT_RETURN(ok, std::make_pair(nullptr, true));
ptr = UnknownGroupParse(ptr, end, object, ctx);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_ASSERT_RETURN(ptr, std::make_pair(nullptr, true));
if (ctx->GroupContinues(depth)) goto group_continues;
break;
}
case 4: {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_ASSERT_RETURN(ok, std::make_pair(nullptr, true));
return std::make_pair(ptr, true);
}
case 5: {
@@ -426,11 +429,9 @@ std::pair<const char*, bool> UnknownFieldParse(uint32 tag, ParseClosure parent,
break;
}
default:
- goto error;
+ GOOGLE_PROTOBUF_ASSERT_RETURN(false, std::make_pair(nullptr, true));
}
return std::make_pair(ptr, false);
-error:
- return std::make_pair(nullptr, true);
len_delim_till_end:
// Length delimited field crosses end
return std::make_pair(
diff --git a/src/google/protobuf/unknown_field_set.h b/src/google/protobuf/unknown_field_set.h
index d891a9e8..7ba33da5 100644
--- a/src/google/protobuf/unknown_field_set.h
+++ b/src/google/protobuf/unknown_field_set.h
@@ -86,7 +86,7 @@ class UnknownField; // below
//
// This class is necessarily tied to the protocol buffer wire format, unlike
// the Reflection interface which is independent of any serialization scheme.
-class LIBPROTOBUF_EXPORT UnknownFieldSet {
+class PROTOBUF_EXPORT UnknownFieldSet {
public:
UnknownFieldSet();
~UnknownFieldSet();
@@ -147,8 +147,8 @@ class LIBPROTOBUF_EXPORT UnknownFieldSet {
void AddVarint(int number, uint64 value);
void AddFixed32(int number, uint32 value);
void AddFixed64(int number, uint64 value);
- void AddLengthDelimited(int number, const string& value);
- string* AddLengthDelimited(int number);
+ void AddLengthDelimited(int number, const std::string& value);
+ std::string* AddLengthDelimited(int number);
UnknownFieldSet* AddGroup(int number);
// Adds an unknown field from another set.
@@ -170,7 +170,7 @@ class LIBPROTOBUF_EXPORT UnknownFieldSet {
bool ParseFromCodedStream(io::CodedInputStream* input);
bool ParseFromZeroCopyStream(io::ZeroCopyInputStream* input);
bool ParseFromArray(const void* data, int size);
- inline bool ParseFromString(const string& data) {
+ inline bool ParseFromString(const std::string& data) {
return ParseFromArray(data.data(), static_cast<int>(data.size()));
}
@@ -198,6 +198,10 @@ namespace internal {
inline void WriteVarint(uint32 num, uint64 val, UnknownFieldSet* unknown) {
unknown->AddVarint(num, val);
}
+inline void WriteLengthDelimited(uint32 num, StringPiece val,
+ UnknownFieldSet* unknown) {
+ unknown->AddLengthDelimited(num)->assign(val.data(), val.size());
+}
const char* PackedValidEnumParser(const char* begin, const char* end,
void* object, ParseContext* ctx);
@@ -206,49 +210,17 @@ const char* PackedValidEnumParserArg(const char* begin, const char* end,
const char* UnknownGroupParse(const char* begin, const char* end, void* object,
ParseContext* ctx);
-std::pair<const char*, bool> UnknownFieldParse(uint32 tag, ParseClosure parent,
+std::pair<const char*, bool> UnknownFieldParse(uint64 tag, ParseClosure parent,
const char* begin,
const char* end,
UnknownFieldSet* unknown,
ParseContext* ctx);
-template <typename Msg>
-const char* ParseMessageSet(const char* begin, const char* end, Msg* msg,
- internal::ParseContext* ctx) {
- auto ptr = begin;
- int depth;
- (void)depth;
- while (ptr < end) {
- uint32 tag;
- ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
- if (tag == 11) {
- if (!ctx->PrepareGroup(tag, &depth)) goto error;
- ctx->extra_parse_data().payload.clear();
- ptr = Msg::InternalParseMessageSetItem(ptr, end, msg, ctx);
- if (!ptr) goto error;
- if (ctx->GroupContinues(depth)) goto group_continues;
- } else {
- auto res = UnknownFieldParse(tag, {Msg::_InternalParse, msg}, begin, end,
- msg->mutable_unknown_fields(), ctx);
- ptr = res.first;
- if (res.second) break;
- }
- }
- return ptr;
-error:
- return nullptr;
-group_continues:
- GOOGLE_DCHECK(ptr >= end);
- ctx->StoreGroup({Msg::_InternalParse, msg},
- {Msg::InternalParseMessageSetItem, msg}, depth);
- return ptr;
-}
} // namespace internal
#endif // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
// Represents one field in an UnknownFieldSet.
-class LIBPROTOBUF_EXPORT UnknownField {
+class PROTOBUF_EXPORT UnknownField {
public:
enum Type {
TYPE_VARINT,
@@ -270,14 +242,14 @@ class LIBPROTOBUF_EXPORT UnknownField {
inline uint64 varint() const;
inline uint32 fixed32() const;
inline uint64 fixed64() const;
- inline const string& length_delimited() const;
+ inline const std::string& length_delimited() const;
inline const UnknownFieldSet& group() const;
inline void set_varint(uint64 value);
inline void set_fixed32(uint32 value);
inline void set_fixed64(uint64 value);
- inline void set_length_delimited(const string& value);
- inline string* mutable_length_delimited();
+ inline void set_length_delimited(const std::string& value);
+ inline std::string* mutable_length_delimited();
inline UnknownFieldSet* mutable_group();
// Serialization API.
@@ -305,7 +277,7 @@ class LIBPROTOBUF_EXPORT UnknownField {
inline void SetType(Type type);
union LengthDelimited {
- string* string_value_;
+ std::string* string_value_;
};
uint32 number_;
@@ -355,7 +327,7 @@ inline UnknownField* UnknownFieldSet::mutable_field(int index) {
}
inline void UnknownFieldSet::AddLengthDelimited(
- int number, const string& value) {
+ int number, const std::string& value) {
AddLengthDelimited(number)->assign(value);
}
@@ -379,7 +351,7 @@ inline uint64 UnknownField::fixed64() const {
assert(type() == TYPE_FIXED64);
return data_.fixed64_;
}
-inline const string& UnknownField::length_delimited() const {
+inline const std::string& UnknownField::length_delimited() const {
assert(type() == TYPE_LENGTH_DELIMITED);
return *data_.length_delimited_.string_value_;
}
@@ -400,11 +372,11 @@ inline void UnknownField::set_fixed64(uint64 value) {
assert(type() == TYPE_FIXED64);
data_.fixed64_ = value;
}
-inline void UnknownField::set_length_delimited(const string& value) {
+inline void UnknownField::set_length_delimited(const std::string& value) {
assert(type() == TYPE_LENGTH_DELIMITED);
data_.length_delimited_.string_value_->assign(value);
}
-inline string* UnknownField::mutable_length_delimited() {
+inline std::string* UnknownField::mutable_length_delimited() {
assert(type() == TYPE_LENGTH_DELIMITED);
return data_.length_delimited_.string_value_;
}
diff --git a/src/google/protobuf/util/delimited_message_util.h b/src/google/protobuf/util/delimited_message_util.h
index ffad0a7a..5f2d94cd 100644
--- a/src/google/protobuf/util/delimited_message_util.h
+++ b/src/google/protobuf/util/delimited_message_util.h
@@ -10,6 +10,8 @@
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace util {
@@ -30,9 +32,11 @@ namespace util {
// then parse it. As a result, they may read past the end of the delimited
// message. There is no way for them to push the extra data back into the
// underlying source, so instead you must keep using the same stream object.
-bool LIBPROTOBUF_EXPORT SerializeDelimitedToFileDescriptor(const MessageLite& message, int file_descriptor);
+bool PROTOBUF_EXPORT SerializeDelimitedToFileDescriptor(
+ const MessageLite& message, int file_descriptor);
-bool LIBPROTOBUF_EXPORT SerializeDelimitedToOstream(const MessageLite& message, std::ostream* output);
+bool PROTOBUF_EXPORT SerializeDelimitedToOstream(const MessageLite& message,
+ std::ostream* output);
// Read a single size-delimited message from the given stream. Delimited
// format allows a single file or stream to contain multiple messages,
@@ -46,21 +50,28 @@ bool LIBPROTOBUF_EXPORT SerializeDelimitedToOstream(const MessageLite& message,
// otherwise it will be set false. Note that these methods return false
// on EOF, but they also return false on other errors, so |clean_eof| is
// needed to distinguish a clean end from errors.
-bool LIBPROTOBUF_EXPORT ParseDelimitedFromZeroCopyStream(MessageLite* message, io::ZeroCopyInputStream* input, bool* clean_eof);
+bool PROTOBUF_EXPORT ParseDelimitedFromZeroCopyStream(
+ MessageLite* message, io::ZeroCopyInputStream* input, bool* clean_eof);
-bool LIBPROTOBUF_EXPORT ParseDelimitedFromCodedStream(MessageLite* message, io::CodedInputStream* input, bool* clean_eof);
+bool PROTOBUF_EXPORT ParseDelimitedFromCodedStream(MessageLite* message,
+ io::CodedInputStream* input,
+ bool* clean_eof);
// Write a single size-delimited message from the given stream. Delimited
// format allows a single file or stream to contain multiple messages,
// whereas normally writing multiple non-delimited messages to the same
// stream would cause them to be merged. A delimited message is a varint
// encoding the message size followed by a message of exactly that size.
-bool LIBPROTOBUF_EXPORT SerializeDelimitedToZeroCopyStream(const MessageLite& message, io::ZeroCopyOutputStream* output);
+bool PROTOBUF_EXPORT SerializeDelimitedToZeroCopyStream(
+ const MessageLite& message, io::ZeroCopyOutputStream* output);
-bool LIBPROTOBUF_EXPORT SerializeDelimitedToCodedStream(const MessageLite& message, io::CodedOutputStream* output);
+bool PROTOBUF_EXPORT SerializeDelimitedToCodedStream(
+ const MessageLite& message, io::CodedOutputStream* output);
} // namespace util
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_UTIL_DELIMITED_MESSAGE_UTIL_H__
diff --git a/src/google/protobuf/util/field_comparator.h b/src/google/protobuf/util/field_comparator.h
index 624fb2cf..8c952831 100644
--- a/src/google/protobuf/util/field_comparator.h
+++ b/src/google/protobuf/util/field_comparator.h
@@ -39,6 +39,8 @@
#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
@@ -55,7 +57,7 @@ class MessageDifferencer;
// Regular users should consider using or subclassing DefaultFieldComparator
// rather than this interface.
// Currently, this does not support comparing unknown fields.
-class LIBPROTOBUF_EXPORT FieldComparator {
+class PROTOBUF_EXPORT FieldComparator {
public:
FieldComparator();
virtual ~FieldComparator();
@@ -95,7 +97,7 @@ class LIBPROTOBUF_EXPORT FieldComparator {
// Basic implementation of FieldComparator. Supports three modes of floating
// point value comparison: exact, approximate using MathUtil::AlmostEqual
// method, and arbitrarily precise using MathUtil::WithinFractionOrMargin.
-class LIBPROTOBUF_EXPORT DefaultFieldComparator : public FieldComparator {
+class PROTOBUF_EXPORT DefaultFieldComparator : public FieldComparator {
public:
enum FloatComparison {
EXACT, // Floats and doubles are compared exactly.
@@ -207,8 +209,8 @@ class LIBPROTOBUF_EXPORT DefaultFieldComparator : public FieldComparator {
return value_1 == value_2;
}
- bool CompareString(const FieldDescriptor& field, const string& value_1,
- const string& value_2) {
+ bool CompareString(const FieldDescriptor& field, const std::string& value_1,
+ const std::string& value_2) {
return value_1 == value_2;
}
@@ -260,4 +262,6 @@ class LIBPROTOBUF_EXPORT DefaultFieldComparator : public FieldComparator {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_UTIL_FIELD_COMPARATOR_H__
diff --git a/src/google/protobuf/util/field_mask_util.cc b/src/google/protobuf/util/field_mask_util.cc
index cf65ef27..7cd652b1 100644
--- a/src/google/protobuf/util/field_mask_util.cc
+++ b/src/google/protobuf/util/field_mask_util.cc
@@ -160,7 +160,7 @@ bool FieldMaskUtil::GetFieldDescriptors(
return true;
}
-void FieldMaskUtil::InternalGetFieldMaskForAllFields(
+void FieldMaskUtil::GetFieldMaskForAllFields(
const Descriptor* descriptor, FieldMask* out) {
for (int i = 0; i < descriptor->field_count(); ++i) {
out->add_paths(descriptor->field(i)->name());
@@ -644,9 +644,9 @@ void FieldMaskUtil::Intersect(const FieldMask& mask1, const FieldMask& mask2,
intersection.MergeToFieldMask(out);
}
-void FieldMaskUtil::InternalSubtract(const Descriptor* descriptor,
- const FieldMask& mask1,
- const FieldMask& mask2, FieldMask* out) {
+void FieldMaskUtil::Subtract(const Descriptor* descriptor,
+ const FieldMask& mask1, const FieldMask& mask2,
+ FieldMask* out) {
if (mask1.paths().empty()) {
out->Clear();
return;
diff --git a/src/google/protobuf/util/field_mask_util.h b/src/google/protobuf/util/field_mask_util.h
index 6fabc3ec..7031442d 100644
--- a/src/google/protobuf/util/field_mask_util.h
+++ b/src/google/protobuf/util/field_mask_util.h
@@ -45,20 +45,20 @@ namespace google {
namespace protobuf {
namespace util {
-class LIBPROTOBUF_EXPORT FieldMaskUtil {
+class PROTOBUF_EXPORT FieldMaskUtil {
typedef google::protobuf::FieldMask FieldMask;
public:
// Converts FieldMask to/from string, formatted by separating each path
// with a comma (e.g., "foo_bar,baz.quz").
- static string ToString(const FieldMask& mask);
+ static std::string ToString(const FieldMask& mask);
static void FromString(StringPiece str, FieldMask* out);
// Converts FieldMask to/from string, formatted according to proto3 JSON
// spec for FieldMask (e.g., "fooBar,baz.quz"). If the field name is not
// style conforming (i.e., not snake_case when converted to string, or not
// camelCase when converted from string), the conversion will fail.
- static bool ToJsonString(const FieldMask& mask, string* out);
+ static bool ToJsonString(const FieldMask& mask, std::string* out);
static bool FromJsonString(StringPiece str, FieldMask* out);
// Get the descriptors of the fields which the given path from the message
@@ -98,15 +98,18 @@ class LIBPROTOBUF_EXPORT FieldMaskUtil {
template <typename T>
static FieldMask GetFieldMaskForAllFields() {
FieldMask out;
- InternalGetFieldMaskForAllFields(T::descriptor(), &out);
+ GetFieldMaskForAllFields(T::descriptor(), &out);
return out;
}
template <typename T>
- GOOGLE_PROTOBUF_DEPRECATED_MSG(
- "Use *out = GetFieldMaskForAllFields() instead")
+ PROTOBUF_DEPRECATED_MSG("Use *out = GetFieldMaskForAllFields() instead")
static void GetFieldMaskForAllFields(FieldMask* out) {
- InternalGetFieldMaskForAllFields(T::descriptor(), out);
+ GetFieldMaskForAllFields(T::descriptor(), out);
}
+ // This flavor takes the protobuf type descriptor as an argument.
+ // Useful when the type is not known at compile time.
+ static void GetFieldMaskForAllFields(const Descriptor* descriptor,
+ FieldMask* out);
// Converts a FieldMask to the canonical form. It will:
// 1. Remove paths that are covered by another path. For example,
@@ -127,8 +130,13 @@ class LIBPROTOBUF_EXPORT FieldMaskUtil {
template <typename T>
static void Subtract(const FieldMask& mask1, const FieldMask& mask2,
FieldMask* out) {
- InternalSubtract(T::descriptor(), mask1, mask2, out);
+ Subtract(T::descriptor(), mask1, mask2, out);
}
+ // This flavor takes the protobuf type descriptor as an argument.
+ // Useful when the type is not known at compile time.
+ static void Subtract(const Descriptor* descriptor,
+ const FieldMask& mask1, const FieldMask& mask2,
+ FieldMask* out);
// Returns true if path is covered by the given FieldMask. Note that path
// "foo.bar" covers all paths like "foo.bar.baz", "foo.bar.quz.x", etc.
@@ -169,7 +177,7 @@ class LIBPROTOBUF_EXPORT FieldMaskUtil {
// Note that the input can contain characters not allowed in C identifiers.
// For example, "foo_bar,baz_quz" will be converted to "fooBar,bazQuz"
// successfully.
- static bool SnakeCaseToCamelCase(StringPiece input, string* output);
+ static bool SnakeCaseToCamelCase(StringPiece input, std::string* output);
// Converts a field name from camelCase to snake_case:
// 1. Every uppercase letter is converted to lowercase with a additional
// preceding "-".
@@ -182,17 +190,10 @@ class LIBPROTOBUF_EXPORT FieldMaskUtil {
// Note that the input can contain characters not allowed in C identifiers.
// For example, "fooBar,bazQuz" will be converted to "foo_bar,baz_quz"
// successfully.
- static bool CamelCaseToSnakeCase(StringPiece input, string* output);
-
- static void InternalGetFieldMaskForAllFields(const Descriptor* descriptor,
- FieldMask* out);
-
- static void InternalSubtract(const Descriptor* descriptor,
- const FieldMask& mask1, const FieldMask& mask2,
- FieldMask* out);
+ static bool CamelCaseToSnakeCase(StringPiece input, std::string* output);
};
-class LIBPROTOBUF_EXPORT FieldMaskUtil::MergeOptions {
+class PROTOBUF_EXPORT FieldMaskUtil::MergeOptions {
public:
MergeOptions()
: replace_message_fields_(false), replace_repeated_fields_(false) {}
@@ -220,7 +221,7 @@ class LIBPROTOBUF_EXPORT FieldMaskUtil::MergeOptions {
bool replace_repeated_fields_;
};
-class LIBPROTOBUF_EXPORT FieldMaskUtil::TrimOptions {
+class PROTOBUF_EXPORT FieldMaskUtil::TrimOptions {
public:
TrimOptions()
: keep_required_fields_(false) {}
diff --git a/src/google/protobuf/util/internal/datapiece.h b/src/google/protobuf/util/internal/datapiece.h
index 074fde69..556c0ec4 100644
--- a/src/google/protobuf/util/internal/datapiece.h
+++ b/src/google/protobuf/util/internal/datapiece.h
@@ -37,6 +37,8 @@
#include <google/protobuf/stubs/stringpiece.h>
#include <google/protobuf/stubs/statusor.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
class Enum;
@@ -58,7 +60,7 @@ class ProtoWriter;
// Just like StringPiece, the DataPiece class does not own the storage for
// the actual string or Cord, so it is the user's responsiblity to guarantee
// that the underlying storage is still valid when the DataPiece is accessed.
-class LIBPROTOBUF_EXPORT DataPiece {
+class PROTOBUF_EXPORT DataPiece {
public:
// Identifies data type of the value.
// These are the types supported by DataPiece.
@@ -121,7 +123,7 @@ class LIBPROTOBUF_EXPORT DataPiece {
bool use_strict_base64_decoding() { return use_strict_base64_decoding_; }
StringPiece str() const {
- GOOGLE_LOG_IF(DFATAL, type_ != TYPE_STRING) << "Not a string type.";
+ GOOGLE_LOG_IF(DFATAL, type_ != TYPE_STRING) << "Not a std::string type.";
return str_;
}
@@ -148,13 +150,13 @@ class LIBPROTOBUF_EXPORT DataPiece {
util::StatusOr<bool> ToBool() const;
// Parses, casts or converts the value stored in the DataPiece into a string.
- util::StatusOr<string> ToString() const;
+ util::StatusOr<std::string> ToString() const;
// Tries to convert the value contained in this datapiece to string. If the
// conversion fails, it returns the default_string.
- string ValueAsStringOrDefault(StringPiece default_string) const;
+ std::string ValueAsStringOrDefault(StringPiece default_string) const;
- util::StatusOr<string> ToBytes() const;
+ util::StatusOr<std::string> ToBytes() const;
// Converts a value into protocol buffer enum number. If the value is a
// string, first attempts conversion by name, trying names as follows:
@@ -198,7 +200,7 @@ class LIBPROTOBUF_EXPORT DataPiece {
To*)) const;
// Decodes a base64 string. Returns true on success.
- bool DecodeBase64(StringPiece src, string* dest) const;
+ bool DecodeBase64(StringPiece src, std::string* dest) const;
// Helper function to initialize this DataPiece with 'other'.
void InternalCopy(const DataPiece& other);
@@ -229,4 +231,6 @@ class LIBPROTOBUF_EXPORT DataPiece {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_DATAPIECE_H__
diff --git a/src/google/protobuf/util/internal/default_value_objectwriter.h b/src/google/protobuf/util/internal/default_value_objectwriter.h
index d15cc7cb..7a8863ca 100644
--- a/src/google/protobuf/util/internal/default_value_objectwriter.h
+++ b/src/google/protobuf/util/internal/default_value_objectwriter.h
@@ -44,6 +44,8 @@
#include <google/protobuf/util/type_resolver.h>
#include <google/protobuf/stubs/stringpiece.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace util {
@@ -55,7 +57,7 @@ namespace converter {
// ObjectWriter when EndObject() is called on the root object. It also writes
// out all non-repeated primitive fields that haven't been explicitly rendered
// with their default values (0 for numbers, "" for strings, etc).
-class LIBPROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter {
+class PROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter {
public:
// A Callback function to check whether a field needs to be scrubbed.
//
@@ -69,7 +71,7 @@ class LIBPROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter {
//
// The Field* should point to the google::protobuf::Field of "c".
typedef ResultCallback2<bool /*return*/,
- const std::vector<string>& /*path of the field*/,
+ const std::vector<std::string>& /*path of the field*/,
const google::protobuf::Field* /*field*/>
FieldScrubCallBack;
@@ -146,11 +148,11 @@ class LIBPROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter {
// "Node" represents a node in the tree that holds the input of
// DefaultValueObjectWriter.
- class LIBPROTOBUF_EXPORT Node {
+ class PROTOBUF_EXPORT Node {
public:
- Node(const string& name, const google::protobuf::Type* type, NodeKind kind,
+ Node(const std::string& name, const google::protobuf::Type* type, NodeKind kind,
const DataPiece& data, bool is_placeholder,
- const std::vector<string>& path, bool suppress_empty_list,
+ const std::vector<std::string>& path, bool suppress_empty_list,
bool preserve_proto_field_names, bool use_ints_for_enums,
FieldScrubCallBack* field_scrub_callback);
virtual ~Node() {
@@ -176,9 +178,9 @@ class LIBPROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter {
virtual void WriteTo(ObjectWriter* ow);
// Accessors
- const string& name() const { return name_; }
+ const std::string& name() const { return name_; }
- const std::vector<string>& path() const { return path_; }
+ const std::vector<std::string>& path() const { return path_; }
const google::protobuf::Type* type() const { return type_; }
@@ -208,7 +210,7 @@ class LIBPROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter {
void WriteChildren(ObjectWriter* ow);
// The name of this node.
- string name_;
+ std::string name_;
// google::protobuf::Type of this node. Owned by TypeInfo.
const google::protobuf::Type* type_;
// The kind of this node.
@@ -226,7 +228,7 @@ class LIBPROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter {
bool is_placeholder_;
// Path of the field of this node
- std::vector<string> path_;
+ std::vector<std::string> path_;
// Whether to suppress empty list output.
bool suppress_empty_list_;
@@ -246,10 +248,10 @@ class LIBPROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter {
};
// Creates a new Node and returns it. Caller owns memory of returned object.
- virtual Node* CreateNewNode(const string& name,
+ virtual Node* CreateNewNode(const std::string& name,
const google::protobuf::Type* type, NodeKind kind,
const DataPiece& data, bool is_placeholder,
- const std::vector<string>& path,
+ const std::vector<std::string>& path,
bool suppress_empty_list,
bool preserve_proto_field_names,
bool use_ints_for_enums,
@@ -297,7 +299,7 @@ class LIBPROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter {
// google::protobuf::Type of the root message type.
const google::protobuf::Type& type_;
// Holds copies of strings passed to RenderString.
- std::vector<string*> string_values_;
+ std::vector<std::string*> string_values_;
// The current Node. Owned by its parents.
Node* current_;
@@ -329,4 +331,6 @@ class LIBPROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_DEFAULT_VALUE_OBJECTWRITER_H__
diff --git a/src/google/protobuf/util/internal/error_listener.h b/src/google/protobuf/util/internal/error_listener.h
index 18666526..c2b7560d 100644
--- a/src/google/protobuf/util/internal/error_listener.h
+++ b/src/google/protobuf/util/internal/error_listener.h
@@ -42,13 +42,15 @@
#include <google/protobuf/util/internal/location_tracker.h>
#include <google/protobuf/stubs/stringpiece.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace util {
namespace converter {
// Interface for error listener.
-class LIBPROTOBUF_EXPORT ErrorListener {
+class PROTOBUF_EXPORT ErrorListener {
public:
virtual ~ErrorListener() {}
@@ -75,7 +77,7 @@ class LIBPROTOBUF_EXPORT ErrorListener {
};
// An error listener that ignores all errors.
-class LIBPROTOBUF_EXPORT NoopErrorListener : public ErrorListener {
+class PROTOBUF_EXPORT NoopErrorListener : public ErrorListener {
public:
NoopErrorListener() {}
~NoopErrorListener() override {}
@@ -101,4 +103,6 @@ class LIBPROTOBUF_EXPORT NoopErrorListener : public ErrorListener {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_ERROR_LISTENER_H__
diff --git a/src/google/protobuf/util/internal/expecting_objectwriter.h b/src/google/protobuf/util/internal/expecting_objectwriter.h
index a7f6fc22..108a15b9 100644
--- a/src/google/protobuf/util/internal/expecting_objectwriter.h
+++ b/src/google/protobuf/util/internal/expecting_objectwriter.h
@@ -94,7 +94,7 @@ class ExpectingObjectWriter : public ObjectWriter {
virtual ObjectWriter* StartObject(StringPiece name) {
(name.empty() ? EXPECT_CALL(*mock_, StartObject(IsEmpty()))
- : EXPECT_CALL(*mock_, StartObject(StrEq(string(name)))))
+ : EXPECT_CALL(*mock_, StartObject(StrEq(std::string(name)))))
.WillOnce(Return(mock_))
.RetiresOnSaturation();
return this;
@@ -109,7 +109,7 @@ class ExpectingObjectWriter : public ObjectWriter {
virtual ObjectWriter* StartList(StringPiece name) {
(name.empty() ? EXPECT_CALL(*mock_, StartList(IsEmpty()))
- : EXPECT_CALL(*mock_, StartList(StrEq(string(name)))))
+ : EXPECT_CALL(*mock_, StartList(StrEq(std::string(name)))))
.WillOnce(Return(mock_))
.RetiresOnSaturation();
return this;
@@ -126,7 +126,7 @@ class ExpectingObjectWriter : public ObjectWriter {
(name.empty()
? EXPECT_CALL(*mock_, RenderBool(IsEmpty(), TypedEq<bool>(value)))
: EXPECT_CALL(*mock_,
- RenderBool(StrEq(string(name)), TypedEq<bool>(value))))
+ RenderBool(StrEq(std::string(name)), TypedEq<bool>(value))))
.WillOnce(Return(mock_))
.RetiresOnSaturation();
return this;
@@ -136,7 +136,7 @@ class ExpectingObjectWriter : public ObjectWriter {
(name.empty()
? EXPECT_CALL(*mock_, RenderInt32(IsEmpty(), TypedEq<int32>(value)))
: EXPECT_CALL(*mock_,
- RenderInt32(StrEq(string(name)), TypedEq<int32>(value))))
+ RenderInt32(StrEq(std::string(name)), TypedEq<int32>(value))))
.WillOnce(Return(mock_))
.RetiresOnSaturation();
return this;
@@ -145,7 +145,7 @@ class ExpectingObjectWriter : public ObjectWriter {
virtual ObjectWriter* RenderUint32(StringPiece name, uint32 value) {
(name.empty()
? EXPECT_CALL(*mock_, RenderUint32(IsEmpty(), TypedEq<uint32>(value)))
- : EXPECT_CALL(*mock_, RenderUint32(StrEq(string(name)),
+ : EXPECT_CALL(*mock_, RenderUint32(StrEq(std::string(name)),
TypedEq<uint32>(value))))
.WillOnce(Return(mock_))
.RetiresOnSaturation();
@@ -156,7 +156,7 @@ class ExpectingObjectWriter : public ObjectWriter {
(name.empty()
? EXPECT_CALL(*mock_, RenderInt64(IsEmpty(), TypedEq<int64>(value)))
: EXPECT_CALL(*mock_,
- RenderInt64(StrEq(string(name)), TypedEq<int64>(value))))
+ RenderInt64(StrEq(std::string(name)), TypedEq<int64>(value))))
.WillOnce(Return(mock_))
.RetiresOnSaturation();
return this;
@@ -165,7 +165,7 @@ class ExpectingObjectWriter : public ObjectWriter {
virtual ObjectWriter* RenderUint64(StringPiece name, uint64 value) {
(name.empty()
? EXPECT_CALL(*mock_, RenderUint64(IsEmpty(), TypedEq<uint64>(value)))
- : EXPECT_CALL(*mock_, RenderUint64(StrEq(string(name)),
+ : EXPECT_CALL(*mock_, RenderUint64(StrEq(std::string(name)),
TypedEq<uint64>(value))))
.WillOnce(Return(mock_))
.RetiresOnSaturation();
@@ -176,7 +176,7 @@ class ExpectingObjectWriter : public ObjectWriter {
(name.empty()
? EXPECT_CALL(*mock_,
RenderDouble(IsEmpty(), NanSensitiveDoubleEq(value)))
- : EXPECT_CALL(*mock_, RenderDouble(StrEq(string(name)),
+ : EXPECT_CALL(*mock_, RenderDouble(StrEq(std::string(name)),
NanSensitiveDoubleEq(value))))
.WillOnce(Return(mock_))
.RetiresOnSaturation();
@@ -187,7 +187,7 @@ class ExpectingObjectWriter : public ObjectWriter {
(name.empty()
? EXPECT_CALL(*mock_,
RenderFloat(IsEmpty(), NanSensitiveFloatEq(value)))
- : EXPECT_CALL(*mock_, RenderFloat(StrEq(string(name)),
+ : EXPECT_CALL(*mock_, RenderFloat(StrEq(std::string(name)),
NanSensitiveFloatEq(value))))
.WillOnce(Return(mock_))
.RetiresOnSaturation();
@@ -199,10 +199,10 @@ class ExpectingObjectWriter : public ObjectWriter {
(name.empty()
? EXPECT_CALL(*mock_,
RenderString(IsEmpty(),
- TypedEq<StringPiece>(string(value))))
+ TypedEq<StringPiece>(std::string(value))))
: EXPECT_CALL(*mock_,
- RenderString(StrEq(string(name)),
- TypedEq<StringPiece>(string(value)))))
+ RenderString(StrEq(std::string(name)),
+ TypedEq<StringPiece>(std::string(value)))))
.WillOnce(Return(mock_))
.RetiresOnSaturation();
return this;
@@ -221,7 +221,7 @@ class ExpectingObjectWriter : public ObjectWriter {
virtual ObjectWriter* RenderNull(StringPiece name) {
(name.empty() ? EXPECT_CALL(*mock_, RenderNull(IsEmpty()))
- : EXPECT_CALL(*mock_, RenderNull(StrEq(string(name))))
+ : EXPECT_CALL(*mock_, RenderNull(StrEq(std::string(name))))
.WillOnce(Return(mock_))
.RetiresOnSaturation());
return this;
diff --git a/src/google/protobuf/util/internal/field_mask_utility.cc b/src/google/protobuf/util/internal/field_mask_utility.cc
index 014b81aa..b0190127 100644
--- a/src/google/protobuf/util/internal/field_mask_utility.cc
+++ b/src/google/protobuf/util/internal/field_mask_utility.cc
@@ -34,6 +34,8 @@
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/status_macros.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace util {
diff --git a/src/google/protobuf/util/internal/field_mask_utility.h b/src/google/protobuf/util/internal/field_mask_utility.h
index 7d1c2af0..97755804 100644
--- a/src/google/protobuf/util/internal/field_mask_utility.h
+++ b/src/google/protobuf/util/internal/field_mask_utility.h
@@ -45,14 +45,14 @@ namespace protobuf {
namespace util {
namespace converter {
-typedef string (*ConverterCallback)(StringPiece);
+typedef std::string (*ConverterCallback)(StringPiece);
typedef ResultCallback1<util::Status, StringPiece>* PathSinkCallback;
// Applies a 'converter' to each segment of a FieldMask path and returns the
// result. Quoted strings in the 'path' are copied to the output as-is without
// converting their content. Escaping is supported within quoted strings.
// For example, "ab\"_c" will be returned as "ab\"_c" without any changes.
-string ConvertFieldMaskPath(const StringPiece path,
+std::string ConvertFieldMaskPath(const StringPiece path,
ConverterCallback converter);
// Decodes a compact list of FieldMasks. For example, "a.b,a.c.d,a.c.e" will be
diff --git a/src/google/protobuf/util/internal/json_objectwriter.h b/src/google/protobuf/util/internal/json_objectwriter.h
index c8a061d5..ebfc7fba 100644
--- a/src/google/protobuf/util/internal/json_objectwriter.h
+++ b/src/google/protobuf/util/internal/json_objectwriter.h
@@ -38,6 +38,8 @@
#include <google/protobuf/util/internal/structured_objectwriter.h>
#include <google/protobuf/stubs/bytestream.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace util {
@@ -82,7 +84,7 @@ namespace converter {
// uint64 would lose precision if rendered as numbers.
//
// JsonObjectWriter is thread-unsafe.
-class LIBPROTOBUF_EXPORT JsonObjectWriter : public StructuredObjectWriter {
+class PROTOBUF_EXPORT JsonObjectWriter : public StructuredObjectWriter {
public:
JsonObjectWriter(StringPiece indent_string, io::CodedOutputStream* out)
: element_(new Element(/*parent=*/nullptr, /*is_json_object=*/false)),
@@ -115,7 +117,7 @@ class LIBPROTOBUF_EXPORT JsonObjectWriter : public StructuredObjectWriter {
}
protected:
- class LIBPROTOBUF_EXPORT Element : public BaseElement {
+ class PROTOBUF_EXPORT Element : public BaseElement {
public:
Element(Element* parent, bool is_json_object)
: BaseElement(parent),
@@ -146,7 +148,7 @@ class LIBPROTOBUF_EXPORT JsonObjectWriter : public StructuredObjectWriter {
Element* element() override { return element_.get(); }
private:
- class LIBPROTOBUF_EXPORT ByteSinkWrapper : public strings::ByteSink {
+ class PROTOBUF_EXPORT ByteSinkWrapper : public strings::ByteSink {
public:
explicit ByteSinkWrapper(io::CodedOutputStream* stream) : stream_(stream) {}
~ByteSinkWrapper() override {}
@@ -165,7 +167,7 @@ class LIBPROTOBUF_EXPORT JsonObjectWriter : public StructuredObjectWriter {
// Renders a simple value as a string. By default all non-string Render
// methods convert their argument to a string and call this method. This
// method can then be used to render the simple value without escaping it.
- JsonObjectWriter* RenderSimple(StringPiece name, const string& value) {
+ JsonObjectWriter* RenderSimple(StringPiece name, const std::string& value) {
WritePrefix(name);
stream_->WriteString(value);
return this;
@@ -210,7 +212,7 @@ class LIBPROTOBUF_EXPORT JsonObjectWriter : public StructuredObjectWriter {
std::unique_ptr<Element> element_;
io::CodedOutputStream* stream_;
ByteSinkWrapper sink_;
- const string indent_string_;
+ const std::string indent_string_;
// Whether to use regular or websafe base64 encoding for byte fields. Defaults
// to regular base64 encoding.
@@ -224,4 +226,6 @@ class LIBPROTOBUF_EXPORT JsonObjectWriter : public StructuredObjectWriter {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_JSON_OBJECTWRITER_H__
diff --git a/src/google/protobuf/util/internal/json_stream_parser.h b/src/google/protobuf/util/internal/json_stream_parser.h
index 4a065d27..3526ec57 100644
--- a/src/google/protobuf/util/internal/json_stream_parser.h
+++ b/src/google/protobuf/util/internal/json_stream_parser.h
@@ -38,6 +38,8 @@
#include <google/protobuf/stubs/stringpiece.h>
#include <google/protobuf/stubs/status.h>
+#include <google/protobuf/port_def.inc>
+
namespace util {
class Status;
} // namespace util
@@ -69,7 +71,7 @@ class ObjectWriter;
//
// This parser is thread-compatible as long as only one thread is calling a
// Parse() method at a time.
-class LIBPROTOBUF_EXPORT JsonStreamParser {
+class PROTOBUF_EXPORT JsonStreamParser {
public:
// Creates a JsonStreamParser that will write to the given ObjectWriter.
explicit JsonStreamParser(ObjectWriter* ow);
@@ -166,7 +168,7 @@ class LIBPROTOBUF_EXPORT JsonStreamParser {
util::Status ParseNumberHelper(NumberResult* result);
// Parse a number as double into a NumberResult.
- util::Status ParseDoubleHelper(const string& number, NumberResult* result);
+ util::Status ParseDoubleHelper(const std::string& number, NumberResult* result);
// Handles a { during parsing of a value.
util::Status HandleBeginObject();
@@ -232,7 +234,7 @@ class LIBPROTOBUF_EXPORT JsonStreamParser {
// Contains any leftover text from a previous chunk that we weren't able to
// fully parse, for example the start of a key or number.
- string leftover_;
+ std::string leftover_;
// The current chunk of JSON being parsed. Primarily used for providing
// context during error reporting.
@@ -246,7 +248,7 @@ class LIBPROTOBUF_EXPORT JsonStreamParser {
// Storage for key_ if we need to keep ownership, for example between chunks
// or if the key was unescaped from a JSON string.
- string key_storage_;
+ std::string key_storage_;
// True during the FinishParse() call, so we know that any errors are fatal.
// For example an unterminated string will normally result in cancelling and
@@ -258,14 +260,14 @@ class LIBPROTOBUF_EXPORT JsonStreamParser {
// Storage for the string we parsed. This may be empty if the string was able
// to be parsed directly from the input.
- string parsed_storage_;
+ std::string parsed_storage_;
// The character that opened the string, either ' or ".
// A value of 0 indicates that string parsing is not in process.
char string_open_;
// Storage for the chunk that are being parsed in ParseChunk().
- string chunk_storage_;
+ std::string chunk_storage_;
// Whether to allow non UTF-8 encoded input and replace invalid code points.
bool coerce_to_utf8_;
@@ -291,4 +293,6 @@ class LIBPROTOBUF_EXPORT JsonStreamParser {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_JSON_STREAM_PARSER_H__
diff --git a/src/google/protobuf/util/internal/location_tracker.h b/src/google/protobuf/util/internal/location_tracker.h
index 52173d76..c29a75a7 100644
--- a/src/google/protobuf/util/internal/location_tracker.h
+++ b/src/google/protobuf/util/internal/location_tracker.h
@@ -35,6 +35,8 @@
#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace util {
@@ -42,12 +44,12 @@ namespace converter {
// LocationTrackerInterface is an interface for classes that track
// the location information for the purpose of error reporting.
-class LIBPROTOBUF_EXPORT LocationTrackerInterface {
+class PROTOBUF_EXPORT LocationTrackerInterface {
public:
virtual ~LocationTrackerInterface() {}
// Returns the object location as human readable string.
- virtual string ToString() const = 0;
+ virtual std::string ToString() const = 0;
protected:
LocationTrackerInterface() {}
@@ -62,4 +64,6 @@ class LIBPROTOBUF_EXPORT LocationTrackerInterface {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_LOCATION_TRACKER_H__
diff --git a/src/google/protobuf/util/internal/object_location_tracker.h b/src/google/protobuf/util/internal/object_location_tracker.h
index 61189a79..571279d5 100644
--- a/src/google/protobuf/util/internal/object_location_tracker.h
+++ b/src/google/protobuf/util/internal/object_location_tracker.h
@@ -50,7 +50,7 @@ class ObjectLocationTracker : public LocationTrackerInterface {
~ObjectLocationTracker() override {}
// Returns empty because nothing is tracked.
- string ToString() const override { return ""; }
+ std::string ToString() const override { return ""; }
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ObjectLocationTracker);
diff --git a/src/google/protobuf/util/internal/object_source.h b/src/google/protobuf/util/internal/object_source.h
index 3a24b750..c8ee36fb 100644
--- a/src/google/protobuf/util/internal/object_source.h
+++ b/src/google/protobuf/util/internal/object_source.h
@@ -35,6 +35,8 @@
#include <google/protobuf/stubs/stringpiece.h>
#include <google/protobuf/stubs/status.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace util {
@@ -48,7 +50,7 @@ class ObjectWriter;
// example, a character stream, or protobuf.
//
// Derived classes could be thread-unsafe.
-class LIBPROTOBUF_EXPORT ObjectSource {
+class PROTOBUF_EXPORT ObjectSource {
public:
virtual ~ObjectSource() {}
@@ -76,4 +78,6 @@ class LIBPROTOBUF_EXPORT ObjectSource {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_OBJECT_SOURCE_H__
diff --git a/src/google/protobuf/util/internal/object_writer.h b/src/google/protobuf/util/internal/object_writer.h
index a92c61da..a4b509da 100644
--- a/src/google/protobuf/util/internal/object_writer.h
+++ b/src/google/protobuf/util/internal/object_writer.h
@@ -34,6 +34,8 @@
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/stringpiece.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace util {
@@ -55,7 +57,7 @@ class DataPiece;
//
// TODO(xinb): seems like a prime candidate to apply the RAII paradigm
// and get rid the need to call EndXXX().
-class LIBPROTOBUF_EXPORT ObjectWriter {
+class PROTOBUF_EXPORT ObjectWriter {
public:
virtual ~ObjectWriter() {}
@@ -137,4 +139,6 @@ class LIBPROTOBUF_EXPORT ObjectWriter {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_OBJECT_WRITER_H__
diff --git a/src/google/protobuf/util/internal/proto_writer.cc b/src/google/protobuf/util/internal/proto_writer.cc
index 52921956..56ee774a 100644
--- a/src/google/protobuf/util/internal/proto_writer.cc
+++ b/src/google/protobuf/util/internal/proto_writer.cc
@@ -52,8 +52,8 @@ namespace protobuf {
namespace util {
namespace converter {
-using ::GOOGLE_PROTOBUF_NAMESPACE_ID::internal::WireFormatLite;
using io::CodedOutputStream;
+using ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite;
using util::Status;
using util::StatusOr;
using util::error::INVALID_ARGUMENT;
@@ -67,6 +67,7 @@ ProtoWriter::ProtoWriter(TypeResolver* type_resolver,
own_typeinfo_(true),
done_(false),
ignore_unknown_fields_(false),
+ ignore_unknown_enum_values_(false),
use_lower_camel_for_enums_(false),
element_(nullptr),
size_insert_(),
@@ -86,6 +87,7 @@ ProtoWriter::ProtoWriter(const TypeInfo* typeinfo,
own_typeinfo_(false),
done_(false),
ignore_unknown_fields_(false),
+ ignore_unknown_enum_values_(false),
use_lower_camel_for_enums_(false),
element_(nullptr),
size_insert_(),
@@ -669,9 +671,10 @@ ProtoWriter* ProtoWriter::RenderPrimitiveField(
break;
}
case google::protobuf::Field_Kind_TYPE_ENUM: {
- status = WriteEnum(
- field.number(), data, typeinfo_->GetEnumByTypeUrl(field.type_url()),
- stream_.get(), use_lower_camel_for_enums_, ignore_unknown_fields_);
+ status = WriteEnum(field.number(), data,
+ typeinfo_->GetEnumByTypeUrl(field.type_url()),
+ stream_.get(), use_lower_camel_for_enums_,
+ ignore_unknown_enum_values_);
break;
}
default: // TYPE_GROUP or TYPE_MESSAGE
diff --git a/src/google/protobuf/util/internal/proto_writer.h b/src/google/protobuf/util/internal/proto_writer.h
index 11761096..1a8df982 100644
--- a/src/google/protobuf/util/internal/proto_writer.h
+++ b/src/google/protobuf/util/internal/proto_writer.h
@@ -48,6 +48,8 @@
#include <google/protobuf/stubs/hash.h>
#include <google/protobuf/stubs/status.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace io {
@@ -76,7 +78,7 @@ class ObjectLocationTracker;
// special types by inheriting from it or by wrapping it.
//
// It also supports streaming.
-class LIBPROTOBUF_EXPORT ProtoWriter : public StructuredObjectWriter {
+class PROTOBUF_EXPORT ProtoWriter : public StructuredObjectWriter {
public:
// Constructor. Does not take ownership of any parameter passed in.
ProtoWriter(TypeResolver* type_resolver, const google::protobuf::Type& type,
@@ -152,12 +154,17 @@ class LIBPROTOBUF_EXPORT ProtoWriter : public StructuredObjectWriter {
ignore_unknown_fields_ = ignore_unknown_fields;
}
+ void set_ignore_unknown_enum_values(bool ignore_unknown_enum_values) {
+ ignore_unknown_enum_values_ = ignore_unknown_enum_values;
+ }
+
void set_use_lower_camel_for_enums(bool use_lower_camel_for_enums) {
use_lower_camel_for_enums_ = use_lower_camel_for_enums;
}
protected:
- class LIBPROTOBUF_EXPORT ProtoElement : public BaseElement, public LocationTrackerInterface {
+ class PROTOBUF_EXPORT ProtoElement : public BaseElement,
+ public LocationTrackerInterface {
public:
// Constructor for the root element. No parent nor field.
ProtoElement(const TypeInfo* typeinfo, const google::protobuf::Type& type,
@@ -187,7 +194,7 @@ class LIBPROTOBUF_EXPORT ProtoWriter : public StructuredObjectWriter {
void RegisterField(const google::protobuf::Field* field);
// To report location on error messages.
- string ToString() const override;
+ std::string ToString() const override;
ProtoElement* parent() const override {
return static_cast<ProtoElement*>(BaseElement::parent());
@@ -321,9 +328,12 @@ class LIBPROTOBUF_EXPORT ProtoWriter : public StructuredObjectWriter {
// Indicates whether we finished writing root message completely.
bool done_;
- // If true, don't report unknown field names and enum values to the listener.
+ // If true, don't report unknown field names to the listener.
bool ignore_unknown_fields_;
+ // If true, don't report unknown enum values to the listener.
+ bool ignore_unknown_enum_values_;
+
// If true, check if enum name in camel case or without underscore matches the
// field name.
bool use_lower_camel_for_enums_;
@@ -342,7 +352,7 @@ class LIBPROTOBUF_EXPORT ProtoWriter : public StructuredObjectWriter {
// adapter_ : internal adapter between CodedOutputStream and buffer_.
// stream_ : wrapper for writing tags and other encodings in wire format.
strings::ByteSink* output_;
- string buffer_;
+ std::string buffer_;
io::StringOutputStream adapter_;
std::unique_ptr<io::CodedOutputStream> stream_;
@@ -362,4 +372,6 @@ class LIBPROTOBUF_EXPORT ProtoWriter : public StructuredObjectWriter {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_PROTO_WRITER_H__
diff --git a/src/google/protobuf/util/internal/protostream_objectsource.cc b/src/google/protobuf/util/internal/protostream_objectsource.cc
index 2a1b2511..97a8bb48 100644
--- a/src/google/protobuf/util/internal/protostream_objectsource.cc
+++ b/src/google/protobuf/util/internal/protostream_objectsource.cc
@@ -66,8 +66,8 @@ using util::error::Code;
using util::error::INTERNAL;
}
namespace converter {
-using ::GOOGLE_PROTOBUF_NAMESPACE_ID::internal::WireFormat;
-using ::GOOGLE_PROTOBUF_NAMESPACE_ID::internal::WireFormatLite;
+using ::PROTOBUF_NAMESPACE_ID::internal::WireFormat;
+using ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite;
using util::Status;
using util::StatusOr;
@@ -701,7 +701,7 @@ Status ProtoStreamObjectSource::RenderFieldMask(
std::unordered_map<string, ProtoStreamObjectSource::TypeRenderer>*
ProtoStreamObjectSource::renderers_ = NULL;
-GOOGLE_PROTOBUF_NAMESPACE_ID::internal::once_flag source_renderers_init_;
+PROTOBUF_NAMESPACE_ID::internal::once_flag source_renderers_init_;
void ProtoStreamObjectSource::InitRendererMap() {
renderers_ =
@@ -748,8 +748,8 @@ void ProtoStreamObjectSource::DeleteRendererMap() {
// static
ProtoStreamObjectSource::TypeRenderer*
ProtoStreamObjectSource::FindTypeRenderer(const string& type_url) {
- GOOGLE_PROTOBUF_NAMESPACE_ID::internal::call_once(source_renderers_init_,
- InitRendererMap);
+ PROTOBUF_NAMESPACE_ID::internal::call_once(source_renderers_init_,
+ InitRendererMap);
return FindOrNull(*renderers_, type_url);
}
diff --git a/src/google/protobuf/util/internal/protostream_objectsource.h b/src/google/protobuf/util/internal/protostream_objectsource.h
index 90e23a3a..c2549878 100644
--- a/src/google/protobuf/util/internal/protostream_objectsource.h
+++ b/src/google/protobuf/util/internal/protostream_objectsource.h
@@ -46,6 +46,8 @@
#include <google/protobuf/stubs/status.h>
#include <google/protobuf/stubs/statusor.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
class Field;
@@ -73,7 +75,7 @@ class TypeInfo;
// <your message google::protobuf::Type>);
//
// Status status = os.WriteTo(<some ObjectWriter>);
-class LIBPROTOBUF_EXPORT ProtoStreamObjectSource : public ObjectSource {
+class PROTOBUF_EXPORT ProtoStreamObjectSource : public ObjectSource {
public:
ProtoStreamObjectSource(io::CodedInputStream* stream,
TypeResolver* type_resolver,
@@ -160,7 +162,7 @@ class LIBPROTOBUF_EXPORT ProtoStreamObjectSource : public ObjectSource {
// Reads field value according to Field spec in 'field' and returns the read
// value as string. This only works for primitive datatypes (no message
// types).
- const string ReadFieldValueAsString(
+ const std::string ReadFieldValueAsString(
const google::protobuf::Field& field) const;
@@ -258,10 +260,10 @@ class LIBPROTOBUF_EXPORT ProtoStreamObjectSource : public ObjectSource {
StringPiece name,
ObjectWriter* ow);
- static std::unordered_map<string, TypeRenderer>* renderers_;
+ static std::unordered_map<std::string, TypeRenderer>* renderers_;
static void InitRendererMap();
static void DeleteRendererMap();
- static TypeRenderer* FindTypeRenderer(const string& type_url);
+ static TypeRenderer* FindTypeRenderer(const std::string& type_url);
// Same as above but renders all non-message field types. Callers don't call
// this function directly. They just use RenderField.
@@ -331,4 +333,6 @@ class LIBPROTOBUF_EXPORT ProtoStreamObjectSource : public ObjectSource {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_PROTOSTREAM_OBJECTSOURCE_H__
diff --git a/src/google/protobuf/util/internal/protostream_objectwriter.cc b/src/google/protobuf/util/internal/protostream_objectwriter.cc
index 3751e07c..9c52116e 100644
--- a/src/google/protobuf/util/internal/protostream_objectwriter.cc
+++ b/src/google/protobuf/util/internal/protostream_objectwriter.cc
@@ -55,7 +55,7 @@ namespace protobuf {
namespace util {
namespace converter {
-using ::GOOGLE_PROTOBUF_NAMESPACE_ID::internal::WireFormatLite;
+using ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite;
using util::Status;
using util::StatusOr;
using util::error::INVALID_ARGUMENT;
@@ -70,6 +70,7 @@ ProtoStreamObjectWriter::ProtoStreamObjectWriter(
current_(nullptr),
options_(options) {
set_ignore_unknown_fields(options_.ignore_unknown_fields);
+ set_ignore_unknown_enum_values(options_.ignore_unknown_enum_values);
set_use_lower_camel_for_enums(options_.use_lower_camel_for_enums);
}
@@ -1165,7 +1166,7 @@ ProtoStreamObjectWriter* ProtoStreamObjectWriter::RenderDataPiece(
// represented by the key.
std::unordered_map<string, ProtoStreamObjectWriter::TypeRenderer>*
ProtoStreamObjectWriter::renderers_ = NULL;
-GOOGLE_PROTOBUF_NAMESPACE_ID::internal::once_flag writer_renderers_init_;
+PROTOBUF_NAMESPACE_ID::internal::once_flag writer_renderers_init_;
void ProtoStreamObjectWriter::InitRendererMap() {
renderers_ =
@@ -1224,8 +1225,8 @@ void ProtoStreamObjectWriter::DeleteRendererMap() {
ProtoStreamObjectWriter::TypeRenderer*
ProtoStreamObjectWriter::FindTypeRenderer(const string& type_url) {
- GOOGLE_PROTOBUF_NAMESPACE_ID::internal::call_once(writer_renderers_init_,
- InitRendererMap);
+ PROTOBUF_NAMESPACE_ID::internal::call_once(writer_renderers_init_,
+ InitRendererMap);
return FindOrNull(*renderers_, type_url);
}
diff --git a/src/google/protobuf/util/internal/protostream_objectwriter.h b/src/google/protobuf/util/internal/protostream_objectwriter.h
index df56a8bd..fe8170d1 100644
--- a/src/google/protobuf/util/internal/protostream_objectwriter.h
+++ b/src/google/protobuf/util/internal/protostream_objectwriter.h
@@ -49,6 +49,8 @@
#include <google/protobuf/stubs/bytestream.h>
#include <google/protobuf/stubs/hash.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace io {
@@ -76,7 +78,7 @@ class ObjectLocationTracker;
// the ProtoWriter class to write raw proto bytes.
//
// It also supports streaming.
-class LIBPROTOBUF_EXPORT ProtoStreamObjectWriter : public ProtoWriter {
+class PROTOBUF_EXPORT ProtoStreamObjectWriter : public ProtoWriter {
public:
// Options that control ProtoStreamObjectWriter class's behavior.
struct Options {
@@ -91,9 +93,13 @@ class LIBPROTOBUF_EXPORT ProtoStreamObjectWriter : public ProtoWriter {
bool struct_integers_as_strings;
// Not treat unknown fields as an error. If there is an unknown fields,
- // just ignore it and continue to process the rest.
+ // just ignore it and continue to process the rest. Note that this doesn't
+ // apply to unknown enum values.
bool ignore_unknown_fields;
+ // Ignore unknown enum values.
+ bool ignore_unknown_enum_values;
+
// If true, check if enum name in camel case or without underscore matches
// the field name.
bool use_lower_camel_for_enums;
@@ -105,6 +111,7 @@ class LIBPROTOBUF_EXPORT ProtoStreamObjectWriter : public ProtoWriter {
Options()
: struct_integers_as_strings(false),
ignore_unknown_fields(false),
+ ignore_unknown_enum_values(false),
use_lower_camel_for_enums(false),
ignore_null_value_map_entry(false) {}
@@ -140,7 +147,7 @@ class LIBPROTOBUF_EXPORT ProtoStreamObjectWriter : public ProtoWriter {
const DataPiece&);
// Handles writing Anys out using nested object writers and the like.
- class LIBPROTOBUF_EXPORT AnyWriter {
+ class PROTOBUF_EXPORT AnyWriter {
public:
explicit AnyWriter(ProtoStreamObjectWriter* parent);
~AnyWriter();
@@ -165,7 +172,7 @@ class LIBPROTOBUF_EXPORT ProtoStreamObjectWriter : public ProtoWriter {
private:
// Before the "@type" field is encountered, we store all incoming data
// into this Event struct and replay them after we get the "@type" field.
- class LIBPROTOBUF_EXPORT Event {
+ class PROTOBUF_EXPORT Event {
public:
enum Type {
START_OBJECT = 0,
@@ -207,9 +214,9 @@ class LIBPROTOBUF_EXPORT ProtoStreamObjectWriter : public ProtoWriter {
void DeepCopy();
Type type_;
- string name_;
+ std::string name_;
DataPiece value_;
- string value_storage_;
+ std::string value_storage_;
};
// Handles starting up the any once we have a type.
@@ -226,14 +233,14 @@ class LIBPROTOBUF_EXPORT ProtoStreamObjectWriter : public ProtoWriter {
std::unique_ptr<ProtoStreamObjectWriter> ow_;
// The type_url_ that this Any represents.
- string type_url_;
+ std::string type_url_;
// Whether this any is invalid. This allows us to only report an invalid
// Any message a single time rather than every time we get a nested field.
bool invalid_;
// The output data and wrapping ByteSink.
- string data_;
+ std::string data_;
strings::StringByteSink output_;
// The depth within the Any, so we can track when we're done.
@@ -254,7 +261,7 @@ class LIBPROTOBUF_EXPORT ProtoStreamObjectWriter : public ProtoWriter {
// Represents an item in a stack of items used to keep state between
// ObjectWrier events.
- class LIBPROTOBUF_EXPORT Item : public BaseElement {
+ class PROTOBUF_EXPORT Item : public BaseElement {
public:
// Indicates the type of item.
enum ItemType {
@@ -306,7 +313,7 @@ class LIBPROTOBUF_EXPORT ProtoStreamObjectWriter : public ProtoWriter {
// Set of map keys already seen for the type_. Used to validate incoming
// messages so no map key appears more than once.
- std::unique_ptr<std::unordered_set<string> > map_keys_;
+ std::unique_ptr<std::unordered_set<std::string> > map_keys_;
// Conveys whether this Item is a placeholder or not. Placeholder items are
// pushed to stack to account for special types.
@@ -367,7 +374,7 @@ class LIBPROTOBUF_EXPORT ProtoStreamObjectWriter : public ProtoWriter {
static void InitRendererMap();
static void DeleteRendererMap();
- static TypeRenderer* FindTypeRenderer(const string& type_url);
+ static TypeRenderer* FindTypeRenderer(const std::string& type_url);
// Returns true if the map key for type_ is not duplicated key.
// If map key is duplicated key, this function returns false.
@@ -397,7 +404,7 @@ class LIBPROTOBUF_EXPORT ProtoStreamObjectWriter : public ProtoWriter {
private:
// Helper functions to create the map and find functions responsible for
// rendering well known types, keyed by type URL.
- static std::unordered_map<string, TypeRenderer>* renderers_;
+ static std::unordered_map<std::string, TypeRenderer>* renderers_;
// Variables for describing the structure of the input tree:
// master_type_: descriptor for the whole protobuf message.
@@ -417,4 +424,6 @@ class LIBPROTOBUF_EXPORT ProtoStreamObjectWriter : public ProtoWriter {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_PROTOSTREAM_OBJECTWRITER_H__
diff --git a/src/google/protobuf/util/internal/protostream_objectwriter_test.cc b/src/google/protobuf/util/internal/protostream_objectwriter_test.cc
index e11dce03..66a8f003 100644
--- a/src/google/protobuf/util/internal/protostream_objectwriter_test.cc
+++ b/src/google/protobuf/util/internal/protostream_objectwriter_test.cc
@@ -921,6 +921,22 @@ TEST_P(ProtoStreamObjectWriterTest, IgnoreUnknownListAtPublisher) {
CheckOutput(expected);
}
+TEST_P(ProtoStreamObjectWriterTest,
+ IgnoreUnknownFieldsDontIgnoreUnknownEnumValues) {
+ ResetTypeInfo(Proto3Message::descriptor());
+
+ Proto3Message expected;
+ EXPECT_CALL(
+ listener_,
+ InvalidValue(_, StringPiece("TYPE_ENUM"),
+ StringPiece("\"someunknownvalueyouwillneverknow\"")))
+ .With(Args<0>(HasObjectLocation("enum_value")));
+ ow_->StartObject("")
+ ->RenderString("enumValue", "someunknownvalueyouwillneverknow")
+ ->EndObject();
+ CheckOutput(expected);
+}
+
TEST_P(ProtoStreamObjectWriterTest, AcceptUnknownEnumValue) {
ResetTypeInfo(Proto3Message::descriptor());
diff --git a/src/google/protobuf/util/internal/structured_objectwriter.h b/src/google/protobuf/util/internal/structured_objectwriter.h
index 3551abc8..bccea718 100644
--- a/src/google/protobuf/util/internal/structured_objectwriter.h
+++ b/src/google/protobuf/util/internal/structured_objectwriter.h
@@ -37,6 +37,8 @@
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/util/internal/object_writer.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace util {
@@ -53,7 +55,7 @@ namespace converter {
// StructuredObjectWriter and its use.
//
// Derived classes could be thread-unsafe.
-class LIBPROTOBUF_EXPORT StructuredObjectWriter : public ObjectWriter {
+class PROTOBUF_EXPORT StructuredObjectWriter : public ObjectWriter {
public:
virtual ~StructuredObjectWriter() {}
@@ -63,7 +65,7 @@ class LIBPROTOBUF_EXPORT StructuredObjectWriter : public ObjectWriter {
// StructuredObjectWriter behaves as a visitor. BaseElement represents a node
// in the input tree. Implementation of StructuredObjectWriter should also
// extend BaseElement to keep track of the location in the input tree.
- class LIBPROTOBUF_EXPORT BaseElement {
+ class PROTOBUF_EXPORT BaseElement {
public:
// Takes ownership of the parent Element.
explicit BaseElement(BaseElement* parent)
@@ -112,4 +114,6 @@ class LIBPROTOBUF_EXPORT StructuredObjectWriter : public ObjectWriter {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_STRUCTURED_OBJECTWRITER_H__
diff --git a/src/google/protobuf/util/internal/type_info.h b/src/google/protobuf/util/internal/type_info.h
index 38d5a3bc..b933b77a 100644
--- a/src/google/protobuf/util/internal/type_info.h
+++ b/src/google/protobuf/util/internal/type_info.h
@@ -38,13 +38,15 @@
#include <google/protobuf/stubs/status.h>
#include <google/protobuf/stubs/statusor.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace util {
namespace converter {
// Internal helper class for type resolving. Note that this class is not
// thread-safe and should only be accessed in one thread.
-class LIBPROTOBUF_EXPORT TypeInfo {
+class PROTOBUF_EXPORT TypeInfo {
public:
TypeInfo() {}
virtual ~TypeInfo() {}
@@ -89,4 +91,6 @@ class LIBPROTOBUF_EXPORT TypeInfo {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_TYPE_INFO_H__
diff --git a/src/google/protobuf/util/internal/type_info_test_helper.h b/src/google/protobuf/util/internal/type_info_test_helper.h
index f1eac346..3cafbceb 100644
--- a/src/google/protobuf/util/internal/type_info_test_helper.h
+++ b/src/google/protobuf/util/internal/type_info_test_helper.h
@@ -72,13 +72,13 @@ class TypeInfoTestHelper {
TypeInfo* GetTypeInfo();
ProtoStreamObjectSource* NewProtoSource(io::CodedInputStream* coded_input,
- const string& type_url);
+ const std::string& type_url);
ProtoStreamObjectWriter* NewProtoWriter(
- const string& type_url, strings::ByteSink* output,
+ const std::string& type_url, strings::ByteSink* output,
ErrorListener* listener, const ProtoStreamObjectWriter::Options& options);
- DefaultValueObjectWriter* NewDefaultValueWriter(const string& type_url,
+ DefaultValueObjectWriter* NewDefaultValueWriter(const std::string& type_url,
ObjectWriter* writer);
private:
diff --git a/src/google/protobuf/util/internal/utility.cc b/src/google/protobuf/util/internal/utility.cc
index 4a3f2ed0..7c7e3f1c 100644
--- a/src/google/protobuf/util/internal/utility.cc
+++ b/src/google/protobuf/util/internal/utility.cc
@@ -327,7 +327,7 @@ string ToSnakeCase(StringPiece input) {
}
std::set<string>* well_known_types_ = NULL;
-GOOGLE_PROTOBUF_NAMESPACE_ID::internal::once_flag well_known_types_init_;
+PROTOBUF_NAMESPACE_ID::internal::once_flag well_known_types_init_;
const char* well_known_types_name_array_[] = {
"google.protobuf.Timestamp", "google.protobuf.Duration",
"google.protobuf.DoubleValue", "google.protobuf.FloatValue",
@@ -347,8 +347,8 @@ void InitWellKnownTypes() {
}
bool IsWellKnownType(const string& type_name) {
- GOOGLE_PROTOBUF_NAMESPACE_ID::internal::call_once(well_known_types_init_,
- InitWellKnownTypes);
+ PROTOBUF_NAMESPACE_ID::internal::call_once(well_known_types_init_,
+ InitWellKnownTypes);
return ContainsKey(*well_known_types_, type_name);
}
diff --git a/src/google/protobuf/util/internal/utility.h b/src/google/protobuf/util/internal/utility.h
index 816987ae..6fe82959 100644
--- a/src/google/protobuf/util/internal/utility.h
+++ b/src/google/protobuf/util/internal/utility.h
@@ -44,6 +44,8 @@
#include <google/protobuf/stubs/status.h>
#include <google/protobuf/stubs/statusor.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
class Method;
@@ -68,46 +70,47 @@ static const int64 kTypeUrlSize = 19;
// Finds the tech option identified by option_name. Parses the boolean value and
// returns it.
// When the option with the given name is not found, default_value is returned.
-LIBPROTOBUF_EXPORT bool GetBoolOptionOrDefault(
+PROTOBUF_EXPORT bool GetBoolOptionOrDefault(
const RepeatedPtrField<google::protobuf::Option>& options,
- const string& option_name, bool default_value);
+ const std::string& option_name, bool default_value);
// Returns int64 option value. If the option isn't found, returns the
// default_value.
-LIBPROTOBUF_EXPORT int64 GetInt64OptionOrDefault(
+PROTOBUF_EXPORT int64 GetInt64OptionOrDefault(
const RepeatedPtrField<google::protobuf::Option>& options,
- const string& option_name, int64 default_value);
+ const std::string& option_name, int64 default_value);
// Returns double option value. If the option isn't found, returns the
// default_value.
-LIBPROTOBUF_EXPORT double GetDoubleOptionOrDefault(
+PROTOBUF_EXPORT double GetDoubleOptionOrDefault(
const RepeatedPtrField<google::protobuf::Option>& options,
- const string& option_name, double default_value);
+ const std::string& option_name, double default_value);
// Returns string option value. If the option isn't found, returns the
// default_value.
-LIBPROTOBUF_EXPORT string GetStringOptionOrDefault(
+PROTOBUF_EXPORT std::string GetStringOptionOrDefault(
const RepeatedPtrField<google::protobuf::Option>& options,
- const string& option_name, const string& default_value);
+ const std::string& option_name, const std::string& default_value);
// Returns a boolean value contained in Any type.
// TODO(skarvaje): Make these utilities dealing with Any types more generic,
// add more error checking and move to a more public/sharable location so others
// can use.
-LIBPROTOBUF_EXPORT bool GetBoolFromAny(const google::protobuf::Any& any);
+PROTOBUF_EXPORT bool GetBoolFromAny(const google::protobuf::Any& any);
// Returns int64 value contained in Any type.
-LIBPROTOBUF_EXPORT int64 GetInt64FromAny(const google::protobuf::Any& any);
+PROTOBUF_EXPORT int64 GetInt64FromAny(const google::protobuf::Any& any);
// Returns double value contained in Any type.
-LIBPROTOBUF_EXPORT double GetDoubleFromAny(const google::protobuf::Any& any);
+PROTOBUF_EXPORT double GetDoubleFromAny(const google::protobuf::Any& any);
// Returns string value contained in Any type.
-LIBPROTOBUF_EXPORT string GetStringFromAny(const google::protobuf::Any& any);
+PROTOBUF_EXPORT std::string GetStringFromAny(const google::protobuf::Any& any);
// Returns the type string without the url prefix. e.g.: If the passed type is
// 'type.googleapis.com/tech.type.Bool', the returned value is 'tech.type.Bool'.
-LIBPROTOBUF_EXPORT const StringPiece GetTypeWithoutUrl(StringPiece type_url);
+PROTOBUF_EXPORT const StringPiece GetTypeWithoutUrl(
+ StringPiece type_url);
// Returns the simple_type with the base type url (kTypeServiceBaseUrl)
// prefixed.
@@ -115,13 +118,13 @@ LIBPROTOBUF_EXPORT const StringPiece GetTypeWithoutUrl(StringPiece type_url);
// E.g:
// GetFullTypeWithUrl("google.protobuf.Timestamp") returns the string
// "type.googleapis.com/google.protobuf.Timestamp".
-LIBPROTOBUF_EXPORT const string GetFullTypeWithUrl(StringPiece simple_type);
+PROTOBUF_EXPORT const std::string GetFullTypeWithUrl(StringPiece simple_type);
// Finds and returns option identified by name and option_name within the
// provided map. Returns nullptr if none found.
const google::protobuf::Option* FindOptionOrNull(
const RepeatedPtrField<google::protobuf::Option>& options,
- const string& option_name);
+ const std::string& option_name);
// Finds and returns the field identified by field_name in the passed tech Type
// object. Returns nullptr if none found.
@@ -155,51 +158,51 @@ const google::protobuf::EnumValue* FindEnumValueByNameWithoutUnderscoreOrNull(
const google::protobuf::Enum* enum_type, StringPiece enum_name);
// Converts input to camel-case and returns it.
-LIBPROTOBUF_EXPORT string ToCamelCase(const StringPiece input);
+PROTOBUF_EXPORT std::string ToCamelCase(const StringPiece input);
// Converts enum name string to camel-case and returns it.
-string EnumValueNameToLowerCamelCase(const StringPiece input);
+std::string EnumValueNameToLowerCamelCase(const StringPiece input);
// Converts input to snake_case and returns it.
-LIBPROTOBUF_EXPORT string ToSnakeCase(StringPiece input);
+PROTOBUF_EXPORT std::string ToSnakeCase(StringPiece input);
// Returns true if type_name represents a well-known type.
-LIBPROTOBUF_EXPORT bool IsWellKnownType(const string& type_name);
+PROTOBUF_EXPORT bool IsWellKnownType(const std::string& type_name);
// Returns true if 'bool_string' represents a valid boolean value. Only "true",
// "false", "0" and "1" are allowed.
-LIBPROTOBUF_EXPORT bool IsValidBoolString(const string& bool_string);
+PROTOBUF_EXPORT bool IsValidBoolString(const std::string& bool_string);
// Returns true if "field" is a protobuf map field based on its type.
-LIBPROTOBUF_EXPORT bool IsMap(const google::protobuf::Field& field,
- const google::protobuf::Type& type);
+PROTOBUF_EXPORT bool IsMap(const google::protobuf::Field& field,
+ const google::protobuf::Type& type);
// Returns true if the given type has special MessageSet wire format.
bool IsMessageSetWireFormat(const google::protobuf::Type& type);
// Infinity/NaN-aware conversion to string.
-LIBPROTOBUF_EXPORT string DoubleAsString(double value);
-LIBPROTOBUF_EXPORT string FloatAsString(float value);
+PROTOBUF_EXPORT std::string DoubleAsString(double value);
+PROTOBUF_EXPORT std::string FloatAsString(float value);
// Convert from int32, int64, uint32, uint64, double or float to string.
template <typename T>
-string ValueAsString(T value) {
+std::string ValueAsString(T value) {
return SimpleItoa(value);
}
template <>
-inline string ValueAsString(float value) {
+inline std::string ValueAsString(float value) {
return FloatAsString(value);
}
template <>
-inline string ValueAsString(double value) {
+inline std::string ValueAsString(double value) {
return DoubleAsString(value);
}
// Converts a string to float. Unlike safe_strtof, conversion will fail if the
// value fits into double but not float (e.g., DBL_MAX).
-LIBPROTOBUF_EXPORT bool SafeStrToFloat(StringPiece str, float* value);
+PROTOBUF_EXPORT bool SafeStrToFloat(StringPiece str, float* value);
// Returns whether a StringPiece begins with the provided prefix.
bool StringStartsWith(StringPiece text, StringPiece prefix);
@@ -211,4 +214,6 @@ bool StringEndsWith(StringPiece text, StringPiece suffix);
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_UTILITY_H__
diff --git a/src/google/protobuf/util/json_util.cc b/src/google/protobuf/util/json_util.cc
index bf82fa7c..19e20a47 100644
--- a/src/google/protobuf/util/json_util.cc
+++ b/src/google/protobuf/util/json_util.cc
@@ -184,6 +184,8 @@ util::Status JsonToBinaryStream(TypeResolver* resolver,
StatusErrorListener listener;
converter::ProtoStreamObjectWriter::Options proto_writer_options;
proto_writer_options.ignore_unknown_fields = options.ignore_unknown_fields;
+ proto_writer_options.ignore_unknown_enum_values =
+ options.ignore_unknown_fields;
converter::ProtoStreamObjectWriter proto_writer(resolver, type, &sink,
&listener,
proto_writer_options);
@@ -215,8 +217,7 @@ util::Status JsonToBinaryString(TypeResolver* resolver,
namespace {
const char* kTypeUrlPrefix = "type.googleapis.com";
TypeResolver* generated_type_resolver_ = NULL;
-GOOGLE_PROTOBUF_NAMESPACE_ID::internal::once_flag
- generated_type_resolver_init_;
+PROTOBUF_NAMESPACE_ID::internal::once_flag generated_type_resolver_init_;
string GetTypeUrl(const Message& message) {
return string(kTypeUrlPrefix) + "/" + message.GetDescriptor()->full_name();
@@ -231,8 +232,8 @@ void InitGeneratedTypeResolver() {
}
TypeResolver* GetGeneratedTypeResolver() {
- GOOGLE_PROTOBUF_NAMESPACE_ID::internal::call_once(
- generated_type_resolver_init_, InitGeneratedTypeResolver);
+ PROTOBUF_NAMESPACE_ID::internal::call_once(generated_type_resolver_init_,
+ InitGeneratedTypeResolver);
return generated_type_resolver_;
}
} // namespace
diff --git a/src/google/protobuf/util/json_util.h b/src/google/protobuf/util/json_util.h
index 96809a4f..f62e7f0f 100644
--- a/src/google/protobuf/util/json_util.h
+++ b/src/google/protobuf/util/json_util.h
@@ -38,6 +38,8 @@
#include <google/protobuf/stubs/bytestream.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace io {
@@ -81,20 +83,20 @@ typedef JsonPrintOptions JsonOptions;
// Converts from protobuf message to JSON and appends it to |output|. This is a
// simple wrapper of BinaryToJsonString(). It will use the DescriptorPool of the
// passed-in message to resolve Any types.
-LIBPROTOBUF_EXPORT util::Status MessageToJsonString(const Message& message,
- string* output,
- const JsonOptions& options);
+PROTOBUF_EXPORT util::Status MessageToJsonString(const Message& message,
+ std::string* output,
+ const JsonOptions& options);
inline util::Status MessageToJsonString(const Message& message,
- string* output) {
+ std::string* output) {
return MessageToJsonString(message, output, JsonOptions());
}
// Converts from JSON to protobuf message. This is a simple wrapper of
// JsonStringToBinary(). It will use the DescriptorPool of the passed-in
// message to resolve Any types.
-LIBPROTOBUF_EXPORT util::Status JsonStringToMessage(StringPiece input, Message* message,
- const JsonParseOptions& options);
+PROTOBUF_EXPORT util::Status JsonStringToMessage(
+ StringPiece input, Message* message, const JsonParseOptions& options);
inline util::Status JsonStringToMessage(StringPiece input,
Message* message) {
@@ -107,32 +109,27 @@ inline util::Status JsonStringToMessage(StringPiece input,
// 2. input is not valid protobuf wire format, or conflicts with the type
// information returned by TypeResolver.
// Note that unknown fields will be discarded silently.
-LIBPROTOBUF_EXPORT util::Status BinaryToJsonStream(
- TypeResolver* resolver,
- const string& type_url,
+PROTOBUF_EXPORT util::Status BinaryToJsonStream(
+ TypeResolver* resolver, const std::string& type_url,
io::ZeroCopyInputStream* binary_input,
- io::ZeroCopyOutputStream* json_output,
- const JsonPrintOptions& options);
+ io::ZeroCopyOutputStream* json_output, const JsonPrintOptions& options);
inline util::Status BinaryToJsonStream(
- TypeResolver* resolver, const string& type_url,
+ TypeResolver* resolver, const std::string& type_url,
io::ZeroCopyInputStream* binary_input,
io::ZeroCopyOutputStream* json_output) {
return BinaryToJsonStream(resolver, type_url, binary_input, json_output,
JsonPrintOptions());
}
-LIBPROTOBUF_EXPORT util::Status BinaryToJsonString(
- TypeResolver* resolver,
- const string& type_url,
- const string& binary_input,
- string* json_output,
- const JsonPrintOptions& options);
+PROTOBUF_EXPORT util::Status BinaryToJsonString(
+ TypeResolver* resolver, const std::string& type_url, const std::string& binary_input,
+ std::string* json_output, const JsonPrintOptions& options);
inline util::Status BinaryToJsonString(TypeResolver* resolver,
- const string& type_url,
- const string& binary_input,
- string* json_output) {
+ const std::string& type_url,
+ const std::string& binary_input,
+ std::string* json_output) {
return BinaryToJsonString(resolver, type_url, binary_input, json_output,
JsonPrintOptions());
}
@@ -142,39 +139,36 @@ inline util::Status BinaryToJsonString(TypeResolver* resolver,
// 1. TypeResolver fails to resolve a type.
// 2. input is not valid JSON format, or conflicts with the type
// information returned by TypeResolver.
-LIBPROTOBUF_EXPORT util::Status JsonToBinaryStream(
- TypeResolver* resolver,
- const string& type_url,
+PROTOBUF_EXPORT util::Status JsonToBinaryStream(
+ TypeResolver* resolver, const std::string& type_url,
io::ZeroCopyInputStream* json_input,
- io::ZeroCopyOutputStream* binary_output,
- const JsonParseOptions& options);
+ io::ZeroCopyOutputStream* binary_output, const JsonParseOptions& options);
inline util::Status JsonToBinaryStream(
TypeResolver* resolver,
- const string& type_url,
+ const std::string& type_url,
io::ZeroCopyInputStream* json_input,
io::ZeroCopyOutputStream* binary_output) {
return JsonToBinaryStream(resolver, type_url, json_input, binary_output,
JsonParseOptions());
}
-LIBPROTOBUF_EXPORT util::Status JsonToBinaryString(TypeResolver* resolver,
- const string& type_url,
- StringPiece json_input,
- string* binary_output,
- const JsonParseOptions& options);
+PROTOBUF_EXPORT util::Status JsonToBinaryString(
+ TypeResolver* resolver, const std::string& type_url,
+ StringPiece json_input, std::string* binary_output,
+ const JsonParseOptions& options);
inline util::Status JsonToBinaryString(TypeResolver* resolver,
- const string& type_url,
+ const std::string& type_url,
StringPiece json_input,
- string* binary_output) {
+ std::string* binary_output) {
return JsonToBinaryString(resolver, type_url, json_input, binary_output,
JsonParseOptions());
}
namespace internal {
// Internal helper class. Put in the header so we can write unit-tests for it.
-class LIBPROTOBUF_EXPORT ZeroCopyStreamByteSink : public strings::ByteSink {
+class PROTOBUF_EXPORT ZeroCopyStreamByteSink : public strings::ByteSink {
public:
explicit ZeroCopyStreamByteSink(io::ZeroCopyOutputStream* stream)
: stream_(stream), buffer_(NULL), buffer_size_(0) {}
@@ -195,4 +189,6 @@ class LIBPROTOBUF_EXPORT ZeroCopyStreamByteSink : public strings::ByteSink {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_UTIL_JSON_UTIL_H__
diff --git a/src/google/protobuf/util/message_differencer.h b/src/google/protobuf/util/message_differencer.h
index 0c2174bf..9419267e 100644
--- a/src/google/protobuf/util/message_differencer.h
+++ b/src/google/protobuf/util/message_differencer.h
@@ -51,6 +51,8 @@
#include <google/protobuf/unknown_field_set.h>
#include <google/protobuf/util/field_comparator.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
@@ -106,7 +108,7 @@ class FieldContext; // declared below MessageDifferencer
// guard it with a lock to use the same MessageDifferencer instance from
// multiple threads. Note that it's fine to call static comparison methods
// (like MessageDifferencer::Equals) concurrently.
-class LIBPROTOBUF_EXPORT MessageDifferencer {
+class PROTOBUF_EXPORT MessageDifferencer {
public:
// Determines whether the supplied messages are equal. Equality is defined as
// all fields within the two messages being set to the same value. Primitive
@@ -212,7 +214,7 @@ class LIBPROTOBUF_EXPORT MessageDifferencer {
// FieldDescriptors. The first will be the field of the embedded message
// itself and the second will be the actual field in the embedded message
// that was added/deleted/modified.
- class LIBPROTOBUF_EXPORT Reporter {
+ class PROTOBUF_EXPORT Reporter {
public:
Reporter();
virtual ~Reporter();
@@ -290,7 +292,7 @@ class LIBPROTOBUF_EXPORT MessageDifferencer {
// MapKeyComparator is used to determine if two elements have the same key
// when comparing elements of a repeated field as a map.
- class LIBPROTOBUF_EXPORT MapKeyComparator {
+ class PROTOBUF_EXPORT MapKeyComparator {
public:
MapKeyComparator();
virtual ~MapKeyComparator();
@@ -313,7 +315,7 @@ class LIBPROTOBUF_EXPORT MessageDifferencer {
// field IsIgnored is called on each added IgnoreCriteria until one returns
// true or all return false.
// IsIgnored is called for fields where at least one side has a value.
- class LIBPROTOBUF_EXPORT IgnoreCriteria {
+ class PROTOBUF_EXPORT IgnoreCriteria {
public:
IgnoreCriteria();
virtual ~IgnoreCriteria();
@@ -579,7 +581,7 @@ class LIBPROTOBUF_EXPORT MessageDifferencer {
// Automatically creates a reporter that will output the differences
// found (if any) to the specified output string pointer. Note that this
// method must be called before Compare.
- void ReportDifferencesToString(string* output);
+ void ReportDifferencesToString(std::string* output);
// Tells the MessageDifferencer to report differences via the specified
// reporter. Note that this method must be called before Compare for
@@ -599,7 +601,7 @@ class LIBPROTOBUF_EXPORT MessageDifferencer {
// complete until after you destroy the reporter. For example, if you use a
// StreamReporter to write to a StringOutputStream, the target string may
// contain uninitialized data until the reporter is destroyed.
- class LIBPROTOBUF_EXPORT StreamReporter : public Reporter {
+ class PROTOBUF_EXPORT StreamReporter : public Reporter {
public:
explicit StreamReporter(io::ZeroCopyOutputStream* output);
explicit StreamReporter(io::Printer* printer); // delimiter '$'
@@ -659,7 +661,7 @@ class LIBPROTOBUF_EXPORT MessageDifferencer {
virtual void PrintUnknownFieldValue(const UnknownField* unknown_field);
// Just print a string
- void Print(const string& str);
+ void Print(const std::string& str);
private:
io::Printer* printer_;
@@ -679,7 +681,7 @@ class LIBPROTOBUF_EXPORT MessageDifferencer {
class MultipleFieldsMapKeyComparator;
// A MapKeyComparator for use with map_entries.
- class LIBPROTOBUF_EXPORT MapEntryKeyComparator : public MapKeyComparator {
+ class PROTOBUF_EXPORT MapEntryKeyComparator : public MapKeyComparator {
public:
explicit MapEntryKeyComparator(MessageDifferencer* message_differencer);
bool IsMatch(
@@ -863,7 +865,7 @@ class LIBPROTOBUF_EXPORT MessageDifferencer {
bool report_moves_;
bool report_ignores_;
- string* output_string_;
+ std::string* output_string_;
std::unique_ptr<DynamicMessageFactory> dynamic_message_factory_;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageDifferencer);
@@ -871,7 +873,7 @@ class LIBPROTOBUF_EXPORT MessageDifferencer {
// This class provides extra information to the FieldComparator::Compare
// function.
-class LIBPROTOBUF_EXPORT FieldContext {
+class PROTOBUF_EXPORT FieldContext {
public:
explicit FieldContext(
std::vector<MessageDifferencer::SpecificField>* parent_fields)
@@ -889,4 +891,6 @@ class LIBPROTOBUF_EXPORT FieldContext {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_UTIL_MESSAGE_DIFFERENCER_H__
diff --git a/src/google/protobuf/util/message_differencer_unittest.cc b/src/google/protobuf/util/message_differencer_unittest.cc
index 1f50ea21..848290b1 100644
--- a/src/google/protobuf/util/message_differencer_unittest.cc
+++ b/src/google/protobuf/util/message_differencer_unittest.cc
@@ -35,6 +35,7 @@
// TODO(ksroka): Move some of these tests to field_comparator_test.cc.
#include <algorithm>
+#include <random>
#include <string>
#include <vector>
@@ -906,8 +907,9 @@ TEST(MessageDifferencerTest, SpecifiedFieldsEqualityAllShuffledTest) {
msg1.GetReflection()->ListFields(msg1, &fields1);
msg2.GetReflection()->ListFields(msg2, &fields2);
- std::random_shuffle(fields1.begin(), fields1.end());
- std::random_shuffle(fields2.begin(), fields2.end());
+ std::default_random_engine rng;
+ std::shuffle(fields1.begin(), fields1.end(), rng);
+ std::shuffle(fields2.begin(), fields2.end(), rng);
util::MessageDifferencer differencer;
EXPECT_TRUE(differencer.CompareWithFields(msg1, msg2, fields1, fields2));
diff --git a/src/google/protobuf/util/time_util.cc b/src/google/protobuf/util/time_util.cc
index 9321a23a..a7cba004 100644
--- a/src/google/protobuf/util/time_util.cc
+++ b/src/google/protobuf/util/time_util.cc
@@ -375,8 +375,8 @@ timeval TimeUtil::DurationToTimeval(const Duration& value) {
namespace google {
namespace protobuf {
namespace {
-using ::GOOGLE_PROTOBUF_NAMESPACE_ID::util::CreateNormalized;
-using ::GOOGLE_PROTOBUF_NAMESPACE_ID::util::kNanosPerSecond;
+using ::PROTOBUF_NAMESPACE_ID::util::CreateNormalized;
+using ::PROTOBUF_NAMESPACE_ID::util::kNanosPerSecond;
// Convert a Duration to uint128.
void ToUint128(const Duration& value, uint128* result, bool* negative) {
diff --git a/src/google/protobuf/util/time_util.h b/src/google/protobuf/util/time_util.h
index b0e19173..bbda5380 100644
--- a/src/google/protobuf/util/time_util.h
+++ b/src/google/protobuf/util/time_util.h
@@ -52,7 +52,7 @@ namespace protobuf {
namespace util {
// Utility functions for Timestamp and Duration.
-class LIBPROTOBUF_EXPORT TimeUtil {
+class PROTOBUF_EXPORT TimeUtil {
typedef google::protobuf::Timestamp Timestamp;
typedef google::protobuf::Duration Duration;
@@ -81,8 +81,8 @@ class LIBPROTOBUF_EXPORT TimeUtil {
//
// Example of accepted format:
// "1972-01-01T10:00:20.021-05:00"
- static string ToString(const Timestamp& timestamp);
- static bool FromString(const string& value, Timestamp* timestamp);
+ static std::string ToString(const Timestamp& timestamp);
+ static bool FromString(const std::string& value, Timestamp* timestamp);
// Converts Duration to/from string format. The string format will contains
// 3, 6, or 9 fractional digits depending on the precision required to
@@ -90,8 +90,8 @@ class LIBPROTOBUF_EXPORT TimeUtil {
// "1s", "1.010s", "1.000000100s", "-3.100s"
// The range that can be represented by Duration is from -315,576,000,000
// to +315,576,000,000 inclusive (in seconds).
- static string ToString(const Duration& duration);
- static bool FromString(const string& value, Duration* timestamp);
+ static std::string ToString(const Duration& duration);
+ static bool FromString(const std::string& value, Duration* timestamp);
#ifdef GetCurrentTime
#undef GetCurrentTime // Visual Studio has macro GetCurrentTime
@@ -165,12 +165,14 @@ namespace protobuf {
// Overloaded operators for Duration.
//
// Assignment operators.
-LIBPROTOBUF_EXPORT Duration& operator+=(Duration& d1, const Duration& d2); // NOLINT
-LIBPROTOBUF_EXPORT Duration& operator-=(Duration& d1, const Duration& d2); // NOLINT
-LIBPROTOBUF_EXPORT Duration& operator*=(Duration& d, int64 r); // NOLINT
-LIBPROTOBUF_EXPORT Duration& operator*=(Duration& d, double r); // NOLINT
-LIBPROTOBUF_EXPORT Duration& operator/=(Duration& d, int64 r); // NOLINT
-LIBPROTOBUF_EXPORT Duration& operator/=(Duration& d, double r); // NOLINT
+PROTOBUF_EXPORT Duration& operator+=(Duration& d1,
+ const Duration& d2); // NOLINT
+PROTOBUF_EXPORT Duration& operator-=(Duration& d1,
+ const Duration& d2); // NOLINT
+PROTOBUF_EXPORT Duration& operator*=(Duration& d, int64 r); // NOLINT
+PROTOBUF_EXPORT Duration& operator*=(Duration& d, double r); // NOLINT
+PROTOBUF_EXPORT Duration& operator/=(Duration& d, int64 r); // NOLINT
+PROTOBUF_EXPORT Duration& operator/=(Duration& d, double r); // NOLINT
// Overload for other integer types.
template <typename T>
Duration& operator*=(Duration& d, T r) { // NOLINT
@@ -182,7 +184,8 @@ Duration& operator/=(Duration& d, T r) { // NOLINT
int64 x = r;
return d /= x;
}
-LIBPROTOBUF_EXPORT Duration& operator%=(Duration& d1, const Duration& d2); // NOLINT
+PROTOBUF_EXPORT Duration& operator%=(Duration& d1,
+ const Duration& d2); // NOLINT
// Relational operators.
inline bool operator<(const Duration& d1, const Duration& d2) {
if (d1.seconds() == d2.seconds()) {
@@ -233,7 +236,7 @@ template<typename T>
inline Duration operator/(Duration d, T r) {
return d /= r;
}
-LIBPROTOBUF_EXPORT int64 operator/(const Duration& d1, const Duration& d2);
+PROTOBUF_EXPORT int64 operator/(const Duration& d1, const Duration& d2);
inline Duration operator%(const Duration& d1, const Duration& d2) {
Duration result = d1;
@@ -241,15 +244,17 @@ inline Duration operator%(const Duration& d1, const Duration& d2) {
}
inline std::ostream& operator<<(std::ostream& out, const Duration& d) {
- out << ::GOOGLE_PROTOBUF_NAMESPACE_ID::util::TimeUtil::ToString(d);
+ out << ::PROTOBUF_NAMESPACE_ID::util::TimeUtil::ToString(d);
return out;
}
// Overloaded operators for Timestamp
//
// Assignement operators.
-LIBPROTOBUF_EXPORT Timestamp& operator+=(Timestamp& t, const Duration& d); // NOLINT
-LIBPROTOBUF_EXPORT Timestamp& operator-=(Timestamp& t, const Duration& d); // NOLINT
+PROTOBUF_EXPORT Timestamp& operator+=(Timestamp& t,
+ const Duration& d); // NOLINT
+PROTOBUF_EXPORT Timestamp& operator-=(Timestamp& t,
+ const Duration& d); // NOLINT
// Relational operators.
inline bool operator<(const Timestamp& t1, const Timestamp& t2) {
if (t1.seconds() == t2.seconds()) {
@@ -285,10 +290,10 @@ inline Timestamp operator-(const Timestamp& t, const Duration& d) {
Timestamp result = t;
return result -= d;
}
-LIBPROTOBUF_EXPORT Duration operator-(const Timestamp& t1, const Timestamp& t2);
+PROTOBUF_EXPORT Duration operator-(const Timestamp& t1, const Timestamp& t2);
inline std::ostream& operator<<(std::ostream& out, const Timestamp& t) {
- out << ::GOOGLE_PROTOBUF_NAMESPACE_ID::util::TimeUtil::ToString(t);
+ out << ::PROTOBUF_NAMESPACE_ID::util::TimeUtil::ToString(t);
return out;
}
diff --git a/src/google/protobuf/util/type_resolver.h b/src/google/protobuf/util/type_resolver.h
index 9c9a7444..bc5f0960 100644
--- a/src/google/protobuf/util/type_resolver.h
+++ b/src/google/protobuf/util/type_resolver.h
@@ -38,6 +38,8 @@
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/status.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
class Type;
@@ -53,17 +55,17 @@ namespace util {
// Abstract interface for a type resovler.
//
// Implementations of this interface must be thread-safe.
-class LIBPROTOBUF_EXPORT TypeResolver {
+class PROTOBUF_EXPORT TypeResolver {
public:
TypeResolver() {}
virtual ~TypeResolver() {}
// Resolves a type url for a message type.
virtual util::Status ResolveMessageType(
- const string& type_url, google::protobuf::Type* message_type) = 0;
+ const std::string& type_url, google::protobuf::Type* message_type) = 0;
// Resolves a type url for an enum type.
- virtual util::Status ResolveEnumType(const string& type_url,
+ virtual util::Status ResolveEnumType(const std::string& type_url,
google::protobuf::Enum* enum_type) = 0;
private:
@@ -74,4 +76,6 @@ class LIBPROTOBUF_EXPORT TypeResolver {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_UTIL_TYPE_RESOLVER_H__
diff --git a/src/google/protobuf/util/type_resolver_util.h b/src/google/protobuf/util/type_resolver_util.h
index c512e6fd..fa912b60 100644
--- a/src/google/protobuf/util/type_resolver_util.h
+++ b/src/google/protobuf/util/type_resolver_util.h
@@ -35,20 +35,23 @@
#include <string>
-#include <google/protobuf/stubs/common.h>
namespace google {
namespace protobuf {
class DescriptorPool;
namespace util {
class TypeResolver;
+#include <google/protobuf/port_def.inc>
+
// Creates a TypeResolver that serves type information in the given descriptor
// pool. Caller takes ownership of the returned TypeResolver.
-LIBPROTOBUF_EXPORT TypeResolver* NewTypeResolverForDescriptorPool(
- const string& url_prefix, const DescriptorPool* pool);
+PROTOBUF_EXPORT TypeResolver* NewTypeResolverForDescriptorPool(
+ const std::string& url_prefix, const DescriptorPool* pool);
} // namespace util
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_UTIL_TYPE_RESOLVER_UTIL_H__
diff --git a/src/google/protobuf/wire_format.h b/src/google/protobuf/wire_format.h
index 5bdb1273..6a658b36 100644
--- a/src/google/protobuf/wire_format.h
+++ b/src/google/protobuf/wire_format.h
@@ -50,6 +50,8 @@
#error "You cannot SWIG proto headers"
#endif
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace io {
@@ -73,7 +75,7 @@ namespace internal {
// non-reflection based routines.
//
// This class is really a namespace that contains only static methods
-class LIBPROTOBUF_EXPORT WireFormat {
+class PROTOBUF_EXPORT WireFormat {
public:
// Given a field return its WireType
static inline WireFormatLite::WireType WireTypeForField(
@@ -250,7 +252,7 @@ class LIBPROTOBUF_EXPORT WireFormat {
};
// Subclass of FieldSkipper which saves skipped fields to an UnknownFieldSet.
-class LIBPROTOBUF_EXPORT UnknownFieldSetFieldSkipper : public FieldSkipper {
+class PROTOBUF_EXPORT UnknownFieldSetFieldSkipper : public FieldSkipper {
public:
UnknownFieldSetFieldSkipper(UnknownFieldSet* unknown_fields)
: unknown_fields_(unknown_fields) {}
@@ -331,12 +333,6 @@ inline void SerializeUnknownMessageSetItems(
WireFormat::SerializeUnknownMessageSetItems(unknown_fields, output);
}
-inline uint8* SerializeUnknownMessageSetItemsToArray(
- const UnknownFieldSet& unknown_fields, uint8* target) {
- return WireFormat::SerializeUnknownMessageSetItemsToArray(unknown_fields,
- target);
-}
-
inline size_t ComputeUnknownMessageSetItemsSize(
const UnknownFieldSet& unknown_fields) {
return WireFormat::ComputeUnknownMessageSetItemsSize(unknown_fields);
@@ -346,4 +342,6 @@ inline size_t ComputeUnknownMessageSetItemsSize(
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_WIRE_FORMAT_H__
diff --git a/src/google/protobuf/wire_format_lite.cc b/src/google/protobuf/wire_format_lite.cc
index 6b0190f7..a393f367 100644
--- a/src/google/protobuf/wire_format_lite.cc
+++ b/src/google/protobuf/wire_format_lite.cc
@@ -582,7 +582,7 @@ void WireFormatLite::WriteMessageMaybeToArray(int field_number,
}
}
-GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE static bool ReadBytesToString(
+PROTOBUF_ALWAYS_INLINE static bool ReadBytesToString(
io::CodedInputStream* input, string* value);
inline static bool ReadBytesToString(io::CodedInputStream* input,
string* value) {
@@ -602,6 +602,19 @@ bool WireFormatLite::ReadBytes(io::CodedInputStream* input, string** p) {
return ReadBytesToString(input, *p);
}
+void PrintUTF8ErrorLog(const char* field_name, const char* operation_str,
+ bool emit_stacktrace) {
+ string stacktrace;
+ string quoted_field_name = "";
+ if (field_name != nullptr) {
+ quoted_field_name = StringPrintf(" '%s'", field_name);
+ }
+ GOOGLE_LOG(ERROR) << "String field" << quoted_field_name << " contains invalid "
+ << "UTF-8 data when " << operation_str << " a protocol "
+ << "buffer. Use the 'bytes' type if you intend to send raw "
+ << "bytes. " << stacktrace;
+}
+
bool WireFormatLite::VerifyUtf8String(const char* data,
int size,
Operation op,
@@ -617,15 +630,7 @@ bool WireFormatLite::VerifyUtf8String(const char* data,
break;
// no default case: have the compiler warn if a case is not covered.
}
- string quoted_field_name = "";
- if (field_name != NULL) {
- quoted_field_name = StringPrintf(" '%s'", field_name);
- }
- // no space below to avoid double space when the field name is missing.
- GOOGLE_LOG(ERROR) << "String field" << quoted_field_name << " contains invalid "
- << "UTF-8 data when " << operation_str << " a protocol "
- << "buffer. Use the 'bytes' type if you intend to send raw "
- << "bytes. ";
+ PrintUTF8ErrorLog(field_name, operation_str, false);
return false;
}
return true;
diff --git a/src/google/protobuf/wire_format_lite.h b/src/google/protobuf/wire_format_lite.h
index dc79ac45..60cadaee 100644
--- a/src/google/protobuf/wire_format_lite.h
+++ b/src/google/protobuf/wire_format_lite.h
@@ -88,7 +88,7 @@ class StringPieceField;
// reflection.
//
// This class is really a namespace that contains only static methods.
-class LIBPROTOBUF_EXPORT WireFormatLite {
+class PROTOBUF_EXPORT WireFormatLite {
public:
// -----------------------------------------------------------------
// Helper constants and functions related to the format. These are
@@ -256,7 +256,7 @@ class LIBPROTOBUF_EXPORT WireFormatLite {
// that file to use these.
#ifdef NDEBUG
-#define INL GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE
+#define INL PROTOBUF_ALWAYS_INLINE
#else
// Avoid excessive inlining in non-optimized builds. Without other optimizations
// the inlining is not going to provide benefits anyway and the huge resulting
@@ -324,16 +324,16 @@ class LIBPROTOBUF_EXPORT WireFormatLite {
io::CodedOutputStream* unknown_fields_stream, RepeatedField<int>* values);
// Read a string. ReadString(..., string* value) requires an existing string.
- static inline bool ReadString(io::CodedInputStream* input, string* value);
+ static inline bool ReadString(io::CodedInputStream* input, std::string* value);
// ReadString(..., string** p) is internal-only, and should only be called
// from generated code. It starts by setting *p to "new string"
// if *p == &GetEmptyStringAlreadyInited(). It then invokes
// ReadString(io::CodedInputStream* input, *p). This is useful for reducing
// code size.
- static inline bool ReadString(io::CodedInputStream* input, string** p);
+ static inline bool ReadString(io::CodedInputStream* input, std::string** p);
// Analogous to ReadString().
- static bool ReadBytes(io::CodedInputStream* input, string* value);
- static bool ReadBytes(io::CodedInputStream* input, string** p);
+ static bool ReadBytes(io::CodedInputStream* input, std::string* value);
+ static bool ReadBytes(io::CodedInputStream* input, std::string** p);
enum Operation {
PARSE = 0,
@@ -438,13 +438,13 @@ class LIBPROTOBUF_EXPORT WireFormatLite {
static void WriteEnum(int field_number, int value,
io::CodedOutputStream* output);
- static void WriteString(int field_number, const string& value,
+ static void WriteString(int field_number, const std::string& value,
io::CodedOutputStream* output);
- static void WriteBytes(int field_number, const string& value,
+ static void WriteBytes(int field_number, const std::string& value,
io::CodedOutputStream* output);
- static void WriteStringMaybeAliased(int field_number, const string& value,
+ static void WriteStringMaybeAliased(int field_number, const std::string& value,
io::CodedOutputStream* output);
- static void WriteBytesMaybeAliased(int field_number, const string& value,
+ static void WriteBytesMaybeAliased(int field_number, const std::string& value,
io::CodedOutputStream* output);
static void WriteGroup(int field_number, const MessageLite& value,
@@ -609,9 +609,9 @@ class LIBPROTOBUF_EXPORT WireFormatLite {
const RepeatedField<int>& value,
uint8* output);
- INL static uint8* WriteStringToArray(int field_number, const string& value,
+ INL static uint8* WriteStringToArray(int field_number, const std::string& value,
uint8* target);
- INL static uint8* WriteBytesToArray(int field_number, const string& value,
+ INL static uint8* WriteBytesToArray(int field_number, const std::string& value,
uint8* target);
// Whether to serialize deterministically (e.g., map keys are
@@ -700,8 +700,8 @@ class LIBPROTOBUF_EXPORT WireFormatLite {
static const size_t kDoubleSize = 8;
static const size_t kBoolSize = 1;
- static inline size_t StringSize(const string& value);
- static inline size_t BytesSize(const string& value);
+ static inline size_t StringSize(const std::string& value);
+ static inline size_t BytesSize(const std::string& value);
template <typename MessageType>
static inline size_t GroupSize(const MessageType& value);
@@ -725,16 +725,14 @@ class LIBPROTOBUF_EXPORT WireFormatLite {
// optimizations for primitive types that have fixed size on the wire, and
// can be read using potentially faster paths.
template <typename CType, enum FieldType DeclaredType>
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE static bool
- ReadRepeatedFixedSizePrimitive(int tag_size, uint32 tag,
- io::CodedInputStream* input,
- RepeatedField<CType>* value);
+ PROTOBUF_ALWAYS_INLINE static bool ReadRepeatedFixedSizePrimitive(
+ int tag_size, uint32 tag, io::CodedInputStream* input,
+ RepeatedField<CType>* value);
// Like ReadRepeatedFixedSizePrimitive but for packed primitive fields.
template <typename CType, enum FieldType DeclaredType>
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE static bool
- ReadPackedFixedSizePrimitive(io::CodedInputStream* input,
- RepeatedField<CType>* value);
+ PROTOBUF_ALWAYS_INLINE static bool ReadPackedFixedSizePrimitive(
+ io::CodedInputStream* input, RepeatedField<CType>* value);
static const CppType kFieldTypeToCppTypeMap[];
static const WireFormatLite::WireType kWireTypeForFieldType[];
@@ -746,7 +744,7 @@ class LIBPROTOBUF_EXPORT WireFormatLite {
// discards them. WireFormat defines a subclass which writes to an
// UnknownFieldSet. This class is used by ExtensionSet::ParseField(), since
// ExtensionSet is part of the lite library but UnknownFieldSet is not.
-class LIBPROTOBUF_EXPORT FieldSkipper {
+class PROTOBUF_EXPORT FieldSkipper {
public:
FieldSkipper() {}
virtual ~FieldSkipper() {}
@@ -766,7 +764,7 @@ class LIBPROTOBUF_EXPORT FieldSkipper {
// Subclass of FieldSkipper which saves skipped fields to a CodedOutputStream.
-class LIBPROTOBUF_EXPORT CodedOutputStreamFieldSkipper : public FieldSkipper {
+class PROTOBUF_EXPORT CodedOutputStreamFieldSkipper : public FieldSkipper {
public:
explicit CodedOutputStreamFieldSkipper(io::CodedOutputStream* unknown_fields)
: unknown_fields_(unknown_fields) {}
@@ -898,27 +896,21 @@ inline int64 WireFormatLite::ZigZagDecode64(uint64 n) {
// call ReadBytes().
inline bool WireFormatLite::ReadString(io::CodedInputStream* input,
- string* value) {
+ std::string* value) {
return ReadBytes(input, value);
}
inline bool WireFormatLite::ReadString(io::CodedInputStream* input,
- string** p) {
+ std::string** p) {
return ReadBytes(input, p);
}
-inline void SerializeUnknownMessageSetItems(const string& unknown_fields,
+inline void SerializeUnknownMessageSetItems(const std::string& unknown_fields,
io::CodedOutputStream* output) {
output->WriteString(unknown_fields);
}
-inline uint8* SerializeUnknownMessageSetItemsToArray(
- const string& unknown_fields, uint8* target) {
- return io::CodedOutputStream::WriteStringWithSizeToArray(unknown_fields,
- target);
-}
-
-inline size_t ComputeUnknownMessageSetItemsSize(const string& unknown_fields) {
+inline size_t ComputeUnknownMessageSetItemsSize(const std::string& unknown_fields) {
return unknown_fields.size();
}
diff --git a/src/google/protobuf/wire_format_lite_inl.h b/src/google/protobuf/wire_format_lite_inl.h
index 2ee5d51d..44c4b5ca 100644
--- a/src/google/protobuf/wire_format_lite_inl.h
+++ b/src/google/protobuf/wire_format_lite_inl.h
@@ -51,6 +51,8 @@
#error "You cannot SWIG proto headers"
#endif
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace internal {
@@ -870,7 +872,7 @@ inline uint8* WireFormatLite::WriteEnumToArray(
return WritePrimitiveToArray(field_number, value, WriteEnumToArray, target);
}
inline uint8* WireFormatLite::WriteStringToArray(int field_number,
- const string& value,
+ const std::string& value,
uint8* target) {
// String is for UTF-8 text only
// WARNING: In wire_format.cc, both strings and bytes are handled by
@@ -880,7 +882,7 @@ inline uint8* WireFormatLite::WriteStringToArray(int field_number,
return io::CodedOutputStream::WriteStringWithSizeToArray(value, target);
}
inline uint8* WireFormatLite::WriteBytesToArray(int field_number,
- const string& value,
+ const std::string& value,
uint8* target) {
target = WriteTagToArray(field_number, WIRETYPE_LENGTH_DELIMITED, target);
return io::CodedOutputStream::WriteStringWithSizeToArray(value, target);
@@ -953,10 +955,10 @@ inline size_t WireFormatLite::EnumSize(int value) {
return io::CodedOutputStream::VarintSize32SignExtended(value);
}
-inline size_t WireFormatLite::StringSize(const string& value) {
+inline size_t WireFormatLite::StringSize(const std::string& value) {
return LengthDelimitedSize(value.size());
}
-inline size_t WireFormatLite::BytesSize(const string& value) {
+inline size_t WireFormatLite::BytesSize(const std::string& value) {
return LengthDelimitedSize(value.size());
}
@@ -1003,7 +1005,7 @@ bool ParseMessageSetItemImpl(io::CodedInputStream* input, MS ms) {
// If we see message data before the type_id, we'll append it to this so
// we can parse it later.
- string message_data;
+ std::string message_data;
while (true) {
const uint32 tag = input->ReadTagNoLastTag();
@@ -1067,4 +1069,6 @@ bool ParseMessageSetItemImpl(io::CodedInputStream* input, MS ms) {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_WIRE_FORMAT_LITE_INL_H__
diff --git a/src/google/protobuf/wire_format_unittest.cc b/src/google/protobuf/wire_format_unittest.cc
index 9dfd13b5..babdcc65 100644
--- a/src/google/protobuf/wire_format_unittest.cc
+++ b/src/google/protobuf/wire_format_unittest.cc
@@ -51,6 +51,8 @@
#include <google/protobuf/stubs/casts.h>
#include <google/protobuf/stubs/stl_util.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace internal {
@@ -665,8 +667,8 @@ TEST(WireFormatTest, UnknownFieldRecursionLimit) {
TEST(WireFormatTest, ZigZag) {
// avoid line-wrapping
-#define LL(x) GOOGLE_LONGLONG(x)
-#define ULL(x) GOOGLE_ULONGLONG(x)
+#define LL(x) PROTOBUF_LONGLONG(x)
+#define ULL(x) PROTOBUF_ULONGLONG(x)
#define ZigZagEncode32(x) WireFormatLite::ZigZagEncode32(x)
#define ZigZagDecode32(x) WireFormatLite::ZigZagDecode32(x)
#define ZigZagEncode64(x) WireFormatLite::ZigZagEncode64(x)
diff --git a/src/google/protobuf/wrappers.pb.cc b/src/google/protobuf/wrappers.pb.cc
index 5a1fb3d7..3d7e7cb9 100644
--- a/src/google/protobuf/wrappers.pb.cc
+++ b/src/google/protobuf/wrappers.pb.cc
@@ -13,10 +13,6 @@
#include <google/protobuf/generated_message_reflection.h>
#include <google/protobuf/reflection_ops.h>
#include <google/protobuf/wire_format.h>
-// This is a temporary google only hack
-#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
-#include "third_party/protobuf/version.h"
-#endif
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>
@@ -71,7 +67,7 @@ static void InitDefaultsDoubleValue_google_2fprotobuf_2fwrappers_2eproto() {
::google::protobuf::DoubleValue::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_DoubleValue_google_2fprotobuf_2fwrappers_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_DoubleValue_google_2fprotobuf_2fwrappers_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsDoubleValue_google_2fprotobuf_2fwrappers_2eproto}, {}};
static void InitDefaultsFloatValue_google_2fprotobuf_2fwrappers_2eproto() {
@@ -85,7 +81,7 @@ static void InitDefaultsFloatValue_google_2fprotobuf_2fwrappers_2eproto() {
::google::protobuf::FloatValue::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_FloatValue_google_2fprotobuf_2fwrappers_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_FloatValue_google_2fprotobuf_2fwrappers_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsFloatValue_google_2fprotobuf_2fwrappers_2eproto}, {}};
static void InitDefaultsInt64Value_google_2fprotobuf_2fwrappers_2eproto() {
@@ -99,7 +95,7 @@ static void InitDefaultsInt64Value_google_2fprotobuf_2fwrappers_2eproto() {
::google::protobuf::Int64Value::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_Int64Value_google_2fprotobuf_2fwrappers_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_Int64Value_google_2fprotobuf_2fwrappers_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsInt64Value_google_2fprotobuf_2fwrappers_2eproto}, {}};
static void InitDefaultsUInt64Value_google_2fprotobuf_2fwrappers_2eproto() {
@@ -113,7 +109,7 @@ static void InitDefaultsUInt64Value_google_2fprotobuf_2fwrappers_2eproto() {
::google::protobuf::UInt64Value::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_UInt64Value_google_2fprotobuf_2fwrappers_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_UInt64Value_google_2fprotobuf_2fwrappers_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsUInt64Value_google_2fprotobuf_2fwrappers_2eproto}, {}};
static void InitDefaultsInt32Value_google_2fprotobuf_2fwrappers_2eproto() {
@@ -127,7 +123,7 @@ static void InitDefaultsInt32Value_google_2fprotobuf_2fwrappers_2eproto() {
::google::protobuf::Int32Value::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_Int32Value_google_2fprotobuf_2fwrappers_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_Int32Value_google_2fprotobuf_2fwrappers_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsInt32Value_google_2fprotobuf_2fwrappers_2eproto}, {}};
static void InitDefaultsUInt32Value_google_2fprotobuf_2fwrappers_2eproto() {
@@ -141,7 +137,7 @@ static void InitDefaultsUInt32Value_google_2fprotobuf_2fwrappers_2eproto() {
::google::protobuf::UInt32Value::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_UInt32Value_google_2fprotobuf_2fwrappers_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_UInt32Value_google_2fprotobuf_2fwrappers_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsUInt32Value_google_2fprotobuf_2fwrappers_2eproto}, {}};
static void InitDefaultsBoolValue_google_2fprotobuf_2fwrappers_2eproto() {
@@ -155,7 +151,7 @@ static void InitDefaultsBoolValue_google_2fprotobuf_2fwrappers_2eproto() {
::google::protobuf::BoolValue::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_BoolValue_google_2fprotobuf_2fwrappers_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_BoolValue_google_2fprotobuf_2fwrappers_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsBoolValue_google_2fprotobuf_2fwrappers_2eproto}, {}};
static void InitDefaultsStringValue_google_2fprotobuf_2fwrappers_2eproto() {
@@ -169,7 +165,7 @@ static void InitDefaultsStringValue_google_2fprotobuf_2fwrappers_2eproto() {
::google::protobuf::StringValue::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_StringValue_google_2fprotobuf_2fwrappers_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_StringValue_google_2fprotobuf_2fwrappers_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsStringValue_google_2fprotobuf_2fwrappers_2eproto}, {}};
static void InitDefaultsBytesValue_google_2fprotobuf_2fwrappers_2eproto() {
@@ -183,7 +179,7 @@ static void InitDefaultsBytesValue_google_2fprotobuf_2fwrappers_2eproto() {
::google::protobuf::BytesValue::InitAsDefaultInstance();
}
-LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_BytesValue_google_2fprotobuf_2fwrappers_2eproto =
+PROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_BytesValue_google_2fprotobuf_2fwrappers_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsBytesValue_google_2fprotobuf_2fwrappers_2eproto}, {}};
void InitDefaults_google_2fprotobuf_2fwrappers_2eproto() {
@@ -202,63 +198,63 @@ void InitDefaults_google_2fprotobuf_2fwrappers_2eproto() {
constexpr ::google::protobuf::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2fwrappers_2eproto = nullptr;
constexpr ::google::protobuf::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fwrappers_2eproto = nullptr;
-const ::google::protobuf::uint32 TableStruct_google_2fprotobuf_2fwrappers_2eproto::offsets[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
+const ::google::protobuf::uint32 TableStruct_google_2fprotobuf_2fwrappers_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
~0u, // no _has_bits_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::DoubleValue, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::DoubleValue, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::DoubleValue, value_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::DoubleValue, value_),
~0u, // no _has_bits_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FloatValue, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FloatValue, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FloatValue, value_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::FloatValue, value_),
~0u, // no _has_bits_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Int64Value, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Int64Value, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Int64Value, value_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Int64Value, value_),
~0u, // no _has_bits_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::UInt64Value, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::UInt64Value, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::UInt64Value, value_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::UInt64Value, value_),
~0u, // no _has_bits_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Int32Value, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Int32Value, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Int32Value, value_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::Int32Value, value_),
~0u, // no _has_bits_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::UInt32Value, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::UInt32Value, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::UInt32Value, value_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::UInt32Value, value_),
~0u, // no _has_bits_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::BoolValue, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::BoolValue, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::BoolValue, value_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::BoolValue, value_),
~0u, // no _has_bits_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::StringValue, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::StringValue, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::StringValue, value_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::StringValue, value_),
~0u, // no _has_bits_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::BytesValue, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::BytesValue, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::BytesValue, value_),
+ PROTOBUF_FIELD_OFFSET(::google::protobuf::BytesValue, value_),
};
-static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
+static const ::google::protobuf::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
{ 0, -1, sizeof(::google::protobuf::DoubleValue)},
{ 6, -1, sizeof(::google::protobuf::FloatValue)},
{ 12, -1, sizeof(::google::protobuf::Int64Value)},
@@ -399,9 +395,8 @@ const char* DoubleValue::_InternalParse(const char* begin, const char* end, void
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// double value = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 9) goto handle_unusual;
@@ -413,8 +408,9 @@ const char* DoubleValue::_InternalParse(const char* begin, const char* end, void
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
@@ -425,8 +421,6 @@ const char* DoubleValue::_InternalParse(const char* begin, const char* end, void
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -438,7 +432,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool DoubleValue::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.DoubleValue)
for (;;) {
@@ -698,9 +692,8 @@ const char* FloatValue::_InternalParse(const char* begin, const char* end, void*
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// float value = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 13) goto handle_unusual;
@@ -712,8 +705,9 @@ const char* FloatValue::_InternalParse(const char* begin, const char* end, void*
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
@@ -724,8 +718,6 @@ const char* FloatValue::_InternalParse(const char* begin, const char* end, void*
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -737,7 +729,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool FloatValue::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.FloatValue)
for (;;) {
@@ -949,7 +941,7 @@ Int64Value::Int64Value(const Int64Value& from)
}
void Int64Value::SharedCtor() {
- value_ = GOOGLE_PROTOBUF_LONGLONG(0);
+ value_ = PROTOBUF_LONGLONG(0);
}
Int64Value::~Int64Value() {
@@ -982,7 +974,7 @@ void Int64Value::Clear() {
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
- value_ = GOOGLE_PROTOBUF_LONGLONG(0);
+ value_ = PROTOBUF_LONGLONG(0);
_internal_metadata_.Clear();
}
@@ -997,23 +989,23 @@ const char* Int64Value::_InternalParse(const char* begin, const char* end, void*
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// int64 value = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 8) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
::google::protobuf::int64 value = val;
msg->set_value(value);
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
@@ -1024,8 +1016,6 @@ const char* Int64Value::_InternalParse(const char* begin, const char* end, void*
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -1037,7 +1027,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool Int64Value::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.Int64Value)
for (;;) {
@@ -1251,7 +1241,7 @@ UInt64Value::UInt64Value(const UInt64Value& from)
}
void UInt64Value::SharedCtor() {
- value_ = GOOGLE_PROTOBUF_ULONGLONG(0);
+ value_ = PROTOBUF_ULONGLONG(0);
}
UInt64Value::~UInt64Value() {
@@ -1284,7 +1274,7 @@ void UInt64Value::Clear() {
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
- value_ = GOOGLE_PROTOBUF_ULONGLONG(0);
+ value_ = PROTOBUF_ULONGLONG(0);
_internal_metadata_.Clear();
}
@@ -1299,23 +1289,23 @@ const char* UInt64Value::_InternalParse(const char* begin, const char* end, void
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// uint64 value = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 8) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
::google::protobuf::uint64 value = val;
msg->set_value(value);
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
@@ -1326,8 +1316,6 @@ const char* UInt64Value::_InternalParse(const char* begin, const char* end, void
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -1339,7 +1327,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool UInt64Value::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.UInt64Value)
for (;;) {
@@ -1601,23 +1589,23 @@ const char* Int32Value::_InternalParse(const char* begin, const char* end, void*
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// int32 value = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 8) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
::google::protobuf::int32 value = val;
msg->set_value(value);
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
@@ -1628,8 +1616,6 @@ const char* Int32Value::_InternalParse(const char* begin, const char* end, void*
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -1641,7 +1627,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool Int32Value::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.Int32Value)
for (;;) {
@@ -1903,23 +1889,23 @@ const char* UInt32Value::_InternalParse(const char* begin, const char* end, void
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// uint32 value = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 8) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
::google::protobuf::uint32 value = val;
msg->set_value(value);
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
@@ -1930,8 +1916,6 @@ const char* UInt32Value::_InternalParse(const char* begin, const char* end, void
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -1943,7 +1927,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool UInt32Value::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.UInt32Value)
for (;;) {
@@ -2205,23 +2189,23 @@ const char* BoolValue::_InternalParse(const char* begin, const char* end, void*
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// bool value = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 8) goto handle_unusual;
::google::protobuf::uint64 val;
ptr = Varint::Parse64(ptr, &val);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
bool value = val;
msg->set_value(value);
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
@@ -2232,8 +2216,6 @@ const char* BoolValue::_InternalParse(const char* begin, const char* end, void*
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -2245,7 +2227,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool BoolValue::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.BoolValue)
for (;;) {
@@ -2512,14 +2494,13 @@ const char* StringValue::_InternalParse(const char* begin, const char* end, void
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// string value = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 10) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
ctx->extra_parse_data().SetFieldName("google.protobuf.StringValue.value");
parser_till_end = ::google::protobuf::internal::StringParserUTF8;
::std::string* str = msg->mutable_value();
@@ -2527,14 +2508,15 @@ const char* StringValue::_InternalParse(const char* begin, const char* end, void
object = str;
if (size > end - ptr) goto len_delim_till_end;
auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ if (size) ptr = parser_till_end(ptr, newend, object, ctx);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr == newend);
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
@@ -2545,8 +2527,6 @@ const char* StringValue::_InternalParse(const char* begin, const char* end, void
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -2558,7 +2538,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool StringValue::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.StringValue)
for (;;) {
@@ -2841,28 +2821,27 @@ const char* BytesValue::_InternalParse(const char* begin, const char* end, void*
while (ptr < end) {
::google::protobuf::uint32 tag;
ptr = Varint::Parse32Inline(ptr, &tag);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
- case 0: goto error;
// bytes value = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 10) goto handle_unusual;
ptr = Varint::Parse32Inline(ptr, &size);
- if (!ptr) goto error;
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::protobuf::internal::StringParser;
::std::string* str = msg->mutable_value();
str->clear();
object = str;
if (size > end - ptr) goto len_delim_till_end;
- auto newend = ptr + size;
- if (!ctx->ParseExactRange({parser_till_end, object}, ptr, newend)) goto error;
- ptr = newend;
+ str->append(ptr, size);
+ ptr += size;
break;
}
default: {
handle_unusual: (void)&&handle_unusual;
- if ((tag & 7) == 4) {
- if (!ctx->ValidEndGroup(tag)) goto error;
+ if ((tag & 7) == 4 || tag == 0) {
+ bool ok = ctx->ValidEndGroup(tag);
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ok);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
@@ -2873,8 +2852,6 @@ const char* BytesValue::_InternalParse(const char* begin, const char* end, void*
} // switch
} // while
return ptr;
-error:
- return nullptr;
len_delim_till_end: (void)&&len_delim_till_end;
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
@@ -2886,7 +2863,7 @@ group_continues: (void)&&group_continues;
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool BytesValue::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.BytesValue)
for (;;) {
@@ -3074,34 +3051,35 @@ void BytesValue::InternalSwap(BytesValue* other) {
} // namespace google
namespace google {
namespace protobuf {
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::DoubleValue* Arena::CreateMaybeMessage< ::google::protobuf::DoubleValue >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::DoubleValue* Arena::CreateMaybeMessage< ::google::protobuf::DoubleValue >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::DoubleValue >(arena);
}
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::FloatValue* Arena::CreateMaybeMessage< ::google::protobuf::FloatValue >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::FloatValue* Arena::CreateMaybeMessage< ::google::protobuf::FloatValue >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::FloatValue >(arena);
}
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Int64Value* Arena::CreateMaybeMessage< ::google::protobuf::Int64Value >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::Int64Value* Arena::CreateMaybeMessage< ::google::protobuf::Int64Value >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::Int64Value >(arena);
}
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::UInt64Value* Arena::CreateMaybeMessage< ::google::protobuf::UInt64Value >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::UInt64Value* Arena::CreateMaybeMessage< ::google::protobuf::UInt64Value >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::UInt64Value >(arena);
}
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Int32Value* Arena::CreateMaybeMessage< ::google::protobuf::Int32Value >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::Int32Value* Arena::CreateMaybeMessage< ::google::protobuf::Int32Value >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::Int32Value >(arena);
}
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::UInt32Value* Arena::CreateMaybeMessage< ::google::protobuf::UInt32Value >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::UInt32Value* Arena::CreateMaybeMessage< ::google::protobuf::UInt32Value >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::UInt32Value >(arena);
}
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::BoolValue* Arena::CreateMaybeMessage< ::google::protobuf::BoolValue >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::BoolValue* Arena::CreateMaybeMessage< ::google::protobuf::BoolValue >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::BoolValue >(arena);
}
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::StringValue* Arena::CreateMaybeMessage< ::google::protobuf::StringValue >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::StringValue* Arena::CreateMaybeMessage< ::google::protobuf::StringValue >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::StringValue >(arena);
}
-template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::BytesValue* Arena::CreateMaybeMessage< ::google::protobuf::BytesValue >(Arena* arena) {
+template<> PROTOBUF_NOINLINE ::google::protobuf::BytesValue* Arena::CreateMaybeMessage< ::google::protobuf::BytesValue >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::BytesValue >(arena);
}
} // namespace protobuf
} // namespace google
// @@protoc_insertion_point(global_scope)
+#include <google/protobuf/port_undef.inc>
diff --git a/src/google/protobuf/wrappers.pb.h b/src/google/protobuf/wrappers.pb.h
index dcf4edfe..5b1d70a7 100644
--- a/src/google/protobuf/wrappers.pb.h
+++ b/src/google/protobuf/wrappers.pb.h
@@ -7,18 +7,19 @@
#include <limits>
#include <string>
-#include <google/protobuf/stubs/common.h>
-#if GOOGLE_PROTOBUF_VERSION < 3006000
+#include <google/protobuf/port_def.inc>
+#if PROTOBUF_VERSION < 3006001
#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 3006001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 3006001 < 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.
#endif
+#include <google/protobuf/port_undef.inc>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
@@ -32,59 +33,59 @@
#include <google/protobuf/unknown_field_set.h>
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>
-#define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fwrappers_2eproto LIBPROTOBUF_EXPORT
+#define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fwrappers_2eproto PROTOBUF_EXPORT
// Internal implementation detail -- do not use these members.
-struct LIBPROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fwrappers_2eproto {
+struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fwrappers_2eproto {
static const ::google::protobuf::internal::ParseTableField entries[]
- GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold);
+ PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::google::protobuf::internal::AuxillaryParseTableField aux[]
- GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold);
+ PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::google::protobuf::internal::ParseTable schema[9]
- GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold);
+ PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::google::protobuf::internal::FieldMetadata field_metadata[];
static const ::google::protobuf::internal::SerializationTable serialization_table[];
static const ::google::protobuf::uint32 offsets[];
};
-void LIBPROTOBUF_EXPORT AddDescriptors_google_2fprotobuf_2fwrappers_2eproto();
+void PROTOBUF_EXPORT AddDescriptors_google_2fprotobuf_2fwrappers_2eproto();
namespace google {
namespace protobuf {
class BoolValue;
class BoolValueDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern BoolValueDefaultTypeInternal _BoolValue_default_instance_;
+PROTOBUF_EXPORT extern BoolValueDefaultTypeInternal _BoolValue_default_instance_;
class BytesValue;
class BytesValueDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern BytesValueDefaultTypeInternal _BytesValue_default_instance_;
+PROTOBUF_EXPORT extern BytesValueDefaultTypeInternal _BytesValue_default_instance_;
class DoubleValue;
class DoubleValueDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern DoubleValueDefaultTypeInternal _DoubleValue_default_instance_;
+PROTOBUF_EXPORT extern DoubleValueDefaultTypeInternal _DoubleValue_default_instance_;
class FloatValue;
class FloatValueDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern FloatValueDefaultTypeInternal _FloatValue_default_instance_;
+PROTOBUF_EXPORT extern FloatValueDefaultTypeInternal _FloatValue_default_instance_;
class Int32Value;
class Int32ValueDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern Int32ValueDefaultTypeInternal _Int32Value_default_instance_;
+PROTOBUF_EXPORT extern Int32ValueDefaultTypeInternal _Int32Value_default_instance_;
class Int64Value;
class Int64ValueDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern Int64ValueDefaultTypeInternal _Int64Value_default_instance_;
+PROTOBUF_EXPORT extern Int64ValueDefaultTypeInternal _Int64Value_default_instance_;
class StringValue;
class StringValueDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern StringValueDefaultTypeInternal _StringValue_default_instance_;
+PROTOBUF_EXPORT extern StringValueDefaultTypeInternal _StringValue_default_instance_;
class UInt32Value;
class UInt32ValueDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern UInt32ValueDefaultTypeInternal _UInt32Value_default_instance_;
+PROTOBUF_EXPORT extern UInt32ValueDefaultTypeInternal _UInt32Value_default_instance_;
class UInt64Value;
class UInt64ValueDefaultTypeInternal;
-LIBPROTOBUF_EXPORT extern UInt64ValueDefaultTypeInternal _UInt64Value_default_instance_;
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::BoolValue* Arena::CreateMaybeMessage<::google::protobuf::BoolValue>(Arena*);
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::BytesValue* Arena::CreateMaybeMessage<::google::protobuf::BytesValue>(Arena*);
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::DoubleValue* Arena::CreateMaybeMessage<::google::protobuf::DoubleValue>(Arena*);
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::FloatValue* Arena::CreateMaybeMessage<::google::protobuf::FloatValue>(Arena*);
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::Int32Value* Arena::CreateMaybeMessage<::google::protobuf::Int32Value>(Arena*);
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::Int64Value* Arena::CreateMaybeMessage<::google::protobuf::Int64Value>(Arena*);
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::StringValue* Arena::CreateMaybeMessage<::google::protobuf::StringValue>(Arena*);
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::UInt32Value* Arena::CreateMaybeMessage<::google::protobuf::UInt32Value>(Arena*);
-template<> LIBPROTOBUF_EXPORT ::google::protobuf::UInt64Value* Arena::CreateMaybeMessage<::google::protobuf::UInt64Value>(Arena*);
+PROTOBUF_EXPORT extern UInt64ValueDefaultTypeInternal _UInt64Value_default_instance_;
+template<> PROTOBUF_EXPORT ::google::protobuf::BoolValue* Arena::CreateMaybeMessage<::google::protobuf::BoolValue>(Arena*);
+template<> PROTOBUF_EXPORT ::google::protobuf::BytesValue* Arena::CreateMaybeMessage<::google::protobuf::BytesValue>(Arena*);
+template<> PROTOBUF_EXPORT ::google::protobuf::DoubleValue* Arena::CreateMaybeMessage<::google::protobuf::DoubleValue>(Arena*);
+template<> PROTOBUF_EXPORT ::google::protobuf::FloatValue* Arena::CreateMaybeMessage<::google::protobuf::FloatValue>(Arena*);
+template<> PROTOBUF_EXPORT ::google::protobuf::Int32Value* Arena::CreateMaybeMessage<::google::protobuf::Int32Value>(Arena*);
+template<> PROTOBUF_EXPORT ::google::protobuf::Int64Value* Arena::CreateMaybeMessage<::google::protobuf::Int64Value>(Arena*);
+template<> PROTOBUF_EXPORT ::google::protobuf::StringValue* Arena::CreateMaybeMessage<::google::protobuf::StringValue>(Arena*);
+template<> PROTOBUF_EXPORT ::google::protobuf::UInt32Value* Arena::CreateMaybeMessage<::google::protobuf::UInt32Value>(Arena*);
+template<> PROTOBUF_EXPORT ::google::protobuf::UInt64Value* Arena::CreateMaybeMessage<::google::protobuf::UInt64Value>(Arena*);
} // namespace protobuf
} // namespace google
namespace google {
@@ -92,7 +93,7 @@ namespace protobuf {
// ===================================================================
-class LIBPROTOBUF_EXPORT DoubleValue : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.DoubleValue) */ {
+class PROTOBUF_EXPORT DoubleValue : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.DoubleValue) */ {
public:
DoubleValue();
virtual ~DoubleValue();
@@ -218,7 +219,7 @@ class LIBPROTOBUF_EXPORT DoubleValue : public ::google::protobuf::Message /* @@p
};
// -------------------------------------------------------------------
-class LIBPROTOBUF_EXPORT FloatValue : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FloatValue) */ {
+class PROTOBUF_EXPORT FloatValue : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FloatValue) */ {
public:
FloatValue();
virtual ~FloatValue();
@@ -344,7 +345,7 @@ class LIBPROTOBUF_EXPORT FloatValue : public ::google::protobuf::Message /* @@pr
};
// -------------------------------------------------------------------
-class LIBPROTOBUF_EXPORT Int64Value : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Int64Value) */ {
+class PROTOBUF_EXPORT Int64Value : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Int64Value) */ {
public:
Int64Value();
virtual ~Int64Value();
@@ -470,7 +471,7 @@ class LIBPROTOBUF_EXPORT Int64Value : public ::google::protobuf::Message /* @@pr
};
// -------------------------------------------------------------------
-class LIBPROTOBUF_EXPORT UInt64Value : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.UInt64Value) */ {
+class PROTOBUF_EXPORT UInt64Value : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.UInt64Value) */ {
public:
UInt64Value();
virtual ~UInt64Value();
@@ -596,7 +597,7 @@ class LIBPROTOBUF_EXPORT UInt64Value : public ::google::protobuf::Message /* @@p
};
// -------------------------------------------------------------------
-class LIBPROTOBUF_EXPORT Int32Value : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Int32Value) */ {
+class PROTOBUF_EXPORT Int32Value : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Int32Value) */ {
public:
Int32Value();
virtual ~Int32Value();
@@ -722,7 +723,7 @@ class LIBPROTOBUF_EXPORT Int32Value : public ::google::protobuf::Message /* @@pr
};
// -------------------------------------------------------------------
-class LIBPROTOBUF_EXPORT UInt32Value : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.UInt32Value) */ {
+class PROTOBUF_EXPORT UInt32Value : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.UInt32Value) */ {
public:
UInt32Value();
virtual ~UInt32Value();
@@ -848,7 +849,7 @@ class LIBPROTOBUF_EXPORT UInt32Value : public ::google::protobuf::Message /* @@p
};
// -------------------------------------------------------------------
-class LIBPROTOBUF_EXPORT BoolValue : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.BoolValue) */ {
+class PROTOBUF_EXPORT BoolValue : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.BoolValue) */ {
public:
BoolValue();
virtual ~BoolValue();
@@ -974,7 +975,7 @@ class LIBPROTOBUF_EXPORT BoolValue : public ::google::protobuf::Message /* @@pro
};
// -------------------------------------------------------------------
-class LIBPROTOBUF_EXPORT StringValue : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.StringValue) */ {
+class PROTOBUF_EXPORT StringValue : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.StringValue) */ {
public:
StringValue();
virtual ~StringValue();
@@ -1117,7 +1118,7 @@ class LIBPROTOBUF_EXPORT StringValue : public ::google::protobuf::Message /* @@p
};
// -------------------------------------------------------------------
-class LIBPROTOBUF_EXPORT BytesValue : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.BytesValue) */ {
+class PROTOBUF_EXPORT BytesValue : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.BytesValue) */ {
public:
BytesValue();
virtual ~BytesValue();
@@ -1307,7 +1308,7 @@ inline void FloatValue::set_value(float value) {
// int64 value = 1;
inline void Int64Value::clear_value() {
- value_ = GOOGLE_PROTOBUF_LONGLONG(0);
+ value_ = PROTOBUF_LONGLONG(0);
}
inline ::google::protobuf::int64 Int64Value::value() const {
// @@protoc_insertion_point(field_get:google.protobuf.Int64Value.value)
@@ -1325,7 +1326,7 @@ inline void Int64Value::set_value(::google::protobuf::int64 value) {
// uint64 value = 1;
inline void UInt64Value::clear_value() {
- value_ = GOOGLE_PROTOBUF_ULONGLONG(0);
+ value_ = PROTOBUF_ULONGLONG(0);
}
inline ::google::protobuf::uint64 UInt64Value::value() const {
// @@protoc_insertion_point(field_get:google.protobuf.UInt64Value.value)
diff --git a/src/google/protobuf/wrappers.proto b/src/google/protobuf/wrappers.proto
index 1940fd19..9ee41e38 100644
--- a/src/google/protobuf/wrappers.proto
+++ b/src/google/protobuf/wrappers.proto
@@ -35,8 +35,8 @@
//
// These wrappers have no meaningful use within repeated fields as they lack
// the ability to detect presence on individual elements.
-// These wrappers have no meaningful use within a map or a oneof since individual
-// entries of a map or fields of a oneof can already detect presence.
+// These wrappers have no meaningful use within a map or a oneof since
+// individual entries of a map or fields of a oneof can already detect presence.
syntax = "proto3";