|
@@ -209,15 +209,15 @@ FileGenerator::FileGenerator(const FileDescriptor *file, const Options& options)
|
|
|
FileGenerator::~FileGenerator() {}
|
|
|
|
|
|
void FileGenerator::GenerateHeader(io::Printer *printer) {
|
|
|
- std::set<string> headers;
|
|
|
+ std::vector<string> headers;
|
|
|
// Generated files bundled with the library get minimal imports, everything
|
|
|
// else gets the wrapper so everything is usable.
|
|
|
if (is_bundled_proto_) {
|
|
|
- headers.insert("GPBRootObject.h");
|
|
|
- headers.insert("GPBMessage.h");
|
|
|
- headers.insert("GPBDescriptor.h");
|
|
|
+ headers.push_back("GPBDescriptor.h");
|
|
|
+ headers.push_back("GPBMessage.h");
|
|
|
+ headers.push_back("GPBRootObject.h");
|
|
|
} else {
|
|
|
- headers.insert("GPBProtocolBuffers.h");
|
|
|
+ headers.push_back("GPBProtocolBuffers.h");
|
|
|
}
|
|
|
PrintFileRuntimePreamble(printer, headers);
|
|
|
|
|
@@ -337,8 +337,8 @@ void FileGenerator::GenerateHeader(io::Printer *printer) {
|
|
|
|
|
|
void FileGenerator::GenerateSource(io::Printer *printer) {
|
|
|
// #import the runtime support.
|
|
|
- std::set<string> headers;
|
|
|
- headers.insert("GPBProtocolBuffers_RuntimeSupport.h");
|
|
|
+ std::vector<string> headers;
|
|
|
+ headers.push_back("GPBProtocolBuffers_RuntimeSupport.h");
|
|
|
PrintFileRuntimePreamble(printer, headers);
|
|
|
|
|
|
// Enums use atomic in the generated code, so add the system import as needed.
|
|
@@ -590,48 +590,14 @@ void FileGenerator::GenerateSource(io::Printer *printer) {
|
|
|
// files. This currently only supports the runtime coming from a framework
|
|
|
// as defined by the official CocoaPod.
|
|
|
void FileGenerator::PrintFileRuntimePreamble(
|
|
|
- io::Printer* printer, const std::set<string>& headers_to_import) const {
|
|
|
+ io::Printer* printer, const std::vector<string>& headers_to_import) const {
|
|
|
printer->Print(
|
|
|
"// Generated by the protocol buffer compiler. DO NOT EDIT!\n"
|
|
|
"// source: $filename$\n"
|
|
|
"\n",
|
|
|
"filename", file_->name());
|
|
|
-
|
|
|
- const string framework_name(ProtobufLibraryFrameworkName);
|
|
|
- const string cpp_symbol(ProtobufFrameworkImportSymbol(framework_name));
|
|
|
-
|
|
|
- printer->Print(
|
|
|
- "// This CPP symbol can be defined to use imports that match up to the framework\n"
|
|
|
- "// imports needed when using CocoaPods.\n"
|
|
|
- "#if !defined($cpp_symbol$)\n"
|
|
|
- " #define $cpp_symbol$ 0\n"
|
|
|
- "#endif\n"
|
|
|
- "\n"
|
|
|
- "#if $cpp_symbol$\n",
|
|
|
- "cpp_symbol", cpp_symbol);
|
|
|
-
|
|
|
-
|
|
|
- for (std::set<string>::const_iterator iter = headers_to_import.begin();
|
|
|
- iter != headers_to_import.end(); ++iter) {
|
|
|
- printer->Print(
|
|
|
- " #import <$framework_name$/$header$>\n",
|
|
|
- "header", *iter,
|
|
|
- "framework_name", framework_name);
|
|
|
- }
|
|
|
-
|
|
|
- printer->Print(
|
|
|
- "#else\n");
|
|
|
-
|
|
|
- for (std::set<string>::const_iterator iter = headers_to_import.begin();
|
|
|
- iter != headers_to_import.end(); ++iter) {
|
|
|
- printer->Print(
|
|
|
- " #import \"$header$\"\n",
|
|
|
- "header", *iter);
|
|
|
- }
|
|
|
-
|
|
|
- printer->Print(
|
|
|
- "#endif\n"
|
|
|
- "\n");
|
|
|
+ ImportWriter::PrintRuntimeImports(printer, headers_to_import, true);
|
|
|
+ printer->Print("\n");
|
|
|
}
|
|
|
|
|
|
} // namespace objectivec
|