| Index: third_party/protobuf/src/google/protobuf/compiler/java/java_shared_code_generator.cc
|
| diff --git a/third_party/protobuf/src/google/protobuf/compiler/java/java_shared_code_generator.cc b/third_party/protobuf/src/google/protobuf/compiler/java/java_shared_code_generator.cc
|
| index 5fe6824529265bf035bedfd3c75708a0e8fa49c2..74253c3fb7a3065462b310b83dabaa6db12ab14c 100644
|
| --- a/third_party/protobuf/src/google/protobuf/compiler/java/java_shared_code_generator.cc
|
| +++ b/third_party/protobuf/src/google/protobuf/compiler/java/java_shared_code_generator.cc
|
| @@ -51,53 +51,44 @@ namespace protobuf {
|
| namespace compiler {
|
| namespace java {
|
|
|
| -SharedCodeGenerator::SharedCodeGenerator(const FileDescriptor* file,
|
| - const Options& options)
|
| - : name_resolver_(new ClassNameResolver), file_(file), options_(options) {}
|
| +SharedCodeGenerator::SharedCodeGenerator(const FileDescriptor* file)
|
| + : name_resolver_(new ClassNameResolver),
|
| + enforce_lite_(false),
|
| + file_(file) {}
|
|
|
| SharedCodeGenerator::~SharedCodeGenerator() {
|
| }
|
|
|
| void SharedCodeGenerator::Generate(GeneratorContext* context,
|
| - std::vector<string>* file_list,
|
| - std::vector<string>* annotation_file_list) {
|
| + vector<string>* file_list) {
|
| string java_package = FileJavaPackage(file_);
|
| string package_dir = JavaPackageToDir(java_package);
|
|
|
| - if (HasDescriptorMethods(file_, options_.enforce_lite)) {
|
| + if (HasDescriptorMethods(file_, enforce_lite_)) {
|
| // Generate descriptors.
|
| string classname = name_resolver_->GetDescriptorClassName(file_);
|
| string filename = package_dir + classname + ".java";
|
| file_list->push_back(filename);
|
| google::protobuf::scoped_ptr<io::ZeroCopyOutputStream> output(context->Open(filename));
|
| - GeneratedCodeInfo annotations;
|
| - io::AnnotationProtoCollector<GeneratedCodeInfo> annotation_collector(
|
| - &annotations);
|
| - google::protobuf::scoped_ptr<io::Printer> printer(
|
| - new io::Printer(output.get(), '$',
|
| - options_.annotate_code ? &annotation_collector : NULL));
|
| - string info_relative_path = classname + ".java.pb.meta";
|
| - string info_full_path = filename + ".pb.meta";
|
| + google::protobuf::scoped_ptr<io::Printer> printer(new io::Printer(output.get(), '$'));
|
| +
|
| printer->Print(
|
| - "// Generated by the protocol buffer compiler. DO NOT EDIT!\n"
|
| - "// source: $filename$\n"
|
| - "\n",
|
| - "filename", file_->name());
|
| + "// Generated by the protocol buffer compiler. DO NOT EDIT!\n"
|
| + "// source: $filename$\n"
|
| + "\n",
|
| + "filename", file_->name());
|
| if (!java_package.empty()) {
|
| printer->Print(
|
| "package $package$;\n"
|
| "\n",
|
| "package", java_package);
|
| }
|
| - PrintGeneratedAnnotation(printer.get(), '$',
|
| - options_.annotate_code ? info_relative_path : "");
|
| printer->Print(
|
| - "public final class $classname$ {\n"
|
| - " public static com.google.protobuf.Descriptors.FileDescriptor\n"
|
| - " descriptor;\n"
|
| - " static {\n",
|
| - "classname", classname);
|
| - printer->Annotate("classname", file_->name());
|
| + "public final class $classname$ {\n"
|
| + " public static com.google.protobuf.Descriptors.FileDescriptor\n"
|
| + " descriptor;\n"
|
| + " static {\n",
|
| + "classname", classname);
|
| printer->Indent();
|
| printer->Indent();
|
| GenerateDescriptors(printer.get());
|
| @@ -107,18 +98,12 @@ void SharedCodeGenerator::Generate(GeneratorContext* context,
|
| " }\n"
|
| "}\n");
|
|
|
| - if (options_.annotate_code) {
|
| - google::protobuf::scoped_ptr<io::ZeroCopyOutputStream> info_output(
|
| - context->Open(info_full_path));
|
| - annotations.SerializeToZeroCopyStream(info_output.get());
|
| - annotation_file_list->push_back(info_full_path);
|
| - }
|
| -
|
| printer.reset();
|
| output.reset();
|
| }
|
| }
|
|
|
| +
|
| void SharedCodeGenerator::GenerateDescriptors(io::Printer* printer) {
|
| // Embed the descriptor. We simply serialize the entire FileDescriptorProto
|
| // and embed it as a string literal, which is parsed and built into real
|
| @@ -133,6 +118,7 @@ void SharedCodeGenerator::GenerateDescriptors(io::Printer* printer) {
|
| FileDescriptorProto file_proto;
|
| file_->CopyTo(&file_proto);
|
|
|
| +
|
| string file_data;
|
| file_proto.SerializeToString(&file_data);
|
|
|
| @@ -179,7 +165,7 @@ void SharedCodeGenerator::GenerateDescriptors(io::Printer* printer) {
|
|
|
| // -----------------------------------------------------------------
|
| // Find out all dependencies.
|
| - std::vector<std::pair<string, string> > dependencies;
|
| + vector<pair<string, string> > dependencies;
|
| for (int i = 0; i < file_->dependency_count(); i++) {
|
| if (ShouldIncludeDependency(file_->dependency(i))) {
|
| string filename = file_->dependency(i)->name();
|
|
|