/** * {@inheritdoc} */ public function readFrom(\Protobuf\ReadContext $context) { $reader = $context->getReader(); $length = $context->getLength(); $stream = $context->getStream(); $limit = $length !== null ? $stream->tell() + $length : null; while ($limit === null || $stream->tell() < $limit) { if ($stream->eof()) { break; } $key = $reader->readVarint($stream); $wire = \Protobuf\WireFormat::getTagWireType($key); $tag = \Protobuf\WireFormat::getTagFieldNumber($key); if ($stream->eof()) { break; } if ($tag === 1) { \Protobuf\WireFormat::assertWireType($wire, 9); $this->name = $reader->readString($stream); continue; } if ($tag === 2) { \Protobuf\WireFormat::assertWireType($wire, 11); $innerSize = $reader->readVarint($stream); $innerMessage = new \google\protobuf\FieldDescriptorProto(); if ($this->field === null) { $this->field = new \Protobuf\MessageCollection(); } $this->field->add($innerMessage); $context->setLength($innerSize); $innerMessage->readFrom($context); $context->setLength($length); continue; } if ($tag === 6) { \Protobuf\WireFormat::assertWireType($wire, 11); $innerSize = $reader->readVarint($stream); $innerMessage = new \google\protobuf\FieldDescriptorProto(); if ($this->extension === null) { $this->extension = new \Protobuf\MessageCollection(); } $this->extension->add($innerMessage); $context->setLength($innerSize); $innerMessage->readFrom($context); $context->setLength($length); continue; } if ($tag === 3) { \Protobuf\WireFormat::assertWireType($wire, 11); $innerSize = $reader->readVarint($stream); $innerMessage = new \google\protobuf\DescriptorProto(); if ($this->nested_type === null) { $this->nested_type = new \Protobuf\MessageCollection(); } $this->nested_type->add($innerMessage); $context->setLength($innerSize); $innerMessage->readFrom($context); $context->setLength($length); continue; } if ($tag === 4) { \Protobuf\WireFormat::assertWireType($wire, 11); $innerSize = $reader->readVarint($stream); $innerMessage = new \google\protobuf\EnumDescriptorProto(); if ($this->enum_type === null) { $this->enum_type = new \Protobuf\MessageCollection(); } $this->enum_type->add($innerMessage); $context->setLength($innerSize); $innerMessage->readFrom($context); $context->setLength($length); continue; } if ($tag === 5) { \Protobuf\WireFormat::assertWireType($wire, 11); $innerSize = $reader->readVarint($stream); $innerMessage = new \google\protobuf\DescriptorProto\ExtensionRange(); if ($this->extension_range === null) { $this->extension_range = new \Protobuf\MessageCollection(); } $this->extension_range->add($innerMessage); $context->setLength($innerSize); $innerMessage->readFrom($context); $context->setLength($length); continue; } if ($tag === 8) { \Protobuf\WireFormat::assertWireType($wire, 11); $innerSize = $reader->readVarint($stream); $innerMessage = new \google\protobuf\OneofDescriptorProto(); if ($this->oneof_decl === null) { $this->oneof_decl = new \Protobuf\MessageCollection(); } $this->oneof_decl->add($innerMessage); $context->setLength($innerSize); $innerMessage->readFrom($context); $context->setLength($length); continue; } if ($tag === 7) { \Protobuf\WireFormat::assertWireType($wire, 11); $innerSize = $reader->readVarint($stream); $innerMessage = new \google\protobuf\MessageOptions(); $this->options = $innerMessage; $context->setLength($innerSize); $innerMessage->readFrom($context); $context->setLength($length); continue; } if ($tag === 9) { \Protobuf\WireFormat::assertWireType($wire, 11); $innerSize = $reader->readVarint($stream); $innerMessage = new \google\protobuf\DescriptorProto\ReservedRange(); if ($this->reserved_range === null) { $this->reserved_range = new \Protobuf\MessageCollection(); } $this->reserved_range->add($innerMessage); $context->setLength($innerSize); $innerMessage->readFrom($context); $context->setLength($length); continue; } if ($tag === 10) { \Protobuf\WireFormat::assertWireType($wire, 9); if ($this->reserved_name === null) { $this->reserved_name = new \Protobuf\ScalarCollection(); } $this->reserved_name->add($reader->readString($stream)); continue; } $extensions = $context->getExtensionRegistry(); $extension = $extensions ? $extensions->findByNumber(__CLASS__, $tag) : null; if ($extension !== null) { $this->extensions()->add($extension, $extension->readFrom($context, $wire)); continue; } if ($this->unknownFieldSet === null) { $this->unknownFieldSet = new \Protobuf\UnknownFieldSet(); } $data = $reader->readUnknown($stream, $wire); $unknown = new \Protobuf\Unknown($tag, $wire, $data); $this->unknownFieldSet->add($unknown); } }
/** * {@inheritdoc} */ public function readFrom(\Protobuf\ReadContext $context) { $reader = $context->getReader(); $length = $context->getLength(); $stream = $context->getStream(); $limit = $length !== null ? $stream->tell() + $length : null; while ($limit === null || $stream->tell() < $limit) { if ($stream->eof()) { break; } $key = $reader->readVarint($stream); $wire = \Protobuf\WireFormat::getTagWireType($key); $tag = \Protobuf\WireFormat::getTagFieldNumber($key); if ($stream->eof()) { break; } if ($tag === 1) { \Protobuf\WireFormat::assertWireType($wire, 9); $this->name = $reader->readString($stream); continue; } if ($tag === 2) { \Protobuf\WireFormat::assertWireType($wire, 9); $this->package = $reader->readString($stream); continue; } if ($tag === 3) { \Protobuf\WireFormat::assertWireType($wire, 9); if ($this->dependency === null) { $this->dependency = new \Protobuf\ScalarCollection(); } $this->dependency->add($reader->readString($stream)); continue; } if ($tag === 10) { \Protobuf\WireFormat::assertWireType($wire, 5); if ($this->public_dependency === null) { $this->public_dependency = new \Protobuf\ScalarCollection(); } $this->public_dependency->add($reader->readVarint($stream)); continue; } if ($tag === 11) { \Protobuf\WireFormat::assertWireType($wire, 5); if ($this->weak_dependency === null) { $this->weak_dependency = new \Protobuf\ScalarCollection(); } $this->weak_dependency->add($reader->readVarint($stream)); continue; } if ($tag === 4) { \Protobuf\WireFormat::assertWireType($wire, 11); $innerSize = $reader->readVarint($stream); $innerMessage = new \google\protobuf\DescriptorProto(); if ($this->message_type === null) { $this->message_type = new \Protobuf\MessageCollection(); } $this->message_type->add($innerMessage); $context->setLength($innerSize); $innerMessage->readFrom($context); $context->setLength($length); continue; } if ($tag === 5) { \Protobuf\WireFormat::assertWireType($wire, 11); $innerSize = $reader->readVarint($stream); $innerMessage = new \google\protobuf\EnumDescriptorProto(); if ($this->enum_type === null) { $this->enum_type = new \Protobuf\MessageCollection(); } $this->enum_type->add($innerMessage); $context->setLength($innerSize); $innerMessage->readFrom($context); $context->setLength($length); continue; } if ($tag === 6) { \Protobuf\WireFormat::assertWireType($wire, 11); $innerSize = $reader->readVarint($stream); $innerMessage = new \google\protobuf\ServiceDescriptorProto(); if ($this->service === null) { $this->service = new \Protobuf\MessageCollection(); } $this->service->add($innerMessage); $context->setLength($innerSize); $innerMessage->readFrom($context); $context->setLength($length); continue; } if ($tag === 7) { \Protobuf\WireFormat::assertWireType($wire, 11); $innerSize = $reader->readVarint($stream); $innerMessage = new \google\protobuf\FieldDescriptorProto(); if ($this->extension === null) { $this->extension = new \Protobuf\MessageCollection(); } $this->extension->add($innerMessage); $context->setLength($innerSize); $innerMessage->readFrom($context); $context->setLength($length); continue; } if ($tag === 8) { \Protobuf\WireFormat::assertWireType($wire, 11); $innerSize = $reader->readVarint($stream); $innerMessage = new \google\protobuf\FileOptions(); $this->options = $innerMessage; $context->setLength($innerSize); $innerMessage->readFrom($context); $context->setLength($length); continue; } if ($tag === 9) { \Protobuf\WireFormat::assertWireType($wire, 11); $innerSize = $reader->readVarint($stream); $innerMessage = new \google\protobuf\SourceCodeInfo(); $this->source_code_info = $innerMessage; $context->setLength($innerSize); $innerMessage->readFrom($context); $context->setLength($length); continue; } if ($tag === 12) { \Protobuf\WireFormat::assertWireType($wire, 9); $this->syntax = $reader->readString($stream); continue; } $extensions = $context->getExtensionRegistry(); $extension = $extensions ? $extensions->findByNumber(__CLASS__, $tag) : null; if ($extension !== null) { $this->extensions()->add($extension, $extension->readFrom($context, $wire)); continue; } if ($this->unknownFieldSet === null) { $this->unknownFieldSet = new \Protobuf\UnknownFieldSet(); } $data = $reader->readUnknown($stream, $wire); $unknown = new \Protobuf\Unknown($tag, $wire, $data); $this->unknownFieldSet->add($unknown); } }