Java Code Examples for com.google.protobuf.DescriptorProtos.DescriptorProto#getNestedTypeCount()

The following examples show how to use com.google.protobuf.DescriptorProtos.DescriptorProto#getNestedTypeCount() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExtensionPool.java    From api-compiler with Apache License 2.0 5 votes vote down vote up
private void add(DescriptorProto message) {
  fullNameSegments.push(message.getName());
  pathSegments.push(DescriptorProto.EXTENSION_FIELD_NUMBER);
  add(message.getExtensionList());
  pathSegments.pop();
  pathSegments.push(DescriptorProto.NESTED_TYPE_FIELD_NUMBER);
  for (int i = 0; i < message.getNestedTypeCount(); i++) {
    pathSegments.push(i);
    DescriptorProto nested = message.getNestedType(i);
    add(nested);
    pathSegments.pop();
  }
  pathSegments.pop();
  fullNameSegments.pop();
}
 
Example 2
Source File: Descriptors.java    From play-store-api with GNU General Public License v3.0 4 votes vote down vote up
private Descriptor(final DescriptorProto proto,
                   final FileDescriptor file,
                   final Descriptor parent,
                   final int index)
            throws DescriptorValidationException {
  this.index = index;
  this.proto = proto;
  fullName = computeFullName(file, parent, proto.getName());
  this.file = file;
  containingType = parent;

  oneofs = new OneofDescriptor[proto.getOneofDeclCount()];
  for (int i = 0; i < proto.getOneofDeclCount(); i++) {
    oneofs[i] = new OneofDescriptor(
      proto.getOneofDecl(i), file, this, i);
  }

  nestedTypes = new Descriptor[proto.getNestedTypeCount()];
  for (int i = 0; i < proto.getNestedTypeCount(); i++) {
    nestedTypes[i] = new Descriptor(
      proto.getNestedType(i), file, this, i);
  }

  enumTypes = new EnumDescriptor[proto.getEnumTypeCount()];
  for (int i = 0; i < proto.getEnumTypeCount(); i++) {
    enumTypes[i] = new EnumDescriptor(
      proto.getEnumType(i), file, this, i);
  }

  fields = new FieldDescriptor[proto.getFieldCount()];
  for (int i = 0; i < proto.getFieldCount(); i++) {
    fields[i] = new FieldDescriptor(
      proto.getField(i), file, this, i, false);
  }

  extensions = new FieldDescriptor[proto.getExtensionCount()];
  for (int i = 0; i < proto.getExtensionCount(); i++) {
    extensions[i] = new FieldDescriptor(
      proto.getExtension(i), file, this, i, true);
  }

  for (int i = 0; i < proto.getOneofDeclCount(); i++) {
    oneofs[i].fields = new FieldDescriptor[oneofs[i].getFieldCount()];
    oneofs[i].fieldCount = 0;
  }
  for (int i = 0; i < proto.getFieldCount(); i++) {
    OneofDescriptor oneofDescriptor = fields[i].getContainingOneof();
    if (oneofDescriptor != null) {
      oneofDescriptor.fields[oneofDescriptor.fieldCount++] = fields[i];
    }
  }

  file.pool.addSymbol(this);
}