aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/compiler
diff options
context:
space:
mode:
authorGravatar Feng Xiao <xfxyjwf@gmail.com>2016-09-22 17:46:22 -0700
committerGravatar Bo Yang <teboring@google.com>2016-10-10 11:44:21 -0700
commit460e7dd7c47b5a3fc290008317c044fac741916a (patch)
tree07ba6084281627598eff9afeeafe4a381bd90569 /src/google/protobuf/compiler
parent4cf072248fc39d1c63dcb1600ff9e73df8757779 (diff)
Fix Visual Studio compile issues.
Change-Id: I6a5078b6bcdf4637e11c1cb9da1f74298e6fc26e
Diffstat (limited to 'src/google/protobuf/compiler')
-rw-r--r--src/google/protobuf/compiler/command_line_interface.cc6
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_message.cc37
-rw-r--r--src/google/protobuf/compiler/plugin.pb.cc33
-rw-r--r--src/google/protobuf/compiler/plugin.pb.h30
4 files changed, 67 insertions, 39 deletions
diff --git a/src/google/protobuf/compiler/command_line_interface.cc b/src/google/protobuf/compiler/command_line_interface.cc
index 0d1c30ce..79d2dd66 100644
--- a/src/google/protobuf/compiler/command_line_interface.cc
+++ b/src/google/protobuf/compiler/command_line_interface.cc
@@ -1179,14 +1179,12 @@ CommandLineInterface::InterpretArgument(const string& name,
if (direct_dependencies_explicitly_set_) {
std::cerr << name << " may only be passed once. To specify multiple "
"direct dependencies, pass them all as a single "
- "parameter separated by '"
- << kPathSeparator << "'." << std::endl;
+ "parameter separated by ':'." << std::endl;
return PARSE_ARGUMENT_FAIL;
}
direct_dependencies_explicitly_set_ = true;
- vector<string> direct = Split(
- value, kPathSeparator, true);
+ vector<string> direct = Split(value, ":", true);
GOOGLE_DCHECK(direct_dependencies_.empty());
direct_dependencies_.insert(direct.begin(), direct.end());
diff --git a/src/google/protobuf/compiler/cpp/cpp_message.cc b/src/google/protobuf/compiler/cpp/cpp_message.cc
index f3dd8067..efc56ddc 100644
--- a/src/google/protobuf/compiler/cpp/cpp_message.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_message.cc
@@ -1101,9 +1101,7 @@ GenerateClassDefinition(io::Printer* printer) {
// TODO(gerbens) make this private, while still granting other protos access.
printer->Print(
vars,
- "static inline const $classname$* internal_default_instance() {\n"
- " return &default_instance_.get();\n"
- "}\n"
+ "static const $classname$* internal_default_instance();\n"
"\n");
@@ -1501,12 +1499,22 @@ GenerateClassDefinition(io::Printer* printer) {
"shutdownfilename", GlobalShutdownFileName(descriptor_->file()->name()));
printer->Print(
- "void InitAsDefaultInstance();\n"
- "static ::google::protobuf::internal::ExplicitlyConstructed<$classname$> default_instance_;\n",
+ "void InitAsDefaultInstance();\n",
"classname", classname_);
printer->Outdent();
- printer->Print("};");
+ printer->Print("};\n");
+
+ // This should ideally be put into the class scope, but Visual Studio just
+ // refuses to compile it and complains about "use of undefined XXX":
+ // https://ci.appveyor.com/project/protobuf/protobuf/build/1.0.2673/job/nrdf4tb9dau0sck5
+ // A program as simple as "struct X { enum { value = sizeof(X) }; };" will
+ // trigger the same error.
+ printer->Print(
+ "extern ::google::protobuf::internal::ExplicitlyConstructed<$classname$> "
+ "$classname$_default_instance_;\n",
+ "classname", classname_);
+
GOOGLE_DCHECK(!need_to_emit_cached_size);
}
@@ -1557,6 +1565,12 @@ GenerateInlineMethods(io::Printer* printer, bool is_inline) {
"_oneof_case_[$oneof_index$]);\n"
"}\n");
}
+
+ printer->Print(
+ "inline const $classname$* $classname$::internal_default_instance() {\n"
+ " return &$classname$_default_instance_.get();\n"
+ "}\n",
+ "classname", classname_);
}
void MessageGenerator::
@@ -1774,7 +1788,7 @@ GenerateDefaultInstanceAllocator(io::Printer* printer) {
// Construct the default instance. We can't call InitAsDefaultInstance() yet
// because we need to make sure all default instances that this one might
// depend on are constructed first.
- printer->Print("$classname$::default_instance_.DefaultConstruct();\n",
+ printer->Print("$classname$_default_instance_.DefaultConstruct();\n",
"classname", classname_);
if ((descriptor_->oneof_decl_count() > 0) &&
@@ -1794,7 +1808,7 @@ GenerateDefaultInstanceAllocator(io::Printer* printer) {
void MessageGenerator::
GenerateDefaultInstanceInitializer(io::Printer* printer) {
printer->Print(
- "$classname$::default_instance_.get_mutable()->InitAsDefaultInstance();"
+ "$classname$_default_instance_.get_mutable()->InitAsDefaultInstance();"
"\n",
"classname", classname_);
@@ -1816,7 +1830,7 @@ GenerateDefaultInstanceInitializer(io::Printer* printer) {
void MessageGenerator::
GenerateShutdownCode(io::Printer* printer) {
printer->Print(
- "$classname$::default_instance_.Shutdown();\n",
+ "$classname$_default_instance_.Shutdown();\n",
"classname", classname_);
if (HasDescriptorMethods(descriptor_->file(), options_)) {
if (descriptor_->oneof_decl_count() > 0) {
@@ -2165,7 +2179,8 @@ GenerateSharedDestructorCode(io::Printer* printer) {
if (!need_delete_message_field) {
need_delete_message_field = true;
printer->Print(
- "if (this != &default_instance_.get()) {\n");
+ "if (this != &$classname$_default_instance_.get()) {\n",
+ "classname", classname_);
printer->Indent();
}
printer->Print("delete $name$_;\n", "name", FieldName(field));
@@ -2422,7 +2437,7 @@ GenerateStructors(io::Printer* printer) {
printer->Print(
"\n"
"::google::protobuf::internal::ExplicitlyConstructed<$classname$> "
- "$classname$::default_instance_;\n"
+ "$classname$_default_instance_;\n"
"\n",
"classname", classname_);
diff --git a/src/google/protobuf/compiler/plugin.pb.cc b/src/google/protobuf/compiler/plugin.pb.cc
index 4fc7c432..a4d4a530 100644
--- a/src/google/protobuf/compiler/plugin.pb.cc
+++ b/src/google/protobuf/compiler/plugin.pb.cc
@@ -114,11 +114,11 @@ void protobuf_RegisterTypes(const ::std::string&) {
} // namespace
void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto() {
- CodeGeneratorRequest::default_instance_.Shutdown();
+ CodeGeneratorRequest_default_instance_.Shutdown();
delete CodeGeneratorRequest_reflection_;
- CodeGeneratorResponse::default_instance_.Shutdown();
+ CodeGeneratorResponse_default_instance_.Shutdown();
delete CodeGeneratorResponse_reflection_;
- CodeGeneratorResponse_File::default_instance_.Shutdown();
+ CodeGeneratorResponse_File_default_instance_.Shutdown();
delete CodeGeneratorResponse_File_reflection_;
}
@@ -127,14 +127,14 @@ void protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl()
::google::protobuf::protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
::google::protobuf::internal::GetEmptyString();
- CodeGeneratorRequest::default_instance_.DefaultConstruct();
+ CodeGeneratorRequest_default_instance_.DefaultConstruct();
::google::protobuf::internal::GetEmptyString();
- CodeGeneratorResponse::default_instance_.DefaultConstruct();
+ CodeGeneratorResponse_default_instance_.DefaultConstruct();
::google::protobuf::internal::GetEmptyString();
- CodeGeneratorResponse_File::default_instance_.DefaultConstruct();
- CodeGeneratorRequest::default_instance_.get_mutable()->InitAsDefaultInstance();
- CodeGeneratorResponse::default_instance_.get_mutable()->InitAsDefaultInstance();
- CodeGeneratorResponse_File::default_instance_.get_mutable()->InitAsDefaultInstance();
+ CodeGeneratorResponse_File_default_instance_.DefaultConstruct();
+ CodeGeneratorRequest_default_instance_.get_mutable()->InitAsDefaultInstance();
+ CodeGeneratorResponse_default_instance_.get_mutable()->InitAsDefaultInstance();
+ CodeGeneratorResponse_File_default_instance_.get_mutable()->InitAsDefaultInstance();
}
GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once_);
@@ -242,7 +242,7 @@ const CodeGeneratorRequest& CodeGeneratorRequest::default_instance() {
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorRequest> CodeGeneratorRequest::default_instance_;
+::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorRequest> CodeGeneratorRequest_default_instance_;
CodeGeneratorRequest* CodeGeneratorRequest::New(::google::protobuf::Arena* arena) const {
CodeGeneratorRequest* n = new CodeGeneratorRequest;
@@ -691,6 +691,9 @@ CodeGeneratorRequest::proto_file() const {
return proto_file_;
}
+inline const CodeGeneratorRequest* CodeGeneratorRequest::internal_default_instance() {
+ return &CodeGeneratorRequest_default_instance_.get();
+}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
@@ -752,7 +755,7 @@ const CodeGeneratorResponse_File& CodeGeneratorResponse_File::default_instance()
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorResponse_File> CodeGeneratorResponse_File::default_instance_;
+::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorResponse_File> CodeGeneratorResponse_File_default_instance_;
CodeGeneratorResponse_File* CodeGeneratorResponse_File::New(::google::protobuf::Arena* arena) const {
CodeGeneratorResponse_File* n = new CodeGeneratorResponse_File;
@@ -1128,7 +1131,7 @@ const CodeGeneratorResponse& CodeGeneratorResponse::default_instance() {
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorResponse> CodeGeneratorResponse::default_instance_;
+::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorResponse> CodeGeneratorResponse_default_instance_;
CodeGeneratorResponse* CodeGeneratorResponse::New(::google::protobuf::Arena* arena) const {
CodeGeneratorResponse* n = new CodeGeneratorResponse;
@@ -1548,6 +1551,9 @@ void CodeGeneratorResponse_File::set_allocated_content(::std::string* content) {
// @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.content)
}
+inline const CodeGeneratorResponse_File* CodeGeneratorResponse_File::internal_default_instance() {
+ return &CodeGeneratorResponse_File_default_instance_.get();
+}
// -------------------------------------------------------------------
// CodeGeneratorResponse
@@ -1636,6 +1642,9 @@ CodeGeneratorResponse::file() const {
return file_;
}
+inline const CodeGeneratorResponse* CodeGeneratorResponse::internal_default_instance() {
+ return &CodeGeneratorResponse_default_instance_.get();
+}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// @@protoc_insertion_point(namespace_scope)
diff --git a/src/google/protobuf/compiler/plugin.pb.h b/src/google/protobuf/compiler/plugin.pb.h
index 85b3d60c..f9a99e75 100644
--- a/src/google/protobuf/compiler/plugin.pb.h
+++ b/src/google/protobuf/compiler/plugin.pb.h
@@ -69,9 +69,7 @@ class LIBPROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message
static const ::google::protobuf::Descriptor* descriptor();
static const CodeGeneratorRequest& default_instance();
- static inline const CodeGeneratorRequest* internal_default_instance() {
- return &default_instance_.get();
- }
+ static const CodeGeneratorRequest* internal_default_instance();
void Swap(CodeGeneratorRequest* other);
@@ -176,8 +174,9 @@ class LIBPROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message
friend void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto();
void InitAsDefaultInstance();
- static ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorRequest> default_instance_;
};
+extern ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorRequest> CodeGeneratorRequest_default_instance_;
+
// -------------------------------------------------------------------
class LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.CodeGeneratorResponse.File) */ {
@@ -203,9 +202,7 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::M
static const ::google::protobuf::Descriptor* descriptor();
static const CodeGeneratorResponse_File& default_instance();
- static inline const CodeGeneratorResponse_File* internal_default_instance() {
- return &default_instance_.get();
- }
+ static const CodeGeneratorResponse_File* internal_default_instance();
void Swap(CodeGeneratorResponse_File* other);
@@ -310,8 +307,9 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::M
friend void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto();
void InitAsDefaultInstance();
- static ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorResponse_File> default_instance_;
};
+extern ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorResponse_File> CodeGeneratorResponse_File_default_instance_;
+
// -------------------------------------------------------------------
class LIBPROTOC_EXPORT CodeGeneratorResponse : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.CodeGeneratorResponse) */ {
@@ -337,9 +335,7 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse : public ::google::protobuf::Messag
static const ::google::protobuf::Descriptor* descriptor();
static const CodeGeneratorResponse& default_instance();
- static inline const CodeGeneratorResponse* internal_default_instance() {
- return &default_instance_.get();
- }
+ static const CodeGeneratorResponse* internal_default_instance();
void Swap(CodeGeneratorResponse* other);
@@ -429,8 +425,9 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse : public ::google::protobuf::Messag
friend void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto();
void InitAsDefaultInstance();
- static ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorResponse> default_instance_;
};
+extern ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorResponse> CodeGeneratorResponse_default_instance_;
+
// ===================================================================
@@ -578,6 +575,9 @@ CodeGeneratorRequest::proto_file() const {
return proto_file_;
}
+inline const CodeGeneratorRequest* CodeGeneratorRequest::internal_default_instance() {
+ return &CodeGeneratorRequest_default_instance_.get();
+}
// -------------------------------------------------------------------
// CodeGeneratorResponse_File
@@ -744,6 +744,9 @@ inline void CodeGeneratorResponse_File::set_allocated_content(::std::string* con
// @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.content)
}
+inline const CodeGeneratorResponse_File* CodeGeneratorResponse_File::internal_default_instance() {
+ return &CodeGeneratorResponse_File_default_instance_.get();
+}
// -------------------------------------------------------------------
// CodeGeneratorResponse
@@ -832,6 +835,9 @@ CodeGeneratorResponse::file() const {
return file_;
}
+inline const CodeGeneratorResponse* CodeGeneratorResponse::internal_default_instance() {
+ return &CodeGeneratorResponse_default_instance_.get();
+}
#endif // !PROTOBUF_INLINE_NOT_IN_HEADERS
// -------------------------------------------------------------------