Преглед на файлове

Merge pull request #136 from cfallin/ruby-proto3-only

Support Ruby code generation only for proto3.
Joshua Haberman преди 10 години
родител
ревизия
59692c3fc0
променени са 1 файла, в които са добавени 8 реда и са изтрити 0 реда
  1. 8 0
      src/google/protobuf/compiler/ruby/ruby_generator.cc

+ 8 - 0
src/google/protobuf/compiler/ruby/ruby_generator.cc

@@ -297,6 +297,14 @@ bool Generator::Generate(
     const string& parameter,
     GeneratorContext* generator_context,
     string* error) const {
+
+  if (file->syntax() != FileDescriptor::SYNTAX_PROTO3) {
+    *error =
+        "Can only generate Ruby code for proto3 .proto files.\n"
+        "Please add 'syntax = \"proto3\";' to the top of your .proto file.\n";
+    return false;
+  }
+
   std::string filename =
       StripDotProto(file->name()) + ".rb";
   scoped_ptr<io::ZeroCopyOutputStream> output(generator_context->Open(filename));