ruby_generator.cc
Go to the documentation of this file.
1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above
12 // copyright notice, this list of conditions and the following disclaimer
13 // in the documentation and/or other materials provided with the
14 // distribution.
15 // * Neither the name of Google Inc. nor the names of its
16 // contributors may be used to endorse or promote products derived from
17 // this software without specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 #include <iomanip>
32 #include <sstream>
33 
40 
42 
43 namespace google {
44 namespace protobuf {
45 namespace compiler {
46 namespace ruby {
47 
48 // Forward decls.
49 template <class numeric_type>
50 std::string NumberToString(numeric_type value);
51 std::string GetRequireName(const std::string& proto_file);
54 bool GenerateMessage(const Descriptor* message, io::Printer* printer,
56 void GenerateEnum(const EnumDescriptor* en, io::Printer* printer);
58  const Descriptor* message, io::Printer* printer);
60  io::Printer* printer);
62 
63 template<class numeric_type>
65  std::ostringstream os;
66  os << value;
67  return os.str();
68 }
69 
71  int lastindex = proto_file.find_last_of(".");
72  return proto_file.substr(0, lastindex) + "_pb";
73 }
74 
76  return GetRequireName(proto_file) + ".rb";
77 }
78 
80  switch (field->label()) {
81  case FieldDescriptor::LABEL_OPTIONAL: return "optional";
82  case FieldDescriptor::LABEL_REQUIRED: return "required";
83  case FieldDescriptor::LABEL_REPEATED: return "repeated";
84  default: assert(false); return "";
85  }
86 }
87 
89  switch (field->type()) {
90  case FieldDescriptor::TYPE_INT32: return "int32";
91  case FieldDescriptor::TYPE_INT64: return "int64";
92  case FieldDescriptor::TYPE_UINT32: return "uint32";
93  case FieldDescriptor::TYPE_UINT64: return "uint64";
94  case FieldDescriptor::TYPE_SINT32: return "sint32";
95  case FieldDescriptor::TYPE_SINT64: return "sint64";
96  case FieldDescriptor::TYPE_FIXED32: return "fixed32";
97  case FieldDescriptor::TYPE_FIXED64: return "fixed64";
98  case FieldDescriptor::TYPE_SFIXED32: return "sfixed32";
99  case FieldDescriptor::TYPE_SFIXED64: return "sfixed64";
100  case FieldDescriptor::TYPE_DOUBLE: return "double";
101  case FieldDescriptor::TYPE_FLOAT: return "float";
102  case FieldDescriptor::TYPE_BOOL: return "bool";
103  case FieldDescriptor::TYPE_ENUM: return "enum";
104  case FieldDescriptor::TYPE_STRING: return "string";
105  case FieldDescriptor::TYPE_BYTES: return "bytes";
106  case FieldDescriptor::TYPE_MESSAGE: return "message";
107  case FieldDescriptor::TYPE_GROUP: return "group";
108  default: assert(false); return "";
109  }
110 }
111 
113  switch (syntax) {
115  return "proto2";
117  return "proto3";
119  default:
120  GOOGLE_LOG(FATAL) << "Unsupported syntax; this generator only supports "
121  "proto2 and proto3 syntax.";
122  return "";
123  }
124 }
125 
127  switch(field->cpp_type()) {
129  return NumberToString(field->default_value_int32());
131  return NumberToString(field->default_value_int64());
133  return NumberToString(field->default_value_uint32());
135  return NumberToString(field->default_value_uint64());
137  return NumberToString(field->default_value_float());
139  return NumberToString(field->default_value_double());
141  return field->default_value_bool() ? "true" : "false";
143  return NumberToString(field->default_value_enum()->number());
145  std::ostringstream os;
146  string default_str = field->default_value_string();
147 
148  if (field->type() == FieldDescriptor::TYPE_STRING) {
149  os << "\"" << default_str << "\"";
150  } else if (field->type() == FieldDescriptor::TYPE_BYTES) {
151  os << "\"";
152 
153  os.fill('0');
154  for (int i = 0; i < default_str.length(); ++i) {
155  // Write the hex form of each byte.
156  os << "\\x" << std::hex << std::setw(2)
157  << ((uint16)((unsigned char)default_str.at(i)));
158  }
159  os << "\".force_encoding(\"ASCII-8BIT\")";
160  }
161 
162  return os.str();
163  }
164  default: assert(false); return "";
165  }
166 }
167 
169  if (field->is_map()) {
170  const FieldDescriptor* key_field =
171  field->message_type()->FindFieldByNumber(1);
172  const FieldDescriptor* value_field =
173  field->message_type()->FindFieldByNumber(2);
174 
175  printer->Print(
176  "map :$name$, :$key_type$, :$value_type$, $number$",
177  "name", field->name(),
178  "key_type", TypeName(key_field),
179  "value_type", TypeName(value_field),
180  "number", NumberToString(field->number()));
181 
182  if (value_field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
183  printer->Print(
184  ", \"$subtype$\"\n",
185  "subtype", value_field->message_type()->full_name());
186  } else if (value_field->cpp_type() == FieldDescriptor::CPPTYPE_ENUM) {
187  printer->Print(
188  ", \"$subtype$\"\n",
189  "subtype", value_field->enum_type()->full_name());
190  } else {
191  printer->Print("\n");
192  }
193  } else {
194 
195  printer->Print(
196  "$label$ :$name$, ",
197  "label", LabelForField(field),
198  "name", field->name());
199  printer->Print(
200  ":$type$, $number$",
201  "type", TypeName(field),
202  "number", NumberToString(field->number()));
203 
204  if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
205  printer->Print(
206  ", \"$subtype$\"",
207  "subtype", field->message_type()->full_name());
208  } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_ENUM) {
209  printer->Print(
210  ", \"$subtype$\"",
211  "subtype", field->enum_type()->full_name());
212  }
213 
214  if (field->has_default_value()) {
215  printer->Print(", default: $default$", "default",
217  }
218 
219  printer->Print("\n");
220  }
221 }
222 
223 void GenerateOneof(const OneofDescriptor* oneof, io::Printer* printer) {
224  printer->Print(
225  "oneof :$name$ do\n",
226  "name", oneof->name());
227  printer->Indent();
228 
229  for (int i = 0; i < oneof->field_count(); i++) {
230  const FieldDescriptor* field = oneof->field(i);
231  GenerateField(field, printer);
232  }
233 
234  printer->Outdent();
235  printer->Print("end\n");
236 }
237 
239  std::string* error) {
240  if (message->extension_range_count() > 0 || message->extension_count() > 0) {
241  *error = "Extensions are not yet supported for proto2 .proto files.";
242  return false;
243  }
244 
245  // Don't generate MapEntry messages -- we use the Ruby extension's native
246  // support for map fields instead.
247  if (message->options().map_entry()) {
248  return true;
249  }
250 
251  printer->Print(
252  "add_message \"$name$\" do\n",
253  "name", message->full_name());
254  printer->Indent();
255 
256  for (int i = 0; i < message->field_count(); i++) {
257  const FieldDescriptor* field = message->field(i);
258  if (!field->containing_oneof()) {
259  GenerateField(field, printer);
260  }
261  }
262 
263  for (int i = 0; i < message->oneof_decl_count(); i++) {
264  const OneofDescriptor* oneof = message->oneof_decl(i);
265  GenerateOneof(oneof, printer);
266  }
267 
268  printer->Outdent();
269  printer->Print("end\n");
270 
271  for (int i = 0; i < message->nested_type_count(); i++) {
272  if (!GenerateMessage(message->nested_type(i), printer, error)) {
273  return false;
274  }
275  }
276  for (int i = 0; i < message->enum_type_count(); i++) {
277  GenerateEnum(message->enum_type(i), printer);
278  }
279 
280  return true;
281 }
282 
283 void GenerateEnum(const EnumDescriptor* en, io::Printer* printer) {
284  printer->Print(
285  "add_enum \"$name$\" do\n",
286  "name", en->full_name());
287  printer->Indent();
288 
289  for (int i = 0; i < en->value_count(); i++) {
290  const EnumValueDescriptor* value = en->value(i);
291  printer->Print(
292  "value :$name$, $number$\n",
293  "name", value->name(),
294  "number", NumberToString(value->number()));
295  }
296 
297  printer->Outdent();
298  printer->Print(
299  "end\n");
300 }
301 
302 // Locale-agnostic utility functions.
303 bool IsLower(char ch) { return ch >= 'a' && ch <= 'z'; }
304 
305 bool IsUpper(char ch) { return ch >= 'A' && ch <= 'Z'; }
306 
307 bool IsAlpha(char ch) { return IsLower(ch) || IsUpper(ch); }
308 
309 char UpperChar(char ch) { return IsLower(ch) ? (ch - 'a' + 'A') : ch; }
310 
311 
312 // Package names in protobuf are snake_case by convention, but Ruby module
313 // names must be PascalCased.
314 //
315 // foo_bar_baz -> FooBarBaz
317  bool next_upper = true;
318  std::string result;
319  result.reserve(name.size());
320 
321  for (int i = 0; i < name.size(); i++) {
322  if (name[i] == '_') {
323  next_upper = true;
324  } else {
325  if (next_upper) {
326  result.push_back(UpperChar(name[i]));
327  } else {
328  result.push_back(name[i]);
329  }
330  next_upper = false;
331  }
332  }
333 
334  return result;
335 }
336 
337 // Class and enum names in protobuf should be PascalCased by convention, but
338 // since there is nothing enforcing this we need to ensure that they are valid
339 // Ruby constants. That mainly means making sure that the first character is
340 // an upper-case letter.
342  std::string ret = name;
343  if (!ret.empty()) {
344  if (IsLower(ret[0])) {
345  // If it starts with a lowercase letter, capitalize it.
346  ret[0] = UpperChar(ret[0]);
347  } else if (!IsAlpha(ret[0])) {
348  // Otherwise (e.g. if it begins with an underscore), we need to come up
349  // with some prefix that starts with a capital letter. We could be smarter
350  // here, e.g. try to strip leading underscores, but this may cause other
351  // problems if the user really intended the name. So let's just prepend a
352  // well-known suffix.
353  ret = "PB_" + ret;
354  }
355  }
356 
357  return ret;
358 }
359 
361  const Descriptor* message,
362  io::Printer* printer) {
363  // Don't generate MapEntry messages -- we use the Ruby extension's native
364  // support for map fields instead.
365  if (message->options().map_entry()) {
366  return;
367  }
368 
369  printer->Print(
370  "$prefix$$name$ = ",
371  "prefix", prefix,
372  "name", RubifyConstant(message->name()));
373  printer->Print(
374  "Google::Protobuf::DescriptorPool.generated_pool."
375  "lookup(\"$full_name$\").msgclass\n",
376  "full_name", message->full_name());
377 
378  std::string nested_prefix = prefix + RubifyConstant(message->name()) + "::";
379  for (int i = 0; i < message->nested_type_count(); i++) {
380  GenerateMessageAssignment(nested_prefix, message->nested_type(i), printer);
381  }
382  for (int i = 0; i < message->enum_type_count(); i++) {
383  GenerateEnumAssignment(nested_prefix, message->enum_type(i), printer);
384  }
385 }
386 
388  io::Printer* printer) {
389  printer->Print(
390  "$prefix$$name$ = ",
391  "prefix", prefix,
392  "name", RubifyConstant(en->name()));
393  printer->Print(
394  "Google::Protobuf::DescriptorPool.generated_pool."
395  "lookup(\"$full_name$\").enummodule\n",
396  "full_name", en->full_name());
397 }
398 
400  int levels = 0;
401  bool need_change_to_module = true;
402  std::string package_name;
403 
404  // Determine the name to use in either format:
405  // proto package: one.two.three
406  // option ruby_package: One::Two::Three
407  if (file->options().has_ruby_package()) {
408  package_name = file->options().ruby_package();
409 
410  // If :: is in the package use the Ruby formated name as-is
411  // -> A::B::C
412  // otherwise, use the dot seperator
413  // -> A.B.C
414  if (package_name.find("::") != std::string::npos) {
415  need_change_to_module = false;
416  } else {
417  GOOGLE_LOG(WARNING) << "ruby_package option should be in the form of:"
418  << " 'A::B::C' and not 'A.B.C'";
419  }
420  } else {
421  package_name = file->package();
422  }
423 
424  // Use the appropriate delimter
425  string delimiter = need_change_to_module ? "." : "::";
426  int delimiter_size = need_change_to_module ? 1 : 2;
427 
428  // Extract each module name and indent
429  while (!package_name.empty()) {
430  size_t dot_index = package_name.find(delimiter);
431  string component;
432  if (dot_index == string::npos) {
433  component = package_name;
434  package_name = "";
435  } else {
436  component = package_name.substr(0, dot_index);
437  package_name = package_name.substr(dot_index + delimiter_size);
438  }
439  if (need_change_to_module) {
440  component = PackageToModule(component);
441  }
442  printer->Print(
443  "module $name$\n",
444  "name", component);
445  printer->Indent();
446  levels++;
447  }
448  return levels;
449 }
450 
451 void EndPackageModules(int levels, io::Printer* printer) {
452  while (levels > 0) {
453  levels--;
454  printer->Outdent();
455  printer->Print(
456  "end\n");
457  }
458 }
459 
461  string* error) {
462  for (int i = 0; i < message->field_count(); i++) {
463  const FieldDescriptor* field = message->field(i);
464  if ((field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE &&
465  field->message_type()->file() == file) ||
466  (field->type() == FieldDescriptor::TYPE_ENUM &&
467  field->enum_type()->file() == file)) {
468  *error = "proto3 message field " + field->full_name() + " in file " +
469  file->name() + " has a dependency on a type from proto2 file " +
470  file->name() +
471  ". Ruby doesn't support proto2 yet, so we must fail.";
472  return true;
473  }
474  }
475 
476  for (int i = 0; i < message->nested_type_count(); i++) {
477  if (UsesTypeFromFile(message->nested_type(i), file, error)) {
478  return true;
479  }
480  }
481 
482  return false;
483 }
484 
485 // Ruby doesn't currently support proto2. This causes a failure even for proto3
486 // files that import proto2. But in some cases, the proto2 file is only being
487 // imported to extend another proto2 message. The prime example is declaring
488 // custom options by extending FileOptions/FieldOptions/etc.
489 //
490 // If the proto3 messages don't have any proto2 submessages, it is safe to omit
491 // the dependency completely. Users won't be able to use any proto2 extensions,
492 // but they already couldn't because proto2 messages aren't supported.
493 //
494 // If/when we add proto2 support, we should remove this.
496  const FileDescriptor* from,
497  io::Printer* printer,
498  string* error) {
499  if (from->syntax() == FileDescriptor::SYNTAX_PROTO3 &&
500  import->syntax() == FileDescriptor::SYNTAX_PROTO2) {
501  for (int i = 0; i < from->message_type_count(); i++) {
502  if (UsesTypeFromFile(from->message_type(i), import, error)) {
503  // Error text was already set by UsesTypeFromFile().
504  return false;
505  }
506  }
507 
508  // Ok to omit this proto2 dependency -- so we won't print anything.
509  GOOGLE_LOG(WARNING) << "Omitting proto2 dependency '" << import->name()
510  << "' from proto3 output file '"
511  << GetOutputFilename(from->name())
512  << "' because we don't support proto2 and no proto2 "
513  "types from that file are being used.";
514  return true;
515  } else {
516  printer->Print(
517  "require '$name$'\n", "name", GetRequireName(import->name()));
518  return true;
519  }
520 }
521 
522 bool GenerateFile(const FileDescriptor* file, io::Printer* printer,
523  string* error) {
524  printer->Print(
525  "# Generated by the protocol buffer compiler. DO NOT EDIT!\n"
526  "# source: $filename$\n"
527  "\n",
528  "filename", file->name());
529 
530  printer->Print(
531  "require 'google/protobuf'\n\n");
532 
533  for (int i = 0; i < file->dependency_count(); i++) {
534  if (!MaybeEmitDependency(file->dependency(i), file, printer, error)) {
535  return false;
536  }
537  }
538 
539  // TODO: Remove this when ruby supports extensions for proto2 syntax.
540  if (file->extension_count() > 0) {
541  *error = "Extensions are not yet supported for proto2 .proto files.";
542  return false;
543  }
544 
545  printer->Print("Google::Protobuf::DescriptorPool.generated_pool.build do\n");
546  printer->Indent();
547  printer->Print("add_file(\"$filename$\", :syntax => :$syntax$) do\n",
548  "filename", file->name(), "syntax",
549  StringifySyntax(file->syntax()));
550  printer->Indent();
551  for (int i = 0; i < file->message_type_count(); i++) {
552  if (!GenerateMessage(file->message_type(i), printer, error)) {
553  return false;
554  }
555  }
556  for (int i = 0; i < file->enum_type_count(); i++) {
557  GenerateEnum(file->enum_type(i), printer);
558  }
559  printer->Outdent();
560  printer->Print("end\n");
561  printer->Outdent();
562  printer->Print(
563  "end\n\n");
564 
565  int levels = GeneratePackageModules(file, printer);
566  for (int i = 0; i < file->message_type_count(); i++) {
567  GenerateMessageAssignment("", file->message_type(i), printer);
568  }
569  for (int i = 0; i < file->enum_type_count(); i++) {
570  GenerateEnumAssignment("", file->enum_type(i), printer);
571  }
572  EndPackageModules(levels, printer);
573  return true;
574 }
575 
577  const FileDescriptor* file,
578  const string& parameter,
579  GeneratorContext* generator_context,
580  string* error) const {
581 
582  if (file->syntax() != FileDescriptor::SYNTAX_PROTO3 &&
584  *error = "Invalid or unsupported proto syntax";
585  return false;
586  }
587 
588  std::unique_ptr<io::ZeroCopyOutputStream> output(
589  generator_context->Open(GetOutputFilename(file->name())));
590  io::Printer printer(output.get(), '$');
591 
592  return GenerateFile(file, &printer, error);
593 }
594 
595 } // namespace ruby
596 } // namespace compiler
597 } // namespace protobuf
598 } // namespace google
google::protobuf::Descriptor::full_name
const std::string & full_name() const
zero_copy_stream.h
google::protobuf::io::Printer::Print
void Print(const std::map< std::string, std::string > &variables, const char *text)
Definition: printer.cc:112
google::protobuf::compiler::ruby::GenerateMessage
bool GenerateMessage(const Descriptor *message, io::Printer *printer, std::string *error)
Definition: ruby_generator.cc:238
google::protobuf::FieldDescriptor::TYPE_SINT64
@ TYPE_SINT64
Definition: src/google/protobuf/descriptor.h:544
google::protobuf::FieldDescriptor::CPPTYPE_ENUM
@ CPPTYPE_ENUM
Definition: src/google/protobuf/descriptor.h:561
google::protobuf::compiler::ruby::GenerateEnumAssignment
void GenerateEnumAssignment(const std::string &prefix, const EnumDescriptor *en, io::Printer *printer)
Definition: ruby_generator.cc:387
name
GLuint const GLchar * name
Definition: glcorearb.h:3055
google::protobuf::FieldDescriptor::enum_type
const EnumDescriptor * enum_type() const
Definition: src/google/protobuf/descriptor.cc:7235
google::protobuf::value
const Descriptor::ReservedRange value
Definition: src/google/protobuf/descriptor.h:1954
google::protobuf::compiler::ruby::LabelForField
std::string LabelForField(FieldDescriptor *field)
google::protobuf::FieldDescriptor::CPPTYPE_STRING
@ CPPTYPE_STRING
Definition: src/google/protobuf/descriptor.h:562
google::protobuf::FieldDescriptor
Definition: src/google/protobuf/descriptor.h:515
google::protobuf::FileDescriptor::enum_type
const EnumDescriptor * enum_type(int index) const
google::protobuf::FieldDescriptor::TYPE_SINT32
@ TYPE_SINT32
Definition: src/google/protobuf/descriptor.h:543
google::protobuf::FieldDescriptor::CPPTYPE_UINT64
@ CPPTYPE_UINT64
Definition: src/google/protobuf/descriptor.h:557
google::protobuf::EnumDescriptor::value_count
int value_count() const
FATAL
const int FATAL
Definition: log_severity.h:60
google::protobuf::FieldDescriptor::TYPE_BYTES
@ TYPE_BYTES
Definition: src/google/protobuf/descriptor.h:538
google::protobuf::compiler::ruby::GenerateEnum
void GenerateEnum(const EnumDescriptor *en, io::Printer *printer)
Definition: ruby_generator.cc:283
google::protobuf::FieldDescriptor::CPPTYPE_INT64
@ CPPTYPE_INT64
Definition: src/google/protobuf/descriptor.h:555
google::protobuf::compiler::GeneratorContext::Open
virtual io::ZeroCopyOutputStream * Open(const std::string &filename)=0
google::protobuf::FieldDescriptor::CPPTYPE_UINT32
@ CPPTYPE_UINT32
Definition: src/google/protobuf/descriptor.h:556
google::protobuf::compiler::ruby::UsesTypeFromFile
bool UsesTypeFromFile(const Descriptor *message, const FileDescriptor *file, string *error)
Definition: ruby_generator.cc:460
google::protobuf::OneofDescriptor
Definition: src/google/protobuf/descriptor.h:843
string
GLsizei const GLchar *const * string
Definition: glcorearb.h:3083
google::protobuf::compiler::ruby::GenerateField
void GenerateField(const FieldDescriptor *field, io::Printer *printer)
Definition: ruby_generator.cc:168
plugin.h
google::protobuf::OneofDescriptor::name
const std::string & name() const
google::protobuf::FileDescriptor::SYNTAX_PROTO2
@ SYNTAX_PROTO2
Definition: src/google/protobuf/descriptor.h:1393
google::protobuf::compiler::ruby::RubifyConstant
std::string RubifyConstant(const std::string &name)
Definition: ruby_generator.cc:341
error
Definition: cJSON.c:88
google::protobuf::OneofDescriptor::field
const FieldDescriptor * field(int index) const
Definition: src/google/protobuf/descriptor.h:2179
google::protobuf::compiler::ruby::GenerateFile
bool GenerateFile(const FileDescriptor *file, io::Printer *printer, string *error)
Definition: ruby_generator.cc:522
google::protobuf::FileDescriptor::enum_type_count
int enum_type_count() const
google::protobuf::FileDescriptor::syntax
Syntax syntax() const
Definition: src/google/protobuf/descriptor.h:2175
google::protobuf::compiler::ruby::Generator::Generate
virtual bool Generate(const FileDescriptor *file, const string &parameter, GeneratorContext *generator_context, string *error) const
Definition: ruby_generator.cc:576
google::protobuf::FileDescriptor::package
const std::string & package() const
google::protobuf::io::Printer::Indent
void Indent()
Definition: printer.cc:185
google::protobuf::compiler::ruby::IsLower
bool IsLower(char ch)
Definition: ruby_generator.cc:303
google::protobuf::FieldDescriptor::LABEL_REQUIRED
@ LABEL_REQUIRED
Definition: src/google/protobuf/descriptor.h:573
google::protobuf::EnumDescriptor::name
const std::string & name() const
google::protobuf::FieldDescriptor::TYPE_UINT32
@ TYPE_UINT32
Definition: src/google/protobuf/descriptor.h:539
google::protobuf::compiler::ruby::DefaultValueForField
std::string DefaultValueForField(const FieldDescriptor *field)
Definition: ruby_generator.cc:126
prefix
static const char prefix[]
Definition: test_pair_ipc.cpp:26
google::protobuf::uint16
uint16_t uint16
Definition: protobuf/src/google/protobuf/stubs/port.h:154
google::protobuf::EnumDescriptor::value
const EnumValueDescriptor * value(int index) const
printer.h
GOOGLE_LOG
#define GOOGLE_LOG(LEVEL)
Definition: logging.h:146
google::protobuf::FieldDescriptor::TYPE_BOOL
@ TYPE_BOOL
Definition: src/google/protobuf/descriptor.h:533
google::protobuf::WARNING
static const LogLevel WARNING
Definition: protobuf/src/google/protobuf/testing/googletest.h:71
google::protobuf::FieldDescriptor::TYPE_STRING
@ TYPE_STRING
Definition: src/google/protobuf/descriptor.h:534
code_generator.h
google::protobuf::FileDescriptor::options
const FileOptions & options() const
google::protobuf::compiler::ruby::GetRequireName
std::string GetRequireName(const std::string &proto_file)
Definition: ruby_generator.cc:70
google::protobuf::FileDescriptor::SYNTAX_PROTO3
@ SYNTAX_PROTO3
Definition: src/google/protobuf/descriptor.h:1394
google::protobuf::compiler::ruby::IsUpper
bool IsUpper(char ch)
Definition: ruby_generator.cc:305
field
const FieldDescriptor * field
Definition: parser_unittest.cc:2694
google::protobuf::FieldDescriptor::CPPTYPE_DOUBLE
@ CPPTYPE_DOUBLE
Definition: src/google/protobuf/descriptor.h:558
google::protobuf::io::Printer
Definition: printer.h:181
ruby_generator.h
google::protobuf::FileDescriptor::SYNTAX_UNKNOWN
@ SYNTAX_UNKNOWN
Definition: src/google/protobuf/descriptor.h:1392
i
int i
Definition: gmock-matchers_test.cc:764
google::protobuf::FieldDescriptor::TYPE_MESSAGE
@ TYPE_MESSAGE
Definition: src/google/protobuf/descriptor.h:536
google::protobuf::FieldDescriptor::TYPE_DOUBLE
@ TYPE_DOUBLE
Definition: src/google/protobuf/descriptor.h:522
google::protobuf::FileDescriptor::name
const std::string & name() const
google::protobuf::FieldDescriptor::CPPTYPE_FLOAT
@ CPPTYPE_FLOAT
Definition: src/google/protobuf/descriptor.h:559
google::protobuf::FieldDescriptor::CPPTYPE_BOOL
@ CPPTYPE_BOOL
Definition: src/google/protobuf/descriptor.h:560
google::protobuf::FieldDescriptor::TYPE_INT32
@ TYPE_INT32
Definition: src/google/protobuf/descriptor.h:528
google::protobuf::FieldDescriptor::TYPE_FLOAT
@ TYPE_FLOAT
Definition: src/google/protobuf/descriptor.h:523
google::protobuf::compiler::ruby::GenerateMessageAssignment
void GenerateMessageAssignment(const std::string &prefix, const Descriptor *message, io::Printer *printer)
Definition: ruby_generator.cc:360
google::protobuf::FileDescriptor::message_type
const Descriptor * message_type(int index) const
google::protobuf::compiler::ruby::NumberToString
std::string NumberToString(numeric_type value)
Definition: ruby_generator.cc:64
google::protobuf::EnumDescriptor::full_name
const std::string & full_name() const
google::protobuf::compiler::ruby::MaybeEmitDependency
bool MaybeEmitDependency(const FileDescriptor *import, const FileDescriptor *from, io::Printer *printer, string *error)
Definition: ruby_generator.cc:495
google::protobuf::FileDescriptor::dependency
const FileDescriptor * dependency(int index) const
Definition: src/google/protobuf/descriptor.cc:7271
ch
char ch
Definition: gmock-matchers_test.cc:3871
google::protobuf::FieldDescriptor::TYPE_FIXED64
@ TYPE_FIXED64
Definition: src/google/protobuf/descriptor.h:531
FileOptions::ruby_package
const std::string & ruby_package() const
Definition: descriptor.pb.h:10346
google::protobuf::EnumValueDescriptor
Definition: src/google/protobuf/descriptor.h:1075
google::protobuf::compiler::ruby::PackageToModule
std::string PackageToModule(const std::string &name)
Definition: ruby_generator.cc:316
google::protobuf::Descriptor
Definition: src/google/protobuf/descriptor.h:231
descriptor.h
google::protobuf::FieldDescriptor::TYPE_GROUP
@ TYPE_GROUP
Definition: src/google/protobuf/descriptor.h:535
google::protobuf::FieldDescriptor::TYPE_SFIXED32
@ TYPE_SFIXED32
Definition: src/google/protobuf/descriptor.h:541
google::protobuf::FieldDescriptor::message_type
const Descriptor * message_type() const
Definition: src/google/protobuf/descriptor.cc:7228
google::protobuf::FieldDescriptor::TYPE_UINT64
@ TYPE_UINT64
Definition: src/google/protobuf/descriptor.h:527
google::protobuf::FileDescriptor
Definition: src/google/protobuf/descriptor.h:1320
google::protobuf::compiler::ruby::EndPackageModules
void EndPackageModules(int levels, io::Printer *printer)
Definition: ruby_generator.cc:451
google::protobuf::compiler::ruby::GenerateOneof
void GenerateOneof(const OneofDescriptor *oneof, io::Printer *printer)
Definition: ruby_generator.cc:223
google::protobuf::FieldDescriptor::LABEL_REPEATED
@ LABEL_REPEATED
Definition: src/google/protobuf/descriptor.h:574
google::protobuf::FieldDescriptor::TYPE_INT64
@ TYPE_INT64
Definition: src/google/protobuf/descriptor.h:524
google::protobuf::compiler::ruby::GeneratePackageModules
int GeneratePackageModules(const FileDescriptor *file, io::Printer *printer)
Definition: ruby_generator.cc:399
google::protobuf::FieldDescriptor::LABEL_OPTIONAL
@ LABEL_OPTIONAL
Definition: src/google/protobuf/descriptor.h:572
google::protobuf::compiler::ruby::TypeName
std::string TypeName(FieldDescriptor *field)
google::protobuf::compiler::ruby::IsAlpha
bool IsAlpha(char ch)
Definition: ruby_generator.cc:307
google::protobuf::compiler::ruby::StringifySyntax
string StringifySyntax(FileDescriptor::Syntax syntax)
Definition: ruby_generator.cc:112
value
GLsizei const GLfloat * value
Definition: glcorearb.h:3093
google::protobuf::OneofDescriptor::field_count
int field_count() const
descriptor.pb.h
google::protobuf::FieldDescriptor::CPPTYPE_MESSAGE
@ CPPTYPE_MESSAGE
Definition: src/google/protobuf/descriptor.h:563
output
const upb_json_parsermethod const upb_symtab upb_sink * output
Definition: ruby/ext/google/protobuf_c/upb.h:10503
google::protobuf::FieldDescriptor::CPPTYPE_INT32
@ CPPTYPE_INT32
Definition: src/google/protobuf/descriptor.h:554
google::protobuf::FieldDescriptor::TYPE_ENUM
@ TYPE_ENUM
Definition: src/google/protobuf/descriptor.h:540
google::protobuf::EnumDescriptor
Definition: src/google/protobuf/descriptor.h:918
google::protobuf::FieldDescriptor::TYPE_SFIXED64
@ TYPE_SFIXED64
Definition: src/google/protobuf/descriptor.h:542
google::protobuf::compiler::GeneratorContext
Definition: code_generator.h:119
google::protobuf::compiler::ruby::UpperChar
char UpperChar(char ch)
Definition: ruby_generator.cc:309
levels
GLsizei levels
Definition: glcorearb.h:4284
google::protobuf::FileDescriptor::message_type_count
int message_type_count() const
google::protobuf::io::Printer::Outdent
void Outdent()
Definition: printer.cc:187
google::protobuf::FieldDescriptor::cpp_type
CppType cpp_type() const
Definition: src/google/protobuf/descriptor.h:2139
compiler
Definition: plugin.pb.cc:22
google
Definition: data_proto2_to_proto3_util.h:11
message
GLenum GLuint GLenum GLsizei const GLchar * message
Definition: glcorearb.h:2695
google::protobuf::FileDescriptor::extension_count
int extension_count() const
google::protobuf::FileDescriptor::Syntax
Syntax
Definition: src/google/protobuf/descriptor.h:1391
google::protobuf::compiler::ruby::GetOutputFilename
std::string GetOutputFilename(const std::string &proto_file)
Definition: ruby_generator.cc:75
google::protobuf::FileDescriptor::dependency_count
int dependency_count() const
google::protobuf::FieldDescriptor::TYPE_FIXED32
@ TYPE_FIXED32
Definition: src/google/protobuf/descriptor.h:532


libaditof
Author(s):
autogenerated on Wed May 21 2025 02:06:58