diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/google/protobuf/compiler/cpp/cpp_file.cc | 34 | ||||
-rw-r--r-- | src/google/protobuf/compiler/cpp/cpp_file.h | 2 | ||||
-rw-r--r-- | src/google/protobuf/descriptor.pb.h | 3 | ||||
-rw-r--r-- | src/google/protobuf/stubs/common.h | 2 |
4 files changed, 11 insertions, 30 deletions
diff --git a/src/google/protobuf/compiler/cpp/cpp_file.cc b/src/google/protobuf/compiler/cpp/cpp_file.cc index 70b434dd..6487979f 100644 --- a/src/google/protobuf/compiler/cpp/cpp_file.cc +++ b/src/google/protobuf/compiler/cpp/cpp_file.cc @@ -59,7 +59,8 @@ FileGenerator::FileGenerator(const FileDescriptor* file, service_generators_( new scoped_ptr<ServiceGenerator>[file->service_count()]), extension_generators_( - new scoped_ptr<ExtensionGenerator>[file->extension_count()]) { + new scoped_ptr<ExtensionGenerator>[file->extension_count()]), + dllexport_decl_(dllexport_decl) { for (int i = 0; i < file->message_type_count(); i++) { message_generators_[i].reset( @@ -146,11 +147,13 @@ void FileGenerator::GenerateHeader(io::Printer* printer) { // declare it to be a friend of each class. printer->Print( "\n" - "// Internal implementation detail -- do not call this.\n" + "// Internal implementation detail -- do not call these.\n" + "void $dllexport_decl$ $builddescriptorsname$();\n" "void $builddescriptorsname$_AssignGlobalDescriptors(\n" " ::google::protobuf::FileDescriptor* file);\n" "\n", - "builddescriptorsname", GlobalBuildDescriptorsName(file_->name())); + "builddescriptorsname", GlobalBuildDescriptorsName(file_->name()), + "dllexport_decl", dllexport_decl_); // Generate forward declarations of classes. for (int i = 0; i < file_->message_type_count(); i++) { @@ -235,31 +238,6 @@ void FileGenerator::GenerateSource(io::Printer* printer) { "#include <google/protobuf/wire_format_inl.h>\n", "basename", StripProto(file_->name())); - // For each dependency, write a prototype for that dependency's - // BuildDescriptors() function. We don't expose these in the header because - // they are internal implementation details, and since this is generated code - // we don't have the usual risks involved with declaring external functions - // within a .cc file. - for (int i = 0; i < file_->dependency_count(); i++) { - const FileDescriptor* dependency = file_->dependency(i); - // Open the dependency's namespace. - vector<string> dependency_package_parts; - SplitStringUsing(dependency->package(), ".", &dependency_package_parts); - for (int i = 0; i < dependency_package_parts.size(); i++) { - printer->Print("namespace $name$ { ", - "name", dependency_package_parts[i]); - } - // Declare its BuildDescriptors() function. - printer->Print( - "void $function$();", - "function", GlobalBuildDescriptorsName(dependency->name())); - // Close the namespace. - for (int i = 0; i < dependency_package_parts.size(); i++) { - printer->Print(" }"); - } - printer->Print("\n"); - } - GenerateNamespaceOpeners(printer); printer->Print( diff --git a/src/google/protobuf/compiler/cpp/cpp_file.h b/src/google/protobuf/compiler/cpp/cpp_file.h index fc3d98cf..b4e01285 100644 --- a/src/google/protobuf/compiler/cpp/cpp_file.h +++ b/src/google/protobuf/compiler/cpp/cpp_file.h @@ -85,6 +85,8 @@ class FileGenerator { // E.g. if the package is foo.bar, package_parts_ is {"foo", "bar"}. vector<string> package_parts_; + string dllexport_decl_; + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileGenerator); }; diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h index 420f178d..4bc315e2 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h @@ -25,7 +25,8 @@ namespace google { namespace protobuf { -// Internal implementation detail -- do not call this. +// Internal implementation detail -- do not call these. +void LIBPROTOBUF_EXPORT protobuf_BuildDesc_google_2fprotobuf_2fdescriptor_2eproto(); void protobuf_BuildDesc_google_2fprotobuf_2fdescriptor_2eproto_AssignGlobalDescriptors( ::google::protobuf::FileDescriptor* file); diff --git a/src/google/protobuf/stubs/common.h b/src/google/protobuf/stubs/common.h index 3744a585..9309b6be 100644 --- a/src/google/protobuf/stubs/common.h +++ b/src/google/protobuf/stubs/common.h @@ -56,7 +56,7 @@ using namespace std; // Don't do this at home, kids. TypeName(const TypeName&); \ void operator=(const TypeName&) -#ifdef _MSC_VER +#if defined(_MSC_VER) && defined(PROTOBUF_USE_DLLS) #ifdef LIBPROTOBUF_EXPORTS #define LIBPROTOBUF_EXPORT __declspec(dllexport) #else |