Use angle bracket for well known type proto header.

This commit is contained in:
Bo Yang 2015-12-04 13:18:44 -08:00
parent dbc91e9797
commit 1f0286a404
19 changed files with 91 additions and 79 deletions

View File

@ -2,7 +2,7 @@
// source: google/protobuf/any.proto
#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
#include "google/protobuf/any.pb.h"
#include <google/protobuf/any.pb.h>
#include <algorithm>
@ -119,10 +119,10 @@ bool Any::UnpackTo(::google::protobuf::Message* message) const {
return _any_metadata_.UnpackTo(message);
}
#ifndef _MSC_VER
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int Any::kTypeUrlFieldNumber;
const int Any::kValueFieldNumber;
#endif // !_MSC_VER
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
Any::Any()
: ::google::protobuf::Message(), _internal_metadata_(NULL), _any_metadata_(&type_url_, &value_) {

View File

@ -27,7 +27,7 @@
#include <google/protobuf/repeated_field.h>
#include <google/protobuf/extension_set.h>
#include <google/protobuf/unknown_field_set.h>
#include "google/protobuf/any.h"
#include <google/protobuf/any.h>
// @@protoc_insertion_point(includes)
namespace google {

View File

@ -2,7 +2,7 @@
// source: google/protobuf/api.proto
#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
#include "google/protobuf/api.pb.h"
#include <google/protobuf/api.pb.h>
#include <algorithm>
@ -186,7 +186,7 @@ static void MergeFromFail(int line) {
// ===================================================================
#ifndef _MSC_VER
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int Api::kNameFieldNumber;
const int Api::kMethodsFieldNumber;
const int Api::kOptionsFieldNumber;
@ -194,7 +194,7 @@ const int Api::kVersionFieldNumber;
const int Api::kSourceContextFieldNumber;
const int Api::kMixinsFieldNumber;
const int Api::kSyntaxFieldNumber;
#endif // !_MSC_VER
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
Api::Api()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
@ -904,7 +904,7 @@ void Api::clear_syntax() {
// ===================================================================
#ifndef _MSC_VER
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int Method::kNameFieldNumber;
const int Method::kRequestTypeUrlFieldNumber;
const int Method::kRequestStreamingFieldNumber;
@ -912,7 +912,7 @@ const int Method::kResponseTypeUrlFieldNumber;
const int Method::kResponseStreamingFieldNumber;
const int Method::kOptionsFieldNumber;
const int Method::kSyntaxFieldNumber;
#endif // !_MSC_VER
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
Method::Method()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
@ -1608,10 +1608,10 @@ void Method::clear_syntax() {
// ===================================================================
#ifndef _MSC_VER
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int Mixin::kNameFieldNumber;
const int Mixin::kRootFieldNumber;
#endif // !_MSC_VER
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
Mixin::Mixin()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {

View File

@ -27,8 +27,8 @@
#include <google/protobuf/repeated_field.h>
#include <google/protobuf/extension_set.h>
#include <google/protobuf/unknown_field_set.h>
#include "google/protobuf/source_context.pb.h"
#include "google/protobuf/type.pb.h"
#include <google/protobuf/source_context.pb.h>
#include <google/protobuf/type.pb.h>
// @@protoc_insertion_point(includes)
namespace google {

View File

@ -237,6 +237,7 @@ void FileGenerator::GeneratePBHeader(io::Printer* printer) {
}
void FileGenerator::GenerateSource(io::Printer* printer) {
bool well_known = IsWellKnownMessage(file_);
string header =
StripProto(file_->name()) + (options_.proto_h ? ".proto.h" : ".pb.h");
printer->Print(
@ -246,7 +247,7 @@ void FileGenerator::GenerateSource(io::Printer* printer) {
// The generated code calls accessors that might be deprecated. We don't
// want the compiler to warn in generated code.
"#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION\n"
"#include \"$header$\"\n"
"#include $left$$header$$right$\n"
"\n"
"#include <algorithm>\n" // for swap()
"\n"
@ -255,7 +256,9 @@ void FileGenerator::GenerateSource(io::Printer* printer) {
"#include <google/protobuf/io/coded_stream.h>\n"
"#include <google/protobuf/wire_format_lite_inl.h>\n",
"filename", file_->name(),
"header", header);
"header", header,
"left", well_known ? "<" : "\"",
"right", well_known ? ">" : "\"");
// Unknown fields implementation in lite mode uses StringOutputStream
if (!UseUnknownFieldSet(file_) && file_->message_type_count() > 0) {
@ -857,14 +860,16 @@ void FileGenerator::GenerateDependencyIncludes(io::Printer* printer) {
}
for (int i = 0; i < file_->dependency_count(); i++) {
bool well_known = IsWellKnownMessage(file_->dependency(i));
const string& name = file_->dependency(i)->name();
bool public_import = (public_import_names.count(name) != 0);
printer->Print(
"#include \"$dependency$.pb.h\"$iwyu$\n",
"#include $left$$dependency$.pb.h$right$$iwyu$\n",
"dependency", StripProto(name),
"iwyu", (public_import) ? " // IWYU pragma: export" : "");
"iwyu", (public_import) ? " // IWYU pragma: export" : "",
"left", well_known ? "<" : "\"",
"right", well_known ? ">" : "\"");
}
}

View File

@ -54,6 +54,7 @@ namespace {
static const char kAnyMessageName[] = "Any";
static const char kAnyProtoFile[] = "google/protobuf/any.proto";
static const char kGoogleProtobufPrefix[] = "google/protobuf/";
string DotsToUnderscores(const string& name) {
return StringReplace(name, ".", "_", true);
@ -600,6 +601,10 @@ bool IsAnyMessage(const Descriptor* descriptor) {
descriptor->file()->name() == kAnyProtoFile;
}
bool IsWellKnownMessage(const FileDescriptor* descriptor) {
return !descriptor->name().compare(0, 16, kGoogleProtobufPrefix);
}
enum Utf8CheckMode {
STRICT = 0, // Parsing will fail if non UTF-8 data is in string fields.
VERIFY = 1, // Only log an error but parsing will succeed.

View File

@ -265,6 +265,8 @@ inline bool SupportsArenas(const FieldDescriptor* field) {
bool IsAnyMessage(const FileDescriptor* descriptor);
bool IsAnyMessage(const Descriptor* descriptor);
bool IsWellKnownMessage(const FileDescriptor* descriptor);
void GenerateUtf8CheckCodeForString(
const FieldDescriptor* field,
bool for_parse,

View File

@ -2,7 +2,7 @@
// source: google/protobuf/compiler/plugin.proto
#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
#include "google/protobuf/compiler/plugin.pb.h"
#include <google/protobuf/compiler/plugin.pb.h>
#include <algorithm>

View File

@ -27,7 +27,7 @@
#include <google/protobuf/repeated_field.h>
#include <google/protobuf/extension_set.h>
#include <google/protobuf/unknown_field_set.h>
#include "google/protobuf/descriptor.pb.h"
#include <google/protobuf/descriptor.pb.h>
// @@protoc_insertion_point(includes)
namespace google {

View File

@ -2,7 +2,7 @@
// source: google/protobuf/descriptor.proto
#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
#include "google/protobuf/descriptor.pb.h"
#include <google/protobuf/descriptor.pb.h>
#include <algorithm>

View File

@ -2,7 +2,7 @@
// source: google/protobuf/duration.proto
#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
#include "google/protobuf/duration.pb.h"
#include <google/protobuf/duration.pb.h>
#include <algorithm>
@ -111,10 +111,10 @@ static void MergeFromFail(int line) {
// ===================================================================
#ifndef _MSC_VER
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int Duration::kSecondsFieldNumber;
const int Duration::kNanosFieldNumber;
#endif // !_MSC_VER
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
Duration::Duration()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {

View File

@ -2,7 +2,7 @@
// source: google/protobuf/empty.proto
#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
#include "google/protobuf/empty.pb.h"
#include <google/protobuf/empty.pb.h>
#include <algorithm>
@ -108,8 +108,8 @@ static void MergeFromFail(int line) {
// ===================================================================
#ifndef _MSC_VER
#endif // !_MSC_VER
#if !defined(_MSC_VER) || _MSC_VER >= 1900
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
Empty::Empty()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {

View File

@ -2,7 +2,7 @@
// source: google/protobuf/field_mask.proto
#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
#include "google/protobuf/field_mask.pb.h"
#include <google/protobuf/field_mask.pb.h>
#include <algorithm>
@ -110,9 +110,9 @@ static void MergeFromFail(int line) {
// ===================================================================
#ifndef _MSC_VER
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int FieldMask::kPathsFieldNumber;
#endif // !_MSC_VER
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
FieldMask::FieldMask()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {

View File

@ -2,7 +2,7 @@
// source: google/protobuf/source_context.proto
#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
#include "google/protobuf/source_context.pb.h"
#include <google/protobuf/source_context.pb.h>
#include <algorithm>
@ -110,9 +110,9 @@ static void MergeFromFail(int line) {
// ===================================================================
#ifndef _MSC_VER
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int SourceContext::kFileNameFieldNumber;
#endif // !_MSC_VER
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
SourceContext::SourceContext()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {

View File

@ -2,7 +2,7 @@
// source: google/protobuf/struct.proto
#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
#include "google/protobuf/struct.pb.h"
#include <google/protobuf/struct.pb.h>
#include <algorithm>
@ -212,9 +212,9 @@ static void MergeFromFail(int line) {
// ===================================================================
#ifndef _MSC_VER
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int Struct::kFieldsFieldNumber;
#endif // !_MSC_VER
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
Struct::Struct()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
@ -480,14 +480,14 @@ Struct::mutable_fields() {
// ===================================================================
#ifndef _MSC_VER
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int Value::kNullValueFieldNumber;
const int Value::kNumberValueFieldNumber;
const int Value::kStringValueFieldNumber;
const int Value::kBoolValueFieldNumber;
const int Value::kStructValueFieldNumber;
const int Value::kListValueFieldNumber;
#endif // !_MSC_VER
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
Value::Value()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
@ -1218,9 +1218,9 @@ Value::KindCase Value::kind_case() const {
// ===================================================================
#ifndef _MSC_VER
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int ListValue::kValuesFieldNumber;
#endif // !_MSC_VER
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
ListValue::ListValue()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {

View File

@ -2,7 +2,7 @@
// source: google/protobuf/timestamp.proto
#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
#include "google/protobuf/timestamp.pb.h"
#include <google/protobuf/timestamp.pb.h>
#include <algorithm>
@ -111,10 +111,10 @@ static void MergeFromFail(int line) {
// ===================================================================
#ifndef _MSC_VER
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int Timestamp::kSecondsFieldNumber;
const int Timestamp::kNanosFieldNumber;
#endif // !_MSC_VER
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
Timestamp::Timestamp()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {

View File

@ -2,7 +2,7 @@
// source: google/protobuf/type.proto
#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
#include "google/protobuf/type.pb.h"
#include <google/protobuf/type.pb.h>
#include <algorithm>
@ -282,14 +282,14 @@ static void MergeFromFail(int line) {
// ===================================================================
#ifndef _MSC_VER
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int Type::kNameFieldNumber;
const int Type::kFieldsFieldNumber;
const int Type::kOneofsFieldNumber;
const int Type::kOptionsFieldNumber;
const int Type::kSourceContextFieldNumber;
const int Type::kSyntaxFieldNumber;
#endif // !_MSC_VER
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
Type::Type()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
@ -967,7 +967,7 @@ bool Field_Kind_IsValid(int value) {
}
}
#ifndef _MSC_VER
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const Field_Kind Field::TYPE_UNKNOWN;
const Field_Kind Field::TYPE_DOUBLE;
const Field_Kind Field::TYPE_FLOAT;
@ -990,7 +990,7 @@ const Field_Kind Field::TYPE_SINT64;
const Field_Kind Field::Kind_MIN;
const Field_Kind Field::Kind_MAX;
const int Field::Kind_ARRAYSIZE;
#endif // _MSC_VER
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
const ::google::protobuf::EnumDescriptor* Field_Cardinality_descriptor() {
protobuf_AssignDescriptorsOnce();
return Field_Cardinality_descriptor_;
@ -1007,7 +1007,7 @@ bool Field_Cardinality_IsValid(int value) {
}
}
#ifndef _MSC_VER
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const Field_Cardinality Field::CARDINALITY_UNKNOWN;
const Field_Cardinality Field::CARDINALITY_OPTIONAL;
const Field_Cardinality Field::CARDINALITY_REQUIRED;
@ -1015,8 +1015,8 @@ const Field_Cardinality Field::CARDINALITY_REPEATED;
const Field_Cardinality Field::Cardinality_MIN;
const Field_Cardinality Field::Cardinality_MAX;
const int Field::Cardinality_ARRAYSIZE;
#endif // _MSC_VER
#ifndef _MSC_VER
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int Field::kKindFieldNumber;
const int Field::kCardinalityFieldNumber;
const int Field::kNumberFieldNumber;
@ -1026,7 +1026,7 @@ const int Field::kOneofIndexFieldNumber;
const int Field::kPackedFieldNumber;
const int Field::kOptionsFieldNumber;
const int Field::kJsonNameFieldNumber;
#endif // !_MSC_VER
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
Field::Field()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
@ -1830,13 +1830,13 @@ void Field::clear_json_name() {
// ===================================================================
#ifndef _MSC_VER
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int Enum::kNameFieldNumber;
const int Enum::kEnumvalueFieldNumber;
const int Enum::kOptionsFieldNumber;
const int Enum::kSourceContextFieldNumber;
const int Enum::kSyntaxFieldNumber;
#endif // !_MSC_VER
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
Enum::Enum()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
@ -2379,11 +2379,11 @@ void Enum::clear_syntax() {
// ===================================================================
#ifndef _MSC_VER
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int EnumValue::kNameFieldNumber;
const int EnumValue::kNumberFieldNumber;
const int EnumValue::kOptionsFieldNumber;
#endif // !_MSC_VER
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
EnumValue::EnumValue()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
@ -2775,10 +2775,10 @@ EnumValue::options() const {
// ===================================================================
#ifndef _MSC_VER
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int Option::kNameFieldNumber;
const int Option::kValueFieldNumber;
#endif // !_MSC_VER
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
Option::Option()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {

View File

@ -28,8 +28,8 @@
#include <google/protobuf/extension_set.h>
#include <google/protobuf/generated_enum_reflection.h>
#include <google/protobuf/unknown_field_set.h>
#include "google/protobuf/any.pb.h"
#include "google/protobuf/source_context.pb.h"
#include <google/protobuf/any.pb.h>
#include <google/protobuf/source_context.pb.h>
// @@protoc_insertion_point(includes)
namespace google {

View File

@ -2,7 +2,7 @@
// source: google/protobuf/wrappers.proto
#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
#include "google/protobuf/wrappers.pb.h"
#include <google/protobuf/wrappers.pb.h>
#include <algorithm>
@ -308,9 +308,9 @@ static void MergeFromFail(int line) {
// ===================================================================
#ifndef _MSC_VER
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int DoubleValue::kValueFieldNumber;
#endif // !_MSC_VER
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
DoubleValue::DoubleValue()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
@ -532,9 +532,9 @@ void DoubleValue::clear_value() {
// ===================================================================
#ifndef _MSC_VER
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int FloatValue::kValueFieldNumber;
#endif // !_MSC_VER
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
FloatValue::FloatValue()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
@ -756,9 +756,9 @@ void FloatValue::clear_value() {
// ===================================================================
#ifndef _MSC_VER
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int Int64Value::kValueFieldNumber;
#endif // !_MSC_VER
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
Int64Value::Int64Value()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
@ -982,9 +982,9 @@ void Int64Value::clear_value() {
// ===================================================================
#ifndef _MSC_VER
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int UInt64Value::kValueFieldNumber;
#endif // !_MSC_VER
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
UInt64Value::UInt64Value()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
@ -1208,9 +1208,9 @@ void UInt64Value::clear_value() {
// ===================================================================
#ifndef _MSC_VER
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int Int32Value::kValueFieldNumber;
#endif // !_MSC_VER
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
Int32Value::Int32Value()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
@ -1434,9 +1434,9 @@ void Int32Value::clear_value() {
// ===================================================================
#ifndef _MSC_VER
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int UInt32Value::kValueFieldNumber;
#endif // !_MSC_VER
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
UInt32Value::UInt32Value()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
@ -1660,9 +1660,9 @@ void UInt32Value::clear_value() {
// ===================================================================
#ifndef _MSC_VER
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int BoolValue::kValueFieldNumber;
#endif // !_MSC_VER
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
BoolValue::BoolValue()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
@ -1884,9 +1884,9 @@ void BoolValue::clear_value() {
// ===================================================================
#ifndef _MSC_VER
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int StringValue::kValueFieldNumber;
#endif // !_MSC_VER
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
StringValue::StringValue()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
@ -2155,9 +2155,9 @@ void StringValue::clear_value() {
// ===================================================================
#ifndef _MSC_VER
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int BytesValue::kValueFieldNumber;
#endif // !_MSC_VER
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
BytesValue::BytesValue()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {