Descriptors.java
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 package com.google.protobuf;
32 
33 import static com.google.protobuf.Internal.checkNotNull;
34 
52 import java.lang.ref.WeakReference;
53 import java.util.ArrayList;
54 import java.util.Arrays;
55 import java.util.Collections;
56 import java.util.HashMap;
57 import java.util.HashSet;
58 import java.util.List;
59 import java.util.Map;
60 import java.util.Set;
61 import java.util.WeakHashMap;
62 import java.util.logging.Logger;
63 
80 public final class Descriptors {
81  private static final Logger logger = Logger.getLogger(Descriptors.class.getName());
87  public static final class FileDescriptor extends GenericDescriptor {
89  @Override
90  public FileDescriptorProto toProto() {
91  return proto;
92  }
93 
95  @Override
96  public String getName() {
97  return proto.getName();
98  }
99 
101  @Override
103  return this;
104  }
105 
107  @Override
108  public String getFullName() {
109  return proto.getName();
110  }
111 
116  public String getPackage() {
117  return proto.getPackage();
118  }
119 
121  public FileOptions getOptions() {
122  return proto.getOptions();
123  }
124 
126  public List<Descriptor> getMessageTypes() {
127  return Collections.unmodifiableList(Arrays.asList(messageTypes));
128  }
129 
131  public List<EnumDescriptor> getEnumTypes() {
132  return Collections.unmodifiableList(Arrays.asList(enumTypes));
133  }
134 
136  public List<ServiceDescriptor> getServices() {
137  return Collections.unmodifiableList(Arrays.asList(services));
138  }
139 
141  public List<FieldDescriptor> getExtensions() {
142  return Collections.unmodifiableList(Arrays.asList(extensions));
143  }
144 
146  public List<FileDescriptor> getDependencies() {
147  return Collections.unmodifiableList(Arrays.asList(dependencies));
148  }
149 
151  public List<FileDescriptor> getPublicDependencies() {
152  return Collections.unmodifiableList(Arrays.asList(publicDependencies));
153  }
154 
156  public enum Syntax {
157  UNKNOWN("unknown"),
158  PROTO2("proto2"),
159  PROTO3("proto3");
160 
161  Syntax(String name) {
162  this.name = name;
163  }
164 
165  private final String name;
166  }
167 
169  public Syntax getSyntax() {
170  if (Syntax.PROTO3.name.equals(proto.getSyntax())) {
171  return Syntax.PROTO3;
172  }
173  return Syntax.PROTO2;
174  }
175 
183  // Don't allow looking up nested types. This will make optimization
184  // easier later.
185  if (name.indexOf('.') != -1) {
186  return null;
187  }
188  final String packageName = getPackage();
189  if (!packageName.isEmpty()) {
190  name = packageName + '.' + name;
191  }
192  final GenericDescriptor result = pool.findSymbol(name);
193  if (result != null && result instanceof Descriptor && result.getFile() == this) {
194  return (Descriptor) result;
195  } else {
196  return null;
197  }
198  }
199 
207  // Don't allow looking up nested types. This will make optimization
208  // easier later.
209  if (name.indexOf('.') != -1) {
210  return null;
211  }
212  final String packageName = getPackage();
213  if (!packageName.isEmpty()) {
214  name = packageName + '.' + name;
215  }
216  final GenericDescriptor result = pool.findSymbol(name);
217  if (result != null && result instanceof EnumDescriptor && result.getFile() == this) {
218  return (EnumDescriptor) result;
219  } else {
220  return null;
221  }
222  }
223 
231  // Don't allow looking up nested types. This will make optimization
232  // easier later.
233  if (name.indexOf('.') != -1) {
234  return null;
235  }
236  final String packageName = getPackage();
237  if (!packageName.isEmpty()) {
238  name = packageName + '.' + name;
239  }
240  final GenericDescriptor result = pool.findSymbol(name);
241  if (result != null && result instanceof ServiceDescriptor && result.getFile() == this) {
242  return (ServiceDescriptor) result;
243  } else {
244  return null;
245  }
246  }
247 
255  if (name.indexOf('.') != -1) {
256  return null;
257  }
258  final String packageName = getPackage();
259  if (!packageName.isEmpty()) {
260  name = packageName + '.' + name;
261  }
262  final GenericDescriptor result = pool.findSymbol(name);
263  if (result != null && result instanceof FieldDescriptor && result.getFile() == this) {
264  return (FieldDescriptor) result;
265  } else {
266  return null;
267  }
268  }
269 
279  public static FileDescriptor buildFrom(
280  final FileDescriptorProto proto, final FileDescriptor[] dependencies)
282  return buildFrom(proto, dependencies, false);
283  }
284 
296  public static FileDescriptor buildFrom(
297  final FileDescriptorProto proto,
299  final boolean allowUnknownDependencies)
301  // Building descriptors involves two steps: translating and linking.
302  // In the translation step (implemented by FileDescriptor's
303  // constructor), we build an object tree mirroring the
304  // FileDescriptorProto's tree and put all of the descriptors into the
305  // DescriptorPool's lookup tables. In the linking step, we look up all
306  // type references in the DescriptorPool, so that, for example, a
307  // FieldDescriptor for an embedded message contains a pointer directly
308  // to the Descriptor for that message's type. We also detect undefined
309  // types in the linking step.
310  final DescriptorPool pool = new DescriptorPool(dependencies, allowUnknownDependencies);
311  final FileDescriptor result =
312  new FileDescriptor(proto, dependencies, pool, allowUnknownDependencies);
313  result.crossLink();
314  return result;
315  }
316 
317  private static byte[] latin1Cat(final String[] strings) {
318  // Hack: We can't embed a raw byte array inside generated Java code
319  // (at least, not efficiently), but we can embed Strings. So, the
320  // protocol compiler embeds the FileDescriptorProto as a giant
321  // string literal which is passed to this function to construct the
322  // file's FileDescriptor. The string literal contains only 8-bit
323  // characters, each one representing a byte of the FileDescriptorProto's
324  // serialized form. So, if we convert it to bytes in ISO-8859-1, we
325  // should get the original bytes that we want.
326  // Literal strings are limited to 64k, so it may be split into multiple strings.
327  if (strings.length == 1) {
328  return strings[0].getBytes(Internal.ISO_8859_1);
329  }
330  StringBuilder descriptorData = new StringBuilder();
331  for (String part : strings) {
332  descriptorData.append(part);
333  }
334  return descriptorData.toString().getBytes(Internal.ISO_8859_1);
335  }
336 
337  private static FileDescriptor[] findDescriptors(
338  final Class<?> descriptorOuterClass,
339  final String[] dependencyClassNames,
340  final String[] dependencyFileNames) {
341  List<FileDescriptor> descriptors = new ArrayList<FileDescriptor>();
342  for (int i = 0; i < dependencyClassNames.length; i++) {
343  try {
344  Class<?> clazz = descriptorOuterClass.getClassLoader().loadClass(dependencyClassNames[i]);
345  descriptors.add((FileDescriptor) clazz.getField("descriptor").get(null));
346  } catch (Exception e) {
347  // We allow unknown dependencies by default. If a dependency cannot
348  // be found we only generate a warning.
349  logger.warning("Descriptors for \"" + dependencyFileNames[i] + "\" can not be found.");
350  }
351  }
352  return descriptors.toArray(new FileDescriptor[0]);
353  }
354 
359  @Deprecated
360  public static void internalBuildGeneratedFileFrom(
361  final String[] descriptorDataParts,
363  final InternalDescriptorAssigner descriptorAssigner) {
364  final byte[] descriptorBytes = latin1Cat(descriptorDataParts);
365 
366  FileDescriptorProto proto;
367  try {
368  proto = FileDescriptorProto.parseFrom(descriptorBytes);
369  } catch (InvalidProtocolBufferException e) {
370  throw new IllegalArgumentException(
371  "Failed to parse protocol buffer descriptor for generated code.", e);
372  }
373 
374  final FileDescriptor result;
375  try {
376  // When building descriptors for generated code, we allow unknown
377  // dependencies by default.
378  result = buildFrom(proto, dependencies, true);
379  } catch (DescriptorValidationException e) {
380  throw new IllegalArgumentException(
381  "Invalid embedded descriptor for \"" + proto.getName() + "\".", e);
382  }
383 
384  final ExtensionRegistry registry = descriptorAssigner.assignDescriptors(result);
385 
386  if (registry != null) {
387  // We must re-parse the proto using the registry.
388  try {
389  proto = FileDescriptorProto.parseFrom(descriptorBytes, registry);
390  } catch (InvalidProtocolBufferException e) {
391  throw new IllegalArgumentException(
392  "Failed to parse protocol buffer descriptor for generated code.", e);
393  }
394 
395  result.setProto(proto);
396  }
397  }
398 
404  final String[] descriptorDataParts,
405  final FileDescriptor[] dependencies) {
406  final byte[] descriptorBytes = latin1Cat(descriptorDataParts);
407 
408  FileDescriptorProto proto;
409  try {
410  proto = FileDescriptorProto.parseFrom(descriptorBytes);
411  } catch (InvalidProtocolBufferException e) {
412  throw new IllegalArgumentException(
413  "Failed to parse protocol buffer descriptor for generated code.", e);
414  }
415 
416  try {
417  // When building descriptors for generated code, we allow unknown
418  // dependencies by default.
419  return buildFrom(proto, dependencies, true);
420  } catch (DescriptorValidationException e) {
421  throw new IllegalArgumentException(
422  "Invalid embedded descriptor for \"" + proto.getName() + "\".", e);
423  }
424  }
425 
430  @Deprecated
431  public static void internalBuildGeneratedFileFrom(
432  final String[] descriptorDataParts,
433  final Class<?> descriptorOuterClass,
434  final String[] dependencyClassNames,
435  final String[] dependencyFileNames,
436  final InternalDescriptorAssigner descriptorAssigner) {
438  descriptorOuterClass, dependencyClassNames, dependencyFileNames);
440  descriptorDataParts, dependencies, descriptorAssigner);
441  }
442 
448  final String[] descriptorDataParts,
449  final Class<?> descriptorOuterClass,
450  final String[] dependencyClassNames,
451  final String[] dependencyFileNames) {
453  descriptorOuterClass, dependencyClassNames, dependencyFileNames);
454  return internalBuildGeneratedFileFrom(descriptorDataParts, dependencies);
455  }
456 
462  public static void internalUpdateFileDescriptor(
463  final FileDescriptor descriptor, final ExtensionRegistry registry) {
464  ByteString bytes = descriptor.proto.toByteString();
465  FileDescriptorProto proto;
466  try {
467  proto = FileDescriptorProto.parseFrom(bytes, registry);
468  } catch (InvalidProtocolBufferException e) {
469  throw new IllegalArgumentException(
470  "Failed to parse protocol buffer descriptor for generated code.", e);
471  }
472  descriptor.setProto(proto);
473  }
474 
487  @Deprecated
488  public interface InternalDescriptorAssigner {
490  }
491 
492  private FileDescriptorProto proto;
493  private final Descriptor[] messageTypes;
494  private final EnumDescriptor[] enumTypes;
495  private final ServiceDescriptor[] services;
496  private final FieldDescriptor[] extensions;
497  private final FileDescriptor[] dependencies;
499  private final DescriptorPool pool;
500 
501  private FileDescriptor(
502  final FileDescriptorProto proto,
504  final DescriptorPool pool,
505  boolean allowUnknownDependencies)
507  this.pool = pool;
508  this.proto = proto;
509  this.dependencies = dependencies.clone();
510  HashMap<String, FileDescriptor> nameToFileMap = new HashMap<String, FileDescriptor>();
511  for (FileDescriptor file : dependencies) {
512  nameToFileMap.put(file.getName(), file);
513  }
514  List<FileDescriptor> publicDependencies = new ArrayList<FileDescriptor>();
515  for (int i = 0; i < proto.getPublicDependencyCount(); i++) {
516  int index = proto.getPublicDependency(i);
517  if (index < 0 || index >= proto.getDependencyCount()) {
518  throw new DescriptorValidationException(this, "Invalid public dependency index.");
519  }
520  String name = proto.getDependency(index);
521  FileDescriptor file = nameToFileMap.get(name);
522  if (file == null) {
523  if (!allowUnknownDependencies) {
524  throw new DescriptorValidationException(this, "Invalid public dependency: " + name);
525  }
526  // Ignore unknown dependencies.
527  } else {
528  publicDependencies.add(file);
529  }
530  }
531  this.publicDependencies = new FileDescriptor[publicDependencies.size()];
532  publicDependencies.toArray(this.publicDependencies);
533 
534  pool.addPackage(getPackage(), this);
535 
536  messageTypes = new Descriptor[proto.getMessageTypeCount()];
537  for (int i = 0; i < proto.getMessageTypeCount(); i++) {
538  messageTypes[i] = new Descriptor(proto.getMessageType(i), this, null, i);
539  }
540 
541  enumTypes = new EnumDescriptor[proto.getEnumTypeCount()];
542  for (int i = 0; i < proto.getEnumTypeCount(); i++) {
543  enumTypes[i] = new EnumDescriptor(proto.getEnumType(i), this, null, i);
544  }
545 
546  services = new ServiceDescriptor[proto.getServiceCount()];
547  for (int i = 0; i < proto.getServiceCount(); i++) {
548  services[i] = new ServiceDescriptor(proto.getService(i), this, i);
549  }
550 
551  extensions = new FieldDescriptor[proto.getExtensionCount()];
552  for (int i = 0; i < proto.getExtensionCount(); i++) {
553  extensions[i] = new FieldDescriptor(proto.getExtension(i), this, null, i, true);
554  }
555  }
556 
558  FileDescriptor(String packageName, Descriptor message) throws DescriptorValidationException {
559  this.pool = new DescriptorPool(new FileDescriptor[0], true);
560  this.proto =
561  FileDescriptorProto.newBuilder()
562  .setName(message.getFullName() + ".placeholder.proto")
563  .setPackage(packageName)
564  .addMessageType(message.toProto())
565  .build();
566  this.dependencies = new FileDescriptor[0];
567  this.publicDependencies = new FileDescriptor[0];
568 
569  messageTypes = new Descriptor[] {message};
570  enumTypes = new EnumDescriptor[0];
571  services = new ServiceDescriptor[0];
572  extensions = new FieldDescriptor[0];
573 
574  pool.addPackage(packageName, this);
575  pool.addSymbol(message);
576  }
577 
579  private void crossLink() throws DescriptorValidationException {
580  for (final Descriptor messageType : messageTypes) {
581  messageType.crossLink();
582  }
583 
584  for (final ServiceDescriptor service : services) {
585  service.crossLink();
586  }
587 
588  for (final FieldDescriptor extension : extensions) {
589  extension.crossLink();
590  }
591  }
592 
601  private void setProto(final FileDescriptorProto proto) {
602  this.proto = proto;
603 
604  for (int i = 0; i < messageTypes.length; i++) {
605  messageTypes[i].setProto(proto.getMessageType(i));
606  }
607 
608  for (int i = 0; i < enumTypes.length; i++) {
609  enumTypes[i].setProto(proto.getEnumType(i));
610  }
611 
612  for (int i = 0; i < services.length; i++) {
613  services[i].setProto(proto.getService(i));
614  }
615 
616  for (int i = 0; i < extensions.length; i++) {
617  extensions[i].setProto(proto.getExtension(i));
618  }
619  }
620 
621  boolean supportsUnknownEnumValue() {
622  return getSyntax() == Syntax.PROTO3;
623  }
624  }
625 
626  // =================================================================
627 
629  public static final class Descriptor extends GenericDescriptor {
646  public int getIndex() {
647  return index;
648  }
649 
651  @Override
652  public DescriptorProto toProto() {
653  return proto;
654  }
655 
657  @Override
658  public String getName() {
659  return proto.getName();
660  }
661 
674  @Override
675  public String getFullName() {
676  return fullName;
677  }
678 
680  @Override
682  return file;
683  }
684 
687  return containingType;
688  }
689 
691  public MessageOptions getOptions() {
692  return proto.getOptions();
693  }
694 
696  public List<FieldDescriptor> getFields() {
697  return Collections.unmodifiableList(Arrays.asList(fields));
698  }
699 
701  public List<OneofDescriptor> getOneofs() {
702  return Collections.unmodifiableList(Arrays.asList(oneofs));
703  }
704 
706  public List<FieldDescriptor> getExtensions() {
707  return Collections.unmodifiableList(Arrays.asList(extensions));
708  }
709 
711  public List<Descriptor> getNestedTypes() {
712  return Collections.unmodifiableList(Arrays.asList(nestedTypes));
713  }
714 
716  public List<EnumDescriptor> getEnumTypes() {
717  return Collections.unmodifiableList(Arrays.asList(enumTypes));
718  }
719 
721  public boolean isExtensionNumber(final int number) {
722  for (final DescriptorProto.ExtensionRange range : proto.getExtensionRangeList()) {
723  if (range.getStart() <= number && number < range.getEnd()) {
724  return true;
725  }
726  }
727  return false;
728  }
729 
731  public boolean isReservedNumber(final int number) {
732  for (final DescriptorProto.ReservedRange range : proto.getReservedRangeList()) {
733  if (range.getStart() <= number && number < range.getEnd()) {
734  return true;
735  }
736  }
737  return false;
738  }
739 
741  public boolean isReservedName(final String name) {
742  checkNotNull(name);
743  for (final String reservedName : proto.getReservedNameList()) {
744  if (reservedName.equals(name)) {
745  return true;
746  }
747  }
748  return false;
749  }
750 
755  public boolean isExtendable() {
756  return proto.getExtensionRangeList().size() != 0;
757  }
758 
765  public FieldDescriptor findFieldByName(final String name) {
766  final GenericDescriptor result = file.pool.findSymbol(fullName + '.' + name);
767  if (result != null && result instanceof FieldDescriptor) {
768  return (FieldDescriptor) result;
769  } else {
770  return null;
771  }
772  }
773 
782  }
783 
790  public Descriptor findNestedTypeByName(final String name) {
791  final GenericDescriptor result = file.pool.findSymbol(fullName + '.' + name);
792  if (result != null && result instanceof Descriptor) {
793  return (Descriptor) result;
794  } else {
795  return null;
796  }
797  }
798 
805  public EnumDescriptor findEnumTypeByName(final String name) {
806  final GenericDescriptor result = file.pool.findSymbol(fullName + '.' + name);
807  if (result != null && result instanceof EnumDescriptor) {
808  return (EnumDescriptor) result;
809  } else {
810  return null;
811  }
812  }
813 
814  private final int index;
815  private DescriptorProto proto;
816  private final String fullName;
817  private final FileDescriptor file;
818  private final Descriptor containingType;
819  private final Descriptor[] nestedTypes;
820  private final EnumDescriptor[] enumTypes;
821  private final FieldDescriptor[] fields;
822  private final FieldDescriptor[] extensions;
823  private final OneofDescriptor[] oneofs;
824 
825  // Used to create a placeholder when the type cannot be found.
826  Descriptor(final String fullname) throws DescriptorValidationException {
827  String name = fullname;
828  String packageName = "";
829  int pos = fullname.lastIndexOf('.');
830  if (pos != -1) {
831  name = fullname.substring(pos + 1);
832  packageName = fullname.substring(0, pos);
833  }
834  this.index = 0;
835  this.proto =
836  DescriptorProto.newBuilder()
837  .setName(name)
838  .addExtensionRange(
839  DescriptorProto.ExtensionRange.newBuilder().setStart(1).setEnd(536870912).build())
840  .build();
841  this.fullName = fullname;
842  this.containingType = null;
843 
844  this.nestedTypes = new Descriptor[0];
845  this.enumTypes = new EnumDescriptor[0];
846  this.fields = new FieldDescriptor[0];
847  this.extensions = new FieldDescriptor[0];
848  this.oneofs = new OneofDescriptor[0];
849 
850  // Create a placeholder FileDescriptor to hold this message.
851  this.file = new FileDescriptor(packageName, this);
852  }
853 
854  private Descriptor(
855  final DescriptorProto proto,
856  final FileDescriptor file,
857  final Descriptor parent,
858  final int index)
860  this.index = index;
861  this.proto = proto;
862  fullName = computeFullName(file, parent, proto.getName());
863  this.file = file;
864  containingType = parent;
865 
866  oneofs = new OneofDescriptor[proto.getOneofDeclCount()];
867  for (int i = 0; i < proto.getOneofDeclCount(); i++) {
868  oneofs[i] = new OneofDescriptor(proto.getOneofDecl(i), file, this, i);
869  }
870 
871  nestedTypes = new Descriptor[proto.getNestedTypeCount()];
872  for (int i = 0; i < proto.getNestedTypeCount(); i++) {
873  nestedTypes[i] = new Descriptor(proto.getNestedType(i), file, this, i);
874  }
875 
876  enumTypes = new EnumDescriptor[proto.getEnumTypeCount()];
877  for (int i = 0; i < proto.getEnumTypeCount(); i++) {
878  enumTypes[i] = new EnumDescriptor(proto.getEnumType(i), file, this, i);
879  }
880 
881  fields = new FieldDescriptor[proto.getFieldCount()];
882  for (int i = 0; i < proto.getFieldCount(); i++) {
883  fields[i] = new FieldDescriptor(proto.getField(i), file, this, i, false);
884  }
885 
886  extensions = new FieldDescriptor[proto.getExtensionCount()];
887  for (int i = 0; i < proto.getExtensionCount(); i++) {
888  extensions[i] = new FieldDescriptor(proto.getExtension(i), file, this, i, true);
889  }
890 
891  for (int i = 0; i < proto.getOneofDeclCount(); i++) {
893  oneofs[i].fieldCount = 0;
894  }
895  for (int i = 0; i < proto.getFieldCount(); i++) {
896  OneofDescriptor oneofDescriptor = fields[i].getContainingOneof();
897  if (oneofDescriptor != null) {
898  oneofDescriptor.fields[oneofDescriptor.fieldCount++] = fields[i];
899  }
900  }
901 
902  file.pool.addSymbol(this);
903  }
904 
906  private void crossLink() throws DescriptorValidationException {
907  for (final Descriptor nestedType : nestedTypes) {
908  nestedType.crossLink();
909  }
910 
911  for (final FieldDescriptor field : fields) {
912  field.crossLink();
913  }
914 
915  for (final FieldDescriptor extension : extensions) {
916  extension.crossLink();
917  }
918  }
919 
921  private void setProto(final DescriptorProto proto) {
922  this.proto = proto;
923 
924  for (int i = 0; i < nestedTypes.length; i++) {
925  nestedTypes[i].setProto(proto.getNestedType(i));
926  }
927 
928  for (int i = 0; i < oneofs.length; i++) {
929  oneofs[i].setProto(proto.getOneofDecl(i));
930  }
931 
932  for (int i = 0; i < enumTypes.length; i++) {
933  enumTypes[i].setProto(proto.getEnumType(i));
934  }
935 
936  for (int i = 0; i < fields.length; i++) {
937  fields[i].setProto(proto.getField(i));
938  }
939 
940  for (int i = 0; i < extensions.length; i++) {
941  extensions[i].setProto(proto.getExtension(i));
942  }
943  }
944  }
945 
946  // =================================================================
947 
949  public static final class FieldDescriptor extends GenericDescriptor
950  implements Comparable<FieldDescriptor>, FieldSet.FieldDescriptorLite<FieldDescriptor> {
956  public int getIndex() {
957  return index;
958  }
959 
961  @Override
962  public FieldDescriptorProto toProto() {
963  return proto;
964  }
965 
967  @Override
968  public String getName() {
969  return proto.getName();
970  }
971 
973  @Override
974  public int getNumber() {
975  return proto.getNumber();
976  }
977 
983  @Override
984  public String getFullName() {
985  return fullName;
986  }
987 
989  public String getJsonName() {
990  return jsonName;
991  }
992 
998  return type.getJavaType();
999  }
1000 
1002  @Override
1004  return getLiteType().getJavaType();
1005  }
1006 
1008  @Override
1010  return file;
1011  }
1012 
1014  public Type getType() {
1015  return type;
1016  }
1017 
1019  @Override
1021  return table[type.ordinal()];
1022  }
1023 
1025  public boolean needsUtf8Check() {
1026  if (type != Type.STRING) {
1027  return false;
1028  }
1029  if (getContainingType().getOptions().getMapEntry()) {
1030  // Always enforce strict UTF-8 checking for map fields.
1031  return true;
1032  }
1033  if (getFile().getSyntax() == Syntax.PROTO3) {
1034  return true;
1035  }
1036  return getFile().getOptions().getJavaStringCheckUtf8();
1037  }
1038 
1039  public boolean isMapField() {
1040  return getType() == Type.MESSAGE
1041  && isRepeated()
1042  && getMessageType().getOptions().getMapEntry();
1043  }
1044 
1045  // I'm pretty sure values() constructs a new array every time, since there
1046  // is nothing stopping the caller from mutating the array. Therefore we
1047  // make a static copy here.
1048  private static final WireFormat.FieldType[] table = WireFormat.FieldType.values();
1049 
1051  public boolean isRequired() {
1052  return proto.getLabel() == FieldDescriptorProto.Label.LABEL_REQUIRED;
1053  }
1054 
1056  public boolean isOptional() {
1057  return proto.getLabel() == FieldDescriptorProto.Label.LABEL_OPTIONAL;
1058  }
1059 
1061  @Override
1062  public boolean isRepeated() {
1063  return proto.getLabel() == FieldDescriptorProto.Label.LABEL_REPEATED;
1064  }
1065 
1070  @Override
1071  public boolean isPacked() {
1072  if (!isPackable()) {
1073  return false;
1074  }
1075  if (getFile().getSyntax() == FileDescriptor.Syntax.PROTO2) {
1076  return getOptions().getPacked();
1077  } else {
1078  return !getOptions().hasPacked() || getOptions().getPacked();
1079  }
1080  }
1081 
1083  public boolean isPackable() {
1084  return isRepeated() && getLiteType().isPackable();
1085  }
1086 
1088  public boolean hasDefaultValue() {
1089  return proto.hasDefaultValue();
1090  }
1091 
1097  public Object getDefaultValue() {
1098  if (getJavaType() == JavaType.MESSAGE) {
1099  throw new UnsupportedOperationException(
1100  "FieldDescriptor.getDefaultValue() called on an embedded message field.");
1101  }
1102  return defaultValue;
1103  }
1104 
1106  public FieldOptions getOptions() {
1107  return proto.getOptions();
1108  }
1109 
1111  public boolean isExtension() {
1112  return proto.hasExtendee();
1113  }
1114 
1120  return containingType;
1121  }
1122 
1125  return containingOneof;
1126  }
1127 
1150  if (!isExtension()) {
1151  throw new UnsupportedOperationException(
1152  String.format("This field is not an extension. (%s)", fullName));
1153  }
1154  return extensionScope;
1155  }
1156 
1159  if (getJavaType() != JavaType.MESSAGE) {
1160  throw new UnsupportedOperationException(
1161  String.format("This field is not of message type. (%s)", fullName));
1162  }
1163  return messageType;
1164  }
1165 
1167  @Override
1169  if (getJavaType() != JavaType.ENUM) {
1170  throw new UnsupportedOperationException(
1171  String.format("This field is not of enum type. (%s)", fullName));
1172  }
1173  return enumType;
1174  }
1175 
1184  @Override
1185  public int compareTo(final FieldDescriptor other) {
1186  if (other.containingType != containingType) {
1187  throw new IllegalArgumentException(
1188  "FieldDescriptors can only be compared to other FieldDescriptors "
1189  + "for fields of the same message type.");
1190  }
1191  return getNumber() - other.getNumber();
1192  }
1193 
1194  @Override
1195  public String toString() {
1196  return getFullName();
1197  }
1198 
1199  private final int index;
1200 
1201  private FieldDescriptorProto proto;
1202  private final String fullName;
1203  private final String jsonName;
1204  private final FileDescriptor file;
1206 
1207  // Possibly initialized during cross-linking.
1208  private Type type;
1213  private Object defaultValue;
1214 
1215  public enum Type {
1234 
1235  Type(final JavaType javaType) {
1236  this.javaType = javaType;
1237  }
1238 
1240 
1241  public FieldDescriptorProto.Type toProto() {
1242  return FieldDescriptorProto.Type.forNumber(ordinal() + 1);
1243  }
1244 
1246  return javaType;
1247  }
1248 
1249  public static Type valueOf(final FieldDescriptorProto.Type type) {
1250  return values()[type.getNumber() - 1];
1251  }
1252  }
1253 
1254  static {
1255  // Refuse to init if someone added a new declared type.
1256  if (Type.values().length != FieldDescriptorProto.Type.values().length) {
1257  throw new RuntimeException(
1258  "descriptor.proto has a new declared type but Descriptors.java wasn't updated.");
1259  }
1260  }
1261 
1262  public enum JavaType {
1263  INT(0),
1264  LONG(0L),
1266  DOUBLE(0D),
1267  BOOLEAN(false),
1268  STRING(""),
1270  ENUM(null),
1271  MESSAGE(null);
1272 
1273  JavaType(final Object defaultDefault) {
1274  this.defaultDefault = defaultDefault;
1275  }
1276 
1281  private final Object defaultDefault;
1282  }
1283 
1284  // This method should match exactly with the ToJsonName() function in C++
1285  // descriptor.cc.
1286  private static String fieldNameToJsonName(String name) {
1287  final int length = name.length();
1288  StringBuilder result = new StringBuilder(length);
1289  boolean isNextUpperCase = false;
1290  for (int i = 0; i < length; i++) {
1291  char ch = name.charAt(i);
1292  if (ch == '_') {
1293  isNextUpperCase = true;
1294  } else if (isNextUpperCase) {
1295  // This closely matches the logic for ASCII characters in:
1296  // http://google3/google/protobuf/descriptor.cc?l=249-251&rcl=228891689
1297  if ('a' <= ch && ch <= 'z') {
1298  ch = (char) (ch - 'a' + 'A');
1299  }
1300  result.append(ch);
1301  isNextUpperCase = false;
1302  } else {
1303  result.append(ch);
1304  }
1305  }
1306  return result.toString();
1307  }
1308 
1310  final FieldDescriptorProto proto,
1311  final FileDescriptor file,
1312  final Descriptor parent,
1313  final int index,
1314  final boolean isExtension)
1316  this.index = index;
1317  this.proto = proto;
1318  fullName = computeFullName(file, parent, proto.getName());
1319  this.file = file;
1320  if (proto.hasJsonName()) {
1321  jsonName = proto.getJsonName();
1322  } else {
1323  jsonName = fieldNameToJsonName(proto.getName());
1324  }
1325 
1326  if (proto.hasType()) {
1327  type = Type.valueOf(proto.getType());
1328  }
1329 
1330  if (getNumber() <= 0) {
1331  throw new DescriptorValidationException(this, "Field numbers must be positive integers.");
1332  }
1333 
1334  if (isExtension) {
1335  if (!proto.hasExtendee()) {
1337  this, "FieldDescriptorProto.extendee not set for extension field.");
1338  }
1339  containingType = null; // Will be filled in when cross-linking
1340  if (parent != null) {
1341  extensionScope = parent;
1342  } else {
1343  extensionScope = null;
1344  }
1345 
1346  if (proto.hasOneofIndex()) {
1348  this, "FieldDescriptorProto.oneof_index set for extension field.");
1349  }
1350  containingOneof = null;
1351  } else {
1352  if (proto.hasExtendee()) {
1354  this, "FieldDescriptorProto.extendee set for non-extension field.");
1355  }
1356  containingType = parent;
1357 
1358  if (proto.hasOneofIndex()) {
1359  if (proto.getOneofIndex() < 0
1360  || proto.getOneofIndex() >= parent.toProto().getOneofDeclCount()) {
1362  this,
1363  "FieldDescriptorProto.oneof_index is out of range for type " + parent.getName());
1364  }
1365  containingOneof = parent.getOneofs().get(proto.getOneofIndex());
1367  } else {
1368  containingOneof = null;
1369  }
1370  extensionScope = null;
1371  }
1372 
1373  file.pool.addSymbol(this);
1374  }
1375 
1378  if (proto.hasExtendee()) {
1379  final GenericDescriptor extendee =
1380  file.pool.lookupSymbol(
1381  proto.getExtendee(), this, DescriptorPool.SearchFilter.TYPES_ONLY);
1382  if (!(extendee instanceof Descriptor)) {
1384  this, '\"' + proto.getExtendee() + "\" is not a message type.");
1385  }
1386  containingType = (Descriptor) extendee;
1387 
1390  this,
1391  '\"'
1393  + "\" does not declare "
1394  + getNumber()
1395  + " as an extension number.");
1396  }
1397  }
1398 
1399  if (proto.hasTypeName()) {
1400  final GenericDescriptor typeDescriptor =
1401  file.pool.lookupSymbol(
1402  proto.getTypeName(), this, DescriptorPool.SearchFilter.TYPES_ONLY);
1403 
1404  if (!proto.hasType()) {
1405  // Choose field type based on symbol.
1406  if (typeDescriptor instanceof Descriptor) {
1407  type = Type.MESSAGE;
1408  } else if (typeDescriptor instanceof EnumDescriptor) {
1409  type = Type.ENUM;
1410  } else {
1412  this, '\"' + proto.getTypeName() + "\" is not a type.");
1413  }
1414  }
1415 
1416  if (getJavaType() == JavaType.MESSAGE) {
1417  if (!(typeDescriptor instanceof Descriptor)) {
1419  this, '\"' + proto.getTypeName() + "\" is not a message type.");
1420  }
1421  messageType = (Descriptor) typeDescriptor;
1422 
1423  if (proto.hasDefaultValue()) {
1424  throw new DescriptorValidationException(this, "Messages can't have default values.");
1425  }
1426  } else if (getJavaType() == JavaType.ENUM) {
1427  if (!(typeDescriptor instanceof EnumDescriptor)) {
1429  this, '\"' + proto.getTypeName() + "\" is not an enum type.");
1430  }
1431  enumType = (EnumDescriptor) typeDescriptor;
1432  } else {
1433  throw new DescriptorValidationException(this, "Field with primitive type has type_name.");
1434  }
1435  } else {
1436  if (getJavaType() == JavaType.MESSAGE || getJavaType() == JavaType.ENUM) {
1438  this, "Field with message or enum type missing type_name.");
1439  }
1440  }
1441 
1442  // Only repeated primitive fields may be packed.
1443  if (proto.getOptions().getPacked() && !isPackable()) {
1445  this, "[packed = true] can only be specified for repeated primitive fields.");
1446  }
1447 
1448  // We don't attempt to parse the default value until here because for
1449  // enums we need the enum type's descriptor.
1450  if (proto.hasDefaultValue()) {
1451  if (isRepeated()) {
1453  this, "Repeated fields cannot have default values.");
1454  }
1455 
1456  try {
1457  switch (getType()) {
1458  case INT32:
1459  case SINT32:
1460  case SFIXED32:
1461  defaultValue = TextFormat.parseInt32(proto.getDefaultValue());
1462  break;
1463  case UINT32:
1464  case FIXED32:
1465  defaultValue = TextFormat.parseUInt32(proto.getDefaultValue());
1466  break;
1467  case INT64:
1468  case SINT64:
1469  case SFIXED64:
1470  defaultValue = TextFormat.parseInt64(proto.getDefaultValue());
1471  break;
1472  case UINT64:
1473  case FIXED64:
1474  defaultValue = TextFormat.parseUInt64(proto.getDefaultValue());
1475  break;
1476  case FLOAT:
1477  if (proto.getDefaultValue().equals("inf")) {
1478  defaultValue = Float.POSITIVE_INFINITY;
1479  } else if (proto.getDefaultValue().equals("-inf")) {
1480  defaultValue = Float.NEGATIVE_INFINITY;
1481  } else if (proto.getDefaultValue().equals("nan")) {
1482  defaultValue = Float.NaN;
1483  } else {
1484  defaultValue = Float.valueOf(proto.getDefaultValue());
1485  }
1486  break;
1487  case DOUBLE:
1488  if (proto.getDefaultValue().equals("inf")) {
1489  defaultValue = Double.POSITIVE_INFINITY;
1490  } else if (proto.getDefaultValue().equals("-inf")) {
1491  defaultValue = Double.NEGATIVE_INFINITY;
1492  } else if (proto.getDefaultValue().equals("nan")) {
1493  defaultValue = Double.NaN;
1494  } else {
1495  defaultValue = Double.valueOf(proto.getDefaultValue());
1496  }
1497  break;
1498  case BOOL:
1499  defaultValue = Boolean.valueOf(proto.getDefaultValue());
1500  break;
1501  case STRING:
1502  defaultValue = proto.getDefaultValue();
1503  break;
1504  case BYTES:
1505  try {
1506  defaultValue = TextFormat.unescapeBytes(proto.getDefaultValue());
1509  this, "Couldn't parse default value: " + e.getMessage(), e);
1510  }
1511  break;
1512  case ENUM:
1513  defaultValue = enumType.findValueByName(proto.getDefaultValue());
1514  if (defaultValue == null) {
1516  this, "Unknown enum default value: \"" + proto.getDefaultValue() + '\"');
1517  }
1518  break;
1519  case MESSAGE:
1520  case GROUP:
1521  throw new DescriptorValidationException(this, "Message type had default value.");
1522  }
1523  } catch (NumberFormatException e) {
1525  this, "Could not parse default value: \"" + proto.getDefaultValue() + '\"', e);
1526  }
1527  } else {
1528  // Determine the default default for this field.
1529  if (isRepeated()) {
1530  defaultValue = Collections.emptyList();
1531  } else {
1532  switch (getJavaType()) {
1533  case ENUM:
1534  // We guarantee elsewhere that an enum type always has at least
1535  // one possible value.
1536  defaultValue = enumType.getValues().get(0);
1537  break;
1538  case MESSAGE:
1539  defaultValue = null;
1540  break;
1541  default:
1543  break;
1544  }
1545  }
1546  }
1547 
1548  if (!isExtension()) {
1549  file.pool.addFieldByNumber(this);
1550  }
1551 
1552  if (containingType != null && containingType.getOptions().getMessageSetWireFormat()) {
1553  if (isExtension()) {
1554  if (!isOptional() || getType() != Type.MESSAGE) {
1556  this, "Extensions of MessageSets must be optional messages.");
1557  }
1558  } else {
1560  this, "MessageSets cannot have fields, only extensions.");
1561  }
1562  }
1563  }
1564 
1566  private void setProto(final FieldDescriptorProto proto) {
1567  this.proto = proto;
1568  }
1569 
1571  @Override
1573  // FieldDescriptors are only used with non-lite messages so we can just
1574  // down-cast and call mergeFrom directly.
1575  return ((Message.Builder) to).mergeFrom((Message) from);
1576  }
1577 
1578  }
1579 
1580  // =================================================================
1581 
1583  public static final class EnumDescriptor extends GenericDescriptor
1584  implements Internal.EnumLiteMap<EnumValueDescriptor> {
1590  public int getIndex() {
1591  return index;
1592  }
1593 
1595  @Override
1596  public EnumDescriptorProto toProto() {
1597  return proto;
1598  }
1599 
1601  @Override
1602  public String getName() {
1603  return proto.getName();
1604  }
1605 
1611  @Override
1612  public String getFullName() {
1613  return fullName;
1614  }
1615 
1617  @Override
1619  return file;
1620  }
1621 
1624  return containingType;
1625  }
1626 
1628  public EnumOptions getOptions() {
1629  return proto.getOptions();
1630  }
1631 
1633  public List<EnumValueDescriptor> getValues() {
1634  return Collections.unmodifiableList(Arrays.asList(values));
1635  }
1636 
1644  final GenericDescriptor result = file.pool.findSymbol(fullName + '.' + name);
1645  if (result != null && result instanceof EnumValueDescriptor) {
1646  return (EnumValueDescriptor) result;
1647  } else {
1648  return null;
1649  }
1650  }
1651 
1659  @Override
1662  }
1663 
1670  if (result != null) {
1671  return result;
1672  }
1673  // The number represents an unknown enum value.
1674  synchronized (this) {
1675  // Descriptors are compared by object identity so for the same number
1676  // we need to return the same EnumValueDescriptor object. This means
1677  // we have to store created EnumValueDescriptors. However, as there
1678  // are potentially 2G unknown enum values, storing all of these
1679  // objects persistently will consume lots of memory for long-running
1680  // services and it's also unnecessary as not many EnumValueDescriptors
1681  // will be used at the same time.
1682  //
1683  // To solve the problem we take advantage of Java's weak references and
1684  // rely on gc to release unused descriptors.
1685  //
1686  // Here is how it works:
1687  // * We store unknown EnumValueDescriptors in a WeakHashMap with the
1688  // value being a weak reference to the descriptor.
1689  // * The descriptor holds a strong reference to the key so as long
1690  // as the EnumValueDescriptor is in use, the key will be there
1691  // and the corresponding map entry will be there. Following-up
1692  // queries with the same number will return the same descriptor.
1693  // * If the user no longer uses an unknown EnumValueDescriptor,
1694  // it will be gc-ed since we only hold a weak reference to it in
1695  // the map. The key in the corresponding map entry will also be
1696  // gc-ed as the only strong reference to it is in the descriptor
1697  // which is just gc-ed. With the key being gone WeakHashMap will
1698  // then remove the whole entry. This way unknown descriptors will
1699  // be freed automatically and we don't need to do anything to
1700  // clean-up unused map entries.
1701 
1702  // Note: We must use "new Integer(number)" here because we don't want
1703  // these Integer objects to be cached.
1704  Integer key = new Integer(number);
1705  WeakReference<EnumValueDescriptor> reference = unknownValues.get(key);
1706  if (reference != null) {
1707  result = reference.get();
1708  }
1709  if (result == null) {
1710  result = new EnumValueDescriptor(file, this, key);
1711  unknownValues.put(key, new WeakReference<EnumValueDescriptor>(result));
1712  }
1713  }
1714  return result;
1715  }
1716 
1717  // Used in tests only.
1718  int getUnknownEnumValueDescriptorCount() {
1719  return unknownValues.size();
1720  }
1721 
1722  private final int index;
1723  private EnumDescriptorProto proto;
1724  private final String fullName;
1725  private final FileDescriptor file;
1728  private final WeakHashMap<Integer, WeakReference<EnumValueDescriptor>> unknownValues =
1729  new WeakHashMap<Integer, WeakReference<EnumValueDescriptor>>();
1730 
1732  final EnumDescriptorProto proto,
1733  final FileDescriptor file,
1734  final Descriptor parent,
1735  final int index)
1737  this.index = index;
1738  this.proto = proto;
1739  fullName = computeFullName(file, parent, proto.getName());
1740  this.file = file;
1741  containingType = parent;
1742 
1743  if (proto.getValueCount() == 0) {
1744  // We cannot allow enums with no values because this would mean there
1745  // would be no valid default value for fields of this type.
1746  throw new DescriptorValidationException(this, "Enums must contain at least one value.");
1747  }
1748 
1749  values = new EnumValueDescriptor[proto.getValueCount()];
1750  for (int i = 0; i < proto.getValueCount(); i++) {
1751  values[i] = new EnumValueDescriptor(proto.getValue(i), file, this, i);
1752  }
1753 
1754  file.pool.addSymbol(this);
1755  }
1756 
1758  private void setProto(final EnumDescriptorProto proto) {
1759  this.proto = proto;
1760 
1761  for (int i = 0; i < values.length; i++) {
1762  values[i].setProto(proto.getValue(i));
1763  }
1764  }
1765  }
1766 
1767  // =================================================================
1768 
1774  public static final class EnumValueDescriptor extends GenericDescriptor
1775  implements Internal.EnumLite {
1781  public int getIndex() {
1782  return index;
1783  }
1784 
1786  @Override
1787  public EnumValueDescriptorProto toProto() {
1788  return proto;
1789  }
1790 
1792  @Override
1793  public String getName() {
1794  return proto.getName();
1795  }
1796 
1798  @Override
1799  public int getNumber() {
1800  return proto.getNumber();
1801  }
1802 
1803  @Override
1804  public String toString() {
1805  return proto.getName();
1806  }
1807 
1813  @Override
1814  public String getFullName() {
1815  return fullName;
1816  }
1817 
1819  @Override
1821  return file;
1822  }
1823 
1826  return type;
1827  }
1828 
1830  public EnumValueOptions getOptions() {
1831  return proto.getOptions();
1832  }
1833 
1834  private final int index;
1835  private EnumValueDescriptorProto proto;
1836  private final String fullName;
1837  private final FileDescriptor file;
1838  private final EnumDescriptor type;
1839 
1841  final EnumValueDescriptorProto proto,
1842  final FileDescriptor file,
1843  final EnumDescriptor parent,
1844  final int index)
1846  this.index = index;
1847  this.proto = proto;
1848  this.file = file;
1849  type = parent;
1850 
1851  fullName = parent.getFullName() + '.' + proto.getName();
1852 
1853  file.pool.addSymbol(this);
1854  file.pool.addEnumValueByNumber(this);
1855  }
1856 
1857  // Create an unknown enum value.
1859  final FileDescriptor file, final EnumDescriptor parent, final Integer number) {
1860  String name = "UNKNOWN_ENUM_VALUE_" + parent.getName() + "_" + number;
1861  EnumValueDescriptorProto proto =
1862  EnumValueDescriptorProto.newBuilder().setName(name).setNumber(number).build();
1863  this.index = -1;
1864  this.proto = proto;
1865  this.file = file;
1866  this.type = parent;
1867  this.fullName = parent.getFullName() + '.' + proto.getName();
1868 
1869  // Don't add this descriptor into pool.
1870  }
1871 
1873  private void setProto(final EnumValueDescriptorProto proto) {
1874  this.proto = proto;
1875  }
1876  }
1877 
1878  // =================================================================
1879 
1881  public static final class ServiceDescriptor extends GenericDescriptor {
1885  public int getIndex() {
1886  return index;
1887  }
1888 
1890  @Override
1891  public ServiceDescriptorProto toProto() {
1892  return proto;
1893  }
1894 
1896  @Override
1897  public String getName() {
1898  return proto.getName();
1899  }
1900 
1906  @Override
1907  public String getFullName() {
1908  return fullName;
1909  }
1910 
1912  @Override
1914  return file;
1915  }
1916 
1918  public ServiceOptions getOptions() {
1919  return proto.getOptions();
1920  }
1921 
1923  public List<MethodDescriptor> getMethods() {
1924  return Collections.unmodifiableList(Arrays.asList(methods));
1925  }
1926 
1933  public MethodDescriptor findMethodByName(final String name) {
1934  final GenericDescriptor result = file.pool.findSymbol(fullName + '.' + name);
1935  if (result != null && result instanceof MethodDescriptor) {
1936  return (MethodDescriptor) result;
1937  } else {
1938  return null;
1939  }
1940  }
1941 
1942  private final int index;
1943  private ServiceDescriptorProto proto;
1944  private final String fullName;
1945  private final FileDescriptor file;
1947 
1949  final ServiceDescriptorProto proto, final FileDescriptor file, final int index)
1951  this.index = index;
1952  this.proto = proto;
1953  fullName = computeFullName(file, null, proto.getName());
1954  this.file = file;
1955 
1956  methods = new MethodDescriptor[proto.getMethodCount()];
1957  for (int i = 0; i < proto.getMethodCount(); i++) {
1958  methods[i] = new MethodDescriptor(proto.getMethod(i), file, this, i);
1959  }
1960 
1961  file.pool.addSymbol(this);
1962  }
1963 
1965  for (final MethodDescriptor method : methods) {
1966  method.crossLink();
1967  }
1968  }
1969 
1971  private void setProto(final ServiceDescriptorProto proto) {
1972  this.proto = proto;
1973 
1974  for (int i = 0; i < methods.length; i++) {
1975  methods[i].setProto(proto.getMethod(i));
1976  }
1977  }
1978  }
1979 
1980  // =================================================================
1981 
1983  public static final class MethodDescriptor extends GenericDescriptor {
1987  public int getIndex() {
1988  return index;
1989  }
1990 
1992  @Override
1993  public MethodDescriptorProto toProto() {
1994  return proto;
1995  }
1996 
1998  @Override
1999  public String getName() {
2000  return proto.getName();
2001  }
2002 
2008  @Override
2009  public String getFullName() {
2010  return fullName;
2011  }
2012 
2014  @Override
2016  return file;
2017  }
2018 
2021  return service;
2022  }
2023 
2026  return inputType;
2027  }
2028 
2031  return outputType;
2032  }
2033 
2035  public boolean isClientStreaming() {
2036  return proto.getClientStreaming();
2037  }
2038 
2040  public boolean isServerStreaming() {
2041  return proto.getServerStreaming();
2042  }
2043 
2045  public MethodOptions getOptions() {
2046  return proto.getOptions();
2047  }
2048 
2049  private final int index;
2050  private MethodDescriptorProto proto;
2051  private final String fullName;
2052  private final FileDescriptor file;
2054 
2055  // Initialized during cross-linking.
2058 
2060  final MethodDescriptorProto proto,
2061  final FileDescriptor file,
2062  final ServiceDescriptor parent,
2063  final int index)
2065  this.index = index;
2066  this.proto = proto;
2067  this.file = file;
2068  service = parent;
2069 
2070  fullName = parent.getFullName() + '.' + proto.getName();
2071 
2072  file.pool.addSymbol(this);
2073  }
2074 
2076  final GenericDescriptor input =
2077  file.pool.lookupSymbol(
2078  proto.getInputType(), this, DescriptorPool.SearchFilter.TYPES_ONLY);
2079  if (!(input instanceof Descriptor)) {
2081  this, '\"' + proto.getInputType() + "\" is not a message type.");
2082  }
2084 
2085  final GenericDescriptor output =
2086  file.pool.lookupSymbol(
2087  proto.getOutputType(), this, DescriptorPool.SearchFilter.TYPES_ONLY);
2088  if (!(output instanceof Descriptor)) {
2090  this, '\"' + proto.getOutputType() + "\" is not a message type.");
2091  }
2093  }
2094 
2096  private void setProto(final MethodDescriptorProto proto) {
2097  this.proto = proto;
2098  }
2099  }
2100 
2101  // =================================================================
2102 
2103  private static String computeFullName(
2104  final FileDescriptor file, final Descriptor parent, final String name) {
2105  if (parent != null) {
2106  return parent.getFullName() + '.' + name;
2107  }
2108 
2109  final String packageName = file.getPackage();
2110  if (!packageName.isEmpty()) {
2111  return packageName + '.' + name;
2112  }
2113 
2114  return name;
2115  }
2116 
2117  // =================================================================
2118 
2123  public abstract static class GenericDescriptor {
2124 
2125  // Private constructor to prevent subclasses outside of com.google.protobuf.Descriptors
2126  private GenericDescriptor() {}
2127 
2128  public abstract Message toProto();
2129 
2130  public abstract String getName();
2131 
2132  public abstract String getFullName();
2133 
2134  public abstract FileDescriptor getFile();
2135  }
2136 
2138  public static class DescriptorValidationException extends Exception {
2139  private static final long serialVersionUID = 5750205775490483148L;
2140 
2142  public String getProblemSymbolName() {
2143  return name;
2144  }
2145 
2148  return proto;
2149  }
2150 
2152  public String getDescription() {
2153  return description;
2154  }
2155 
2156  private final String name;
2157  private final Message proto;
2158  private final String description;
2159 
2161  final GenericDescriptor problemDescriptor, final String description) {
2162  super(problemDescriptor.getFullName() + ": " + description);
2163 
2164  // Note that problemDescriptor may be partially uninitialized, so we
2165  // don't want to expose it directly to the user. So, we only provide
2166  // the name and the original proto.
2167  name = problemDescriptor.getFullName();
2168  proto = problemDescriptor.toProto();
2169  this.description = description;
2170  }
2171 
2173  final GenericDescriptor problemDescriptor,
2174  final String description,
2175  final Throwable cause) {
2176  this(problemDescriptor, description);
2177  initCause(cause);
2178  }
2179 
2181  final FileDescriptor problemDescriptor, final String description) {
2182  super(problemDescriptor.getName() + ": " + description);
2183 
2184  // Note that problemDescriptor may be partially uninitialized, so we
2185  // don't want to expose it directly to the user. So, we only provide
2186  // the name and the original proto.
2187  name = problemDescriptor.getName();
2188  proto = problemDescriptor.toProto();
2189  this.description = description;
2190  }
2191  }
2192 
2193  // =================================================================
2194 
2199  private static final class DescriptorPool {
2200 
2202  enum SearchFilter {
2203  TYPES_ONLY,
2204  AGGREGATES_ONLY,
2205  ALL_SYMBOLS
2206  }
2207 
2209  this.dependencies = new HashSet<FileDescriptor>();
2210  this.allowUnknownDependencies = allowUnknownDependencies;
2211 
2212  for (int i = 0; i < dependencies.length; i++) {
2213  this.dependencies.add(dependencies[i]);
2215  }
2216 
2217  for (final FileDescriptor dependency : this.dependencies) {
2218  try {
2219  addPackage(dependency.getPackage(), dependency);
2220  } catch (DescriptorValidationException e) {
2221  // Can't happen, because addPackage() only fails when the name
2222  // conflicts with a non-package, but we have not yet added any
2223  // non-packages at this point.
2224  throw new AssertionError(e);
2225  }
2226  }
2227  }
2228 
2230  private void importPublicDependencies(final FileDescriptor file) {
2231  for (FileDescriptor dependency : file.getPublicDependencies()) {
2232  if (dependencies.add(dependency)) {
2233  importPublicDependencies(dependency);
2234  }
2235  }
2236  }
2237 
2238  private final Set<FileDescriptor> dependencies;
2239  private boolean allowUnknownDependencies;
2240 
2241  private final Map<String, GenericDescriptor> descriptorsByName =
2242  new HashMap<String, GenericDescriptor>();
2243  private final Map<DescriptorIntPair, FieldDescriptor> fieldsByNumber =
2244  new HashMap<DescriptorIntPair, FieldDescriptor>();
2245  private final Map<DescriptorIntPair, EnumValueDescriptor> enumValuesByNumber =
2246  new HashMap<DescriptorIntPair, EnumValueDescriptor>();
2247 
2249  GenericDescriptor findSymbol(final String fullName) {
2250  return findSymbol(fullName, SearchFilter.ALL_SYMBOLS);
2251  }
2252 
2257  GenericDescriptor findSymbol(final String fullName, final SearchFilter filter) {
2258  GenericDescriptor result = descriptorsByName.get(fullName);
2259  if (result != null) {
2260  if ((filter == SearchFilter.ALL_SYMBOLS)
2261  || ((filter == SearchFilter.TYPES_ONLY) && isType(result))
2262  || ((filter == SearchFilter.AGGREGATES_ONLY) && isAggregate(result))) {
2263  return result;
2264  }
2265  }
2266 
2267  for (final FileDescriptor dependency : dependencies) {
2268  result = dependency.pool.descriptorsByName.get(fullName);
2269  if (result != null) {
2270  if ((filter == SearchFilter.ALL_SYMBOLS)
2271  || ((filter == SearchFilter.TYPES_ONLY) && isType(result))
2272  || ((filter == SearchFilter.AGGREGATES_ONLY) && isAggregate(result))) {
2273  return result;
2274  }
2275  }
2276  }
2277 
2278  return null;
2279  }
2280 
2282  boolean isType(GenericDescriptor descriptor) {
2283  return (descriptor instanceof Descriptor) || (descriptor instanceof EnumDescriptor);
2284  }
2285 
2287  boolean isAggregate(GenericDescriptor descriptor) {
2288  return (descriptor instanceof Descriptor)
2289  || (descriptor instanceof EnumDescriptor)
2290  || (descriptor instanceof PackageDescriptor)
2291  || (descriptor instanceof ServiceDescriptor);
2292  }
2293 
2299  GenericDescriptor lookupSymbol(
2300  final String name,
2301  final GenericDescriptor relativeTo,
2302  final DescriptorPool.SearchFilter filter)
2303  throws DescriptorValidationException {
2304  // TODO(kenton): This could be optimized in a number of ways.
2305 
2306  GenericDescriptor result;
2307  String fullname;
2308  if (name.startsWith(".")) {
2309  // Fully-qualified name.
2310  fullname = name.substring(1);
2311  result = findSymbol(fullname, filter);
2312  } else {
2313  // If "name" is a compound identifier, we want to search for the
2314  // first component of it, then search within it for the rest.
2315  // If name is something like "Foo.Bar.baz", and symbols named "Foo" are
2316  // defined in multiple parent scopes, we only want to find "Bar.baz" in
2317  // the innermost one. E.g., the following should produce an error:
2318  // message Bar { message Baz {} }
2319  // message Foo {
2320  // message Bar {
2321  // }
2322  // optional Bar.Baz baz = 1;
2323  // }
2324  // So, we look for just "Foo" first, then look for "Bar.baz" within it
2325  // if found.
2326  final int firstPartLength = name.indexOf('.');
2327  final String firstPart;
2328  if (firstPartLength == -1) {
2329  firstPart = name;
2330  } else {
2331  firstPart = name.substring(0, firstPartLength);
2332  }
2333 
2334  // We will search each parent scope of "relativeTo" looking for the
2335  // symbol.
2336  final StringBuilder scopeToTry = new StringBuilder(relativeTo.getFullName());
2337 
2338  while (true) {
2339  // Chop off the last component of the scope.
2340  final int dotpos = scopeToTry.lastIndexOf(".");
2341  if (dotpos == -1) {
2342  fullname = name;
2343  result = findSymbol(name, filter);
2344  break;
2345  } else {
2346  scopeToTry.setLength(dotpos + 1);
2347 
2348  // Append firstPart and try to find
2349  scopeToTry.append(firstPart);
2350  result = findSymbol(scopeToTry.toString(), DescriptorPool.SearchFilter.AGGREGATES_ONLY);
2351 
2352  if (result != null) {
2353  if (firstPartLength != -1) {
2354  // We only found the first part of the symbol. Now look for
2355  // the whole thing. If this fails, we *don't* want to keep
2356  // searching parent scopes.
2357  scopeToTry.setLength(dotpos + 1);
2358  scopeToTry.append(name);
2359  result = findSymbol(scopeToTry.toString(), filter);
2360  }
2361  fullname = scopeToTry.toString();
2362  break;
2363  }
2364 
2365  // Not found. Remove the name so we can try again.
2366  scopeToTry.setLength(dotpos);
2367  }
2368  }
2369  }
2370 
2371  if (result == null) {
2372  if (allowUnknownDependencies && filter == SearchFilter.TYPES_ONLY) {
2373  logger.warning(
2374  "The descriptor for message type \""
2375  + name
2376  + "\" can not be found and a placeholder is created for it");
2377  // We create a dummy message descriptor here regardless of the
2378  // expected type. If the type should be message, this dummy
2379  // descriptor will work well and if the type should be enum, a
2380  // DescriptorValidationException will be thrown latter. In either
2381  // case, the code works as expected: we allow unknown message types
2382  // but not unknown enum types.
2383  result = new Descriptor(fullname);
2384  // Add the placeholder file as a dependency so we can find the
2385  // placeholder symbol when resolving other references.
2386  this.dependencies.add(result.getFile());
2387  return result;
2388  } else {
2389  throw new DescriptorValidationException(relativeTo, '\"' + name + "\" is not defined.");
2390  }
2391  } else {
2392  return result;
2393  }
2394  }
2395 
2400  void addSymbol(final GenericDescriptor descriptor) throws DescriptorValidationException {
2401  validateSymbolName(descriptor);
2402 
2403  final String fullName = descriptor.getFullName();
2404 
2405  final GenericDescriptor old = descriptorsByName.put(fullName, descriptor);
2406  if (old != null) {
2407  descriptorsByName.put(fullName, old);
2408 
2409  if (descriptor.getFile() == old.getFile()) {
2410  final int dotpos = fullName.lastIndexOf('.');
2411  if (dotpos == -1) {
2412  throw new DescriptorValidationException(
2413  descriptor, '\"' + fullName + "\" is already defined.");
2414  } else {
2415  throw new DescriptorValidationException(
2416  descriptor,
2417  '\"'
2418  + fullName.substring(dotpos + 1)
2419  + "\" is already defined in \""
2420  + fullName.substring(0, dotpos)
2421  + "\".");
2422  }
2423  } else {
2424  throw new DescriptorValidationException(
2425  descriptor,
2426  '\"'
2427  + fullName
2428  + "\" is already defined in file \""
2429  + old.getFile().getName()
2430  + "\".");
2431  }
2432  }
2433  }
2434 
2440  private static final class PackageDescriptor extends GenericDescriptor {
2441  @Override
2442  public Message toProto() {
2443  return file.toProto();
2444  }
2445 
2446  @Override
2447  public String getName() {
2448  return name;
2449  }
2450 
2451  @Override
2452  public String getFullName() {
2453  return fullName;
2454  }
2455 
2456  @Override
2458  return file;
2459  }
2460 
2461  PackageDescriptor(final String name, final String fullName, final FileDescriptor file) {
2462  this.file = file;
2463  this.fullName = fullName;
2464  this.name = name;
2465  }
2466 
2467  private final String name;
2468  private final String fullName;
2469  private final FileDescriptor file;
2470  }
2471 
2477  void addPackage(final String fullName, final FileDescriptor file)
2479  final int dotpos = fullName.lastIndexOf('.');
2480  final String name;
2481  if (dotpos == -1) {
2482  name = fullName;
2483  } else {
2484  addPackage(fullName.substring(0, dotpos), file);
2485  name = fullName.substring(dotpos + 1);
2486  }
2487 
2488  final GenericDescriptor old =
2489  descriptorsByName.put(fullName, new PackageDescriptor(name, fullName, file));
2490  if (old != null) {
2491  descriptorsByName.put(fullName, old);
2492  if (!(old instanceof PackageDescriptor)) {
2494  file,
2495  '\"'
2496  + name
2497  + "\" is already defined (as something other than a "
2498  + "package) in file \""
2499  + old.getFile().getName()
2500  + "\".");
2501  }
2502  }
2503  }
2504 
2506  private static final class DescriptorIntPair {
2508  private final int number;
2509 
2511  this.descriptor = descriptor;
2512  this.number = number;
2513  }
2514 
2515  @Override
2516  public int hashCode() {
2517  return descriptor.hashCode() * ((1 << 16) - 1) + number;
2518  }
2519 
2520  @Override
2521  public boolean equals(final Object obj) {
2522  if (!(obj instanceof DescriptorIntPair)) {
2523  return false;
2524  }
2525  final DescriptorIntPair other = (DescriptorIntPair) obj;
2526  return descriptor == other.descriptor && number == other.number;
2527  }
2528  }
2529 
2534  void addFieldByNumber(final FieldDescriptor field) throws DescriptorValidationException {
2535  final DescriptorIntPair key =
2536  new DescriptorIntPair(field.getContainingType(), field.getNumber());
2537  final FieldDescriptor old = fieldsByNumber.put(key, field);
2538  if (old != null) {
2539  fieldsByNumber.put(key, old);
2541  field,
2542  "Field number "
2543  + field.getNumber()
2544  + " has already been used in \""
2545  + field.getContainingType().getFullName()
2546  + "\" by field \""
2547  + old.getName()
2548  + "\".");
2549  }
2550  }
2551 
2557  void addEnumValueByNumber(final EnumValueDescriptor value) {
2558  final DescriptorIntPair key = new DescriptorIntPair(value.getType(), value.getNumber());
2559  final EnumValueDescriptor old = enumValuesByNumber.put(key, value);
2560  if (old != null) {
2561  enumValuesByNumber.put(key, old);
2562  // Not an error: Multiple enum values may have the same number, but
2563  // we only want the first one in the map.
2564  }
2565  }
2566 
2571  static void validateSymbolName(final GenericDescriptor descriptor)
2572  throws DescriptorValidationException {
2573  final String name = descriptor.getName();
2574  if (name.length() == 0) {
2575  throw new DescriptorValidationException(descriptor, "Missing name.");
2576  }
2577 
2578  // Non-ASCII characters are not valid in protobuf identifiers, even
2579  // if they are letters or digits.
2580  // The first character must be a letter or '_'.
2581  // Subsequent characters may be letters, numbers, or digits.
2582  for (int i = 0; i < name.length(); i++) {
2583  final char c = name.charAt(i);
2584  if (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z')
2585  || (c == '_')
2586  || ('0' <= c && c <= '9' && i > 0)) {
2587  // Valid
2588  continue;
2589  }
2590  throw new DescriptorValidationException(
2591  descriptor, '\"' + name + "\" is not a valid identifier.");
2592  }
2593  }
2594  }
2595 
2597  public static final class OneofDescriptor extends GenericDescriptor {
2599  public int getIndex() {
2600  return index;
2601  }
2602 
2603  @Override
2604  public String getName() {
2605  return proto.getName();
2606  }
2607 
2608  @Override
2610  return file;
2611  }
2612 
2613  @Override
2614  public String getFullName() {
2615  return fullName;
2616  }
2617 
2619  return containingType;
2620  }
2621 
2622  public int getFieldCount() {
2623  return fieldCount;
2624  }
2625 
2626  public OneofOptions getOptions() {
2627  return proto.getOptions();
2628  }
2629 
2631  public List<FieldDescriptor> getFields() {
2632  return Collections.unmodifiableList(Arrays.asList(fields));
2633  }
2634 
2636  return fields[index];
2637  }
2638 
2639  @Override
2640  public OneofDescriptorProto toProto() {
2641  return proto;
2642  }
2643 
2644  private void setProto(final OneofDescriptorProto proto) {
2645  this.proto = proto;
2646  }
2647 
2649  final OneofDescriptorProto proto,
2650  final FileDescriptor file,
2651  final Descriptor parent,
2652  final int index)
2654  this.proto = proto;
2655  fullName = computeFullName(file, parent, proto.getName());
2656  this.file = file;
2657  this.index = index;
2658 
2659  containingType = parent;
2660  fieldCount = 0;
2661  }
2662 
2663  private final int index;
2664  private OneofDescriptorProto proto;
2665  private final String fullName;
2666  private final FileDescriptor file;
2667 
2669  private int fieldCount;
2671  }
2672 }
com.google.protobuf.Descriptors.EnumValueDescriptor.proto
EnumValueDescriptorProto proto
Definition: Descriptors.java:1835
com.google.protobuf.Descriptors.GenericDescriptor.getFullName
abstract String getFullName()
com.google.protobuf.Descriptors
Definition: Descriptors.java:80
com.google.protobuf.Descriptors.MethodDescriptor
Definition: Descriptors.java:1983
com.google.protobuf.Descriptors.Descriptor.isReservedName
boolean isReservedName(final String name)
Definition: Descriptors.java:741
java::lang
com.google.protobuf.Descriptors.DescriptorPool.PackageDescriptor.getFile
FileDescriptor getFile()
Definition: Descriptors.java:2457
com.google.protobuf.Descriptors.Descriptor.findEnumTypeByName
EnumDescriptor findEnumTypeByName(final String name)
Definition: Descriptors.java:805
com.google.protobuf.Descriptors.FieldDescriptor.crossLink
void crossLink()
Definition: Descriptors.java:1377
com.google.protobuf.Descriptors.FieldDescriptor.Type.GROUP
GROUP
Definition: Descriptors.java:1225
com.google.protobuf.Descriptors.MethodDescriptor.service
final ServiceDescriptor service
Definition: Descriptors.java:2053
name
GLuint const GLchar * name
Definition: glcorearb.h:3055
com.google.protobuf.Descriptors.FieldDescriptor.Type.getJavaType
JavaType getJavaType()
Definition: Descriptors.java:1245
com.google.protobuf.Descriptors.EnumValueDescriptor.toString
String toString()
Definition: Descriptors.java:1804
com.google.protobuf::DescriptorProtos::EnumOptions
com.google.protobuf.Descriptors.FileDescriptor.getDependencies
List< FileDescriptor > getDependencies()
Definition: Descriptors.java:146
com.google.protobuf.Descriptors.DescriptorValidationException.getDescription
String getDescription()
Definition: Descriptors.java:2152
com.google.protobuf.Descriptors.MethodDescriptor.getService
ServiceDescriptor getService()
Definition: Descriptors.java:2020
com.google.protobuf::DescriptorProtos::FieldDescriptorProto
com.google.protobuf.Descriptors.MethodDescriptor.isClientStreaming
boolean isClientStreaming()
Definition: Descriptors.java:2035
com.google.protobuf.Descriptors.Descriptor.isExtensionNumber
boolean isExtensionNumber(final int number)
Definition: Descriptors.java:721
com.google.protobuf.Descriptors.computeFullName
static String computeFullName(final FileDescriptor file, final Descriptor parent, final String name)
Definition: Descriptors.java:2103
com.google.protobuf.Descriptors.FileDescriptor.Syntax.Syntax
Syntax(String name)
Definition: Descriptors.java:161
com.google.protobuf.Descriptors.MethodDescriptor.toProto
MethodDescriptorProto toProto()
Definition: Descriptors.java:1993
com.google.protobuf.Descriptors.FileDescriptor.enumTypes
final EnumDescriptor[] enumTypes
Definition: Descriptors.java:494
com.google.protobuf.Descriptors.MethodDescriptor.proto
MethodDescriptorProto proto
Definition: Descriptors.java:2050
com.google.protobuf::DescriptorProtos::EnumValueOptions
com.google.protobuf::DescriptorProtos::ServiceOptions
com.google.protobuf.Descriptors.EnumDescriptor.getName
String getName()
Definition: Descriptors.java:1602
com.google.protobuf.Descriptors.OneofDescriptor.getFields
List< FieldDescriptor > getFields()
Definition: Descriptors.java:2631
com.google.protobuf.Descriptors.DescriptorPool.DescriptorIntPair
Definition: Descriptors.java:2506
com.google.protobuf.Descriptors.FileDescriptor.Syntax.name
final String name
Definition: Descriptors.java:165
google::protobuf::extension
const Descriptor::ReservedRange const EnumValueDescriptor const MethodDescriptor extension
Definition: src/google/protobuf/descriptor.h:2001
com.google.protobuf.Descriptors.FileDescriptor.pool
final DescriptorPool pool
Definition: Descriptors.java:499
com.google.protobuf.Descriptors.EnumValueDescriptor.fullName
final String fullName
Definition: Descriptors.java:1836
com.google.protobuf.Descriptors.ServiceDescriptor
Definition: Descriptors.java:1881
com.google.protobuf.Descriptors.DescriptorPool.descriptorsByName
final Map< String, GenericDescriptor > descriptorsByName
Definition: Descriptors.java:2241
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner.assignDescriptors
ExtensionRegistry assignDescriptors(FileDescriptor root)
com.google.protobuf.Internal.EnumLiteMap
Definition: Internal.java:210
com.google.protobuf.Descriptors.EnumValueDescriptor.file
final FileDescriptor file
Definition: Descriptors.java:1837
com.google.protobuf.Descriptors.MethodDescriptor.outputType
Descriptor outputType
Definition: Descriptors.java:2057
com.google.protobuf.Descriptors.EnumDescriptor.getIndex
int getIndex()
Definition: Descriptors.java:1590
com.google.protobuf.Descriptors.FieldDescriptor.proto
FieldDescriptorProto proto
Definition: Descriptors.java:1201
com.google.protobuf.Descriptors.MethodDescriptor.getIndex
int getIndex()
Definition: Descriptors.java:1987
com.google.protobuf.Descriptors.Descriptor.fullName
final String fullName
Definition: Descriptors.java:816
com.google.protobuf.Descriptors.DescriptorPool.DescriptorIntPair.descriptor
final GenericDescriptor descriptor
Definition: Descriptors.java:2507
com.google.protobuf.Descriptors.GenericDescriptor.toProto
abstract Message toProto()
com.google.protobuf.Descriptors.FieldDescriptor.extensionScope
final Descriptor extensionScope
Definition: Descriptors.java:1205
com.google.protobuf.Descriptors.OneofDescriptor.getOptions
OneofOptions getOptions()
Definition: Descriptors.java:2626
com.google.protobuf.Descriptors.FieldDescriptor.getLiteType
WireFormat.FieldType getLiteType()
Definition: Descriptors.java:1020
length
GLenum GLuint GLenum GLsizei length
Definition: glcorearb.h:2695
input
std::string input
Definition: tokenizer_unittest.cc:197
com.google.protobuf.Descriptors.FileDescriptor.buildFrom
static FileDescriptor buildFrom(final FileDescriptorProto proto, final FileDescriptor[] dependencies, final boolean allowUnknownDependencies)
Definition: Descriptors.java:296
com.google.protobuf.Descriptors.DescriptorValidationException.proto
final Message proto
Definition: Descriptors.java:2157
com.google.protobuf.Descriptors.EnumValueDescriptor.type
final EnumDescriptor type
Definition: Descriptors.java:1838
com.google.protobuf.Descriptors.FieldDescriptor.getJsonName
String getJsonName()
Definition: Descriptors.java:989
com.google.protobuf.Descriptors.FieldDescriptor.Type.UINT64
UINT64
Definition: Descriptors.java:1219
com.google.protobuf.Descriptors.Descriptor.isExtendable
boolean isExtendable()
Definition: Descriptors.java:755
com.google.protobuf::DescriptorProtos::MessageOptions
com.google.protobuf.Descriptors.FileDescriptor.getFullName
String getFullName()
Definition: Descriptors.java:108
com.google.protobuf.Descriptors.FileDescriptor.findServiceByName
ServiceDescriptor findServiceByName(String name)
Definition: Descriptors.java:230
com.google.protobuf.Descriptors.Descriptor.getContainingType
Descriptor getContainingType()
Definition: Descriptors.java:686
com.google.protobuf.Descriptors.FileDescriptor.dependencies
final FileDescriptor[] dependencies
Definition: Descriptors.java:497
FileDescriptor
Definition: ruby/ext/google/protobuf_c/protobuf.h:125
com.google.protobuf.Descriptors.DescriptorPool.PackageDescriptor
Definition: Descriptors.java:2440
com.google.protobuf::DescriptorProtos::FieldOptions
com.google.protobuf.Descriptors.FileDescriptor.toProto
FileDescriptorProto toProto()
Definition: Descriptors.java:90
com.google.protobuf.Descriptors.ServiceDescriptor.getIndex
int getIndex()
Definition: Descriptors.java:1885
com.google.protobuf.Descriptors.Descriptor.getEnumTypes
List< EnumDescriptor > getEnumTypes()
Definition: Descriptors.java:716
strings
GLsizei const GLchar *const * strings
Definition: glcorearb.h:4046
com.google.protobuf.Descriptors.OneofDescriptor.getName
String getName()
Definition: Descriptors.java:2604
com.google.protobuf.Descriptors.DescriptorValidationException.serialVersionUID
static final long serialVersionUID
Definition: Descriptors.java:2139
com.google.protobuf.Descriptors.FieldDescriptor.Type.INT32
INT32
Definition: Descriptors.java:1220
com.google.protobuf.Descriptors.DescriptorPool.allowUnknownDependencies
boolean allowUnknownDependencies
Definition: Descriptors.java:2239
com.google.protobuf.Descriptors.FieldDescriptor.Type.SFIXED32
SFIXED32
Definition: Descriptors.java:1230
com.google.protobuf::DescriptorProtos::ServiceDescriptorProto
com.google.protobuf.Descriptors.DescriptorPool.PackageDescriptor.getFullName
String getFullName()
Definition: Descriptors.java:2452
com.google.protobuf::DescriptorProtos::OneofOptions
com.google.protobuf.Descriptors.FieldDescriptor.Type.MESSAGE
MESSAGE
Definition: Descriptors.java:1226
com.google.protobuf.Descriptors.Descriptor.getExtensions
List< FieldDescriptor > getExtensions()
Definition: Descriptors.java:706
com.google.protobuf.Descriptors.FieldDescriptor.isPacked
boolean isPacked()
Definition: Descriptors.java:1071
com.google.protobuf.Descriptors.ServiceDescriptor.getOptions
ServiceOptions getOptions()
Definition: Descriptors.java:1918
com.google.protobuf.Descriptors.OneofDescriptor.getContainingType
Descriptor getContainingType()
Definition: Descriptors.java:2618
com.google.protobuf.Descriptors.GenericDescriptor.getName
abstract String getName()
com.google.protobuf.Descriptors.ServiceDescriptor.findMethodByName
MethodDescriptor findMethodByName(final String name)
Definition: Descriptors.java:1933
com.google.protobuf::DescriptorProtos::FileDescriptorProto
com.google.protobuf
Definition: ProtoCaliperBenchmark.java:2
com.google.protobuf.Descriptors.EnumDescriptor.findValueByName
EnumValueDescriptor findValueByName(final String name)
Definition: Descriptors.java:1643
com.google.protobuf.Descriptors.FileDescriptor.Syntax.PROTO3
PROTO3
Definition: Descriptors.java:159
com.google.protobuf.Descriptors.EnumDescriptor.getFile
FileDescriptor getFile()
Definition: Descriptors.java:1618
com.google.protobuf.Descriptors.DescriptorValidationException.DescriptorValidationException
DescriptorValidationException(final GenericDescriptor problemDescriptor, final String description)
Definition: Descriptors.java:2160
descriptor
Descriptor * descriptor
Definition: php/ext/google/protobuf/protobuf.h:936
com.google.protobuf::DescriptorProtos::DescriptorProto
com.google.protobuf.ByteString.EMPTY
static final ByteString EMPTY
Definition: ByteString.java:85
com.google.protobuf.Descriptors.GenericDescriptor.getFile
abstract FileDescriptor getFile()
com.google.protobuf.Descriptors.FileDescriptor.services
final ServiceDescriptor[] services
Definition: Descriptors.java:495
com.google.protobuf.Descriptors.FileDescriptor.getMessageTypes
List< Descriptor > getMessageTypes()
Definition: Descriptors.java:126
com.google.protobuf.WireFormat
Definition: WireFormat.java:45
com.google.protobuf::DescriptorProtos::EnumDescriptorProto
com.google.protobuf.Descriptors.EnumValueDescriptor.getName
String getName()
Definition: Descriptors.java:1793
com.google.protobuf.Descriptors.FieldDescriptor.Type
Definition: Descriptors.java:1215
com.google.protobuf.Descriptors.ServiceDescriptor.ServiceDescriptor
ServiceDescriptor(final ServiceDescriptorProto proto, final FileDescriptor file, final int index)
Definition: Descriptors.java:1948
com.google.protobuf.Descriptors.Descriptor.enumTypes
final EnumDescriptor[] enumTypes
Definition: Descriptors.java:820
com.google.protobuf.Descriptors.DescriptorValidationException.DescriptorValidationException
DescriptorValidationException(final FileDescriptor problemDescriptor, final String description)
Definition: Descriptors.java:2180
com.google.protobuf.Descriptors.DescriptorValidationException.getProblemSymbolName
String getProblemSymbolName()
Definition: Descriptors.java:2142
EnumDescriptor
struct EnumDescriptor EnumDescriptor
Definition: php/ext/google/protobuf/protobuf.h:632
Descriptor
Definition: ruby/ext/google/protobuf_c/protobuf.h:113
com.google.protobuf.Descriptors.FieldDescriptor.getDefaultValue
Object getDefaultValue()
Definition: Descriptors.java:1097
com.google.protobuf.Descriptors.FileDescriptor.getPublicDependencies
List< FileDescriptor > getPublicDependencies()
Definition: Descriptors.java:151
bytes
uint8 bytes[10]
Definition: coded_stream_unittest.cc:153
com.google.protobuf.Descriptors.Descriptor.getFullName
String getFullName()
Definition: Descriptors.java:675
com.google.protobuf.Descriptors.Descriptor.oneofs
final OneofDescriptor[] oneofs
Definition: Descriptors.java:823
com.google.protobuf.Descriptors.FileDescriptor.getEnumTypes
List< EnumDescriptor > getEnumTypes()
Definition: Descriptors.java:131
com.google.protobuf.Descriptors.FileDescriptor.getSyntax
Syntax getSyntax()
Definition: Descriptors.java:169
com.google.protobuf.Descriptors.MethodDescriptor.getOutputType
Descriptor getOutputType()
Definition: Descriptors.java:2030
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner
Definition: Descriptors.java:488
FileDescriptor
struct FileDescriptor FileDescriptor
Definition: ruby/ext/google/protobuf_c/protobuf.h:56
testing::internal::Double
FloatingPoint< double > Double
Definition: gtest-internal.h:429
com.google.protobuf.Descriptors.FieldDescriptor.getIndex
int getIndex()
Definition: Descriptors.java:956
com.google.protobuf.Descriptors.DescriptorValidationException.description
final String description
Definition: Descriptors.java:2158
com.google.protobuf.Descriptors.MethodDescriptor.getName
String getName()
Definition: Descriptors.java:1999
com.google.protobuf.Descriptors.FieldDescriptor.JavaType.FLOAT
FLOAT
Definition: Descriptors.java:1265
values
GLenum GLsizei GLsizei GLint * values
Definition: glcorearb.h:3591
com.google.protobuf.Descriptors.MethodDescriptor.crossLink
void crossLink()
Definition: Descriptors.java:2075
com.google.protobuf.Descriptors.MethodDescriptor.getFullName
String getFullName()
Definition: Descriptors.java:2009
com.google.protobuf.Descriptors.FieldDescriptor.getLiteJavaType
WireFormat.JavaType getLiteJavaType()
Definition: Descriptors.java:1003
com.google.protobuf.Descriptors.EnumDescriptor.proto
EnumDescriptorProto proto
Definition: Descriptors.java:1723
range
GLenum GLint * range
Definition: glcorearb.h:3963
com.google.protobuf.Descriptors.OneofDescriptor.setProto
void setProto(final OneofDescriptorProto proto)
Definition: Descriptors.java:2644
com.google.protobuf.Descriptors.FieldDescriptor.Type.javaType
JavaType javaType
Definition: Descriptors.java:1239
com.google.protobuf.Descriptors.MethodDescriptor.file
final FileDescriptor file
Definition: Descriptors.java:2052
com.google.protobuf.Descriptors.FieldDescriptor.Type.BYTES
BYTES
Definition: Descriptors.java:1227
com.google.protobuf.Descriptors.EnumDescriptor.file
final FileDescriptor file
Definition: Descriptors.java:1725
com.google.protobuf.Descriptors.FieldDescriptor.getOptions
FieldOptions getOptions()
Definition: Descriptors.java:1106
com.google.protobuf.Descriptors.FieldDescriptor.JavaType.ENUM
ENUM
Definition: Descriptors.java:1270
com.google.protobuf.Descriptors.FieldDescriptor.isRequired
boolean isRequired()
Definition: Descriptors.java:1051
com.google.protobuf.Descriptors.FileDescriptor.messageTypes
final Descriptor[] messageTypes
Definition: Descriptors.java:493
com.google.protobuf.Descriptors.EnumDescriptor.fullName
final String fullName
Definition: Descriptors.java:1724
com.google.protobuf.Descriptors.ServiceDescriptor.getMethods
List< MethodDescriptor > getMethods()
Definition: Descriptors.java:1923
obj
GLsizei GLsizei GLuint * obj
Definition: glcorearb.h:3066
com.google.protobuf.Descriptors.ServiceDescriptor.getFile
FileDescriptor getFile()
Definition: Descriptors.java:1913
com.google.protobuf.Descriptors.OneofDescriptor.file
final FileDescriptor file
Definition: Descriptors.java:2666
com.google.protobuf.Descriptors.FieldDescriptor.FieldDescriptor
FieldDescriptor(final FieldDescriptorProto proto, final FileDescriptor file, final Descriptor parent, final int index, final boolean isExtension)
Definition: Descriptors.java:1309
com.google.protobuf.Descriptors.FieldDescriptor.file
final FileDescriptor file
Definition: Descriptors.java:1204
com.google.protobuf.Descriptors.Descriptor.extensions
final FieldDescriptor[] extensions
Definition: Descriptors.java:822
com.google.protobuf.Descriptors.OneofDescriptor.getField
FieldDescriptor getField(int index)
Definition: Descriptors.java:2635
com.google.protobuf.Descriptors.FieldDescriptor.getType
Type getType()
Definition: Descriptors.java:1014
com.google.protobuf.Descriptors.DescriptorPool.DescriptorIntPair.number
final int number
Definition: Descriptors.java:2508
com.google.protobuf.Descriptors.EnumValueDescriptor.EnumValueDescriptor
EnumValueDescriptor(final EnumValueDescriptorProto proto, final FileDescriptor file, final EnumDescriptor parent, final int index)
Definition: Descriptors.java:1840
com.google.protobuf.Descriptors.FieldDescriptor.isRepeated
boolean isRepeated()
Definition: Descriptors.java:1062
com.google.protobuf.Descriptors.FieldDescriptor.Type.FIXED64
FIXED64
Definition: Descriptors.java:1221
com.google.protobuf.Descriptors.Descriptor.getIndex
int getIndex()
Definition: Descriptors.java:646
mingw.root
def root(location=None, arch=None, version=None, threading=None, exceptions=None, revision=None, log=EmptyLogger())
Definition: mingw.py:172
com.google.protobuf.Descriptors.GenericDescriptor
Definition: Descriptors.java:2123
com.google.protobuf.Descriptors.FileDescriptor.findEnumTypeByName
EnumDescriptor findEnumTypeByName(String name)
Definition: Descriptors.java:206
com.google.protobuf.Descriptors.EnumDescriptor.index
final int index
Definition: Descriptors.java:1722
com.google.protobuf.Descriptors.OneofDescriptor
Definition: Descriptors.java:2597
com.google.protobuf::DescriptorProtos::MethodDescriptorProto
com.google.protobuf.Message.Builder
Definition: Message.java:104
com.google.protobuf.Descriptors.FieldDescriptor.JavaType.STRING
STRING
Definition: Descriptors.java:1268
com.google.protobuf.Descriptors.DescriptorPool.enumValuesByNumber
final Map< DescriptorIntPair, EnumValueDescriptor > enumValuesByNumber
Definition: Descriptors.java:2245
com.google.protobuf.Descriptors.FieldDescriptor.toProto
FieldDescriptorProto toProto()
Definition: Descriptors.java:962
testing::internal::Float
FloatingPoint< float > Float
Definition: gtest-internal.h:428
com.google.protobuf.Descriptors.DescriptorValidationException.getProblemProto
Message getProblemProto()
Definition: Descriptors.java:2147
com.google.protobuf.Descriptors.MethodDescriptor.inputType
Descriptor inputType
Definition: Descriptors.java:2056
com.google.protobuf.Descriptors.FileDescriptor.findExtensionByName
FieldDescriptor findExtensionByName(String name)
Definition: Descriptors.java:254
com.google.protobuf.Descriptors.EnumDescriptor.toProto
EnumDescriptorProto toProto()
Definition: Descriptors.java:1596
com.google.protobuf.Internal.EnumLite
Definition: Internal.java:199
com.google.protobuf.Descriptors.Descriptor.fields
final FieldDescriptor[] fields
Definition: Descriptors.java:821
com.google.protobuf.Descriptors.OneofDescriptor.getFieldCount
int getFieldCount()
Definition: Descriptors.java:2622
com.google.protobuf.Descriptors.Descriptor.Descriptor
Descriptor(final DescriptorProto proto, final FileDescriptor file, final Descriptor parent, final int index)
Definition: Descriptors.java:854
com.google.protobuf.Descriptors.DescriptorPool
Definition: Descriptors.java:2199
com.google.protobuf.Descriptors.ServiceDescriptor.crossLink
void crossLink()
Definition: Descriptors.java:1964
com.google.protobuf.Descriptors.FieldDescriptor.getNumber
int getNumber()
Definition: Descriptors.java:974
com.google.protobuf.Descriptors.FileDescriptor.proto
FileDescriptorProto proto
Definition: Descriptors.java:492
com.google.protobuf.Descriptors.FieldDescriptor.Type.UINT32
UINT32
Definition: Descriptors.java:1228
com.google.protobuf.Descriptors.DescriptorPool.SearchFilter
Definition: Descriptors.java:2202
com.google.protobuf.Descriptors.DescriptorPool.fieldsByNumber
final Map< DescriptorIntPair, FieldDescriptor > fieldsByNumber
Definition: Descriptors.java:2243
com.google.protobuf.Descriptors.FieldDescriptor.enumType
EnumDescriptor enumType
Definition: Descriptors.java:1212
com.google.protobuf.Descriptors.OneofDescriptor.fieldCount
int fieldCount
Definition: Descriptors.java:2669
com.google.protobuf.Descriptors.MethodDescriptor.isServerStreaming
boolean isServerStreaming()
Definition: Descriptors.java:2040
com.google.protobuf.Descriptors.logger
static final Logger logger
Definition: Descriptors.java:81
com.google.protobuf.Descriptors.ServiceDescriptor.methods
MethodDescriptor[] methods
Definition: Descriptors.java:1946
com.google.protobuf.Descriptors.DescriptorPool.PackageDescriptor.file
final FileDescriptor file
Definition: Descriptors.java:2469
com.google.protobuf.Descriptors.FieldDescriptor.JavaType
Definition: Descriptors.java:1262
com.google.protobuf.Descriptors.FileDescriptor.findMessageTypeByName
Descriptor findMessageTypeByName(String name)
Definition: Descriptors.java:182
com.google.protobuf.Descriptors.ServiceDescriptor.fullName
final String fullName
Definition: Descriptors.java:1944
com.google.protobuf.Descriptors.EnumDescriptor.findValueByNumber
EnumValueDescriptor findValueByNumber(final int number)
Definition: Descriptors.java:1660
com.google.protobuf.Descriptors.Descriptor.proto
DescriptorProto proto
Definition: Descriptors.java:815
EnumValueDescriptor
struct EnumValueDescriptor EnumValueDescriptor
Definition: php/ext/google/protobuf/protobuf.h:634
com.google.protobuf.Descriptors.FieldDescriptor.Type.FIXED32
FIXED32
Definition: Descriptors.java:1222
com.google.protobuf.Descriptors.FieldDescriptor.containingType
Descriptor containingType
Definition: Descriptors.java:1209
com.google.protobuf.Descriptors.EnumDescriptor
Definition: Descriptors.java:1583
com.google.protobuf.Descriptors.EnumValueDescriptor.index
final int index
Definition: Descriptors.java:1834
com.google.protobuf.Descriptors.FieldDescriptor.internalMergeFrom
MessageLite.Builder internalMergeFrom(MessageLite.Builder to, MessageLite from)
Definition: Descriptors.java:1572
com.google.protobuf.Descriptors.DescriptorValidationException.name
final String name
Definition: Descriptors.java:2156
com.google.protobuf.Descriptors.FieldDescriptor.getJavaType
JavaType getJavaType()
Definition: Descriptors.java:997
com.google.protobuf.Descriptors.Descriptor.getOptions
MessageOptions getOptions()
Definition: Descriptors.java:691
com.google.protobuf.Descriptors.EnumValueDescriptor.setProto
void setProto(final EnumValueDescriptorProto proto)
Definition: Descriptors.java:1873
com.google.protobuf.Descriptors.Descriptor.getFields
List< FieldDescriptor > getFields()
Definition: Descriptors.java:696
com.google.protobuf.Descriptors.FieldDescriptor.Type.toProto
FieldDescriptorProto.Type toProto()
Definition: Descriptors.java:1241
com.google.protobuf.Descriptors.FieldDescriptor.isExtension
boolean isExtension()
Definition: Descriptors.java:1111
com.google.protobuf.Descriptors.FieldDescriptor.getExtensionScope
Descriptor getExtensionScope()
Definition: Descriptors.java:1149
com.google.protobuf.Descriptors.FieldDescriptor.getFullName
String getFullName()
Definition: Descriptors.java:984
com.google.protobuf.Descriptors.Descriptor.crossLink
void crossLink()
Definition: Descriptors.java:906
com.google.protobuf.Descriptors.FieldDescriptor.isOptional
boolean isOptional()
Definition: Descriptors.java:1056
com.google.protobuf.Descriptors.FieldDescriptor.Type.BOOL
BOOL
Definition: Descriptors.java:1223
com.google.protobuf.Descriptors.DescriptorPool.DescriptorIntPair.hashCode
int hashCode()
Definition: Descriptors.java:2516
com.google.protobuf.Descriptors.FieldDescriptor.Type.FLOAT
FLOAT
Definition: Descriptors.java:1217
com.google.protobuf.Descriptors.FileDescriptor.Syntax
Definition: Descriptors.java:156
com.google.protobuf.Descriptors.FieldDescriptor.setProto
void setProto(final FieldDescriptorProto proto)
Definition: Descriptors.java:1566
com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom
static void internalBuildGeneratedFileFrom(final String[] descriptorDataParts, final FileDescriptor[] dependencies, final InternalDescriptorAssigner descriptorAssigner)
Definition: Descriptors.java:360
Descriptor
struct Descriptor Descriptor
Definition: php/ext/google/protobuf/protobuf.h:628
com.google.protobuf::DescriptorProtos::OneofDescriptorProto
com.google.protobuf.MessageLite.Builder
Definition: MessageLite.java:133
F
#define F(msg, field)
Definition: ruby/ext/google/protobuf_c/upb.c:9347
com.google.protobuf.Descriptors.FieldDescriptor.isPackable
boolean isPackable()
Definition: Descriptors.java:1083
com.google.protobuf.Descriptors.FieldDescriptor.Type.SINT32
SINT32
Definition: Descriptors.java:1232
com.google.protobuf.Descriptors.EnumValueDescriptor.getFile
FileDescriptor getFile()
Definition: Descriptors.java:1820
com.google.protobuf.Descriptors.EnumDescriptor.getOptions
EnumOptions getOptions()
Definition: Descriptors.java:1628
field
const FieldDescriptor * field
Definition: parser_unittest.cc:2694
com.google.protobuf::DescriptorProtos::EnumValueDescriptorProto
com.google.protobuf.Descriptors.FieldDescriptor.Type.STRING
STRING
Definition: Descriptors.java:1224
key
const SETUP_TEARDOWN_TESTCONTEXT char * key
Definition: test_wss_transport.cpp:10
com.google.protobuf.Descriptors.FileDescriptor.FileDescriptor
FileDescriptor(final FileDescriptorProto proto, final FileDescriptor[] dependencies, final DescriptorPool pool, boolean allowUnknownDependencies)
Definition: Descriptors.java:501
com.google.protobuf.Descriptors.FileDescriptor.crossLink
void crossLink()
Definition: Descriptors.java:579
com.google.protobuf.Descriptors.OneofDescriptor.getFullName
String getFullName()
Definition: Descriptors.java:2614
com.google.protobuf.Descriptors.EnumValueDescriptor.getOptions
EnumValueOptions getOptions()
Definition: Descriptors.java:1830
com.google.protobuf.Descriptors.EnumDescriptor.getContainingType
Descriptor getContainingType()
Definition: Descriptors.java:1623
com.google.protobuf.Descriptors.FieldDescriptor.messageType
Descriptor messageType
Definition: Descriptors.java:1210
com.google.protobuf.Descriptors.ServiceDescriptor.getName
String getName()
Definition: Descriptors.java:1897
com.google.protobuf.Descriptors.FileDescriptor.getFile
FileDescriptor getFile()
Definition: Descriptors.java:102
com.google.protobuf.Descriptors.OneofDescriptor.OneofDescriptor
OneofDescriptor(final OneofDescriptorProto proto, final FileDescriptor file, final Descriptor parent, final int index)
Definition: Descriptors.java:2648
com.google.protobuf.Descriptors.FileDescriptor.buildFrom
static FileDescriptor buildFrom(final FileDescriptorProto proto, final FileDescriptor[] dependencies)
Definition: Descriptors.java:279
i
int i
Definition: gmock-matchers_test.cc:764
com.google.protobuf.Descriptors.FieldDescriptor.JavaType.LONG
LONG
Definition: Descriptors.java:1264
com.google.protobuf.Descriptors.Descriptor.isReservedNumber
boolean isReservedNumber(final int number)
Definition: Descriptors.java:731
java
com.google.protobuf.Descriptors.EnumDescriptor.containingType
final Descriptor containingType
Definition: Descriptors.java:1726
com.google.protobuf.Descriptors.Descriptor
Definition: Descriptors.java:629
com.google.protobuf.Descriptors.FileDescriptor.getExtensions
List< FieldDescriptor > getExtensions()
Definition: Descriptors.java:141
type
GLenum type
Definition: glcorearb.h:2695
com.google.protobuf.Descriptors.OneofDescriptor.index
final int index
Definition: Descriptors.java:2663
com.google.protobuf.TextFormat.unescapeBytes
static ByteString unescapeBytes(final CharSequence charString)
Definition: TextFormat.java:2043
com.google.protobuf.Descriptors.FieldDescriptor.fullName
final String fullName
Definition: Descriptors.java:1202
com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom
static FileDescriptor internalBuildGeneratedFileFrom(final String[] descriptorDataParts, final Class<?> descriptorOuterClass, final String[] dependencyClassNames, final String[] dependencyFileNames)
Definition: Descriptors.java:447
com.google.protobuf.Descriptors.EnumDescriptor.values
EnumValueDescriptor[] values
Definition: Descriptors.java:1727
com.google.protobuf.Descriptors.Descriptor.setProto
void setProto(final DescriptorProto proto)
Definition: Descriptors.java:921
com.google.protobuf.Descriptors.FileDescriptor.Syntax.PROTO2
PROTO2
Definition: Descriptors.java:158
com.google.protobuf.Descriptors.Descriptor.getNestedTypes
List< Descriptor > getNestedTypes()
Definition: Descriptors.java:711
com.google.protobuf.Descriptors.FieldDescriptor.Type.DOUBLE
DOUBLE
Definition: Descriptors.java:1216
com.google.protobuf.Descriptors.DescriptorPool.dependencies
final Set< FileDescriptor > dependencies
Definition: Descriptors.java:2238
com.google.protobuf.Descriptors.FieldDescriptor.JavaType.BYTE_STRING
BYTE_STRING
Definition: Descriptors.java:1269
com.google.protobuf.Descriptors.MethodDescriptor.fullName
final String fullName
Definition: Descriptors.java:2051
com.google.protobuf.Descriptors.OneofDescriptor.fields
FieldDescriptor[] fields
Definition: Descriptors.java:2670
com.google.protobuf.Descriptors.MethodDescriptor.getFile
FileDescriptor getFile()
Definition: Descriptors.java:2015
com.google.protobuf.Descriptors.EnumDescriptor.unknownValues
final WeakHashMap< Integer, WeakReference< EnumValueDescriptor > > unknownValues
Definition: Descriptors.java:1728
com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom
static FileDescriptor internalBuildGeneratedFileFrom(final String[] descriptorDataParts, final FileDescriptor[] dependencies)
Definition: Descriptors.java:403
com.google.protobuf.Descriptors.DescriptorPool.PackageDescriptor.getName
String getName()
Definition: Descriptors.java:2447
com.google.protobuf.Descriptors.OneofDescriptor.getIndex
int getIndex()
Definition: Descriptors.java:2599
filter
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glcorearb.h:3467
com.google.protobuf.Descriptors.MethodDescriptor.MethodDescriptor
MethodDescriptor(final MethodDescriptorProto proto, final FileDescriptor file, final ServiceDescriptor parent, final int index)
Definition: Descriptors.java:2059
com.google.protobuf.Descriptors.FileDescriptor.Syntax.UNKNOWN
UNKNOWN
Definition: Descriptors.java:157
com.google.protobuf::DescriptorProtos::MethodOptions
com.google.protobuf.Descriptors.FieldDescriptor.toString
String toString()
Definition: Descriptors.java:1195
com.google.protobuf.Descriptors.FieldDescriptor.needsUtf8Check
boolean needsUtf8Check()
Definition: Descriptors.java:1025
com.google.protobuf.Descriptors.MethodDescriptor.setProto
void setProto(final MethodDescriptorProto proto)
Definition: Descriptors.java:2096
com.google.protobuf.Descriptors.FieldDescriptor.JavaType.BOOLEAN
BOOLEAN
Definition: Descriptors.java:1267
com.google.protobuf.Descriptors.FieldDescriptor.isMapField
boolean isMapField()
Definition: Descriptors.java:1039
ch
char ch
Definition: gmock-matchers_test.cc:3871
com.google.protobuf.Descriptors.FieldDescriptor.defaultValue
Object defaultValue
Definition: Descriptors.java:1213
com.google.protobuf.Descriptors.MethodDescriptor.index
final int index
Definition: Descriptors.java:2049
com.google.protobuf.Descriptors.ServiceDescriptor.file
final FileDescriptor file
Definition: Descriptors.java:1945
com.google.protobuf.Descriptors.FileDescriptor.getServices
List< ServiceDescriptor > getServices()
Definition: Descriptors.java:136
com.google.protobuf.Descriptors.FieldDescriptor.getContainingType
Descriptor getContainingType()
Definition: Descriptors.java:1119
com.google.protobuf.TextFormat.InvalidEscapeSequenceException
Definition: TextFormat.java:2148
com.google.protobuf.Descriptors.ServiceDescriptor.toProto
ServiceDescriptorProto toProto()
Definition: Descriptors.java:1891
com.google.protobuf.Descriptors.FieldDescriptor.JavaType.defaultDefault
final Object defaultDefault
Definition: Descriptors.java:1281
com.google.protobuf.Descriptors.ServiceDescriptor.index
final int index
Definition: Descriptors.java:1942
com.google.protobuf.Descriptors.Descriptor.getOneofs
List< OneofDescriptor > getOneofs()
Definition: Descriptors.java:701
com.google.protobuf.Descriptors.ServiceDescriptor.getFullName
String getFullName()
Definition: Descriptors.java:1907
com.google.protobuf.Descriptors.EnumValueDescriptor.getIndex
int getIndex()
Definition: Descriptors.java:1781
com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom
static void internalBuildGeneratedFileFrom(final String[] descriptorDataParts, final Class<?> descriptorOuterClass, final String[] dependencyClassNames, final String[] dependencyFileNames, final InternalDescriptorAssigner descriptorAssigner)
Definition: Descriptors.java:431
com.google.protobuf.Descriptors.FileDescriptor.extensions
final FieldDescriptor[] extensions
Definition: Descriptors.java:496
com.google
com.google.protobuf.Descriptors.DescriptorPool.importPublicDependencies
void importPublicDependencies(final FileDescriptor file)
Definition: Descriptors.java:2230
com.google.protobuf.Descriptors.FieldDescriptor.containingOneof
OneofDescriptor containingOneof
Definition: Descriptors.java:1211
com
com.google.protobuf.Descriptors.FieldDescriptor.jsonName
final String jsonName
Definition: Descriptors.java:1203
com.google.protobuf.Descriptors.EnumDescriptor.getValues
List< EnumValueDescriptor > getValues()
Definition: Descriptors.java:1633
com.google.protobuf.ExtensionRegistry
Definition: ExtensionRegistry.java:91
com.google.protobuf.Descriptors.Descriptor.containingType
final Descriptor containingType
Definition: Descriptors.java:818
com.google.protobuf.Descriptors.EnumValueDescriptor.toProto
EnumValueDescriptorProto toProto()
Definition: Descriptors.java:1787
com.google.protobuf.Descriptors.EnumValueDescriptor.getFullName
String getFullName()
Definition: Descriptors.java:1814
com.google.protobuf.Descriptors.FieldDescriptor.JavaType.JavaType
JavaType(final Object defaultDefault)
Definition: Descriptors.java:1273
com.google.protobuf.Descriptors.DescriptorPool.PackageDescriptor.name
final String name
Definition: Descriptors.java:2467
com.google.protobuf.Descriptors.FieldDescriptor.table
static final WireFormat.FieldType[] table
Definition: Descriptors.java:1048
com.google.protobuf.Descriptors.MethodDescriptor.getOptions
MethodOptions getOptions()
Definition: Descriptors.java:2045
com.google.protobuf.Descriptors.FieldDescriptor.fieldNameToJsonName
static String fieldNameToJsonName(String name)
Definition: Descriptors.java:1286
com.google.protobuf.Descriptors.DescriptorPool.DescriptorIntPair.equals
boolean equals(final Object obj)
Definition: Descriptors.java:2521
com.google.protobuf.Descriptors.MethodDescriptor.getInputType
Descriptor getInputType()
Definition: Descriptors.java:2025
com.google.protobuf.Descriptors.Descriptor.findFieldByName
FieldDescriptor findFieldByName(final String name)
Definition: Descriptors.java:765
com.google.protobuf.Descriptors.FieldDescriptor.index
final int index
Definition: Descriptors.java:1199
com.google.protobuf.Descriptors.Descriptor.file
final FileDescriptor file
Definition: Descriptors.java:817
com.google.protobuf.Descriptors.GenericDescriptor.GenericDescriptor
GenericDescriptor()
Definition: Descriptors.java:2126
com.google.protobuf.Descriptors.FileDescriptor.getPackage
String getPackage()
Definition: Descriptors.java:116
com.google.protobuf.Internal
Definition: Internal.java:54
com.google.protobuf.Descriptors.ServiceDescriptor.setProto
void setProto(final ServiceDescriptorProto proto)
Definition: Descriptors.java:1971
com.google.protobuf.Descriptors.EnumDescriptor.setProto
void setProto(final EnumDescriptorProto proto)
Definition: Descriptors.java:1758
com.google.protobuf.InvalidProtocolBufferException
Definition: InvalidProtocolBufferException.java:41
com.google.protobuf.Descriptors.FileDescriptor.publicDependencies
final FileDescriptor[] publicDependencies
Definition: Descriptors.java:498
com.google.protobuf.Descriptors.FieldDescriptor.compareTo
int compareTo(final FieldDescriptor other)
Definition: Descriptors.java:1185
com.google.protobuf.Descriptors.FieldDescriptor.getName
String getName()
Definition: Descriptors.java:968
FieldDescriptor
struct FieldDescriptor FieldDescriptor
Definition: php/ext/google/protobuf/protobuf.h:637
com.google.protobuf.Descriptors.FieldDescriptor.Type.Type
Type(final JavaType javaType)
Definition: Descriptors.java:1235
com.google.protobuf.Descriptors.OneofDescriptor.fullName
final String fullName
Definition: Descriptors.java:2665
com.google.protobuf.Descriptors.Descriptor.nestedTypes
final Descriptor[] nestedTypes
Definition: Descriptors.java:819
com.google.protobuf.Descriptors.EnumValueDescriptor
Definition: Descriptors.java:1774
value
GLsizei const GLfloat * value
Definition: glcorearb.h:3093
com.google.protobuf.Descriptors.OneofDescriptor.getFile
FileDescriptor getFile()
Definition: Descriptors.java:2609
com.google.protobuf.Descriptors.FieldDescriptor.JavaType.DOUBLE
DOUBLE
Definition: Descriptors.java:1266
com.google.protobuf.WireFormat.FieldType
Definition: WireFormat.java:111
com.google.protobuf::DescriptorProtos
com.google.protobuf.Descriptors.Descriptor.findNestedTypeByName
Descriptor findNestedTypeByName(final String name)
Definition: Descriptors.java:790
com.google.protobuf::DescriptorProtos::FileOptions
com.google.protobuf.Descriptors.FieldDescriptor.hasDefaultValue
boolean hasDefaultValue()
Definition: Descriptors.java:1088
com.google.protobuf.Descriptors.FileDescriptor.setProto
void setProto(final FileDescriptorProto proto)
Definition: Descriptors.java:601
com.google.protobuf.Descriptors.DescriptorValidationException.DescriptorValidationException
DescriptorValidationException(final GenericDescriptor problemDescriptor, final String description, final Throwable cause)
Definition: Descriptors.java:2172
com.google.protobuf.Descriptors.EnumValueDescriptor.getType
EnumDescriptor getType()
Definition: Descriptors.java:1825
com.google.protobuf.Descriptors.FileDescriptor.latin1Cat
static byte[] latin1Cat(final String[] strings)
Definition: Descriptors.java:317
output
const upb_json_parsermethod const upb_symtab upb_sink * output
Definition: ruby/ext/google/protobuf_c/upb.h:10503
com.google.protobuf.Descriptors.DescriptorPool.PackageDescriptor.fullName
final String fullName
Definition: Descriptors.java:2468
com.google.protobuf.Descriptors.FileDescriptor
Definition: Descriptors.java:87
com.google.protobuf.Descriptors.FieldDescriptor.Type.valueOf
static Type valueOf(final FieldDescriptorProto.Type type)
Definition: Descriptors.java:1249
com.google.protobuf.Descriptors.ServiceDescriptor.proto
ServiceDescriptorProto proto
Definition: Descriptors.java:1943
DescriptorPool
Definition: ruby/ext/google/protobuf_c/protobuf.h:109
com.google.protobuf.Descriptors.EnumDescriptor.EnumDescriptor
EnumDescriptor(final EnumDescriptorProto proto, final FileDescriptor file, final Descriptor parent, final int index)
Definition: Descriptors.java:1731
com.google.protobuf.Descriptors.EnumValueDescriptor.getNumber
int getNumber()
Definition: Descriptors.java:1799
DescriptorPool
struct DescriptorPool DescriptorPool
Definition: php/ext/google/protobuf/protobuf.h:629
index
GLuint index
Definition: glcorearb.h:3055
com.google.protobuf.Descriptors.FieldDescriptor.JavaType.INT
INT
Definition: Descriptors.java:1263
com.google.protobuf.Descriptors.FieldDescriptor.type
Type type
Definition: Descriptors.java:1208
com.google.protobuf.Descriptors.EnumValueDescriptor.EnumValueDescriptor
EnumValueDescriptor(final FileDescriptor file, final EnumDescriptor parent, final Integer number)
Definition: Descriptors.java:1858
com.google.protobuf.Descriptors.Descriptor.index
final int index
Definition: Descriptors.java:814
com.google.protobuf.Descriptors.FieldDescriptor.getContainingOneof
OneofDescriptor getContainingOneof()
Definition: Descriptors.java:1124
com.google.protobuf.Descriptors.FieldDescriptor.Type.SFIXED64
SFIXED64
Definition: Descriptors.java:1231
com.google.protobuf.Descriptors.EnumDescriptor.getFullName
String getFullName()
Definition: Descriptors.java:1612
number
double number
Definition: cJSON.h:326
com.google.protobuf.Descriptors.FileDescriptor.findDescriptors
static FileDescriptor[] findDescriptors(final Class<?> descriptorOuterClass, final String[] dependencyClassNames, final String[] dependencyFileNames)
Definition: Descriptors.java:337
message
GLenum GLuint GLenum GLsizei const GLchar * message
Definition: glcorearb.h:2695
com.google.protobuf.Descriptors.FileDescriptor.getOptions
FileOptions getOptions()
Definition: Descriptors.java:121
com.google.protobuf.FieldSet.FieldDescriptorLite
Definition: FieldSet.java:57
com.google.protobuf.Message
Definition: Message.java:50
google::protobuf::method
const Descriptor::ReservedRange const EnumValueDescriptor method
Definition: src/google/protobuf/descriptor.h:1973
com.google.protobuf.Descriptors.OneofDescriptor.containingType
Descriptor containingType
Definition: Descriptors.java:2668
com.google.protobuf.Descriptors.Descriptor.toProto
DescriptorProto toProto()
Definition: Descriptors.java:652
OneofDescriptor
struct OneofDescriptor OneofDescriptor
Definition: ruby/ext/google/protobuf_c/protobuf.h:58
com.google.protobuf.Descriptors.FieldDescriptor.Type.SINT64
SINT64
Definition: Descriptors.java:1233
com.google.protobuf.TextFormat
Definition: TextFormat.java:55
com.google.protobuf.Descriptors.OneofDescriptor.toProto
OneofDescriptorProto toProto()
Definition: Descriptors.java:2640
com.google.protobuf.Descriptors.DescriptorPool.PackageDescriptor.toProto
Message toProto()
Definition: Descriptors.java:2442
com.google.protobuf.Descriptors.FieldDescriptor.Type.INT64
INT64
Definition: Descriptors.java:1218
com.google.protobuf.Descriptors.FieldDescriptor.getEnumType
EnumDescriptor getEnumType()
Definition: Descriptors.java:1168
com.google.protobuf.MessageLite
Definition: MessageLite.java:65
com.google.protobuf.Descriptors.Descriptor.getName
String getName()
Definition: Descriptors.java:658
com.google.protobuf.Descriptors.FileDescriptor.internalUpdateFileDescriptor
static void internalUpdateFileDescriptor(final FileDescriptor descriptor, final ExtensionRegistry registry)
Definition: Descriptors.java:462
com.google.protobuf.Descriptors.Descriptor.getFile
FileDescriptor getFile()
Definition: Descriptors.java:681
com.google.protobuf.Descriptors.FieldDescriptor.Type.ENUM
ENUM
Definition: Descriptors.java:1229
com.google.protobuf.Descriptors.Descriptor.findFieldByNumber
FieldDescriptor findFieldByNumber(final int number)
Definition: Descriptors.java:780
com.google.protobuf.Descriptors.FieldDescriptor
Definition: Descriptors.java:949
com.google.protobuf.Descriptors.FieldDescriptor.getMessageType
Descriptor getMessageType()
Definition: Descriptors.java:1158
com.google.protobuf.Descriptors.OneofDescriptor.proto
OneofDescriptorProto proto
Definition: Descriptors.java:2664
com.google.protobuf.ByteString
Definition: ByteString.java:67
com.google.protobuf.Descriptors.FieldDescriptor.getFile
FileDescriptor getFile()
Definition: Descriptors.java:1009
com.google.protobuf.WireFormat.JavaType
Definition: WireFormat.java:84
com.google.protobuf.Descriptors.FieldDescriptor.JavaType.MESSAGE
MESSAGE
Definition: Descriptors.java:1271
com.google.protobuf.Descriptors.DescriptorValidationException
Definition: Descriptors.java:2138
com.google.protobuf.Descriptors.EnumDescriptor.findValueByNumberCreatingIfUnknown
EnumValueDescriptor findValueByNumberCreatingIfUnknown(final int number)
Definition: Descriptors.java:1668
com.google.protobuf.Descriptors.FileDescriptor.getName
String getName()
Definition: Descriptors.java:96


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