| Index: third_party/protobuf/src/google/protobuf/compiler/objectivec/objectivec_generator.cc
|
| diff --git a/third_party/protobuf/src/google/protobuf/compiler/code_generator.cc b/third_party/protobuf/src/google/protobuf/compiler/objectivec/objectivec_generator.cc
|
| similarity index 53%
|
| copy from third_party/protobuf/src/google/protobuf/compiler/code_generator.cc
|
| copy to third_party/protobuf/src/google/protobuf/compiler/objectivec/objectivec_generator.cc
|
| index 455c239a936bd9cec724ab65e85092b743fa1070..4449087a1f16880db8d0695037e0532b0b54e182 100644
|
| --- a/third_party/protobuf/src/google/protobuf/compiler/code_generator.cc
|
| +++ b/third_party/protobuf/src/google/protobuf/compiler/objectivec/objectivec_generator.cc
|
| @@ -1,6 +1,6 @@
|
| // Protocol Buffers - Google's data interchange format
|
| // Copyright 2008 Google Inc. All rights reserved.
|
| -// http://code.google.com/p/protobuf/
|
| +// 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
|
| @@ -28,53 +28,59 @@
|
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
| -// Author: kenton@google.com (Kenton Varda)
|
| -// Based on original Protocol Buffers design by
|
| -// Sanjay Ghemawat, Jeff Dean, and others.
|
| -
|
| -#include <google/protobuf/compiler/code_generator.h>
|
| -
|
| -#include <google/protobuf/stubs/common.h>
|
| +#include <iostream>
|
| +#include <google/protobuf/compiler/objectivec/objectivec_generator.h>
|
| +#include <google/protobuf/compiler/objectivec/objectivec_file.h>
|
| +#include <google/protobuf/compiler/objectivec/objectivec_helpers.h>
|
| +#include <google/protobuf/io/printer.h>
|
| +#include <google/protobuf/io/zero_copy_stream.h>
|
| #include <google/protobuf/stubs/strutil.h>
|
|
|
| namespace google {
|
| namespace protobuf {
|
| namespace compiler {
|
| +namespace objectivec {
|
|
|
| -CodeGenerator::~CodeGenerator() {}
|
| -GeneratorContext::~GeneratorContext() {}
|
| +ObjectiveCGenerator::ObjectiveCGenerator() {}
|
|
|
| -io::ZeroCopyOutputStream* GeneratorContext::OpenForInsert(
|
| - const string& filename, const string& insertion_point) {
|
| - GOOGLE_LOG(FATAL) << "This GeneratorContext does not support insertion.";
|
| - return NULL; // make compiler happy
|
| -}
|
| +ObjectiveCGenerator::~ObjectiveCGenerator() {}
|
|
|
| -void GeneratorContext::ListParsedFiles(
|
| - vector<const FileDescriptor*>* output) {
|
| - GOOGLE_LOG(FATAL) << "This GeneratorContext does not support ListParsedFiles";
|
| -}
|
| +bool ObjectiveCGenerator::Generate(const FileDescriptor* file,
|
| + const string& parameter,
|
| + OutputDirectory* output_directory,
|
| + string* error) const {
|
| + // ObjC doesn't have any options at the moment, error if passed one.
|
| + vector<pair<string, string> > options;
|
| + ParseGeneratorParameter(parameter, &options);
|
| + for (int i = 0; i < options.size(); i++) {
|
| + *error = "error:: Unknown generator option: " + options[i].first;
|
| + return false;
|
| + }
|
|
|
| -// Parses a set of comma-delimited name/value pairs.
|
| -void ParseGeneratorParameter(const string& text,
|
| - vector<pair<string, string> >* output) {
|
| - vector<string> parts;
|
| - SplitStringUsing(text, ",", &parts);
|
| + FileGenerator file_generator(file);
|
|
|
| - for (int i = 0; i < parts.size(); i++) {
|
| - string::size_type equals_pos = parts[i].find_first_of('=');
|
| - pair<string, string> value;
|
| - if (equals_pos == string::npos) {
|
| - value.first = parts[i];
|
| - value.second = "";
|
| - } else {
|
| - value.first = parts[i].substr(0, equals_pos);
|
| - value.second = parts[i].substr(equals_pos + 1);
|
| - }
|
| - output->push_back(value);
|
| + string filepath = FilePath(file);
|
| +
|
| + // Generate header.
|
| + {
|
| + scoped_ptr<io::ZeroCopyOutputStream> output(
|
| + output_directory->Open(filepath + ".pbobjc.h"));
|
| + io::Printer printer(output.get(), '$');
|
| + file_generator.GenerateHeader(&printer);
|
| + }
|
| +
|
| + // Generate m file.
|
| + {
|
| + scoped_ptr<io::ZeroCopyOutputStream> output(
|
| + output_directory->Open(filepath + ".pbobjc.m"));
|
| + io::Printer printer(output.get(), '$');
|
| + file_generator.GenerateSource(&printer);
|
| }
|
| +
|
| + return true;
|
| }
|
|
|
| +} // namespace objectivec
|
| } // namespace compiler
|
| } // namespace protobuf
|
| } // namespace google
|
|
|