Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Plugin/Generator/ProtoGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,8 @@ private function generateMessage(
$parameters[] = $field->options?->packed === true;
} elseif ($this->edition !== null) {
// In editions, PACKED is the default for eligible types unless explicitly set to EXPANDED.
$parameters[] = $features?->repeatedFieldEncoding === null || $features->repeatedFieldEncoding === FeatureSet\RepeatedFieldEncoding::PACKED;
// The feature resolves to PACKED for any field, but only packable types are packed.
$parameters[] = $type->packable && ($features?->repeatedFieldEncoding === null || $features->repeatedFieldEncoding === FeatureSet\RepeatedFieldEncoding::PACKED);
} elseif ($field->options?->packed === false) {
// In proto3, packable fields are packed by default, which is also what the runtime does
// when packed is not given; only an explicit [packed = false] needs to be spelled out.
Expand Down
5 changes: 5 additions & 0 deletions src/Plugin/Generator/TypeDeclaration.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ public function __construct(
public bool $isMap = false,
public ?string $docType = null,
public mixed $default = null,
/**
* Whether repeated values of the type can be packed into one length-delimited record:
* only scalar numeric, bool and enum types can, as in protobuf and the runtime (ListT).
*/
public bool $packable = false,
) {}

public function resolvedType(): string
Expand Down
5 changes: 5 additions & 0 deletions src/Plugin/Generator/TypeDeclarationFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public function create(Parser\FieldDescriptor $field, RuntimeImports $runtime):
nullable: !$isEnum,
docType: $fieldType->fqcn,
default: $default,
packable: $isEnum,
);
}

