protobuf/src/google/protobuf/compiler/java/java_helpers.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 // Author: kenton@google.com (Kenton Varda)
32 // Based on original Protocol Buffers design by
33 // Sanjay Ghemawat, Jeff Dean, and others.
34 
35 #include <google/protobuf/compiler/java/java_helpers.h>
36 
37 #include <algorithm>
38 #include <cstdint>
39 #include <limits>
40 #include <unordered_set>
41 #include <vector>
42 
43 #include <google/protobuf/stubs/stringprintf.h>
44 #include <google/protobuf/compiler/java/java_name_resolver.h>
45 #include <google/protobuf/compiler/java/java_names.h>
46 #include <google/protobuf/descriptor.pb.h>
47 #include <google/protobuf/wire_format.h>
48 #include <google/protobuf/stubs/strutil.h>
49 #include <google/protobuf/stubs/substitute.h>
50 #include <google/protobuf/stubs/hash.h> // for hash<T *>
51 
52 namespace google {
53 namespace protobuf {
54 namespace compiler {
55 namespace java {
56 
57 using internal::WireFormat;
58 using internal::WireFormatLite;
59 
60 const char kThickSeparator[] =
61  "// ===================================================================\n";
62 const char kThinSeparator[] =
63  "// -------------------------------------------------------------------\n";
64 
65 namespace {
66 
67 const char* kDefaultPackage = "";
68 
69 // Names that should be avoided as field names.
70 // Using them will cause the compiler to generate accessors whose names are
71 // colliding with methods defined in base classes.
72 const char* kForbiddenWordList[] = {
73  // message base class:
74  "cached_size",
75  "serialized_size",
76  // java.lang.Object:
77  "class",
78 };
79 
80 const std::unordered_set<std::string>* kReservedNames =
81  new std::unordered_set<std::string>({
82  "abstract", "assert", "boolean", "break", "byte",
83  "case", "catch", "char", "class", "const",
84  "continue", "default", "do", "double", "else",
85  "enum", "extends", "final", "finally", "float",
86  "for", "goto", "if", "implements", "import",
87  "instanceof", "int", "interface", "long", "native",
88  "new", "package", "private", "protected", "public",
89  "return", "short", "static", "strictfp", "super",
90  "switch", "synchronized", "this", "throw", "throws",
91  "transient", "try", "void", "volatile", "while",
92  });
93 
94 bool IsForbidden(const std::string& field_name) {
95  for (int i = 0; i < GOOGLE_ARRAYSIZE(kForbiddenWordList); ++i) {
96  if (field_name == kForbiddenWordList[i]) {
97  return true;
98  }
99  }
100  return false;
101 }
102 
104  std::string field_name;
105  // Groups are hacky: The name of the field is just the lower-cased name
106  // of the group type. In Java, though, we would like to retain the original
107  // capitalization of the type name.
109  field_name = field->message_type()->name();
110  } else {
111  field_name = field->name();
112  }
113  if (IsForbidden(field_name)) {
114  // Append a trailing "#" to indicate that the name should be decorated to
115  // avoid collision with other names.
116  field_name += "#";
117  }
118  return field_name;
119 }
120 
121 
122 } // namespace
123 
124 void PrintGeneratedAnnotation(io::Printer* printer, char delimiter,
125  const std::string& annotation_file) {
126  if (annotation_file.empty()) {
127  return;
128  }
129  std::string ptemplate =
130  "@javax.annotation.Generated(value=\"protoc\", comments=\"annotations:";
131  ptemplate.push_back(delimiter);
132  ptemplate.append("annotation_file");
133  ptemplate.push_back(delimiter);
134  ptemplate.append("\")\n");
135  printer->Print(ptemplate.c_str(), "annotation_file", annotation_file);
136 }
137 
138 void PrintEnumVerifierLogic(io::Printer* printer,
140  const std::map<std::string, std::string>& variables,
141  const char* var_name,
142  const char* terminating_string, bool enforce_lite) {
143  std::string enum_verifier_string =
144  enforce_lite ? StrCat(var_name, ".internalGetVerifier()")
145  : StrCat(
146  "new com.google.protobuf.Internal.EnumVerifier() {\n"
147  " @java.lang.Override\n"
148  " public boolean isInRange(int number) {\n"
149  " return ",
150  var_name,
151  ".forNumber(number) != null;\n"
152  " }\n"
153  " }");
154  printer->Print(
155  variables,
156  StrCat(enum_verifier_string, terminating_string).c_str());
157 }
158 
160  bool cap_next_letter) {
161  GOOGLE_CHECK(!input.empty());
163  // Note: I distrust ctype.h due to locales.
164  for (int i = 0; i < input.size(); i++) {
165  if ('a' <= input[i] && input[i] <= 'z') {
166  if (cap_next_letter) {
167  result += input[i] + ('A' - 'a');
168  } else {
169  result += input[i];
170  }
171  cap_next_letter = false;
172  } else if ('A' <= input[i] && input[i] <= 'Z') {
173  if (i == 0 && !cap_next_letter) {
174  // Force first letter to lower-case unless explicitly told to
175  // capitalize it.
176  result += input[i] + ('a' - 'A');
177  } else {
178  // Capital letters after the first are left as-is.
179  result += input[i];
180  }
181  cap_next_letter = false;
182  } else if ('0' <= input[i] && input[i] <= '9') {
183  result += input[i];
184  cap_next_letter = true;
185  } else {
186  cap_next_letter = true;
187  }
188  }
189  // Add a trailing "_" if the name should be altered.
190  if (input[input.size() - 1] == '#') {
191  result += '_';
192  }
193  return result;
194 }
195 
196 std::string ToCamelCase(const std::string& input, bool lower_first) {
197  bool capitalize_next = !lower_first;
199  result.reserve(input.size());
200 
201  for (char i : input) {
202  if (i == '_') {
203  capitalize_next = true;
204  } else if (capitalize_next) {
205  result.push_back(ToUpperCh(i));
206  capitalize_next = false;
207  } else {
208  result.push_back(i);
209  }
210  }
211 
212  // Lower-case the first letter.
213  if (lower_first && !result.empty()) {
214  result[0] = ToLowerCh(result[0]);
215  }
216 
217  return result;
218 }
219 
220 char ToUpperCh(char ch) {
221  return (ch >= 'a' && ch <= 'z') ? (ch - 'a' + 'A') : ch;
222 }
223 
224 char ToLowerCh(char ch) {
225  return (ch >= 'A' && ch <= 'Z') ? (ch - 'A' + 'a') : ch;
226 }
227 
229  return UnderscoresToCamelCase(FieldName(field), false);
230 }
231 
233  return UnderscoresToCamelCase(FieldName(field), true);
234 }
235 
238 }
239 
241  return UnderscoresToCamelCase(method->name(), false);
242 }
243 
246  if (kReservedNames->find(name) != kReservedNames->end()) {
247  return name + "_";
248  }
249  return name;
250 }
251 
252 bool IsForbiddenKotlin(const std::string& field_name) {
253  // Names that should be avoided as field names in Kotlin.
254  // All Kotlin hard keywords are in this list.
255  const std::unordered_set<std::string>* kKotlinForbiddenNames =
256  new std::unordered_set<std::string>({
257  "as", "as?", "break", "class", "continue", "do",
258  "else", "false", "for", "fun", "if", "in",
259  "!in", "interface", "is", "!is", "null", "object",
260  "package", "return", "super", "this", "throw", "true",
261  "try", "typealias", "typeof", "val", "var", "when",
262  "while",
263  });
264  return kKotlinForbiddenNames->find(field_name) !=
265  kKotlinForbiddenNames->end();
266 }
267 
269  return "static_" + StringReplace(descriptor->full_name(), ".", "_", true);
270 }
271 
274  if ('0' <= fieldName[0] && fieldName[0] <= '9') {
275  return '_' + fieldName;
276  }
277  return fieldName;
278 }
279 
280 std::string FileClassName(const FileDescriptor* file, bool immutable) {
281  ClassNameResolver name_resolver;
282  return name_resolver.GetFileClassName(file, immutable);
283 }
284 
285 std::string FileJavaPackage(const FileDescriptor* file, bool immutable) {
287 
288  if (file->options().has_java_package()) {
289  result = file->options().java_package();
290  } else {
291  result = kDefaultPackage;
292  if (!file->package().empty()) {
293  if (!result.empty()) result += '.';
294  result += file->package();
295  }
296  }
297 
298  return result;
299 }
300 
302  return FileJavaPackage(file, true /* immutable */);
303 }
304 
306  std::string package_dir = StringReplace(package_name, ".", "/", true);
307  if (!package_dir.empty()) package_dir += "/";
308  return package_dir;
309 }
310 
312  ClassNameResolver name_resolver;
313  return name_resolver.GetClassName(descriptor, true);
314 }
315 
317  ClassNameResolver name_resolver;
318  return name_resolver.GetClassName(descriptor, true);
319 }
320 
322  ClassNameResolver name_resolver;
323  return name_resolver.GetClassName(descriptor, true);
324 }
325 
327  ClassNameResolver name_resolver;
328  return name_resolver.GetClassName(descriptor, true);
329 }
330 
331 
333  std::string interfaces = "// @@protoc_insertion_point(message_implements:" +
334  descriptor->full_name() + ")";
335  return interfaces;
336 }
337 
338 
340  std::string interfaces = "// @@protoc_insertion_point(builder_implements:" +
341  descriptor->full_name() + ")";
342  return interfaces;
343 }
344 
346  std::string interfaces = "// @@protoc_insertion_point(interface_extends:" +
347  descriptor->full_name() + ")";
348  return interfaces;
349 }
350 
352  std::string name = field->name() + "_FIELD_NUMBER";
353  ToUpper(&name);
354  return name;
355 }
356 
358  return field->type();
359 }
360 
362  switch (GetType(field)) {
368  return JAVATYPE_INT;
369 
375  return JAVATYPE_LONG;
376 
378  return JAVATYPE_FLOAT;
379 
381  return JAVATYPE_DOUBLE;
382 
384  return JAVATYPE_BOOLEAN;
385 
387  return JAVATYPE_STRING;
388 
390  return JAVATYPE_BYTES;
391 
393  return JAVATYPE_ENUM;
394 
397  return JAVATYPE_MESSAGE;
398 
399  // No default because we want the compiler to complain if any new
400  // types are added.
401  }
402 
403  GOOGLE_LOG(FATAL) << "Can't get here.";
404  return JAVATYPE_INT;
405 }
406 
407 const char* PrimitiveTypeName(JavaType type) {
408  switch (type) {
409  case JAVATYPE_INT:
410  return "int";
411  case JAVATYPE_LONG:
412  return "long";
413  case JAVATYPE_FLOAT:
414  return "float";
415  case JAVATYPE_DOUBLE:
416  return "double";
417  case JAVATYPE_BOOLEAN:
418  return "boolean";
419  case JAVATYPE_STRING:
420  return "java.lang.String";
421  case JAVATYPE_BYTES:
422  return "com.google.protobuf.ByteString";
423  case JAVATYPE_ENUM:
424  return NULL;
425  case JAVATYPE_MESSAGE:
426  return NULL;
427 
428  // No default because we want the compiler to complain if any new
429  // JavaTypes are added.
430  }
431 
432  GOOGLE_LOG(FATAL) << "Can't get here.";
433  return NULL;
434 }
435 
436 const char* PrimitiveTypeName(const FieldDescriptor* descriptor) {
438 }
439 
440 const char* BoxedPrimitiveTypeName(JavaType type) {
441  switch (type) {
442  case JAVATYPE_INT:
443  return "java.lang.Integer";
444  case JAVATYPE_LONG:
445  return "java.lang.Long";
446  case JAVATYPE_FLOAT:
447  return "java.lang.Float";
448  case JAVATYPE_DOUBLE:
449  return "java.lang.Double";
450  case JAVATYPE_BOOLEAN:
451  return "java.lang.Boolean";
452  case JAVATYPE_STRING:
453  return "java.lang.String";
454  case JAVATYPE_BYTES:
455  return "com.google.protobuf.ByteString";
456  case JAVATYPE_ENUM:
457  return NULL;
458  case JAVATYPE_MESSAGE:
459  return NULL;
460 
461  // No default because we want the compiler to complain if any new
462  // JavaTypes are added.
463  }
464 
465  GOOGLE_LOG(FATAL) << "Can't get here.";
466  return NULL;
467 }
468 
471 }
472 
474  switch (type) {
475  case JAVATYPE_INT:
476  return "kotlin.Int";
477  case JAVATYPE_LONG:
478  return "kotlin.Long";
479  case JAVATYPE_FLOAT:
480  return "kotlin.Float";
481  case JAVATYPE_DOUBLE:
482  return "kotlin.Double";
483  case JAVATYPE_BOOLEAN:
484  return "kotlin.Boolean";
485  case JAVATYPE_STRING:
486  return "kotlin.String";
487  case JAVATYPE_BYTES:
488  return "com.google.protobuf.ByteString";
489  case JAVATYPE_ENUM:
490  return NULL;
491  case JAVATYPE_MESSAGE:
492  return NULL;
493 
494  // No default because we want the compiler to complain if any new
495  // JavaTypes are added.
496  }
497 
498  GOOGLE_LOG(FATAL) << "Can't get here.";
499  return NULL;
500 }
501 
503  const JavaType javaType = GetJavaType(field);
504  switch (javaType) {
505  case JAVATYPE_ENUM:
506  return "java.lang.Integer";
507  case JAVATYPE_MESSAGE:
508  return ClassName(field->message_type());
509  default:
510  return BoxedPrimitiveTypeName(javaType);
511  }
512 }
513 
515  switch (field_type) {
517  return "INT32";
519  return "UINT32";
521  return "SINT32";
523  return "FIXED32";
525  return "SFIXED32";
527  return "INT64";
529  return "UINT64";
531  return "SINT64";
533  return "FIXED64";
535  return "SFIXED64";
537  return "FLOAT";
539  return "DOUBLE";
541  return "BOOL";
543  return "STRING";
545  return "BYTES";
547  return "ENUM";
549  return "GROUP";
551  return "MESSAGE";
552 
553  // No default because we want the compiler to complain if any new
554  // types are added.
555  }
556 
557  GOOGLE_LOG(FATAL) << "Can't get here.";
558  return NULL;
559 }
560 
561 bool AllAscii(const std::string& text) {
562  for (int i = 0; i < text.size(); i++) {
563  if ((text[i] & 0x80) != 0) {
564  return false;
565  }
566  }
567  return true;
568 }
569 
570 std::string DefaultValue(const FieldDescriptor* field, bool immutable,
571  ClassNameResolver* name_resolver) {
572  // Switch on CppType since we need to know which default_value_* method
573  // of FieldDescriptor to call.
574  switch (field->cpp_type()) {
576  return StrCat(field->default_value_int32());
578  // Need to print as a signed int since Java has no unsigned.
579  return StrCat(static_cast<int32_t>(field->default_value_uint32()));
581  return StrCat(field->default_value_int64()) + "L";
583  return StrCat(static_cast<int64_t>(field->default_value_uint64())) +
584  "L";
586  double value = field->default_value_double();
587  if (value == std::numeric_limits<double>::infinity()) {
588  return "Double.POSITIVE_INFINITY";
589  } else if (value == -std::numeric_limits<double>::infinity()) {
590  return "Double.NEGATIVE_INFINITY";
591  } else if (value != value) {
592  return "Double.NaN";
593  } else {
594  return SimpleDtoa(value) + "D";
595  }
596  }
598  float value = field->default_value_float();
599  if (value == std::numeric_limits<float>::infinity()) {
600  return "Float.POSITIVE_INFINITY";
601  } else if (value == -std::numeric_limits<float>::infinity()) {
602  return "Float.NEGATIVE_INFINITY";
603  } else if (value != value) {
604  return "Float.NaN";
605  } else {
606  return SimpleFtoa(value) + "F";
607  }
608  }
610  return field->default_value_bool() ? "true" : "false";
613  if (field->has_default_value()) {
614  // See comments in Internal.java for gory details.
615  return strings::Substitute(
616  "com.google.protobuf.Internal.bytesDefaultValue(\"$0\")",
617  CEscape(field->default_value_string()));
618  } else {
619  return "com.google.protobuf.ByteString.EMPTY";
620  }
621  } else {
622  if (AllAscii(field->default_value_string())) {
623  // All chars are ASCII. In this case CEscape() works fine.
624  return "\"" + CEscape(field->default_value_string()) + "\"";
625  } else {
626  // See comments in Internal.java for gory details.
627  return strings::Substitute(
628  "com.google.protobuf.Internal.stringDefaultValue(\"$0\")",
629  CEscape(field->default_value_string()));
630  }
631  }
632 
634  return name_resolver->GetClassName(field->enum_type(), immutable) + "." +
635  field->default_value_enum()->name();
636 
638  return name_resolver->GetClassName(field->message_type(), immutable) +
639  ".getDefaultInstance()";
640 
641  // No default because we want the compiler to complain if any new
642  // types are added.
643  }
644 
645  GOOGLE_LOG(FATAL) << "Can't get here.";
646  return "";
647 }
648 
650  // Switch on CppType since we need to know which default_value_* method
651  // of FieldDescriptor to call.
652  switch (field->cpp_type()) {
654  return field->default_value_int32() == 0;
656  return field->default_value_uint32() == 0;
658  return field->default_value_int64() == 0L;
660  return field->default_value_uint64() == 0L;
662  return field->default_value_double() == 0.0;
664  return field->default_value_float() == 0.0;
666  return field->default_value_bool() == false;
668  return field->default_value_enum()->number() == 0;
671  return false;
672 
673  // No default because we want the compiler to complain if any new
674  // types are added.
675  }
676 
677  GOOGLE_LOG(FATAL) << "Can't get here.";
678  return false;
679 }
680 
682  return GetJavaType(field) == JAVATYPE_BYTES &&
683  field->default_value_string() != "";
684 }
685 
686 const char* bit_masks[] = {
687  "0x00000001", "0x00000002", "0x00000004", "0x00000008",
688  "0x00000010", "0x00000020", "0x00000040", "0x00000080",
689 
690  "0x00000100", "0x00000200", "0x00000400", "0x00000800",
691  "0x00001000", "0x00002000", "0x00004000", "0x00008000",
692 
693  "0x00010000", "0x00020000", "0x00040000", "0x00080000",
694  "0x00100000", "0x00200000", "0x00400000", "0x00800000",
695 
696  "0x01000000", "0x02000000", "0x04000000", "0x08000000",
697  "0x10000000", "0x20000000", "0x40000000", "0x80000000",
698 };
699 
701  std::string varName = "bitField";
702  varName += StrCat(index);
703  varName += "_";
704  return varName;
705 }
706 
707 std::string GetBitFieldNameForBit(int bitIndex) {
708  return GetBitFieldName(bitIndex / 32);
709 }
710 
711 namespace {
712 
713 std::string GenerateGetBitInternal(const std::string& prefix, int bitIndex) {
714  std::string varName = prefix + GetBitFieldNameForBit(bitIndex);
715  int bitInVarIndex = bitIndex % 32;
716 
717  std::string mask = bit_masks[bitInVarIndex];
718  std::string result = "((" + varName + " & " + mask + ") != 0)";
719  return result;
720 }
721 
722 std::string GenerateSetBitInternal(const std::string& prefix, int bitIndex) {
723  std::string varName = prefix + GetBitFieldNameForBit(bitIndex);
724  int bitInVarIndex = bitIndex % 32;
725 
726  std::string mask = bit_masks[bitInVarIndex];
727  std::string result = varName + " |= " + mask;
728  return result;
729 }
730 
731 } // namespace
732 
733 std::string GenerateGetBit(int bitIndex) {
734  return GenerateGetBitInternal("", bitIndex);
735 }
736 
737 std::string GenerateSetBit(int bitIndex) {
738  return GenerateSetBitInternal("", bitIndex);
739 }
740 
741 std::string GenerateClearBit(int bitIndex) {
742  std::string varName = GetBitFieldNameForBit(bitIndex);
743  int bitInVarIndex = bitIndex % 32;
744 
745  std::string mask = bit_masks[bitInVarIndex];
746  std::string result = varName + " = (" + varName + " & ~" + mask + ")";
747  return result;
748 }
749 
750 std::string GenerateGetBitFromLocal(int bitIndex) {
751  return GenerateGetBitInternal("from_", bitIndex);
752 }
753 
754 std::string GenerateSetBitToLocal(int bitIndex) {
755  return GenerateSetBitInternal("to_", bitIndex);
756 }
757 
759  return GenerateGetBitInternal("mutable_", bitIndex);
760 }
761 
763  return GenerateSetBitInternal("mutable_", bitIndex);
764 }
765 
767  switch (type) {
768  case JAVATYPE_INT:
769  return false;
770  case JAVATYPE_LONG:
771  return false;
772  case JAVATYPE_FLOAT:
773  return false;
774  case JAVATYPE_DOUBLE:
775  return false;
776  case JAVATYPE_BOOLEAN:
777  return false;
778  case JAVATYPE_STRING:
779  return true;
780  case JAVATYPE_BYTES:
781  return true;
782  case JAVATYPE_ENUM:
783  return true;
784  case JAVATYPE_MESSAGE:
785  return true;
786 
787  // No default because we want the compiler to complain if any new
788  // JavaTypes are added.
789  }
790 
791  GOOGLE_LOG(FATAL) << "Can't get here.";
792  return false;
793 }
794 
795 const char* GetCapitalizedType(const FieldDescriptor* field, bool immutable) {
796  switch (GetType(field)) {
798  return "Int32";
800  return "UInt32";
802  return "SInt32";
804  return "Fixed32";
806  return "SFixed32";
808  return "Int64";
810  return "UInt64";
812  return "SInt64";
814  return "Fixed64";
816  return "SFixed64";
818  return "Float";
820  return "Double";
822  return "Bool";
824  return "String";
826  return "Bytes";
827  }
829  return "Enum";
831  return "Group";
833  return "Message";
834 
835  // No default because we want the compiler to complain if any new
836  // types are added.
837  }
838 
839  GOOGLE_LOG(FATAL) << "Can't get here.";
840  return NULL;
841 }
842 
843 // For encodings with fixed sizes, returns that size in bytes. Otherwise
844 // returns -1.
846  switch (type) {
848  return -1;
850  return -1;
852  return -1;
854  return -1;
856  return -1;
858  return -1;
871 
875  return -1;
876 
878  return -1;
880  return -1;
882  return -1;
884  return -1;
885 
886  // No default because we want the compiler to complain if any new
887  // types are added.
888  }
889  GOOGLE_LOG(FATAL) << "Can't get here.";
890  return -1;
891 }
892 
893 // Sort the fields of the given Descriptor by number into a new[]'d array
894 // and return it. The caller should delete the returned array.
896  const FieldDescriptor** fields =
897  new const FieldDescriptor*[descriptor->field_count()];
898  for (int i = 0; i < descriptor->field_count(); i++) {
899  fields[i] = descriptor->field(i);
900  }
901  std::sort(fields, fields + descriptor->field_count(),
902  FieldOrderingByNumber());
903  return fields;
904 }
905 
906 // Returns true if the message type has any required fields. If it doesn't,
907 // we can optimize out calls to its isInitialized() method.
908 //
909 // already_seen is used to avoid checking the same type multiple times
910 // (and also to protect against recursion).
911 bool HasRequiredFields(const Descriptor* type,
912  std::unordered_set<const Descriptor*>* already_seen) {
913  if (already_seen->count(type) > 0) {
914  // The type is already in cache. This means that either:
915  // a. The type has no required fields.
916  // b. We are in the midst of checking if the type has required fields,
917  // somewhere up the stack. In this case, we know that if the type
918  // has any required fields, they'll be found when we return to it,
919  // and the whole call to HasRequiredFields() will return true.
920  // Therefore, we don't have to check if this type has required fields
921  // here.
922  return false;
923  }
924  already_seen->insert(type);
925 
926  // If the type has extensions, an extension with message type could contain
927  // required fields, so we have to be conservative and assume such an
928  // extension exists.
929  if (type->extension_range_count() > 0) return true;
930 
931  for (int i = 0; i < type->field_count(); i++) {
932  const FieldDescriptor* field = type->field(i);
933  if (field->is_required()) {
934  return true;
935  }
937  if (HasRequiredFields(field->message_type(), already_seen)) {
938  return true;
939  }
940  }
941  }
942 
943  return false;
944 }
945 
946 bool HasRequiredFields(const Descriptor* type) {
947  std::unordered_set<const Descriptor*> already_seen;
948  return HasRequiredFields(type, &already_seen);
949 }
950 
952  for (int i = 0; i < descriptor->field_count(); ++i) {
953  const FieldDescriptor* field = descriptor->field(i);
954  if (field->is_repeated()) {
955  return true;
956  }
957  }
958  return false;
959 }
960 
961 // Encode an unsigned 32-bit value into a sequence of UTF-16 characters.
962 //
963 // If the value is in [0x0000, 0xD7FF], we encode it with a single character
964 // with the same numeric value.
965 //
966 // If the value is larger than 0xD7FF, we encode its lowest 13 bits into a
967 // character in the range [0xE000, 0xFFFF] by combining these 13 bits with
968 // 0xE000 using logic-or. Then we shift the value to the right by 13 bits, and
969 // encode the remaining value by repeating this same process until we get to
970 // a value in [0x0000, 0xD7FF] where we will encode it using a character with
971 // the same numeric value.
972 //
973 // Note that we only use code points in [0x0000, 0xD7FF] and [0xE000, 0xFFFF].
974 // There will be no surrogate pairs in the encoded character sequence.
976  std::vector<uint16_t>* output) {
977  // For values in [0x0000, 0xD7FF], only use one char to encode it.
978  if (number < 0xD800) {
979  output->push_back(static_cast<uint16_t>(number));
980  return;
981  }
982  // Encode into multiple chars. All except the last char will be in the range
983  // [0xE000, 0xFFFF], and the last char will be in the range [0x0000, 0xD7FF].
984  // Note that we don't use any value in range [0xD800, 0xDFFF] because they
985  // have to come in pairs and the encoding is just more space-efficient w/o
986  // them.
987  while (number >= 0xD800) {
988  // [0xE000, 0xFFFF] can represent 13 bits of info.
989  output->push_back(static_cast<uint16_t>(0xE000 | (number & 0x1FFF)));
990  number >>= 13;
991  }
992  output->push_back(static_cast<uint16_t>(number));
993 }
994 
996  // j/c/g/protobuf/FieldType.java lists field types in a slightly different
997  // order from FieldDescriptor::Type so we can't do a simple cast.
998  //
999  // TODO(xiaofeng): Make j/c/g/protobuf/FieldType.java follow the same order.
1000  int result = field->type();
1002  return 17;
1003  } else if (result < FieldDescriptor::TYPE_GROUP) {
1004  return result - 1;
1005  } else {
1006  return result - 2;
1007  }
1008 }
1009 
1011  if (field->type() == FieldDescriptor::TYPE_GROUP) {
1012  return 49;
1013  } else {
1015  }
1016 }
1017 
1019  int result = field->type();
1021  return result + 34;
1022  } else if (result > FieldDescriptor::TYPE_BYTES) {
1023  return result + 30;
1024  } else {
1025  GOOGLE_LOG(FATAL) << field->full_name() << " can't be packed.";
1026  return 0;
1027  }
1028 }
1029 
1031  static const int kMapFieldType = 50;
1032  static const int kOneofFieldTypeOffset = 51;
1033  static const int kRequiredBit = 0x100;
1034  static const int kUtf8CheckBit = 0x200;
1035  static const int kCheckInitialized = 0x400;
1036  static const int kMapWithProto2EnumValue = 0x800;
1037  static const int kHasHasBit = 0x1000;
1038  int extra_bits = field->is_required() ? kRequiredBit : 0;
1039  if (field->type() == FieldDescriptor::TYPE_STRING && CheckUtf8(field)) {
1040  extra_bits |= kUtf8CheckBit;
1041  }
1042  if (field->is_required() || (GetJavaType(field) == JAVATYPE_MESSAGE &&
1043  HasRequiredFields(field->message_type()))) {
1044  extra_bits |= kCheckInitialized;
1045  }
1046  if (HasHasbit(field)) {
1047  extra_bits |= kHasHasBit;
1048  }
1049 
1050  if (field->is_map()) {
1052  const FieldDescriptor* value =
1053  field->message_type()->FindFieldByName("value");
1054  if (GetJavaType(value) == JAVATYPE_ENUM) {
1055  extra_bits |= kMapWithProto2EnumValue;
1056  }
1057  }
1058  return kMapFieldType | extra_bits;
1059  } else if (field->is_packed()) {
1061  } else if (field->is_repeated()) {
1062  return GetExperimentalJavaFieldTypeForRepeated(field) | extra_bits;
1063  } else if (IsRealOneof(field)) {
1065  kOneofFieldTypeOffset) |
1066  extra_bits;
1067  } else {
1068  return GetExperimentalJavaFieldTypeForSingular(field) | extra_bits;
1069  }
1070 }
1071 
1072 // Escape a UTF-16 character to be embedded in a Java string.
1074  if (code == '\t') {
1075  output->append("\\t");
1076  } else if (code == '\b') {
1077  output->append("\\b");
1078  } else if (code == '\n') {
1079  output->append("\\n");
1080  } else if (code == '\r') {
1081  output->append("\\r");
1082  } else if (code == '\f') {
1083  output->append("\\f");
1084  } else if (code == '\'') {
1085  output->append("\\'");
1086  } else if (code == '\"') {
1087  output->append("\\\"");
1088  } else if (code == '\\') {
1089  output->append("\\\\");
1090  } else if (code >= 0x20 && code <= 0x7f) {
1091  output->push_back(static_cast<char>(code));
1092  } else {
1093  output->append(StringPrintf("\\u%04x", code));
1094  }
1095 }
1096 
1097 } // namespace java
1098 } // namespace compiler
1099 } // namespace protobuf
1100 } // namespace google
google::protobuf::FieldDescriptor::Type
Type
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:521
google::protobuf::compiler::java::UnderscoresToCamelCase
std::string UnderscoresToCamelCase(const std::string &input, bool cap_next_letter)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:157
google::protobuf.internal::WireFormatLite::kFixed64Size
static const size_t kFixed64Size
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:688
google::protobuf::compiler::java::GenerateClearBit
std::string GenerateClearBit(int bitIndex)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:670
_gevent_test_main.result
result
Definition: _gevent_test_main.py:96
google::protobuf::compiler::java::UnderscoresToCamelCaseCheckReserved
std::string UnderscoresToCamelCaseCheckReserved(const FieldDescriptor *field)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:210
google::protobuf::value
const Descriptor::ReservedRange value
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:1954
google::protobuf::FieldDescriptor
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:515
google::protobuf::compiler::java::kThinSeparator
const char kThinSeparator[]
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:60
google::protobuf::compiler::java::ToUpperCh
char ToUpperCh(char ch)
Definition: protobuf/src/google/protobuf/compiler/java/java_helpers.cc:220
google::protobuf::compiler::java::bit_masks
const char * bit_masks[]
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:615
google::protobuf::compiler::java::JAVATYPE_INT
@ JAVATYPE_INT
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.h:206
google::protobuf::FieldDescriptor::CPPTYPE_STRING
@ CPPTYPE_STRING
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:562
google::protobuf::FieldDescriptor::TYPE_SFIXED64
@ TYPE_SFIXED64
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:542
google::protobuf::compiler::cpp::FieldName
std::string FieldName(const FieldDescriptor *field)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_helpers.cc:416
google::protobuf::compiler::java::GenerateGetBitMutableLocal
std::string GenerateGetBitMutableLocal(int bitIndex)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:687
google::protobuf::compiler::java::IsByteStringWithCustomDefaultValue
bool IsByteStringWithCustomDefaultValue(const FieldDescriptor *field)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:610
uint16_t
unsigned short uint16_t
Definition: stdint-msvc2008.h:79
google::protobuf::compiler::java::JAVATYPE_BOOLEAN
@ JAVATYPE_BOOLEAN
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.h:210
google::protobuf::compiler::java::GetExperimentalJavaFieldTypeForPacked
int GetExperimentalJavaFieldTypeForPacked(const FieldDescriptor *field)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:947
google::protobuf::compiler::java::HasRepeatedFields
bool HasRepeatedFields(const Descriptor *descriptor)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:880
google::protobuf::compiler::java::GenerateSetBit
std::string GenerateSetBit(int bitIndex)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:666
google::protobuf::compiler::java::JAVATYPE_LONG
@ JAVATYPE_LONG
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.h:207
FileDescriptor
Definition: bloaty/third_party/protobuf/ruby/ext/google/protobuf_c/protobuf.h:128
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
google::protobuf::FieldDescriptor::TYPE_BYTES
@ TYPE_BYTES
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:538
google::protobuf::FieldDescriptor::TYPE_DOUBLE
@ TYPE_DOUBLE
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:522
google::protobuf::compiler::java::ToCamelCase
std::string ToCamelCase(const std::string &input, bool lower_first)
Definition: protobuf/src/google/protobuf/compiler/java/java_helpers.cc:196
google::protobuf.internal::WireFormatLite::kBoolSize
static const size_t kBoolSize
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:693
file
Definition: bloaty/third_party/zlib/examples/gzappend.c:170
google::protobuf::CEscape
string CEscape(const string &src)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/strutil.cc:615
grpc::protobuf::io::Printer
GRPC_CUSTOM_PRINTER Printer
Definition: src/compiler/config.h:54
google::protobuf
Definition: bloaty/third_party/protobuf/benchmarks/util/data_proto2_to_proto3_util.h:12
google::protobuf::FieldDescriptor::TYPE_BOOL
@ TYPE_BOOL
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:533
google::protobuf::compiler::java::UnderscoresToCapitalizedCamelCase
std::string UnderscoresToCapitalizedCamelCase(const FieldDescriptor *field)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:198
setup.name
name
Definition: setup.py:542
google::protobuf::compiler::java::PrintEnumVerifierLogic
void PrintEnumVerifierLogic(io::Printer *printer, const FieldDescriptor *descriptor, const std::map< std::string, std::string > &variables, const char *var_name, const char *terminating_string, bool enforce_lite)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:136
google::protobuf::compiler::java::GetExperimentalJavaFieldTypeForSingular
int GetExperimentalJavaFieldTypeForSingular(const FieldDescriptor *field)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:924
google::protobuf::FieldDescriptor::TYPE_GROUP
@ TYPE_GROUP
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:535
google::protobuf::compiler::java::KotlinTypeName
const char * KotlinTypeName(JavaType type)
Definition: protobuf/src/google/protobuf/compiler/java/java_helpers.cc:473
google::protobuf.internal::WireFormatLite::kDoubleSize
static const size_t kDoubleSize
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:692
google::protobuf::FieldDescriptor::TYPE_INT64
@ TYPE_INT64
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:524
google::protobuf::compiler::java::GetExperimentalJavaFieldType
int GetExperimentalJavaFieldType(const FieldDescriptor *field)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:959
google::protobuf::StrCat
string StrCat(const AlphaNum &a, const AlphaNum &b)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/strutil.cc:1482
Descriptor
Definition: bloaty/third_party/protobuf/ruby/ext/google/protobuf_c/protobuf.h:121
google::protobuf::compiler::java::CamelCaseFieldName
std::string CamelCaseFieldName(const FieldDescriptor *field)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:222
google::protobuf::compiler::java::JAVATYPE_FLOAT
@ JAVATYPE_FLOAT
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.h:208
google::protobuf::compiler::java::IsRealOneof
bool IsRealOneof(const FieldDescriptor *descriptor)
Definition: protobuf/src/google/protobuf/compiler/java/java_helpers.h:364
uint32_t
unsigned int uint32_t
Definition: stdint-msvc2008.h:80
google::protobuf::EnumValueDescriptor::name
const std::string & name() const
google::protobuf::compiler::java::HasHasbit
bool HasHasbit(const FieldDescriptor *descriptor)
Definition: protobuf/src/google/protobuf/compiler/java/java_helpers.h:375
google::protobuf::compiler::java::CheckUtf8
bool CheckUtf8(const FieldDescriptor *descriptor)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.h:391
google::protobuf::compiler::java::ExtraMessageOrBuilderInterfaces
std::string ExtraMessageOrBuilderInterfaces(const Descriptor *descriptor)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:303
FieldDescriptor
Definition: bloaty/third_party/protobuf/ruby/ext/google/protobuf_c/protobuf.h:133
google::protobuf::FieldDescriptor::TYPE_ENUM
@ TYPE_ENUM
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:540
google::protobuf::compiler::java::GetExperimentalJavaFieldTypeForRepeated
int GetExperimentalJavaFieldTypeForRepeated(const FieldDescriptor *field)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:939
google::protobuf::compiler::java::IsDefaultValueJavaDefault
bool IsDefaultValueJavaDefault(const FieldDescriptor *field)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:578
google::protobuf::compiler::java::BoxedPrimitiveTypeName
const char * BoxedPrimitiveTypeName(JavaType type)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:398
gen_server_registered_method_bad_client_test_body.text
def text
Definition: gen_server_registered_method_bad_client_test_body.py:50
google::protobuf::compiler::java::IsForbiddenKotlin
bool IsForbiddenKotlin(const std::string &field_name)
Definition: protobuf/src/google/protobuf/compiler/java/java_helpers.cc:252
google::protobuf::compiler::java::SupportUnknownEnumValue
bool SupportUnknownEnumValue(const FileDescriptor *descriptor)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.h:368
int64_t
signed __int64 int64_t
Definition: stdint-msvc2008.h:89
gen_stats_data.c_str
def c_str(s, encoding='ascii')
Definition: gen_stats_data.py:38
gmock_output_test.output
output
Definition: bloaty/third_party/googletest/googlemock/test/gmock_output_test.py:175
google::protobuf::compiler::java::JavaPackageToDir
std::string JavaPackageToDir(std::string package_name)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:263
google::protobuf::compiler::java::kThickSeparator
const char kThickSeparator[]
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:58
google::protobuf::compiler::java::PrintGeneratedAnnotation
void PrintGeneratedAnnotation(io::Printer *printer, char delimiter, const std::string &annotation_file)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:122
google::protobuf::FieldDescriptor::TYPE_FIXED32
@ TYPE_FIXED32
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:532
google::protobuf::compiler::java::FileClassName
std::string FileClassName(const FileDescriptor *file, bool immutable)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:238
grpc::protobuf::MethodDescriptor
GRPC_CUSTOM_METHODDESCRIPTOR MethodDescriptor
Definition: include/grpcpp/impl/codegen/config_protobuf.h:87
google::protobuf::SimpleFtoa
string SimpleFtoa(float value)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/strutil.cc:1226
google::protobuf::compiler::java::GetJavaType
JavaType GetJavaType(const FieldDescriptor *field)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:319
google::protobuf::compiler::java::ExtraMessageInterfaces
std::string ExtraMessageInterfaces(const Descriptor *descriptor)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:290
google::protobuf::StringPrintf
string StringPrintf(const char *format,...)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/stringprintf.cc:109
google::protobuf::compiler::java::IsReferenceType
bool IsReferenceType(JavaType type)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:695
google::protobuf::compiler::java::GenerateSetBitToLocal
std::string GenerateSetBitToLocal(int bitIndex)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:683
number
int32_t number
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:850
google::protobuf::compiler::java::GetBitFieldName
std::string GetBitFieldName(int index)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:629
google::protobuf::compiler::java::FixedSize
int FixedSize(FieldDescriptor::Type type)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:774
google::protobuf::strings::Substitute
string Substitute(const char *format, const SubstituteArg &arg0, const SubstituteArg &arg1, const SubstituteArg &arg2, const SubstituteArg &arg3, const SubstituteArg &arg4, const SubstituteArg &arg5, const SubstituteArg &arg6, const SubstituteArg &arg7, const SubstituteArg &arg8, const SubstituteArg &arg9)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/substitute.cc:55
kReservedNames
const char *const kReservedNames[]
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.c:168
google::protobuf::FieldDescriptor::CPPTYPE_UINT64
@ CPPTYPE_UINT64
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:557
EnumDescriptor
Definition: bloaty/third_party/protobuf/ruby/ext/google/protobuf_c/protobuf.h:143
google::protobuf::compiler::java::FileJavaPackage
std::string FileJavaPackage(const FileDescriptor *file, bool immutable)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:243
google::protobuf::compiler::java::WriteUInt32ToUtf16CharSequence
void WriteUInt32ToUtf16CharSequence(uint32 number, std::vector< uint16 > *output)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:904
google::protobuf::compiler::java::JAVATYPE_BYTES
@ JAVATYPE_BYTES
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.h:212
setup.package_dir
package_dir
Definition: setup.py:553
google::protobuf::compiler::java::GetType
FieldDescriptor::Type GetType(const FieldDescriptor *field)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:315
google::protobuf::FieldDescriptor::CPPTYPE_INT64
@ CPPTYPE_INT64
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:555
google::protobuf::FieldDescriptor::TYPE_SINT32
@ TYPE_SINT32
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:543
java
FATAL
#define FATAL(msg)
Definition: task.h:88
google::protobuf.internal::WireFormatLite::kSFixed32Size
static const size_t kSFixed32Size
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:689
google::protobuf::SimpleDtoa
string SimpleDtoa(double value)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/strutil.cc:1221
field
const FieldDescriptor * field
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/parser_unittest.cc:2692
google::protobuf::FieldDescriptor::CPPTYPE_UINT32
@ CPPTYPE_UINT32
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:556
google::protobuf::FieldDescriptor::CPPTYPE_FLOAT
@ CPPTYPE_FLOAT
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:559
google::protobuf::FieldDescriptor::TYPE_SINT64
@ TYPE_SINT64
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:544
google::protobuf::compiler::java::ClassName
std::string ClassName(const Descriptor *descriptor)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:269
google::protobuf::compiler::java::FieldTypeName
const char * FieldTypeName(FieldDescriptor::Type field_type)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:443
google::protobuf::StringReplace
void StringReplace(const string &s, const string &oldsub, const string &newsub, bool replace_all, string *res)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/strutil.cc:148
google::protobuf::FieldDescriptor::TYPE_FLOAT
@ TYPE_FLOAT
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:523
google::protobuf::compiler::java::CapitalizedFieldName
std::string CapitalizedFieldName(const FieldDescriptor *field)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:202
google::protobuf::compiler::java::GetBitFieldNameForBit
std::string GetBitFieldNameForBit(int bitIndex)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:636
google::protobuf::FieldDescriptor::TYPE_SFIXED32
@ TYPE_SFIXED32
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:541
google::protobuf::compiler::java::UniqueFileScopeIdentifier
std::string UniqueFileScopeIdentifier(const Descriptor *descriptor)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:218
google::protobuf::compiler::java::GenerateSetBitMutableLocal
std::string GenerateSetBitMutableLocal(int bitIndex)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:691
index
int index
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:1184
google::protobuf::FieldDescriptor::CPPTYPE_BOOL
@ CPPTYPE_BOOL
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:560
google::protobuf::FieldDescriptor::CPPTYPE_DOUBLE
@ CPPTYPE_DOUBLE
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:558
profile_analyzer.fields
list fields
Definition: profile_analyzer.py:266
L
lua_State * L
Definition: upb/upb/bindings/lua/main.c:35
GOOGLE_ARRAYSIZE
#define GOOGLE_ARRAYSIZE(a)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/macros.h:88
google::protobuf::compiler::java::JAVATYPE_DOUBLE
@ JAVATYPE_DOUBLE
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.h:209
google::protobuf::FieldDescriptor::CPPTYPE_ENUM
@ CPPTYPE_ENUM
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:561
google::protobuf::compiler::java::ToLowerCh
char ToLowerCh(char ch)
Definition: protobuf/src/google/protobuf/compiler/java/java_helpers.cc:224
field_type
zend_class_entry * field_type
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/message.c:2030
prefix
static const char prefix[]
Definition: head_of_line_blocking.cc:28
GOOGLE_CHECK
#define GOOGLE_CHECK(EXPRESSION)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/logging.h:153
google::protobuf::Descriptor
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:231
google::protobuf::FieldDescriptor::TYPE_MESSAGE
@ TYPE_MESSAGE
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:536
google::protobuf::compiler::java::GetOneofStoredType
std::string GetOneofStoredType(const FieldDescriptor *field)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:431
google::protobuf::FieldDescriptor::TYPE_UINT32
@ TYPE_UINT32
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:539
google::protobuf::compiler::java::JAVATYPE_ENUM
@ JAVATYPE_ENUM
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.h:213
google::protobuf::compiler::java::AllAscii
bool AllAscii(const std::string &text)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:490
google::protobuf::compiler::java::ExtraBuilderInterfaces
std::string ExtraBuilderInterfaces(const Descriptor *descriptor)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:297
input
std::string input
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/tokenizer_unittest.cc:197
google::protobuf::ToUpper
string ToUpper(const string &s)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/strutil.h:193
google::protobuf::FieldDescriptor::TYPE_FIXED64
@ TYPE_FIXED64
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:531
google::protobuf::compiler::java::FieldConstantName
std::string FieldConstantName(const FieldDescriptor *field)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:309
google::protobuf::compiler::java::DefaultValue
std::string DefaultValue(const FieldDescriptor *field, bool immutable, ClassNameResolver *name_resolver)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:499
google::protobuf.internal::WireFormatLite::kFloatSize
static const size_t kFloatSize
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:691
google::protobuf::compiler::java::GenerateGetBit
std::string GenerateGetBit(int bitIndex)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:662
google::protobuf::compiler::java::JAVATYPE_MESSAGE
@ JAVATYPE_MESSAGE
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.h:214
google::protobuf::FieldDescriptor::CPPTYPE_MESSAGE
@ CPPTYPE_MESSAGE
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:563
google::protobuf::compiler::java::HasRequiredFields
bool HasRequiredFields(const Descriptor *type, std::unordered_set< const Descriptor * > *already_seen)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:840
google::protobuf::compiler::java::JAVATYPE_STRING
@ JAVATYPE_STRING
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.h:211
google::protobuf.internal::WireFormatLite::kFixed32Size
static const size_t kFixed32Size
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:687
asyncio_get_stats.type
type
Definition: asyncio_get_stats.py:37
code
Definition: bloaty/third_party/zlib/contrib/infback9/inftree9.h:24
google::protobuf::compiler::java::GetCapitalizedType
const char * GetCapitalizedType(const FieldDescriptor *field, bool immutable)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:724
ch
char ch
Definition: bloaty/third_party/googletest/googlemock/test/gmock-matchers_test.cc:3621
google::protobuf::FieldDescriptor::TYPE_INT32
@ TYPE_INT32
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:528
int32_t
signed int int32_t
Definition: stdint-msvc2008.h:77
google::protobuf::compiler::java::JavaType
JavaType
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.h:205
GOOGLE_LOG
#define GOOGLE_LOG(LEVEL)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/logging.h:146
google::protobuf::compiler::java::PrimitiveTypeName
const char * PrimitiveTypeName(JavaType type)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:365
google::protobuf::compiler::java::SortFieldsByNumber
const FieldDescriptor ** SortFieldsByNumber(const Descriptor *descriptor)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:824
descriptor
static const char descriptor[1336]
Definition: certs.upbdefs.c:16
google::protobuf.internal::WireFormatLite::kSFixed64Size
static const size_t kSFixed64Size
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:690
google::protobuf::FieldDescriptor::TYPE_STRING
@ TYPE_STRING
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:534
grpc::protobuf::ServiceDescriptor
GRPC_CUSTOM_SERVICEDESCRIPTOR ServiceDescriptor
Definition: include/grpcpp/impl/codegen/config_protobuf.h:88
compiler
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/plugin.pb.cc:21
google
Definition: bloaty/third_party/protobuf/benchmarks/util/data_proto2_to_proto3_util.h:11
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230
google::protobuf::method
const Descriptor::ReservedRange const EnumValueDescriptor method
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:1973
google::protobuf::FieldDescriptor::TYPE_UINT64
@ TYPE_UINT64
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:527
google::protobuf::compiler::java::GenerateGetBitFromLocal
std::string GenerateGetBitFromLocal(int bitIndex)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:679
google::protobuf::compiler::java::EscapeUtf16ToString
void EscapeUtf16ToString(uint16 code, std::string *output)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc:998
google::protobuf::FieldDescriptor::CPPTYPE_INT32
@ CPPTYPE_INT32
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:554


grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:09