Expand All @@ -59,6 +60,7 @@ public function create(Parser\FieldDescriptor $field, RuntimeImports $runtime):
Type::TYPE_DOUBLE => $runtime->reflection('DoubleT::T'),
}),
default: 0,
packable: true,
),
Type::TYPE_UINT64,
Type::TYPE_FIXED64 => new TypeDeclaration(
Expand All @@ -68,6 +70,7 @@ public function create(Parser\FieldDescriptor $field, RuntimeImports $runtime):
Type::TYPE_FIXED64 => $runtime->reflection('Fixed64T::T'),
}),
default: Literal::new('\BcMath\Number', [0]),
packable: true,
),
Type::TYPE_INT32,
Type::TYPE_UINT32,
Expand All @@ -89,11 +92,13 @@ public function create(Parser\FieldDescriptor $field, RuntimeImports $runtime):
Type::TYPE_SINT64 => $runtime->reflection('SInt64T::T'),
}),
default: 0,
packable: true,
),
Type::TYPE_BOOL => new TypeDeclaration(
phpType: 'bool',
reflectionType: new Literal($runtime->reflection('BoolT::T')),
default: false,
packable: true,
),
Type::TYPE_STRING,
Type::TYPE_BYTES => new TypeDeclaration(
Expand Down
92 changes: 92 additions & 0 deletions tests/GeneratedCode/samples/editions_packed.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?php

declare(strict_types=1);

/**
* Samples of the editions_packed snapshot case, keyed by label (see GeneratedCodeTest): populated messages and a check
* of the wire encoding every repeated field is written in.
*/

use BcMath\Number;
use Editions\Packed\V1\Color;
use Editions\Packed\V1\Inner;
use Editions\Packed\V1\Repeated;
use Editions\Packed\V1\RepeatedExpanded;
use Thesis\Protobuf\Encoder;

return [
'all fields set' => new Repeated(
int32Default: [1, -2, 3],
int32Expanded: [-6, 7],
enumDefault: [Color::COLOR_RED, Color::COLOR_GREEN],
enumExpanded: [Color::COLOR_RED, Color::COLOR_UNSPECIFIED],
boolDefault: [true, false],
boolExpanded: [true, true, false],
sint64Default: [-1, 1],
fixed32Default: [1, 4_294_967_295],
doubleDefault: [1.5, -0.25],
uint64Default: [new Number(1), new Number('18446744073709551615')],
uint64Expanded: [new Number(0), new Number(2)],
stringDefault: ['a', ''],
stringExpanded: ['b'],
bytesDefault: ["\x00\xff", ''],
bytesExpanded: ["\x01"],
messageDefault: [new Inner(1), new Inner()],
messageExpanded: [new Inner(-1)],
),
'all fields set, file default expanded' => new RepeatedExpanded(
int32Default: [1, -2, 3],
int32Packed: [4, 5],
enumDefault: [Color::COLOR_GREEN],
enumPacked: [Color::COLOR_RED, Color::COLOR_UNSPECIFIED],
doubleDefault: [0.5],
doublePacked: [1.5, -0.25],
stringDefault: ['a', ''],
bytesDefault: ["\x00\xff"],
messageDefault: [new Inner(1), new Inner()],
),
'wire encoding follows the repeated_field_encoding feature' => static function (): void {
$encoder = Encoder\Builder::buildDefault();

$expected = [
// PACKED by default: one length-delimited record
'int32Default' => [new Repeated(int32Default: [1, 2]), "\x0A\x02\x01\x02"],
'enumDefault' => [new Repeated(enumDefault: [Color::COLOR_RED, Color::COLOR_GREEN]), "\x1A\x02\x01\x02"],
'boolDefault' => [new Repeated(boolDefault: [true, false]), "\x2A\x02\x01\x00"],
'sint64Default' => [new Repeated(sint64Default: [-1, 1]), "\x3A\x02\x01\x02"],
'fixed32Default' => [new Repeated(fixed32Default: [1, 2]), "\x42\x08\x01\x00\x00\x00\x02\x00\x00\x00"],
'doubleDefault' => [new Repeated(doubleDefault: [1.5]), "\x4A\x08" . pack('e', 1.5)],
'uint64Default' => [new Repeated(uint64Default: [new Number(1), new Number(2)]), "\x52\x02\x01\x02"],
// EXPANDED on the field: a record per element
'int32Expanded' => [new Repeated(int32Expanded: [1, 2]), "\x10\x01\x10\x02"],
'enumExpanded' => [new Repeated(enumExpanded: [Color::COLOR_RED, Color::COLOR_GREEN]), "\x20\x01\x20\x02"],
'boolExpanded' => [new Repeated(boolExpanded: [true, false]), "\x30\x01\x30\x00"],
'uint64Expanded' => [new Repeated(uint64Expanded: [new Number(1), new Number(2)]), "\x58\x01\x58\x02"],
// non-packable types: a record per element whatever the feature resolves to
'stringDefault' => [new Repeated(stringDefault: ['a', 'b']), "\x62\x01a\x62\x01b"],
'stringExpanded' => [new Repeated(stringExpanded: ['a', 'b']), "\x6A\x01a\x6A\x01b"],
'bytesDefault' => [new Repeated(bytesDefault: ["\x01"]), "\x72\x01\x01"],
'bytesExpanded' => [new Repeated(bytesExpanded: ["\x01"]), "\x7A\x01\x01"],
'messageDefault' => [new Repeated(messageDefault: [new Inner(1)]), "\x82\x01\x02\x08\x01"],
'messageExpanded' => [new Repeated(messageExpanded: [new Inner(1)]), "\x8A\x01\x02\x08\x01"],
// file default EXPANDED: a record per element unless the field is set to PACKED
'expanded int32Default' => [new RepeatedExpanded(int32Default: [1, 2]), "\x08\x01\x08\x02"],
'expanded int32Packed' => [new RepeatedExpanded(int32Packed: [1, 2]), "\x12\x02\x01\x02"],
'expanded enumDefault' => [new RepeatedExpanded(enumDefault: [Color::COLOR_RED, Color::COLOR_GREEN]), "\x18\x01\x18\x02"],
'expanded enumPacked' => [new RepeatedExpanded(enumPacked: [Color::COLOR_RED, Color::COLOR_GREEN]), "\x22\x02\x01\x02"],
'expanded doubleDefault' => [new RepeatedExpanded(doubleDefault: [1.5]), "\x29" . pack('e', 1.5)],
'expanded doublePacked' => [new RepeatedExpanded(doublePacked: [1.5]), "\x32\x08" . pack('e', 1.5)],
'expanded stringDefault' => [new RepeatedExpanded(stringDefault: ['a', 'b']), "\x3A\x01a\x3A\x01b"],
'expanded bytesDefault' => [new RepeatedExpanded(bytesDefault: ["\x01"]), "\x42\x01\x01"],
'expanded messageDefault' => [new RepeatedExpanded(messageDefault: [new Inner(1)]), "\x4A\x02\x08\x01"],
];

foreach ($expected as $property => [$message, $bytes]) {
$actual = $encoder->encode($message);

if ($actual !== $bytes) {
throw new LogicException(sprintf('%s: expected %s on the wire, got %s', $property, bin2hex($bytes), bin2hex($actual)));
}
}
},
];
20 changes: 20 additions & 0 deletions tests/fixtures/editions_packed/expanded.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
edition = "2023";

package editions.packed.v1;

import "packed.proto";

option features.repeated_field_encoding = EXPANDED;

// The file default is EXPANDED: packable fields are packed only when set to PACKED.
message RepeatedExpanded {
repeated int32 int32_default = 1;
repeated int32 int32_packed = 2 [features.repeated_field_encoding = PACKED];
repeated Color enum_default = 3;
repeated Color enum_packed = 4 [features.repeated_field_encoding = PACKED];
repeated double double_default = 5;
repeated double double_packed = 6 [features.repeated_field_encoding = PACKED];
repeated string string_default = 7;
repeated bytes bytes_default = 8;
repeated Inner message_default = 9;
}
35 changes: 35 additions & 0 deletions tests/fixtures/editions_packed/packed.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
edition = "2023";

package editions.packed.v1;

enum Color {
COLOR_UNSPECIFIED = 0;
COLOR_RED = 1;
COLOR_GREEN = 2;
}

message Inner {
int32 value = 1;
}

// features.repeated_field_encoding is PACKED by default: packable fields are packed unless set to EXPANDED.
message Repeated {
repeated int32 int32_default = 1;
repeated int32 int32_expanded = 2 [features.repeated_field_encoding = EXPANDED];
repeated Color enum_default = 3;
repeated Color enum_expanded = 4 [features.repeated_field_encoding = EXPANDED];
repeated bool bool_default = 5;
repeated bool bool_expanded = 6 [features.repeated_field_encoding = EXPANDED];
repeated sint64 sint64_default = 7;
repeated fixed32 fixed32_default = 8;
repeated double double_default = 9;
repeated uint64 uint64_default = 10;
repeated uint64 uint64_expanded = 11 [features.repeated_field_encoding = EXPANDED];
// Non-packable types are never packed, although the feature resolves to PACKED for them too.
repeated string string_default = 12;
repeated string string_expanded = 13 [features.repeated_field_encoding = EXPANDED];
repeated bytes bytes_default = 14;
repeated bytes bytes_expanded = 15 [features.repeated_field_encoding = EXPANDED];
repeated Inner message_default = 16;
repeated Inner message_expanded = 17 [features.repeated_field_encoding = EXPANDED];
}
23 changes: 23 additions & 0 deletions tests/snapshots/editions_packed/Editions/Packed/V1/Color.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

/**
* Code generated by thesis/protoc-plugin. DO NOT EDIT.
* Versions:
* thesis/protoc-plugin — v0.6.x-dev
* protoc — v6.32.1
* Source: packed.proto
*/

declare(strict_types=1);

namespace Editions\Packed\V1;

/**
* @api
*/
enum Color: int
{
case COLOR_UNSPECIFIED = 0;
case COLOR_RED = 1;
case COLOR_GREEN = 2;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

/**
* Code generated by thesis/protoc-plugin. DO NOT EDIT.
* Versions:
* thesis/protoc-plugin — v0.6.x-dev
* protoc — v6.32.1
* Source: expanded.proto, packed.proto
*/

declare(strict_types=1);

namespace Editions\Packed\V1;

use Override;
use Thesis\Protobuf\Registry;
use Thesis\Protobuf\Registry\File;

/**
* @api
*/
final readonly class DescriptorRegistry implements Registry\Registrar
{
private const string EXPANDED_DESCRIPTOR_BUFFER = 'Cg5leHBhbmRlZC5wcm90bxISZWRpdGlvbnMucGFja2VkLnYxGgxwYWNrZWQucHJvdG8ixQMKEFJlcGVhdGVkRXhwYW5kZWQSIwoNaW50MzJfZGVmYXVsdBgBIAMoBVIMaW50MzJEZWZhdWx0EigKDGludDMyX3BhY2tlZBgCIAMoBVILaW50MzJQYWNrZWRCBaoBAhgBEjwKDGVudW1fZGVmYXVsdBgDIAMoDjIZLmVkaXRpb25zLnBhY2tlZC52MS5Db2xvclILZW51bURlZmF1bHQSQQoLZW51bV9wYWNrZWQYBCADKA4yGS5lZGl0aW9ucy5wYWNrZWQudjEuQ29sb3JSCmVudW1QYWNrZWRCBaoBAhgBEiUKDmRvdWJsZV9kZWZhdWx0GAUgAygBUg1kb3VibGVEZWZhdWx0EioKDWRvdWJsZV9wYWNrZWQYBiADKAFSDGRvdWJsZVBhY2tlZEIFqgECGAESJQoOc3RyaW5nX2RlZmF1bHQYByADKAlSDXN0cmluZ0RlZmF1bHQSIwoNYnl0ZXNfZGVmYXVsdBgIIAMoDFIMYnl0ZXNEZWZhdWx0EkIKD21lc3NhZ2VfZGVmYXVsdBgJIAMoCzIZLmVkaXRpb25zLnBhY2tlZC52MS5Jbm5lclIObWVzc2FnZURlZmF1bHRCB0gBkgMCGAJK8QYKBhIEAAATAQoICgEMEgMAABEKCAoBAhIDAgAbCgkKAgMAEgMEABYKCAoBCBIDBgAzCgoKAwgyAxIDBgAzCl8KAgQAEgQJABMBGlMgVGhlIGZpbGUgZGVmYXVsdCBpcyBFWFBBTkRFRDogcGFja2FibGUgZmllbGRzIG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BIDHQRXCgwKBQQBAgwEEgMdBAwKDAoFBAECDAUSAx0NEwoMCgUEAQIMARIDHRQjCgwKBQQBAgwDEgMdJigKDAoFBAECDAgSAx0pVgoOCgcEAQIMCBUDEgMdKlUKCwoEBAECDRIDHgQmCgwKBQQBAg0EEgMeBAwKDAoFBAECDQUSAx4NEgoMCgUEAQINARIDHhMgCgwKBQQBAg0DEgMeIyUKCwoEBAECDhIDHwRVCgwKBQQBAg4EEgMfBAwKDAoFBAECDgUSAx8NEgoMCgUEAQIOARIDHxMhCgwKBQQBAg4DEgMfJCYKDAoFBAECDggSAx8nVAoOCgcEAQIOCBUDEgMfKFMKCwoEBAECDxIDIAQoCgwKBQQBAg8EEgMgBAwKDAoFBAECDwYSAyANEgoMCgUEAQIPARIDIBMiCgwKBQQBAg8DEgMgJScKCwoEBAECEBIDIQRXCgwKBQQBAhAEEgMhBAwKDAoFBAECEAYSAyENEgoMCgUEAQIQARIDIRMjCgwKBQQBAhADEgMhJigKDAoFBAECEAgSAyEpVgoOCgcEAQIQCBUDEgMhKlViCGVkaXRpb25zcOgH';

#[Override]
public function register(Registry\Pool $pool): void
{
$pool->add(Registry\Descriptor::base64(self::EXPANDED_DESCRIPTOR_BUFFER), new File(
name: 'expanded.proto',
dependencies: [
'packed.proto',
],
messages: [
new File\MessageDescriptor('editions.packed.v1.RepeatedExpanded', \Editions\Packed\V1\RepeatedExpanded::class),
],
));

$pool->add(Registry\Descriptor::base64(self::PACKED_DESCRIPTOR_BUFFER), new File(
name: 'packed.proto',
messages: [
new File\MessageDescriptor('editions.packed.v1.Inner', \Editions\Packed\V1\Inner::class),
new File\MessageDescriptor('editions.packed.v1.Repeated', \Editions\Packed\V1\Repeated::class),
],
enums: [
new File\EnumDescriptor('editions.packed.v1.Color', \Editions\Packed\V1\Color::class),
],
));
}
}
26 changes: 26 additions & 0 deletions tests/snapshots/editions_packed/Editions/Packed/V1/Inner.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

/**
* Code generated by thesis/protoc-plugin. DO NOT EDIT.
* Versions:
* thesis/protoc-plugin — v0.6.x-dev
* protoc — v6.32.1
* Source: packed.proto
*/

declare(strict_types=1);

namespace Editions\Packed\V1;

use Thesis\Protobuf\Reflection;

/**
* @api
*/
final readonly class Inner
{
public function __construct(
#[Reflection\Field(1, Reflection\Int32T::T)]
public ?int $value = null,
) {}
}
Loading