reflect/prototype: hoist semantic options into builders
Add fields to the Message and Field builder structs which hold the value
of MessageOptions.map_entry, FieldOptions.packed, and FieldOptions.weak
options. Remove all access to the contents of options messages from the
prototype package.
Change IsPacked to always return false for unpackable field types,
which is consistent with the equivalent C++ API.
This change helps avoid dependency cycles between prototype and the
options messages. (Previously this was resolved by accessing options
with reflection, but just breaking the dependency from prototype to the
options message is cleaner and simpler.)
Change-Id: I756aefe2e04cfa8fea31eaaaa0b5a99d4ac9e851
Reviewed-on: https://go-review.googlesource.com/c/153517
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
diff --git a/cmd/protoc-gen-go/internal_gengo/reflect.go b/cmd/protoc-gen-go/internal_gengo/reflect.go
index 2126ee9..4cc1089 100644
--- a/cmd/protoc-gen-go/internal_gengo/reflect.go
+++ b/cmd/protoc-gen-go/internal_gengo/reflect.go
@@ -289,6 +289,14 @@
if oneof := field.OneofType(); oneof != nil {
g.P("OneofName: ", strconv.Quote(string(oneof.Name())), ",")
}
+ if field.IsPacked() {
+ g.P("IsPacked: ", prototypePackage.Ident("True"), ",")
+ } else {
+ g.P("IsPacked: ", prototypePackage.Ident("False"), ",")
+ }
+ if field.IsWeak() {
+ g.P("IsWeak: true,")
+ }
// NOTE: MessageType and EnumType are populated by init.
g.P("},")
}
@@ -326,6 +334,9 @@
}
g.P("ExtensionRanges: [][2]", protoreflectPackage.Ident("FieldNumber"), "{", strings.Join(ss, ","), "},")
}
+ if message.Desc.IsMapEntry() {
+ g.P("IsMapEntry: true,")
+ }
// NOTE: Messages, Enums, and Extensions are populated by init.
g.P("},")
}
diff --git a/cmd/protoc-gen-go/testdata/annotations/annotations.pb.go b/cmd/protoc-gen-go/testdata/annotations/annotations.pb.go
index 71b33e9..ef72ffd 100644
--- a/cmd/protoc-gen-go/testdata/annotations/annotations.pb.go
+++ b/cmd/protoc-gen-go/testdata/annotations/annotations.pb.go
@@ -198,6 +198,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "AnnotationsTestField",
+ IsPacked: prototype.False,
},
},
},
diff --git a/cmd/protoc-gen-go/testdata/comments/comments.pb.go b/cmd/protoc-gen-go/testdata/comments/comments.pb.go
index 17d1200..ad1462b 100644
--- a/cmd/protoc-gen-go/testdata/comments/comments.pb.go
+++ b/cmd/protoc-gen-go/testdata/comments/comments.pb.go
@@ -458,6 +458,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "Field1A",
+ IsPacked: prototype.False,
},
{
Name: "Oneof1AField1",
@@ -466,6 +467,7 @@
Kind: protoreflect.StringKind,
JSONName: "Oneof1AField1",
OneofName: "Oneof1a",
+ IsPacked: prototype.False,
},
},
Oneofs: []prototype.Oneof{
diff --git a/cmd/protoc-gen-go/testdata/comments/deprecated.pb.go b/cmd/protoc-gen-go/testdata/comments/deprecated.pb.go
index 86e7968..ae3d74b 100644
--- a/cmd/protoc-gen-go/testdata/comments/deprecated.pb.go
+++ b/cmd/protoc-gen-go/testdata/comments/deprecated.pb.go
@@ -184,6 +184,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "deprecatedField",
+ IsPacked: prototype.False,
},
},
},
diff --git a/cmd/protoc-gen-go/testdata/extensions/base/base.pb.go b/cmd/protoc-gen-go/testdata/extensions/base/base.pb.go
index 602d373..6dfb1f6 100644
--- a/cmd/protoc-gen-go/testdata/extensions/base/base.pb.go
+++ b/cmd/protoc-gen-go/testdata/extensions/base/base.pb.go
@@ -206,6 +206,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "field",
+ IsPacked: prototype.False,
},
},
ExtensionRanges: [][2]protoreflect.FieldNumber{{4, 10}, {16, 536870912}},
diff --git a/cmd/protoc-gen-go/testdata/extensions/ext/ext.pb.go b/cmd/protoc-gen-go/testdata/extensions/ext/ext.pb.go
index e0b3b5b..2a948e1 100644
--- a/cmd/protoc-gen-go/testdata/extensions/ext/ext.pb.go
+++ b/cmd/protoc-gen-go/testdata/extensions/ext/ext.pb.go
@@ -1131,6 +1131,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.BytesKind,
JSONName: "data",
+ IsPacked: prototype.False,
},
},
},
@@ -1143,6 +1144,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "extensionGroup",
+ IsPacked: prototype.False,
},
},
},
@@ -1158,6 +1160,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.StringKind,
JSONName: "repeatedXGroup",
+ IsPacked: prototype.False,
},
},
},
diff --git a/cmd/protoc-gen-go/testdata/extensions/extra/extra.pb.go b/cmd/protoc-gen-go/testdata/extensions/extra/extra.pb.go
index 9bcf01a..a01577f 100644
--- a/cmd/protoc-gen-go/testdata/extensions/extra/extra.pb.go
+++ b/cmd/protoc-gen-go/testdata/extensions/extra/extra.pb.go
@@ -128,6 +128,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.BytesKind,
JSONName: "data",
+ IsPacked: prototype.False,
},
},
},
diff --git a/cmd/protoc-gen-go/testdata/fieldnames/fieldnames.pb.go b/cmd/protoc-gen-go/testdata/fieldnames/fieldnames.pb.go
index 32866bb..fff2bd7 100644
--- a/cmd/protoc-gen-go/testdata/fieldnames/fieldnames.pb.go
+++ b/cmd/protoc-gen-go/testdata/fieldnames/fieldnames.pb.go
@@ -426,6 +426,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "fieldOne",
+ IsPacked: prototype.False,
},
{
Name: "FieldTwo",
@@ -433,6 +434,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "FieldTwo",
+ IsPacked: prototype.False,
},
{
Name: "fieldThree",
@@ -440,6 +442,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "fieldThree",
+ IsPacked: prototype.False,
},
{
Name: "field__four",
@@ -447,6 +450,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "fieldFour",
+ IsPacked: prototype.False,
},
{
Name: "descriptor",
@@ -454,6 +458,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "descriptor",
+ IsPacked: prototype.False,
},
{
Name: "marshal",
@@ -461,6 +466,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "marshal",
+ IsPacked: prototype.False,
},
{
Name: "unmarshal",
@@ -468,6 +474,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "unmarshal",
+ IsPacked: prototype.False,
},
{
Name: "proto_message",
@@ -475,6 +482,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "protoMessage",
+ IsPacked: prototype.False,
},
{
Name: "CamelCase",
@@ -482,6 +490,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "CamelCase",
+ IsPacked: prototype.False,
},
{
Name: "CamelCase_",
@@ -489,6 +498,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "CamelCase",
+ IsPacked: prototype.False,
},
{
Name: "camel_case",
@@ -496,6 +506,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "camelCase",
+ IsPacked: prototype.False,
},
{
Name: "CamelCase__",
@@ -503,6 +514,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "CamelCase",
+ IsPacked: prototype.False,
},
{
Name: "get_name",
@@ -510,6 +522,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "getName",
+ IsPacked: prototype.False,
},
{
Name: "name",
@@ -517,6 +530,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "name",
+ IsPacked: prototype.False,
},
{
Name: "OneofConflictA",
@@ -525,6 +539,7 @@
Kind: protoreflect.StringKind,
JSONName: "OneofConflictA",
OneofName: "oneof_conflict_a",
+ IsPacked: prototype.False,
},
{
Name: "oneof_no_conflict",
@@ -533,6 +548,7 @@
Kind: protoreflect.StringKind,
JSONName: "oneofNoConflict",
OneofName: "oneof_conflict_b",
+ IsPacked: prototype.False,
},
{
Name: "OneofConflictB",
@@ -541,6 +557,7 @@
Kind: protoreflect.StringKind,
JSONName: "OneofConflictB",
OneofName: "oneof_conflict_b",
+ IsPacked: prototype.False,
},
{
Name: "oneof_message_conflict",
@@ -549,6 +566,7 @@
Kind: protoreflect.StringKind,
JSONName: "oneofMessageConflict",
OneofName: "oneof_conflict_c",
+ IsPacked: prototype.False,
},
},
Oneofs: []prototype.Oneof{
diff --git a/cmd/protoc-gen-go/testdata/import_public/a.pb.go b/cmd/protoc-gen-go/testdata/import_public/a.pb.go
index e324cc2..5cb190b 100644
--- a/cmd/protoc-gen-go/testdata/import_public/a.pb.go
+++ b/cmd/protoc-gen-go/testdata/import_public/a.pb.go
@@ -196,6 +196,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.MessageKind,
JSONName: "m",
+ IsPacked: prototype.False,
},
{
Name: "e",
@@ -203,6 +204,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.EnumKind,
JSONName: "e",
+ IsPacked: prototype.False,
},
{
Name: "local",
@@ -210,6 +212,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.MessageKind,
JSONName: "local",
+ IsPacked: prototype.False,
},
},
},
diff --git a/cmd/protoc-gen-go/testdata/import_public/b.pb.go b/cmd/protoc-gen-go/testdata/import_public/b.pb.go
index 9b6589e..878425a 100644
--- a/cmd/protoc-gen-go/testdata/import_public/b.pb.go
+++ b/cmd/protoc-gen-go/testdata/import_public/b.pb.go
@@ -143,6 +143,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.MessageKind,
JSONName: "m",
+ IsPacked: prototype.False,
},
{
Name: "e",
@@ -150,6 +151,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.EnumKind,
JSONName: "e",
+ IsPacked: prototype.False,
},
},
},
diff --git a/cmd/protoc-gen-go/testdata/import_public/sub/a.pb.go b/cmd/protoc-gen-go/testdata/import_public/sub/a.pb.go
index ec8b341..faefc5e 100644
--- a/cmd/protoc-gen-go/testdata/import_public/sub/a.pb.go
+++ b/cmd/protoc-gen-go/testdata/import_public/sub/a.pb.go
@@ -546,6 +546,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.MessageKind,
JSONName: "m2",
+ IsPacked: prototype.False,
},
{
Name: "s",
@@ -554,6 +555,7 @@
Kind: protoreflect.StringKind,
JSONName: "s",
Default: protoreflect.ValueOf(string("default")),
+ IsPacked: prototype.False,
},
{
Name: "b",
@@ -562,6 +564,7 @@
Kind: protoreflect.BytesKind,
JSONName: "b",
Default: protoreflect.ValueOf(("default")),
+ IsPacked: prototype.False,
},
{
Name: "f",
@@ -570,6 +573,7 @@
Kind: protoreflect.DoubleKind,
JSONName: "f",
Default: protoreflect.ValueOf(float64(math.NaN())),
+ IsPacked: prototype.False,
},
{
Name: "oneof_int32",
@@ -578,6 +582,7 @@
Kind: protoreflect.Int32Kind,
JSONName: "oneofInt32",
OneofName: "oneof_field",
+ IsPacked: prototype.False,
},
{
Name: "oneof_int64",
@@ -586,6 +591,7 @@
Kind: protoreflect.Int64Kind,
JSONName: "oneofInt64",
OneofName: "oneof_field",
+ IsPacked: prototype.False,
},
},
Oneofs: []prototype.Oneof{
@@ -603,6 +609,7 @@
Kind: protoreflect.Int32Kind,
JSONName: "submessageOneofInt32",
OneofName: "submessage_oneof_field",
+ IsPacked: prototype.False,
},
{
Name: "submessage_oneof_int64",
@@ -611,6 +618,7 @@
Kind: protoreflect.Int64Kind,
JSONName: "submessageOneofInt64",
OneofName: "submessage_oneof_field",
+ IsPacked: prototype.False,
},
},
Oneofs: []prototype.Oneof{
diff --git a/cmd/protoc-gen-go/testdata/imports/test_a_1/m1.pb.go b/cmd/protoc-gen-go/testdata/imports/test_a_1/m1.pb.go
index 50006a4..91da206 100644
--- a/cmd/protoc-gen-go/testdata/imports/test_a_1/m1.pb.go
+++ b/cmd/protoc-gen-go/testdata/imports/test_a_1/m1.pb.go
@@ -241,6 +241,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.MessageKind,
JSONName: "m1",
+ IsPacked: prototype.False,
},
},
},
diff --git a/cmd/protoc-gen-go/testdata/imports/test_import_a1m1.pb.go b/cmd/protoc-gen-go/testdata/imports/test_import_a1m1.pb.go
index 67f5a50..fcb6000 100644
--- a/cmd/protoc-gen-go/testdata/imports/test_import_a1m1.pb.go
+++ b/cmd/protoc-gen-go/testdata/imports/test_import_a1m1.pb.go
@@ -133,6 +133,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.MessageKind,
JSONName: "f",
+ IsPacked: prototype.False,
},
},
},
diff --git a/cmd/protoc-gen-go/testdata/imports/test_import_a1m2.pb.go b/cmd/protoc-gen-go/testdata/imports/test_import_a1m2.pb.go
index 070d020..20ec02c 100644
--- a/cmd/protoc-gen-go/testdata/imports/test_import_a1m2.pb.go
+++ b/cmd/protoc-gen-go/testdata/imports/test_import_a1m2.pb.go
@@ -133,6 +133,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.MessageKind,
JSONName: "f",
+ IsPacked: prototype.False,
},
},
},
diff --git a/cmd/protoc-gen-go/testdata/imports/test_import_all.pb.go b/cmd/protoc-gen-go/testdata/imports/test_import_all.pb.go
index f4265e2..1ddae96 100644
--- a/cmd/protoc-gen-go/testdata/imports/test_import_all.pb.go
+++ b/cmd/protoc-gen-go/testdata/imports/test_import_all.pb.go
@@ -184,6 +184,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.MessageKind,
JSONName: "am1",
+ IsPacked: prototype.False,
},
{
Name: "am2",
@@ -191,6 +192,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.MessageKind,
JSONName: "am2",
+ IsPacked: prototype.False,
},
{
Name: "bm1",
@@ -198,6 +200,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.MessageKind,
JSONName: "bm1",
+ IsPacked: prototype.False,
},
{
Name: "bm2",
@@ -205,6 +208,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.MessageKind,
JSONName: "bm2",
+ IsPacked: prototype.False,
},
{
Name: "fmt",
@@ -212,6 +216,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.MessageKind,
JSONName: "fmt",
+ IsPacked: prototype.False,
},
},
},
diff --git a/cmd/protoc-gen-go/testdata/nopackage/nopackage.pb.go b/cmd/protoc-gen-go/testdata/nopackage/nopackage.pb.go
index 4174d6d..6bfdcee 100644
--- a/cmd/protoc-gen-go/testdata/nopackage/nopackage.pb.go
+++ b/cmd/protoc-gen-go/testdata/nopackage/nopackage.pb.go
@@ -205,6 +205,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "stringField",
+ IsPacked: prototype.False,
},
{
Name: "enum_field",
@@ -213,6 +214,7 @@
Kind: protoreflect.EnumKind,
JSONName: "enumField",
Default: protoreflect.ValueOf(string("ZERO")),
+ IsPacked: prototype.False,
},
},
},
diff --git a/cmd/protoc-gen-go/testdata/proto2/enum.pb.go b/cmd/protoc-gen-go/testdata/proto2/enum.pb.go
index 3ff891b..f5d0dd4 100644
--- a/cmd/protoc-gen-go/testdata/proto2/enum.pb.go
+++ b/cmd/protoc-gen-go/testdata/proto2/enum.pb.go
@@ -611,6 +611,7 @@
Kind: protoreflect.EnumKind,
JSONName: "defaultDuplicate1",
Default: protoreflect.ValueOf(string("duplicate1")),
+ IsPacked: prototype.False,
},
{
Name: "default_duplicate2",
@@ -619,6 +620,7 @@
Kind: protoreflect.EnumKind,
JSONName: "defaultDuplicate2",
Default: protoreflect.ValueOf(string("duplicate2")),
+ IsPacked: prototype.False,
},
},
},
diff --git a/cmd/protoc-gen-go/testdata/proto2/fields.pb.go b/cmd/protoc-gen-go/testdata/proto2/fields.pb.go
index e296e51..0e51367 100644
--- a/cmd/protoc-gen-go/testdata/proto2/fields.pb.go
+++ b/cmd/protoc-gen-go/testdata/proto2/fields.pb.go
@@ -1673,6 +1673,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.BoolKind,
JSONName: "optionalBool",
+ IsPacked: prototype.False,
},
{
Name: "optional_enum",
@@ -1680,6 +1681,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.EnumKind,
JSONName: "optionalEnum",
+ IsPacked: prototype.False,
},
{
Name: "optional_int32",
@@ -1687,6 +1689,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.Int32Kind,
JSONName: "optionalInt32",
+ IsPacked: prototype.False,
},
{
Name: "optional_sint32",
@@ -1694,6 +1697,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.Sint32Kind,
JSONName: "optionalSint32",
+ IsPacked: prototype.False,
},
{
Name: "optional_uint32",
@@ -1701,6 +1705,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.Uint32Kind,
JSONName: "optionalUint32",
+ IsPacked: prototype.False,
},
{
Name: "optional_int64",
@@ -1708,6 +1713,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.Int64Kind,
JSONName: "optionalInt64",
+ IsPacked: prototype.False,
},
{
Name: "optional_sint64",
@@ -1715,6 +1721,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.Sint64Kind,
JSONName: "optionalSint64",
+ IsPacked: prototype.False,
},
{
Name: "optional_uint64",
@@ -1722,6 +1729,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.Uint64Kind,
JSONName: "optionalUint64",
+ IsPacked: prototype.False,
},
{
Name: "optional_sfixed32",
@@ -1729,6 +1737,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.Sfixed32Kind,
JSONName: "optionalSfixed32",
+ IsPacked: prototype.False,
},
{
Name: "optional_fixed32",
@@ -1736,6 +1745,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.Fixed32Kind,
JSONName: "optionalFixed32",
+ IsPacked: prototype.False,
},
{
Name: "optional_float",
@@ -1743,6 +1753,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.FloatKind,
JSONName: "optionalFloat",
+ IsPacked: prototype.False,
},
{
Name: "optional_sfixed64",
@@ -1750,6 +1761,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.Sfixed64Kind,
JSONName: "optionalSfixed64",
+ IsPacked: prototype.False,
},
{
Name: "optional_fixed64",
@@ -1757,6 +1769,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.Fixed64Kind,
JSONName: "optionalFixed64",
+ IsPacked: prototype.False,
},
{
Name: "optional_double",
@@ -1764,6 +1777,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.DoubleKind,
JSONName: "optionalDouble",
+ IsPacked: prototype.False,
},
{
Name: "optional_string",
@@ -1771,6 +1785,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "optionalString",
+ IsPacked: prototype.False,
},
{
Name: "optional_bytes",
@@ -1778,6 +1793,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.BytesKind,
JSONName: "optionalBytes",
+ IsPacked: prototype.False,
},
{
Name: "optional_Message",
@@ -1785,6 +1801,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.MessageKind,
JSONName: "optionalMessage",
+ IsPacked: prototype.False,
},
{
Name: "optionalgroup",
@@ -1792,6 +1809,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.GroupKind,
JSONName: "optionalgroup",
+ IsPacked: prototype.False,
},
{
Name: "required_bool",
@@ -1799,6 +1817,7 @@
Cardinality: protoreflect.Required,
Kind: protoreflect.BoolKind,
JSONName: "requiredBool",
+ IsPacked: prototype.False,
},
{
Name: "required_enum",
@@ -1806,6 +1825,7 @@
Cardinality: protoreflect.Required,
Kind: protoreflect.EnumKind,
JSONName: "requiredEnum",
+ IsPacked: prototype.False,
},
{
Name: "required_int32",
@@ -1813,6 +1833,7 @@
Cardinality: protoreflect.Required,
Kind: protoreflect.Int32Kind,
JSONName: "requiredInt32",
+ IsPacked: prototype.False,
},
{
Name: "required_sint32",
@@ -1820,6 +1841,7 @@
Cardinality: protoreflect.Required,
Kind: protoreflect.Sint32Kind,
JSONName: "requiredSint32",
+ IsPacked: prototype.False,
},
{
Name: "required_uint32",
@@ -1827,6 +1849,7 @@
Cardinality: protoreflect.Required,
Kind: protoreflect.Uint32Kind,
JSONName: "requiredUint32",
+ IsPacked: prototype.False,
},
{
Name: "required_int64",
@@ -1834,6 +1857,7 @@
Cardinality: protoreflect.Required,
Kind: protoreflect.Int64Kind,
JSONName: "requiredInt64",
+ IsPacked: prototype.False,
},
{
Name: "required_sint64",
@@ -1841,6 +1865,7 @@
Cardinality: protoreflect.Required,
Kind: protoreflect.Sint64Kind,
JSONName: "requiredSint64",
+ IsPacked: prototype.False,
},
{
Name: "required_uint64",
@@ -1848,6 +1873,7 @@
Cardinality: protoreflect.Required,
Kind: protoreflect.Uint64Kind,
JSONName: "requiredUint64",
+ IsPacked: prototype.False,
},
{
Name: "required_sfixed32",
@@ -1855,6 +1881,7 @@
Cardinality: protoreflect.Required,
Kind: protoreflect.Sfixed32Kind,
JSONName: "requiredSfixed32",
+ IsPacked: prototype.False,
},
{
Name: "required_fixed32",
@@ -1862,6 +1889,7 @@
Cardinality: protoreflect.Required,
Kind: protoreflect.Fixed32Kind,
JSONName: "requiredFixed32",
+ IsPacked: prototype.False,
},
{
Name: "required_float",
@@ -1869,6 +1897,7 @@
Cardinality: protoreflect.Required,
Kind: protoreflect.FloatKind,
JSONName: "requiredFloat",
+ IsPacked: prototype.False,
},
{
Name: "required_sfixed64",
@@ -1876,6 +1905,7 @@
Cardinality: protoreflect.Required,
Kind: protoreflect.Sfixed64Kind,
JSONName: "requiredSfixed64",
+ IsPacked: prototype.False,
},
{
Name: "required_fixed64",
@@ -1883,6 +1913,7 @@
Cardinality: protoreflect.Required,
Kind: protoreflect.Fixed64Kind,
JSONName: "requiredFixed64",
+ IsPacked: prototype.False,
},
{
Name: "required_double",
@@ -1890,6 +1921,7 @@
Cardinality: protoreflect.Required,
Kind: protoreflect.DoubleKind,
JSONName: "requiredDouble",
+ IsPacked: prototype.False,
},
{
Name: "required_string",
@@ -1897,6 +1929,7 @@
Cardinality: protoreflect.Required,
Kind: protoreflect.StringKind,
JSONName: "requiredString",
+ IsPacked: prototype.False,
},
{
Name: "required_bytes",
@@ -1904,6 +1937,7 @@
Cardinality: protoreflect.Required,
Kind: protoreflect.BytesKind,
JSONName: "requiredBytes",
+ IsPacked: prototype.False,
},
{
Name: "required_Message",
@@ -1911,6 +1945,7 @@
Cardinality: protoreflect.Required,
Kind: protoreflect.MessageKind,
JSONName: "requiredMessage",
+ IsPacked: prototype.False,
},
{
Name: "requiredgroup",
@@ -1918,6 +1953,7 @@
Cardinality: protoreflect.Required,
Kind: protoreflect.GroupKind,
JSONName: "requiredgroup",
+ IsPacked: prototype.False,
},
{
Name: "repeated_bool",
@@ -1925,6 +1961,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.BoolKind,
JSONName: "repeatedBool",
+ IsPacked: prototype.False,
},
{
Name: "repeated_enum",
@@ -1932,6 +1969,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.EnumKind,
JSONName: "repeatedEnum",
+ IsPacked: prototype.False,
},
{
Name: "repeated_int32",
@@ -1939,6 +1977,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.Int32Kind,
JSONName: "repeatedInt32",
+ IsPacked: prototype.False,
},
{
Name: "repeated_sint32",
@@ -1946,6 +1985,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.Sint32Kind,
JSONName: "repeatedSint32",
+ IsPacked: prototype.False,
},
{
Name: "repeated_uint32",
@@ -1953,6 +1993,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.Uint32Kind,
JSONName: "repeatedUint32",
+ IsPacked: prototype.False,
},
{
Name: "repeated_int64",
@@ -1960,6 +2001,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.Int64Kind,
JSONName: "repeatedInt64",
+ IsPacked: prototype.False,
},
{
Name: "repeated_sint64",
@@ -1967,6 +2009,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.Sint64Kind,
JSONName: "repeatedSint64",
+ IsPacked: prototype.False,
},
{
Name: "repeated_uint64",
@@ -1974,6 +2017,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.Uint64Kind,
JSONName: "repeatedUint64",
+ IsPacked: prototype.False,
},
{
Name: "repeated_sfixed32",
@@ -1981,6 +2025,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.Sfixed32Kind,
JSONName: "repeatedSfixed32",
+ IsPacked: prototype.False,
},
{
Name: "repeated_fixed32",
@@ -1988,6 +2033,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.Fixed32Kind,
JSONName: "repeatedFixed32",
+ IsPacked: prototype.False,
},
{
Name: "repeated_float",
@@ -1995,6 +2041,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.FloatKind,
JSONName: "repeatedFloat",
+ IsPacked: prototype.False,
},
{
Name: "repeated_sfixed64",
@@ -2002,6 +2049,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.Sfixed64Kind,
JSONName: "repeatedSfixed64",
+ IsPacked: prototype.False,
},
{
Name: "repeated_fixed64",
@@ -2009,6 +2057,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.Fixed64Kind,
JSONName: "repeatedFixed64",
+ IsPacked: prototype.False,
},
{
Name: "repeated_double",
@@ -2016,6 +2065,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.DoubleKind,
JSONName: "repeatedDouble",
+ IsPacked: prototype.False,
},
{
Name: "repeated_string",
@@ -2023,6 +2073,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.StringKind,
JSONName: "repeatedString",
+ IsPacked: prototype.False,
},
{
Name: "repeated_bytes",
@@ -2030,6 +2081,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.BytesKind,
JSONName: "repeatedBytes",
+ IsPacked: prototype.False,
},
{
Name: "repeated_Message",
@@ -2037,6 +2089,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.MessageKind,
JSONName: "repeatedMessage",
+ IsPacked: prototype.False,
},
{
Name: "repeatedgroup",
@@ -2044,6 +2097,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.GroupKind,
JSONName: "repeatedgroup",
+ IsPacked: prototype.False,
},
{
Name: "default_bool",
@@ -2052,6 +2106,7 @@
Kind: protoreflect.BoolKind,
JSONName: "defaultBool",
Default: protoreflect.ValueOf(bool(true)),
+ IsPacked: prototype.False,
},
{
Name: "default_enum",
@@ -2060,6 +2115,7 @@
Kind: protoreflect.EnumKind,
JSONName: "defaultEnum",
Default: protoreflect.ValueOf(string("ONE")),
+ IsPacked: prototype.False,
},
{
Name: "default_int32",
@@ -2068,6 +2124,7 @@
Kind: protoreflect.Int32Kind,
JSONName: "defaultInt32",
Default: protoreflect.ValueOf(int32(1)),
+ IsPacked: prototype.False,
},
{
Name: "default_sint32",
@@ -2076,6 +2133,7 @@
Kind: protoreflect.Sint32Kind,
JSONName: "defaultSint32",
Default: protoreflect.ValueOf(int32(1)),
+ IsPacked: prototype.False,
},
{
Name: "default_uint32",
@@ -2084,6 +2142,7 @@
Kind: protoreflect.Uint32Kind,
JSONName: "defaultUint32",
Default: protoreflect.ValueOf(uint32(1)),
+ IsPacked: prototype.False,
},
{
Name: "default_int64",
@@ -2092,6 +2151,7 @@
Kind: protoreflect.Int64Kind,
JSONName: "defaultInt64",
Default: protoreflect.ValueOf(int64(1)),
+ IsPacked: prototype.False,
},
{
Name: "default_sint64",
@@ -2100,6 +2160,7 @@
Kind: protoreflect.Sint64Kind,
JSONName: "defaultSint64",
Default: protoreflect.ValueOf(int64(1)),
+ IsPacked: prototype.False,
},
{
Name: "default_uint64",
@@ -2108,6 +2169,7 @@
Kind: protoreflect.Uint64Kind,
JSONName: "defaultUint64",
Default: protoreflect.ValueOf(uint64(1)),
+ IsPacked: prototype.False,
},
{
Name: "default_sfixed32",
@@ -2116,6 +2178,7 @@
Kind: protoreflect.Sfixed32Kind,
JSONName: "defaultSfixed32",
Default: protoreflect.ValueOf(int32(1)),
+ IsPacked: prototype.False,
},
{
Name: "default_fixed32",
@@ -2124,6 +2187,7 @@
Kind: protoreflect.Fixed32Kind,
JSONName: "defaultFixed32",
Default: protoreflect.ValueOf(uint32(1)),
+ IsPacked: prototype.False,
},
{
Name: "default_float",
@@ -2132,6 +2196,7 @@
Kind: protoreflect.FloatKind,
JSONName: "defaultFloat",
Default: protoreflect.ValueOf(float32(3.14)),
+ IsPacked: prototype.False,
},
{
Name: "default_sfixed64",
@@ -2140,6 +2205,7 @@
Kind: protoreflect.Sfixed64Kind,
JSONName: "defaultSfixed64",
Default: protoreflect.ValueOf(int64(1)),
+ IsPacked: prototype.False,
},
{
Name: "default_fixed64",
@@ -2148,6 +2214,7 @@
Kind: protoreflect.Fixed64Kind,
JSONName: "defaultFixed64",
Default: protoreflect.ValueOf(uint64(1)),
+ IsPacked: prototype.False,
},
{
Name: "default_double",
@@ -2156,6 +2223,7 @@
Kind: protoreflect.DoubleKind,
JSONName: "defaultDouble",
Default: protoreflect.ValueOf(float64(3.1415)),
+ IsPacked: prototype.False,
},
{
Name: "default_string",
@@ -2164,6 +2232,7 @@
Kind: protoreflect.StringKind,
JSONName: "defaultString",
Default: protoreflect.ValueOf(string("hello,\"world!\"\n")),
+ IsPacked: prototype.False,
},
{
Name: "default_bytes",
@@ -2172,6 +2241,7 @@
Kind: protoreflect.BytesKind,
JSONName: "defaultBytes",
Default: protoreflect.ValueOf(("hello,Þ\xbe\xef")),
+ IsPacked: prototype.False,
},
{
Name: "default_zero_string",
@@ -2180,6 +2250,7 @@
Kind: protoreflect.StringKind,
JSONName: "defaultZeroString",
Default: protoreflect.ValueOf(string("")),
+ IsPacked: prototype.False,
},
{
Name: "default_zero_bytes",
@@ -2188,6 +2259,7 @@
Kind: protoreflect.BytesKind,
JSONName: "defaultZeroBytes",
Default: protoreflect.ValueOf(("")),
+ IsPacked: prototype.False,
},
{
Name: "default_float_neginf",
@@ -2196,6 +2268,7 @@
Kind: protoreflect.FloatKind,
JSONName: "defaultFloatNeginf",
Default: protoreflect.ValueOf(float32(math.Inf(-1))),
+ IsPacked: prototype.False,
},
{
Name: "default_float_posinf",
@@ -2204,6 +2277,7 @@
Kind: protoreflect.FloatKind,
JSONName: "defaultFloatPosinf",
Default: protoreflect.ValueOf(float32(math.Inf(+1))),
+ IsPacked: prototype.False,
},
{
Name: "default_float_nan",
@@ -2212,6 +2286,7 @@
Kind: protoreflect.FloatKind,
JSONName: "defaultFloatNan",
Default: protoreflect.ValueOf(float32(math.NaN())),
+ IsPacked: prototype.False,
},
{
Name: "default_double_neginf",
@@ -2220,6 +2295,7 @@
Kind: protoreflect.DoubleKind,
JSONName: "defaultDoubleNeginf",
Default: protoreflect.ValueOf(float64(math.Inf(-1))),
+ IsPacked: prototype.False,
},
{
Name: "default_double_posinf",
@@ -2228,6 +2304,7 @@
Kind: protoreflect.DoubleKind,
JSONName: "defaultDoublePosinf",
Default: protoreflect.ValueOf(float64(math.Inf(+1))),
+ IsPacked: prototype.False,
},
{
Name: "default_double_nan",
@@ -2236,6 +2313,7 @@
Kind: protoreflect.DoubleKind,
JSONName: "defaultDoubleNan",
Default: protoreflect.ValueOf(float64(math.NaN())),
+ IsPacked: prototype.False,
},
{
Name: "map_int32_int64",
@@ -2243,6 +2321,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.MessageKind,
JSONName: "mapInt32Int64",
+ IsPacked: prototype.False,
},
{
Name: "map_string_message",
@@ -2250,6 +2329,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.MessageKind,
JSONName: "mapStringMessage",
+ IsPacked: prototype.False,
},
{
Name: "map_fixed64_enum",
@@ -2257,6 +2337,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.MessageKind,
JSONName: "mapFixed64Enum",
+ IsPacked: prototype.False,
},
{
Name: "oneof_bool",
@@ -2265,6 +2346,7 @@
Kind: protoreflect.BoolKind,
JSONName: "oneofBool",
OneofName: "oneof_field",
+ IsPacked: prototype.False,
},
{
Name: "oneof_enum",
@@ -2273,6 +2355,7 @@
Kind: protoreflect.EnumKind,
JSONName: "oneofEnum",
OneofName: "oneof_field",
+ IsPacked: prototype.False,
},
{
Name: "oneof_int32",
@@ -2281,6 +2364,7 @@
Kind: protoreflect.Int32Kind,
JSONName: "oneofInt32",
OneofName: "oneof_field",
+ IsPacked: prototype.False,
},
{
Name: "oneof_sint32",
@@ -2289,6 +2373,7 @@
Kind: protoreflect.Sint32Kind,
JSONName: "oneofSint32",
OneofName: "oneof_field",
+ IsPacked: prototype.False,
},
{
Name: "oneof_uint32",
@@ -2297,6 +2382,7 @@
Kind: protoreflect.Uint32Kind,
JSONName: "oneofUint32",
OneofName: "oneof_field",
+ IsPacked: prototype.False,
},
{
Name: "oneof_int64",
@@ -2305,6 +2391,7 @@
Kind: protoreflect.Int64Kind,
JSONName: "oneofInt64",
OneofName: "oneof_field",
+ IsPacked: prototype.False,
},
{
Name: "oneof_sint64",
@@ -2313,6 +2400,7 @@
Kind: protoreflect.Sint64Kind,
JSONName: "oneofSint64",
OneofName: "oneof_field",
+ IsPacked: prototype.False,
},
{
Name: "oneof_uint64",
@@ -2321,6 +2409,7 @@
Kind: protoreflect.Uint64Kind,
JSONName: "oneofUint64",
OneofName: "oneof_field",
+ IsPacked: prototype.False,
},
{
Name: "oneof_sfixed32",
@@ -2329,6 +2418,7 @@
Kind: protoreflect.Sfixed32Kind,
JSONName: "oneofSfixed32",
OneofName: "oneof_field",
+ IsPacked: prototype.False,
},
{
Name: "oneof_fixed32",
@@ -2337,6 +2427,7 @@
Kind: protoreflect.Fixed32Kind,
JSONName: "oneofFixed32",
OneofName: "oneof_field",
+ IsPacked: prototype.False,
},
{
Name: "oneof_float",
@@ -2345,6 +2436,7 @@
Kind: protoreflect.FloatKind,
JSONName: "oneofFloat",
OneofName: "oneof_field",
+ IsPacked: prototype.False,
},
{
Name: "oneof_sfixed64",
@@ -2353,6 +2445,7 @@
Kind: protoreflect.Sfixed64Kind,
JSONName: "oneofSfixed64",
OneofName: "oneof_field",
+ IsPacked: prototype.False,
},
{
Name: "oneof_fixed64",
@@ -2361,6 +2454,7 @@
Kind: protoreflect.Fixed64Kind,
JSONName: "oneofFixed64",
OneofName: "oneof_field",
+ IsPacked: prototype.False,
},
{
Name: "oneof_double",
@@ -2369,6 +2463,7 @@
Kind: protoreflect.DoubleKind,
JSONName: "oneofDouble",
OneofName: "oneof_field",
+ IsPacked: prototype.False,
},
{
Name: "oneof_string",
@@ -2377,6 +2472,7 @@
Kind: protoreflect.StringKind,
JSONName: "oneofString",
OneofName: "oneof_field",
+ IsPacked: prototype.False,
},
{
Name: "oneof_bytes",
@@ -2385,6 +2481,7 @@
Kind: protoreflect.BytesKind,
JSONName: "oneofBytes",
OneofName: "oneof_field",
+ IsPacked: prototype.False,
},
{
Name: "oneof_Message",
@@ -2393,6 +2490,7 @@
Kind: protoreflect.MessageKind,
JSONName: "oneofMessage",
OneofName: "oneof_field",
+ IsPacked: prototype.False,
},
{
Name: "oneofgroup",
@@ -2401,6 +2499,7 @@
Kind: protoreflect.GroupKind,
JSONName: "oneofgroup",
OneofName: "oneof_field",
+ IsPacked: prototype.False,
},
{
Name: "oneof_largest_tag",
@@ -2409,6 +2508,7 @@
Kind: protoreflect.Int32Kind,
JSONName: "oneofLargestTag",
OneofName: "oneof_field",
+ IsPacked: prototype.False,
},
{
Name: "oneof_two_1",
@@ -2417,6 +2517,7 @@
Kind: protoreflect.Int32Kind,
JSONName: "oneofTwo1",
OneofName: "oneof_two",
+ IsPacked: prototype.False,
},
{
Name: "oneof_two_2",
@@ -2425,6 +2526,7 @@
Kind: protoreflect.Int64Kind,
JSONName: "oneofTwo2",
OneofName: "oneof_two",
+ IsPacked: prototype.False,
},
},
Oneofs: []prototype.Oneof{
@@ -2443,6 +2545,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "optionalGroup",
+ IsPacked: prototype.False,
},
},
},
@@ -2455,6 +2558,7 @@
Cardinality: protoreflect.Required,
Kind: protoreflect.StringKind,
JSONName: "requiredGroup",
+ IsPacked: prototype.False,
},
},
},
@@ -2467,6 +2571,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.StringKind,
JSONName: "repeatedGroup",
+ IsPacked: prototype.False,
},
},
},
@@ -2479,6 +2584,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.Int32Kind,
JSONName: "key",
+ IsPacked: prototype.False,
},
{
Name: "value",
@@ -2486,8 +2592,10 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.Int64Kind,
JSONName: "value",
+ IsPacked: prototype.False,
},
},
+ IsMapEntry: true,
},
{
Name: "MapStringMessageEntry",
@@ -2498,6 +2606,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "key",
+ IsPacked: prototype.False,
},
{
Name: "value",
@@ -2505,8 +2614,10 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.MessageKind,
JSONName: "value",
+ IsPacked: prototype.False,
},
},
+ IsMapEntry: true,
},
{
Name: "MapFixed64EnumEntry",
@@ -2517,6 +2628,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.Fixed64Kind,
JSONName: "key",
+ IsPacked: prototype.False,
},
{
Name: "value",
@@ -2524,8 +2636,10 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.EnumKind,
JSONName: "value",
+ IsPacked: prototype.False,
},
},
+ IsMapEntry: true,
},
{
Name: "OneofGroup",
@@ -2536,6 +2650,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "oneofGroupField",
+ IsPacked: prototype.False,
},
},
},
diff --git a/cmd/protoc-gen-go/testdata/proto2/nested_messages.pb.go b/cmd/protoc-gen-go/testdata/proto2/nested_messages.pb.go
index 19061d3..e47c90f 100644
--- a/cmd/protoc-gen-go/testdata/proto2/nested_messages.pb.go
+++ b/cmd/protoc-gen-go/testdata/proto2/nested_messages.pb.go
@@ -263,6 +263,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.MessageKind,
JSONName: "l2",
+ IsPacked: prototype.False,
},
{
Name: "l3",
@@ -270,6 +271,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.MessageKind,
JSONName: "l3",
+ IsPacked: prototype.False,
},
},
},
@@ -282,6 +284,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.MessageKind,
JSONName: "l3",
+ IsPacked: prototype.False,
},
},
},
diff --git a/cmd/protoc-gen-go/testdata/proto2/proto2.pb.go b/cmd/protoc-gen-go/testdata/proto2/proto2.pb.go
index db64579..7630e86 100644
--- a/cmd/protoc-gen-go/testdata/proto2/proto2.pb.go
+++ b/cmd/protoc-gen-go/testdata/proto2/proto2.pb.go
@@ -137,6 +137,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.Int32Kind,
JSONName: "i32",
+ IsPacked: prototype.False,
},
{
Name: "m",
@@ -144,6 +145,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.MessageKind,
JSONName: "m",
+ IsPacked: prototype.False,
},
},
},
diff --git a/cmd/protoc-gen-go/testdata/proto3/fields.pb.go b/cmd/protoc-gen-go/testdata/proto3/fields.pb.go
index 293a5b3..1701832 100644
--- a/cmd/protoc-gen-go/testdata/proto3/fields.pb.go
+++ b/cmd/protoc-gen-go/testdata/proto3/fields.pb.go
@@ -582,6 +582,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "optionalBool",
+ IsPacked: prototype.False,
},
{
Name: "optional_enum",
@@ -589,6 +590,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.EnumKind,
JSONName: "optionalEnum",
+ IsPacked: prototype.False,
},
{
Name: "optional_int32",
@@ -596,6 +598,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.Int32Kind,
JSONName: "optionalInt32",
+ IsPacked: prototype.False,
},
{
Name: "optional_sint32",
@@ -603,6 +606,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.Sint32Kind,
JSONName: "optionalSint32",
+ IsPacked: prototype.False,
},
{
Name: "optional_uint32",
@@ -610,6 +614,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.Uint32Kind,
JSONName: "optionalUint32",
+ IsPacked: prototype.False,
},
{
Name: "optional_int64",
@@ -617,6 +622,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.Int64Kind,
JSONName: "optionalInt64",
+ IsPacked: prototype.False,
},
{
Name: "optional_sint64",
@@ -624,6 +630,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.Sint64Kind,
JSONName: "optionalSint64",
+ IsPacked: prototype.False,
},
{
Name: "optional_uint64",
@@ -631,6 +638,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.Uint64Kind,
JSONName: "optionalUint64",
+ IsPacked: prototype.False,
},
{
Name: "optional_sfixed32",
@@ -638,6 +646,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.Sfixed32Kind,
JSONName: "optionalSfixed32",
+ IsPacked: prototype.False,
},
{
Name: "optional_fixed32",
@@ -645,6 +654,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.Fixed32Kind,
JSONName: "optionalFixed32",
+ IsPacked: prototype.False,
},
{
Name: "optional_float",
@@ -652,6 +662,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.FloatKind,
JSONName: "optionalFloat",
+ IsPacked: prototype.False,
},
{
Name: "optional_sfixed64",
@@ -659,6 +670,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.Sfixed64Kind,
JSONName: "optionalSfixed64",
+ IsPacked: prototype.False,
},
{
Name: "optional_fixed64",
@@ -666,6 +678,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.Fixed64Kind,
JSONName: "optionalFixed64",
+ IsPacked: prototype.False,
},
{
Name: "optional_double",
@@ -673,6 +686,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.DoubleKind,
JSONName: "optionalDouble",
+ IsPacked: prototype.False,
},
{
Name: "optional_string",
@@ -680,6 +694,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "optionalString",
+ IsPacked: prototype.False,
},
{
Name: "optional_bytes",
@@ -687,6 +702,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.BytesKind,
JSONName: "optionalBytes",
+ IsPacked: prototype.False,
},
{
Name: "optional_Message",
@@ -694,6 +710,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.MessageKind,
JSONName: "optionalMessage",
+ IsPacked: prototype.False,
},
{
Name: "repeated_bool",
@@ -701,6 +718,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.BoolKind,
JSONName: "repeatedBool",
+ IsPacked: prototype.True,
},
{
Name: "repeated_enum",
@@ -708,6 +726,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.EnumKind,
JSONName: "repeatedEnum",
+ IsPacked: prototype.True,
},
{
Name: "repeated_int32",
@@ -715,6 +734,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.Int32Kind,
JSONName: "repeatedInt32",
+ IsPacked: prototype.True,
},
{
Name: "repeated_sint32",
@@ -722,6 +742,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.Sint32Kind,
JSONName: "repeatedSint32",
+ IsPacked: prototype.True,
},
{
Name: "repeated_uint32",
@@ -729,6 +750,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.Uint32Kind,
JSONName: "repeatedUint32",
+ IsPacked: prototype.True,
},
{
Name: "repeated_int64",
@@ -736,6 +758,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.Int64Kind,
JSONName: "repeatedInt64",
+ IsPacked: prototype.True,
},
{
Name: "repeated_sint64",
@@ -743,6 +766,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.Sint64Kind,
JSONName: "repeatedSint64",
+ IsPacked: prototype.True,
},
{
Name: "repeated_uint64",
@@ -750,6 +774,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.Uint64Kind,
JSONName: "repeatedUint64",
+ IsPacked: prototype.True,
},
{
Name: "repeated_sfixed32",
@@ -757,6 +782,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.Sfixed32Kind,
JSONName: "repeatedSfixed32",
+ IsPacked: prototype.True,
},
{
Name: "repeated_fixed32",
@@ -764,6 +790,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.Fixed32Kind,
JSONName: "repeatedFixed32",
+ IsPacked: prototype.True,
},
{
Name: "repeated_float",
@@ -771,6 +798,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.FloatKind,
JSONName: "repeatedFloat",
+ IsPacked: prototype.True,
},
{
Name: "repeated_sfixed64",
@@ -778,6 +806,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.Sfixed64Kind,
JSONName: "repeatedSfixed64",
+ IsPacked: prototype.True,
},
{
Name: "repeated_fixed64",
@@ -785,6 +814,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.Fixed64Kind,
JSONName: "repeatedFixed64",
+ IsPacked: prototype.True,
},
{
Name: "repeated_double",
@@ -792,6 +822,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.DoubleKind,
JSONName: "repeatedDouble",
+ IsPacked: prototype.True,
},
{
Name: "repeated_string",
@@ -799,6 +830,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.StringKind,
JSONName: "repeatedString",
+ IsPacked: prototype.False,
},
{
Name: "repeated_bytes",
@@ -806,6 +838,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.BytesKind,
JSONName: "repeatedBytes",
+ IsPacked: prototype.False,
},
{
Name: "repeated_Message",
@@ -813,6 +846,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.MessageKind,
JSONName: "repeatedMessage",
+ IsPacked: prototype.False,
},
{
Name: "map_int32_int64",
@@ -820,6 +854,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.MessageKind,
JSONName: "mapInt32Int64",
+ IsPacked: prototype.False,
},
{
Name: "map_string_message",
@@ -827,6 +862,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.MessageKind,
JSONName: "mapStringMessage",
+ IsPacked: prototype.False,
},
{
Name: "map_fixed64_enum",
@@ -834,6 +870,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.MessageKind,
JSONName: "mapFixed64Enum",
+ IsPacked: prototype.False,
},
},
},
@@ -846,6 +883,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.Int32Kind,
JSONName: "key",
+ IsPacked: prototype.False,
},
{
Name: "value",
@@ -853,8 +891,10 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.Int64Kind,
JSONName: "value",
+ IsPacked: prototype.False,
},
},
+ IsMapEntry: true,
},
{
Name: "MapStringMessageEntry",
@@ -865,6 +905,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "key",
+ IsPacked: prototype.False,
},
{
Name: "value",
@@ -872,8 +913,10 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.MessageKind,
JSONName: "value",
+ IsPacked: prototype.False,
},
},
+ IsMapEntry: true,
},
{
Name: "MapFixed64EnumEntry",
@@ -884,6 +927,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.Fixed64Kind,
JSONName: "key",
+ IsPacked: prototype.False,
},
{
Name: "value",
@@ -891,8 +935,10 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.EnumKind,
JSONName: "value",
+ IsPacked: prototype.False,
},
},
+ IsMapEntry: true,
},
{
Name: "Message",
diff --git a/internal/encoding/pack/pack_test.go b/internal/encoding/pack/pack_test.go
index 3a56ebb..73c2acb 100644
--- a/internal/encoding/pack/pack_test.go
+++ b/internal/encoding/pack/pack_test.go
@@ -14,8 +14,6 @@
pref "github.com/golang/protobuf/v2/reflect/protoreflect"
ptype "github.com/golang/protobuf/v2/reflect/prototype"
cmp "github.com/google/go-cmp/cmp"
-
- descriptorpb "github.com/golang/protobuf/v2/types/descriptor"
)
var msgDesc = func() pref.MessageDescriptor {
@@ -23,16 +21,16 @@
Syntax: pref.Proto2,
FullName: "Message",
Fields: []ptype.Field{
- {Name: "F1", Number: 1, Cardinality: pref.Repeated, Kind: pref.BoolKind, Options: packedOpt(true)},
- {Name: "F2", Number: 2, Cardinality: pref.Repeated, Kind: pref.Int64Kind, Options: packedOpt(true)},
- {Name: "F3", Number: 3, Cardinality: pref.Repeated, Kind: pref.Sint64Kind, Options: packedOpt(true)},
- {Name: "F4", Number: 4, Cardinality: pref.Repeated, Kind: pref.Uint64Kind, Options: packedOpt(true)},
- {Name: "F5", Number: 5, Cardinality: pref.Repeated, Kind: pref.Fixed32Kind, Options: packedOpt(true)},
- {Name: "F6", Number: 6, Cardinality: pref.Repeated, Kind: pref.Sfixed32Kind, Options: packedOpt(true)},
- {Name: "F7", Number: 7, Cardinality: pref.Repeated, Kind: pref.FloatKind, Options: packedOpt(true)},
- {Name: "F8", Number: 8, Cardinality: pref.Repeated, Kind: pref.Fixed64Kind, Options: packedOpt(true)},
- {Name: "F9", Number: 9, Cardinality: pref.Repeated, Kind: pref.Sfixed64Kind, Options: packedOpt(true)},
- {Name: "F10", Number: 10, Cardinality: pref.Repeated, Kind: pref.DoubleKind, Options: packedOpt(true)},
+ {Name: "F1", Number: 1, Cardinality: pref.Repeated, Kind: pref.BoolKind, IsPacked: ptype.True},
+ {Name: "F2", Number: 2, Cardinality: pref.Repeated, Kind: pref.Int64Kind, IsPacked: ptype.True},
+ {Name: "F3", Number: 3, Cardinality: pref.Repeated, Kind: pref.Sint64Kind, IsPacked: ptype.True},
+ {Name: "F4", Number: 4, Cardinality: pref.Repeated, Kind: pref.Uint64Kind, IsPacked: ptype.True},
+ {Name: "F5", Number: 5, Cardinality: pref.Repeated, Kind: pref.Fixed32Kind, IsPacked: ptype.True},
+ {Name: "F6", Number: 6, Cardinality: pref.Repeated, Kind: pref.Sfixed32Kind, IsPacked: ptype.True},
+ {Name: "F7", Number: 7, Cardinality: pref.Repeated, Kind: pref.FloatKind, IsPacked: ptype.True},
+ {Name: "F8", Number: 8, Cardinality: pref.Repeated, Kind: pref.Fixed64Kind, IsPacked: ptype.True},
+ {Name: "F9", Number: 9, Cardinality: pref.Repeated, Kind: pref.Sfixed64Kind, IsPacked: ptype.True},
+ {Name: "F10", Number: 10, Cardinality: pref.Repeated, Kind: pref.DoubleKind, IsPacked: ptype.True},
{Name: "F11", Number: 11, Cardinality: pref.Optional, Kind: pref.StringKind},
{Name: "F12", Number: 12, Cardinality: pref.Optional, Kind: pref.BytesKind},
{Name: "F13", Number: 13, Cardinality: pref.Optional, Kind: pref.MessageKind, MessageType: ptype.PlaceholderMessage("Message")},
@@ -44,10 +42,6 @@
return mtyp
}()
-func packedOpt(b bool) *descriptorpb.FieldOptions {
- return &descriptorpb.FieldOptions{Packed: &b}
-}
-
// dhex decodes a hex-string and returns the bytes and panics if s is invalid.
func dhex(s string) []byte {
b, err := hex.DecodeString(s)
diff --git a/internal/impl/message_test.go b/internal/impl/message_test.go
index f49e5c1..97fbabd 100644
--- a/internal/impl/message_test.go
+++ b/internal/impl/message_test.go
@@ -592,7 +592,8 @@
{Name: "key", Number: 1, Cardinality: pref.Optional, Kind: keyKind},
{Name: "value", Number: 2, Cardinality: pref.Optional, Kind: valKind},
},
- Options: &descriptorpb.MessageOptions{MapEntry: scalar.Bool(true)},
+ Options: &descriptorpb.MessageOptions{MapEntry: scalar.Bool(true)},
+ IsMapEntry: true,
}),
}
}
@@ -1007,7 +1008,8 @@
{Name: "key", Number: 1, Cardinality: pref.Optional, Kind: pref.StringKind},
{Name: "value", Number: 2, Cardinality: pref.Optional, Kind: pref.EnumKind, EnumType: enumProto3Type},
},
- Options: &descriptorpb.MessageOptions{MapEntry: scalar.Bool(true)},
+ Options: &descriptorpb.MessageOptions{MapEntry: scalar.Bool(true)},
+ IsMapEntry: true,
})
var messageMapDesc = mustMakeMessageDesc(ptype.StandaloneMessage{
@@ -1017,7 +1019,8 @@
{Name: "key", Number: 1, Cardinality: pref.Optional, Kind: pref.StringKind},
{Name: "value", Number: 2, Cardinality: pref.Optional, Kind: pref.MessageKind, MessageType: scalarProto3Type.Type},
},
- Options: &descriptorpb.MessageOptions{MapEntry: scalar.Bool(true)},
+ Options: &descriptorpb.MessageOptions{MapEntry: scalar.Bool(true)},
+ IsMapEntry: true,
})
func (m *EnumMessages) Type() pref.MessageType { return enumMessagesType.Type }
diff --git a/internal/legacy/message.go b/internal/legacy/message.go
index 6e77385..f4b358f 100644
--- a/internal/legacy/message.go
+++ b/internal/legacy/message.go
@@ -230,9 +230,10 @@
f.MessageType = mv.ProtoReflect().Type()
} else if t.Kind() == reflect.Map {
m := &ptype.StandaloneMessage{
- Syntax: parent.Syntax,
- FullName: parent.FullName.Append(mapEntryName(f.Name)),
- Options: &descriptorpb.MessageOptions{MapEntry: scalar.Bool(true)},
+ Syntax: parent.Syntax,
+ FullName: parent.FullName.Append(mapEntryName(f.Name)),
+ Options: &descriptorpb.MessageOptions{MapEntry: scalar.Bool(true)},
+ IsMapEntry: true,
Fields: []ptype.Field{
ms.parseField(tagKey, "", "", t.Key(), nil),
ms.parseField(tagVal, "", "", t.Elem(), nil),
diff --git a/reflect/protodesc/protodesc.go b/reflect/protodesc/protodesc.go
index 38d03a7..e2b402b 100644
--- a/reflect/protodesc/protodesc.go
+++ b/reflect/protodesc/protodesc.go
@@ -122,13 +122,23 @@
var m prototype.Message
m.Name = protoreflect.Name(md.GetName())
m.Options = md.GetOptions()
+ m.IsMapEntry = md.GetOptions().GetMapEntry()
for _, fd := range md.GetField() {
var f prototype.Field
f.Name = protoreflect.Name(fd.GetName())
f.Number = protoreflect.FieldNumber(fd.GetNumber())
f.Cardinality = protoreflect.Cardinality(fd.GetLabel())
f.Kind = protoreflect.Kind(fd.GetType())
- f.Options = fd.GetOptions()
+ opts := fd.GetOptions()
+ f.Options = opts
+ if opts != nil && opts.Packed != nil {
+ if *opts.Packed {
+ f.IsPacked = prototype.True
+ } else {
+ f.IsPacked = prototype.False
+ }
+ }
+ f.IsWeak = opts.GetWeak()
f.JSONName = fd.GetJsonName()
if fd.DefaultValue != nil {
f.Default, err = defval.Unmarshal(fd.GetDefaultValue(), f.Kind, defval.Descriptor)
@@ -143,7 +153,6 @@
}
f.OneofName = protoreflect.Name(md.GetOneofDecl()[i].GetName())
}
- opts, _ := f.Options.(*descriptorpb.FieldOptions)
switch f.Kind {
case protoreflect.EnumKind:
f.EnumType, err = findEnumDescriptor(fd.GetTypeName(), r)
diff --git a/reflect/prototype/protofile.go b/reflect/prototype/protofile.go
index d7dca23..8ca96b0 100644
--- a/reflect/prototype/protofile.go
+++ b/reflect/prototype/protofile.go
@@ -11,6 +11,13 @@
// information must be provided such as the full type name and the proto syntax.
// When creating an entire file, the syntax and full name is derived from
// the parent type.
+//
+// Most types contain options, defined as messages in descriptor.proto.
+// To avoid cyclic dependencies, the prototype package treats these options
+// as opaque protoreflect.ProtoMessage values. In some cases where the option
+// contains semantically important information (e.g.,
+// google.protobuf.MessageOptions.map_entry), this information must be provided
+// as a field of the corresponding type (e.g., prototype.Message.MapEntry).
package prototype
import "github.com/golang/protobuf/v2/reflect/protoreflect"
@@ -103,6 +110,7 @@
ExtensionRanges [][2]protoreflect.FieldNumber
ExtensionRangeOptions []protoreflect.ProtoMessage
Options protoreflect.ProtoMessage
+ IsMapEntry bool
Enums []Enum
Messages []Message
@@ -131,6 +139,8 @@
MessageType protoreflect.MessageDescriptor
EnumType protoreflect.EnumDescriptor
Options protoreflect.ProtoMessage
+ IsPacked OptionalBool
+ IsWeak bool
*fieldMeta
}
@@ -154,6 +164,7 @@
EnumType protoreflect.EnumDescriptor
ExtendedType protoreflect.MessageDescriptor
Options protoreflect.ProtoMessage
+ IsPacked OptionalBool
*extensionMeta
}
@@ -206,3 +217,13 @@
*methodMeta
}
+
+// OptionalBool is a tristate boolean.
+type OptionalBool uint8
+
+// Tristate boolean values.
+const (
+ DefaultBool OptionalBool = iota
+ True
+ False
+)
diff --git a/reflect/prototype/protofile_type.go b/reflect/prototype/protofile_type.go
index 4e2e0c4..442ad92 100644
--- a/reflect/prototype/protofile_type.go
+++ b/reflect/prototype/protofile_type.go
@@ -165,7 +165,6 @@
ms messagesMeta
es enumsMeta
xs extensionsMeta
- mo messageOptions
}
type messageDesc struct{ m *Message }
@@ -176,7 +175,7 @@
func (t messageDesc) FullName() pref.FullName { return t.m.fullName }
func (t messageDesc) IsPlaceholder() bool { return false }
func (t messageDesc) Options() pref.ProtoMessage { return altOptions(t.m.Options, optionTypes.Message) }
-func (t messageDesc) IsMapEntry() bool { return t.m.mo.lazyInit(t).isMapEntry }
+func (t messageDesc) IsMapEntry() bool { return t.m.IsMapEntry }
func (t messageDesc) Fields() pref.FieldDescriptors { return t.m.fs.lazyInit(t, t.m.Fields) }
func (t messageDesc) Oneofs() pref.OneofDescriptors { return t.m.os.lazyInit(t, t.m.Oneofs) }
func (t messageDesc) ReservedNames() pref.Names { return (*names)(&t.m.ReservedNames) }
@@ -207,22 +206,6 @@
return m
}
-type messageOptions struct {
- once sync.Once
- isMapEntry bool
-}
-
-func (p *messageOptions) lazyInit(m pref.MessageDescriptor) *messageOptions {
- p.once.Do(func() {
- if m.Options() != optionTypes.Message {
- const mapEntryFieldNumber = 7 // google.protobuf.MessageOptions.map_entry
- fs := m.Options().ProtoReflect().KnownFields()
- p.isMapEntry = fs.Get(mapEntryFieldNumber).Bool()
- }
- })
- return p
-}
-
type fieldMeta struct {
inheritedMeta
@@ -231,25 +214,29 @@
ot oneofReference
mt messageReference
et enumReference
- fo fieldOptions
}
type fieldDesc struct{ f *Field }
-func (t fieldDesc) Parent() (pref.Descriptor, bool) { return t.f.parent, true }
-func (t fieldDesc) Index() int { return t.f.index }
-func (t fieldDesc) Syntax() pref.Syntax { return t.f.syntax }
-func (t fieldDesc) Name() pref.Name { return t.f.Name }
-func (t fieldDesc) FullName() pref.FullName { return t.f.fullName }
-func (t fieldDesc) IsPlaceholder() bool { return false }
-func (t fieldDesc) Options() pref.ProtoMessage { return altOptions(t.f.Options, optionTypes.Field) }
-func (t fieldDesc) Number() pref.FieldNumber { return t.f.Number }
-func (t fieldDesc) Cardinality() pref.Cardinality { return t.f.Cardinality }
-func (t fieldDesc) Kind() pref.Kind { return t.f.Kind }
-func (t fieldDesc) HasJSONName() bool { return t.f.JSONName != "" }
-func (t fieldDesc) JSONName() string { return t.f.js.lazyInit(t.f) }
-func (t fieldDesc) IsPacked() bool { return t.f.fo.lazyInit(t).isPacked }
-func (t fieldDesc) IsWeak() bool { return t.f.fo.lazyInit(t).isWeak }
-func (t fieldDesc) IsMap() bool { return t.f.fo.lazyInit(t).isMap }
+func (t fieldDesc) Parent() (pref.Descriptor, bool) { return t.f.parent, true }
+func (t fieldDesc) Index() int { return t.f.index }
+func (t fieldDesc) Syntax() pref.Syntax { return t.f.syntax }
+func (t fieldDesc) Name() pref.Name { return t.f.Name }
+func (t fieldDesc) FullName() pref.FullName { return t.f.fullName }
+func (t fieldDesc) IsPlaceholder() bool { return false }
+func (t fieldDesc) Options() pref.ProtoMessage { return altOptions(t.f.Options, optionTypes.Field) }
+func (t fieldDesc) Number() pref.FieldNumber { return t.f.Number }
+func (t fieldDesc) Cardinality() pref.Cardinality { return t.f.Cardinality }
+func (t fieldDesc) Kind() pref.Kind { return t.f.Kind }
+func (t fieldDesc) HasJSONName() bool { return t.f.JSONName != "" }
+func (t fieldDesc) JSONName() string { return t.f.js.lazyInit(t.f) }
+func (t fieldDesc) IsPacked() bool {
+ return isPacked(t.f.IsPacked, t.f.syntax, t.f.Cardinality, t.f.Kind)
+}
+func (t fieldDesc) IsWeak() bool { return t.f.IsWeak }
+func (t fieldDesc) IsMap() bool {
+ mt := t.MessageType()
+ return mt != nil && mt.IsMapEntry()
+}
func (t fieldDesc) HasDefault() bool { return t.f.Default.IsValid() }
func (t fieldDesc) Default() pref.Value { return t.f.dv.value(t, t.f.Default) }
func (t fieldDesc) DefaultEnumValue() pref.EnumValueDescriptor { return t.f.dv.enum(t, t.f.Default) }
@@ -261,6 +248,20 @@
func (t fieldDesc) ProtoType(pref.FieldDescriptor) {}
func (t fieldDesc) ProtoInternal(pragma.DoNotImplement) {}
+func isPacked(packed OptionalBool, s pref.Syntax, c pref.Cardinality, k pref.Kind) bool {
+ if packed == False || (packed == DefaultBool && s == pref.Proto2) {
+ return false
+ }
+ if c != pref.Repeated {
+ return false
+ }
+ switch k {
+ case pref.StringKind, pref.BytesKind, pref.MessageKind, pref.GroupKind:
+ return false
+ }
+ return true
+}
+
type jsonName struct {
once sync.Once
name string
@@ -310,77 +311,6 @@
return p.otyp
}
-type fieldOptions struct {
- once sync.Once
- isPacked bool
- isWeak bool
- isMap bool
-}
-
-func (p *fieldOptions) lazyInit(f pref.FieldDescriptor) *fieldOptions {
- p.once.Do(func() {
- if f.Cardinality() == pref.Repeated {
- // In proto3, repeated fields of scalar numeric types use
- // packed encoding by default.
- // See https://developers.google.com/protocol-buffers/docs/proto3
- if f.Syntax() == pref.Proto3 {
- p.isPacked = isScalarNumeric[f.Kind()]
- }
- if f.Kind() == pref.MessageKind {
- p.isMap = f.MessageType().IsMapEntry()
- }
- }
-
- if f.Options() != optionTypes.Field {
- const packedFieldNumber = 2 // google.protobuf.FieldOptions.packed
- const weakFieldNumber = 10 // google.protobuf.FieldOptions.weak
- fs := f.Options().ProtoReflect().KnownFields()
- if fs.Has(packedFieldNumber) {
- p.isPacked = fs.Get(packedFieldNumber).Bool()
- }
- p.isWeak = fs.Get(weakFieldNumber).Bool()
- }
- })
- return p
-}
-
-// isPacked reports whether the packed options is set.
-func isPacked(m pref.ProtoMessage) (isPacked bool) {
- if m != optionTypes.Field {
- const packedFieldNumber = 2 // google.protobuf.FieldOptions.packed
- fs := m.ProtoReflect().KnownFields()
- isPacked = fs.Get(packedFieldNumber).Bool()
- }
- return isPacked
-}
-
-// isWeak reports whether the weak options is set.
-func isWeak(m pref.ProtoMessage) (isWeak bool) {
- if m != optionTypes.Field {
- const weakFieldNumber = 10 // google.protobuf.FieldOptions.weak
- fs := m.ProtoReflect().KnownFields()
- isWeak = fs.Get(weakFieldNumber).Bool()
- }
- return isWeak
-}
-
-var isScalarNumeric = map[pref.Kind]bool{
- pref.BoolKind: true,
- pref.EnumKind: true,
- pref.Int32Kind: true,
- pref.Sint32Kind: true,
- pref.Uint32Kind: true,
- pref.Int64Kind: true,
- pref.Sint64Kind: true,
- pref.Uint64Kind: true,
- pref.Sfixed32Kind: true,
- pref.Fixed32Kind: true,
- pref.FloatKind: true,
- pref.Sfixed64Kind: true,
- pref.Fixed64Kind: true,
- pref.DoubleKind: true,
-}
-
type oneofMeta struct {
inheritedMeta
@@ -410,19 +340,22 @@
}
type extensionDesc struct{ x *Extension }
-func (t extensionDesc) Parent() (pref.Descriptor, bool) { return t.x.parent, true }
-func (t extensionDesc) Syntax() pref.Syntax { return t.x.syntax }
-func (t extensionDesc) Index() int { return t.x.index }
-func (t extensionDesc) Name() pref.Name { return t.x.Name }
-func (t extensionDesc) FullName() pref.FullName { return t.x.fullName }
-func (t extensionDesc) IsPlaceholder() bool { return false }
-func (t extensionDesc) Options() pref.ProtoMessage { return altOptions(t.x.Options, optionTypes.Field) }
-func (t extensionDesc) Number() pref.FieldNumber { return t.x.Number }
-func (t extensionDesc) Cardinality() pref.Cardinality { return t.x.Cardinality }
-func (t extensionDesc) Kind() pref.Kind { return t.x.Kind }
-func (t extensionDesc) HasJSONName() bool { return false }
-func (t extensionDesc) JSONName() string { return "" }
-func (t extensionDesc) IsPacked() bool { return isPacked(t.Options()) }
+func (t extensionDesc) Parent() (pref.Descriptor, bool) { return t.x.parent, true }
+func (t extensionDesc) Syntax() pref.Syntax { return t.x.syntax }
+func (t extensionDesc) Index() int { return t.x.index }
+func (t extensionDesc) Name() pref.Name { return t.x.Name }
+func (t extensionDesc) FullName() pref.FullName { return t.x.fullName }
+func (t extensionDesc) IsPlaceholder() bool { return false }
+func (t extensionDesc) Options() pref.ProtoMessage { return altOptions(t.x.Options, optionTypes.Field) }
+func (t extensionDesc) Number() pref.FieldNumber { return t.x.Number }
+func (t extensionDesc) Cardinality() pref.Cardinality { return t.x.Cardinality }
+func (t extensionDesc) Kind() pref.Kind { return t.x.Kind }
+func (t extensionDesc) HasJSONName() bool { return false }
+func (t extensionDesc) JSONName() string { return "" }
+func (t extensionDesc) IsPacked() bool {
+ // Extensions always use proto2 defaults for packing.
+ return isPacked(t.x.IsPacked, pref.Proto2, t.x.Cardinality, t.x.Kind)
+}
func (t extensionDesc) IsWeak() bool { return false }
func (t extensionDesc) IsMap() bool { return false }
func (t extensionDesc) HasDefault() bool { return t.x.Default.IsValid() }
diff --git a/reflect/prototype/standalone.go b/reflect/prototype/standalone.go
index c934c5c..4184e82 100644
--- a/reflect/prototype/standalone.go
+++ b/reflect/prototype/standalone.go
@@ -24,11 +24,11 @@
ExtensionRanges [][2]protoreflect.FieldNumber
ExtensionRangeOptions []protoreflect.ProtoMessage
Options protoreflect.ProtoMessage
+ IsMapEntry bool
- fields fieldsMeta
- oneofs oneofsMeta
- nums numbersMeta
- options messageOptions
+ fields fieldsMeta
+ oneofs oneofsMeta
+ nums numbersMeta
}
// NewMessage creates a new protoreflect.MessageDescriptor.
@@ -67,7 +67,7 @@
for i, f := range t.Fields {
// Resolve placeholder messages with a concrete standalone message.
// If this fails, validateMessage will complain about it later.
- if f.MessageType != nil && f.MessageType.IsPlaceholder() && !isWeak(f.Options) {
+ if f.MessageType != nil && f.MessageType.IsPlaceholder() && !f.IsWeak {
if m, ok := ms[f.MessageType.FullName()]; ok {
t.Fields[i].MessageType = m
}
@@ -118,6 +118,7 @@
EnumType protoreflect.EnumDescriptor
ExtendedType protoreflect.MessageDescriptor
Options protoreflect.ProtoMessage
+ IsPacked OptionalBool
dv defaultValue
}
diff --git a/reflect/prototype/standalone_type.go b/reflect/prototype/standalone_type.go
index 4728c4e..a087a9d 100644
--- a/reflect/prototype/standalone_type.go
+++ b/reflect/prototype/standalone_type.go
@@ -23,7 +23,7 @@
func (t standaloneMessage) Options() pref.ProtoMessage {
return altOptions(t.m.Options, optionTypes.Message)
}
-func (t standaloneMessage) IsMapEntry() bool { return t.m.options.lazyInit(t).isMapEntry }
+func (t standaloneMessage) IsMapEntry() bool { return t.m.IsMapEntry }
func (t standaloneMessage) Fields() pref.FieldDescriptors { return t.m.fields.lazyInit(t, t.m.Fields) }
func (t standaloneMessage) Oneofs() pref.OneofDescriptors { return t.m.oneofs.lazyInit(t, t.m.Oneofs) }
func (t standaloneMessage) ReservedNames() pref.Names { return (*names)(&t.m.ReservedNames) }
@@ -76,11 +76,13 @@
func (t standaloneExtension) Kind() pref.Kind { return t.x.Kind }
func (t standaloneExtension) HasJSONName() bool { return false }
func (t standaloneExtension) JSONName() string { return "" }
-func (t standaloneExtension) IsPacked() bool { return isPacked(t.Options()) }
-func (t standaloneExtension) IsWeak() bool { return false }
-func (t standaloneExtension) IsMap() bool { return false }
-func (t standaloneExtension) HasDefault() bool { return t.x.Default.IsValid() }
-func (t standaloneExtension) Default() pref.Value { return t.x.dv.value(t, t.x.Default) }
+func (t standaloneExtension) IsPacked() bool {
+ return isPacked(t.x.IsPacked, pref.Proto2, t.x.Cardinality, t.x.Kind)
+}
+func (t standaloneExtension) IsWeak() bool { return false }
+func (t standaloneExtension) IsMap() bool { return false }
+func (t standaloneExtension) HasDefault() bool { return t.x.Default.IsValid() }
+func (t standaloneExtension) Default() pref.Value { return t.x.dv.value(t, t.x.Default) }
func (t standaloneExtension) DefaultEnumValue() pref.EnumValueDescriptor {
return t.x.dv.enum(t, t.x.Default)
}
diff --git a/reflect/prototype/type_test.go b/reflect/prototype/type_test.go
index 4bac6c6..56edebb 100644
--- a/reflect/prototype/type_test.go
+++ b/reflect/prototype/type_test.go
@@ -41,6 +41,7 @@
MapEntry: scalar.Bool(true),
Deprecated: scalar.Bool(true),
},
+ IsMapEntry: true,
Fields: []ptype.Field{{
Name: "key", // "test.A.key"
Number: 1,
@@ -92,6 +93,7 @@
Cardinality: pref.Repeated,
Kind: pref.Int32Kind,
Options: &descriptorpb.FieldOptions{Packed: scalar.Bool(true)},
+ IsPacked: ptype.True,
}, {
Name: "field_six", // "test.B.field_six"
Number: 6,
@@ -132,6 +134,7 @@
Cardinality: pref.Repeated,
Kind: pref.MessageKind,
Options: &descriptorpb.FieldOptions{Packed: scalar.Bool(false)},
+ IsPacked: ptype.False,
MessageType: ptype.PlaceholderMessage("test.C"),
ExtendedType: ptype.PlaceholderMessage("test.B"),
}},
@@ -156,6 +159,7 @@
Cardinality: pref.Repeated,
Kind: pref.MessageKind,
Options: &descriptorpb.FieldOptions{Packed: scalar.Bool(true)},
+ IsPacked: ptype.True,
MessageType: ptype.PlaceholderMessage("test.C"),
ExtendedType: ptype.PlaceholderMessage("test.B"),
}},
@@ -601,7 +605,7 @@
"Number": pref.FieldNumber(1000),
"Cardinality": pref.Repeated,
"Kind": pref.MessageKind,
- "IsPacked": true,
+ "IsPacked": false,
"MessageType": M{"FullName": pref.FullName("test.C"), "IsPlaceholder": false},
"ExtendedType": M{"FullName": pref.FullName("test.B"), "IsPlaceholder": false},
"Options": &descriptorpb.FieldOptions{Packed: scalar.Bool(true)},
@@ -862,7 +866,6 @@
Number: 1000
Cardinality: repeated
Kind: message
- IsPacked: true
ExtendedType: test.B
MessageType: test.C
}]
diff --git a/types/descriptor/descriptor.pb.go b/types/descriptor/descriptor.pb.go
index be51fb2..35679c3 100644
--- a/types/descriptor/descriptor.pb.go
+++ b/types/descriptor/descriptor.pb.go
@@ -3309,6 +3309,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.MessageKind,
JSONName: "file",
+ IsPacked: prototype.False,
},
},
},
@@ -3321,6 +3322,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "name",
+ IsPacked: prototype.False,
},
{
Name: "package",
@@ -3328,6 +3330,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "package",
+ IsPacked: prototype.False,
},
{
Name: "dependency",
@@ -3335,6 +3338,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.StringKind,
JSONName: "dependency",
+ IsPacked: prototype.False,
},
{
Name: "public_dependency",
@@ -3342,6 +3346,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.Int32Kind,
JSONName: "publicDependency",
+ IsPacked: prototype.False,
},
{
Name: "weak_dependency",
@@ -3349,6 +3354,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.Int32Kind,
JSONName: "weakDependency",
+ IsPacked: prototype.False,
},
{
Name: "message_type",
@@ -3356,6 +3362,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.MessageKind,
JSONName: "messageType",
+ IsPacked: prototype.False,
},
{
Name: "enum_type",
@@ -3363,6 +3370,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.MessageKind,
JSONName: "enumType",
+ IsPacked: prototype.False,
},
{
Name: "service",
@@ -3370,6 +3378,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.MessageKind,
JSONName: "service",
+ IsPacked: prototype.False,
},
{
Name: "extension",
@@ -3377,6 +3386,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.MessageKind,
JSONName: "extension",
+ IsPacked: prototype.False,
},
{
Name: "options",
@@ -3384,6 +3394,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.MessageKind,
JSONName: "options",
+ IsPacked: prototype.False,
},
{
Name: "source_code_info",
@@ -3391,6 +3402,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.MessageKind,
JSONName: "sourceCodeInfo",
+ IsPacked: prototype.False,
},
{
Name: "syntax",
@@ -3398,6 +3410,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "syntax",
+ IsPacked: prototype.False,
},
},
},
@@ -3410,6 +3423,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "name",
+ IsPacked: prototype.False,
},
{
Name: "field",
@@ -3417,6 +3431,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.MessageKind,
JSONName: "field",
+ IsPacked: prototype.False,
},
{
Name: "extension",
@@ -3424,6 +3439,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.MessageKind,
JSONName: "extension",
+ IsPacked: prototype.False,
},
{
Name: "nested_type",
@@ -3431,6 +3447,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.MessageKind,
JSONName: "nestedType",
+ IsPacked: prototype.False,
},
{
Name: "enum_type",
@@ -3438,6 +3455,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.MessageKind,
JSONName: "enumType",
+ IsPacked: prototype.False,
},
{
Name: "extension_range",
@@ -3445,6 +3463,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.MessageKind,
JSONName: "extensionRange",
+ IsPacked: prototype.False,
},
{
Name: "oneof_decl",
@@ -3452,6 +3471,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.MessageKind,
JSONName: "oneofDecl",
+ IsPacked: prototype.False,
},
{
Name: "options",
@@ -3459,6 +3479,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.MessageKind,
JSONName: "options",
+ IsPacked: prototype.False,
},
{
Name: "reserved_range",
@@ -3466,6 +3487,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.MessageKind,
JSONName: "reservedRange",
+ IsPacked: prototype.False,
},
{
Name: "reserved_name",
@@ -3473,6 +3495,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.StringKind,
JSONName: "reservedName",
+ IsPacked: prototype.False,
},
},
},
@@ -3485,6 +3508,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.MessageKind,
JSONName: "uninterpretedOption",
+ IsPacked: prototype.False,
},
},
ExtensionRanges: [][2]protoreflect.FieldNumber{{1000, 536870912}},
@@ -3498,6 +3522,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "name",
+ IsPacked: prototype.False,
},
{
Name: "number",
@@ -3505,6 +3530,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.Int32Kind,
JSONName: "number",
+ IsPacked: prototype.False,
},
{
Name: "label",
@@ -3512,6 +3538,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.EnumKind,
JSONName: "label",
+ IsPacked: prototype.False,
},
{
Name: "type",
@@ -3519,6 +3546,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.EnumKind,
JSONName: "type",
+ IsPacked: prototype.False,
},
{
Name: "type_name",
@@ -3526,6 +3554,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "typeName",
+ IsPacked: prototype.False,
},
{
Name: "extendee",
@@ -3533,6 +3562,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "extendee",
+ IsPacked: prototype.False,
},
{
Name: "default_value",
@@ -3540,6 +3570,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "defaultValue",
+ IsPacked: prototype.False,
},
{
Name: "oneof_index",
@@ -3547,6 +3578,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.Int32Kind,
JSONName: "oneofIndex",
+ IsPacked: prototype.False,
},
{
Name: "json_name",
@@ -3554,6 +3586,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "jsonName",
+ IsPacked: prototype.False,
},
{
Name: "options",
@@ -3561,6 +3594,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.MessageKind,
JSONName: "options",
+ IsPacked: prototype.False,
},
},
},
@@ -3573,6 +3607,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "name",
+ IsPacked: prototype.False,
},
{
Name: "options",
@@ -3580,6 +3615,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.MessageKind,
JSONName: "options",
+ IsPacked: prototype.False,
},
},
},
@@ -3592,6 +3628,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "name",
+ IsPacked: prototype.False,
},
{
Name: "value",
@@ -3599,6 +3636,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.MessageKind,
JSONName: "value",
+ IsPacked: prototype.False,
},
{
Name: "options",
@@ -3606,6 +3644,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.MessageKind,
JSONName: "options",
+ IsPacked: prototype.False,
},
{
Name: "reserved_range",
@@ -3613,6 +3652,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.MessageKind,
JSONName: "reservedRange",
+ IsPacked: prototype.False,
},
{
Name: "reserved_name",
@@ -3620,6 +3660,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.StringKind,
JSONName: "reservedName",
+ IsPacked: prototype.False,
},
},
},
@@ -3632,6 +3673,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "name",
+ IsPacked: prototype.False,
},
{
Name: "number",
@@ -3639,6 +3681,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.Int32Kind,
JSONName: "number",
+ IsPacked: prototype.False,
},
{
Name: "options",
@@ -3646,6 +3689,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.MessageKind,
JSONName: "options",
+ IsPacked: prototype.False,
},
},
},
@@ -3658,6 +3702,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "name",
+ IsPacked: prototype.False,
},
{
Name: "method",
@@ -3665,6 +3710,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.MessageKind,
JSONName: "method",
+ IsPacked: prototype.False,
},
{
Name: "options",
@@ -3672,6 +3718,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.MessageKind,
JSONName: "options",
+ IsPacked: prototype.False,
},
},
},
@@ -3684,6 +3731,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "name",
+ IsPacked: prototype.False,
},
{
Name: "input_type",
@@ -3691,6 +3739,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "inputType",
+ IsPacked: prototype.False,
},
{
Name: "output_type",
@@ -3698,6 +3747,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "outputType",
+ IsPacked: prototype.False,
},
{
Name: "options",
@@ -3705,6 +3755,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.MessageKind,
JSONName: "options",
+ IsPacked: prototype.False,
},
{
Name: "client_streaming",
@@ -3713,6 +3764,7 @@
Kind: protoreflect.BoolKind,
JSONName: "clientStreaming",
Default: protoreflect.ValueOf(bool(false)),
+ IsPacked: prototype.False,
},
{
Name: "server_streaming",
@@ -3721,6 +3773,7 @@
Kind: protoreflect.BoolKind,
JSONName: "serverStreaming",
Default: protoreflect.ValueOf(bool(false)),
+ IsPacked: prototype.False,
},
},
},
@@ -3733,6 +3786,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "javaPackage",
+ IsPacked: prototype.False,
},
{
Name: "java_outer_classname",
@@ -3740,6 +3794,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "javaOuterClassname",
+ IsPacked: prototype.False,
},
{
Name: "java_multiple_files",
@@ -3748,6 +3803,7 @@
Kind: protoreflect.BoolKind,
JSONName: "javaMultipleFiles",
Default: protoreflect.ValueOf(bool(false)),
+ IsPacked: prototype.False,
},
{
Name: "java_generate_equals_and_hash",
@@ -3755,6 +3811,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.BoolKind,
JSONName: "javaGenerateEqualsAndHash",
+ IsPacked: prototype.False,
},
{
Name: "java_string_check_utf8",
@@ -3763,6 +3820,7 @@
Kind: protoreflect.BoolKind,
JSONName: "javaStringCheckUtf8",
Default: protoreflect.ValueOf(bool(false)),
+ IsPacked: prototype.False,
},
{
Name: "optimize_for",
@@ -3771,6 +3829,7 @@
Kind: protoreflect.EnumKind,
JSONName: "optimizeFor",
Default: protoreflect.ValueOf(string("SPEED")),
+ IsPacked: prototype.False,
},
{
Name: "go_package",
@@ -3778,6 +3837,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "goPackage",
+ IsPacked: prototype.False,
},
{
Name: "cc_generic_services",
@@ -3786,6 +3846,7 @@
Kind: protoreflect.BoolKind,
JSONName: "ccGenericServices",
Default: protoreflect.ValueOf(bool(false)),
+ IsPacked: prototype.False,
},
{
Name: "java_generic_services",
@@ -3794,6 +3855,7 @@
Kind: protoreflect.BoolKind,
JSONName: "javaGenericServices",
Default: protoreflect.ValueOf(bool(false)),
+ IsPacked: prototype.False,
},
{
Name: "py_generic_services",
@@ -3802,6 +3864,7 @@
Kind: protoreflect.BoolKind,
JSONName: "pyGenericServices",
Default: protoreflect.ValueOf(bool(false)),
+ IsPacked: prototype.False,
},
{
Name: "php_generic_services",
@@ -3810,6 +3873,7 @@
Kind: protoreflect.BoolKind,
JSONName: "phpGenericServices",
Default: protoreflect.ValueOf(bool(false)),
+ IsPacked: prototype.False,
},
{
Name: "deprecated",
@@ -3818,6 +3882,7 @@
Kind: protoreflect.BoolKind,
JSONName: "deprecated",
Default: protoreflect.ValueOf(bool(false)),
+ IsPacked: prototype.False,
},
{
Name: "cc_enable_arenas",
@@ -3826,6 +3891,7 @@
Kind: protoreflect.BoolKind,
JSONName: "ccEnableArenas",
Default: protoreflect.ValueOf(bool(false)),
+ IsPacked: prototype.False,
},
{
Name: "objc_class_prefix",
@@ -3833,6 +3899,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "objcClassPrefix",
+ IsPacked: prototype.False,
},
{
Name: "csharp_namespace",
@@ -3840,6 +3907,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "csharpNamespace",
+ IsPacked: prototype.False,
},
{
Name: "swift_prefix",
@@ -3847,6 +3915,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "swiftPrefix",
+ IsPacked: prototype.False,
},
{
Name: "php_class_prefix",
@@ -3854,6 +3923,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "phpClassPrefix",
+ IsPacked: prototype.False,
},
{
Name: "php_namespace",
@@ -3861,6 +3931,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "phpNamespace",
+ IsPacked: prototype.False,
},
{
Name: "php_metadata_namespace",
@@ -3868,6 +3939,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "phpMetadataNamespace",
+ IsPacked: prototype.False,
},
{
Name: "ruby_package",
@@ -3875,6 +3947,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "rubyPackage",
+ IsPacked: prototype.False,
},
{
Name: "uninterpreted_option",
@@ -3882,6 +3955,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.MessageKind,
JSONName: "uninterpretedOption",
+ IsPacked: prototype.False,
},
},
ReservedRanges: [][2]protoreflect.FieldNumber{{38, 39}},
@@ -3897,6 +3971,7 @@
Kind: protoreflect.BoolKind,
JSONName: "messageSetWireFormat",
Default: protoreflect.ValueOf(bool(false)),
+ IsPacked: prototype.False,
},
{
Name: "no_standard_descriptor_accessor",
@@ -3905,6 +3980,7 @@
Kind: protoreflect.BoolKind,
JSONName: "noStandardDescriptorAccessor",
Default: protoreflect.ValueOf(bool(false)),
+ IsPacked: prototype.False,
},
{
Name: "deprecated",
@@ -3913,6 +3989,7 @@
Kind: protoreflect.BoolKind,
JSONName: "deprecated",
Default: protoreflect.ValueOf(bool(false)),
+ IsPacked: prototype.False,
},
{
Name: "map_entry",
@@ -3920,6 +3997,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.BoolKind,
JSONName: "mapEntry",
+ IsPacked: prototype.False,
},
{
Name: "uninterpreted_option",
@@ -3927,6 +4005,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.MessageKind,
JSONName: "uninterpretedOption",
+ IsPacked: prototype.False,
},
},
ReservedRanges: [][2]protoreflect.FieldNumber{{8, 9}, {9, 10}},
@@ -3942,6 +4021,7 @@
Kind: protoreflect.EnumKind,
JSONName: "ctype",
Default: protoreflect.ValueOf(string("STRING")),
+ IsPacked: prototype.False,
},
{
Name: "packed",
@@ -3949,6 +4029,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.BoolKind,
JSONName: "packed",
+ IsPacked: prototype.False,
},
{
Name: "jstype",
@@ -3957,6 +4038,7 @@
Kind: protoreflect.EnumKind,
JSONName: "jstype",
Default: protoreflect.ValueOf(string("JS_NORMAL")),
+ IsPacked: prototype.False,
},
{
Name: "lazy",
@@ -3965,6 +4047,7 @@
Kind: protoreflect.BoolKind,
JSONName: "lazy",
Default: protoreflect.ValueOf(bool(false)),
+ IsPacked: prototype.False,
},
{
Name: "deprecated",
@@ -3973,6 +4056,7 @@
Kind: protoreflect.BoolKind,
JSONName: "deprecated",
Default: protoreflect.ValueOf(bool(false)),
+ IsPacked: prototype.False,
},
{
Name: "weak",
@@ -3981,6 +4065,7 @@
Kind: protoreflect.BoolKind,
JSONName: "weak",
Default: protoreflect.ValueOf(bool(false)),
+ IsPacked: prototype.False,
},
{
Name: "uninterpreted_option",
@@ -3988,6 +4073,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.MessageKind,
JSONName: "uninterpretedOption",
+ IsPacked: prototype.False,
},
},
ReservedRanges: [][2]protoreflect.FieldNumber{{4, 5}},
@@ -4002,6 +4088,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.MessageKind,
JSONName: "uninterpretedOption",
+ IsPacked: prototype.False,
},
},
ExtensionRanges: [][2]protoreflect.FieldNumber{{1000, 536870912}},
@@ -4015,6 +4102,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.BoolKind,
JSONName: "allowAlias",
+ IsPacked: prototype.False,
},
{
Name: "deprecated",
@@ -4023,6 +4111,7 @@
Kind: protoreflect.BoolKind,
JSONName: "deprecated",
Default: protoreflect.ValueOf(bool(false)),
+ IsPacked: prototype.False,
},
{
Name: "uninterpreted_option",
@@ -4030,6 +4119,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.MessageKind,
JSONName: "uninterpretedOption",
+ IsPacked: prototype.False,
},
},
ReservedRanges: [][2]protoreflect.FieldNumber{{5, 6}},
@@ -4045,6 +4135,7 @@
Kind: protoreflect.BoolKind,
JSONName: "deprecated",
Default: protoreflect.ValueOf(bool(false)),
+ IsPacked: prototype.False,
},
{
Name: "uninterpreted_option",
@@ -4052,6 +4143,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.MessageKind,
JSONName: "uninterpretedOption",
+ IsPacked: prototype.False,
},
},
ExtensionRanges: [][2]protoreflect.FieldNumber{{1000, 536870912}},
@@ -4066,6 +4158,7 @@
Kind: protoreflect.BoolKind,
JSONName: "deprecated",
Default: protoreflect.ValueOf(bool(false)),
+ IsPacked: prototype.False,
},
{
Name: "uninterpreted_option",
@@ -4073,6 +4166,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.MessageKind,
JSONName: "uninterpretedOption",
+ IsPacked: prototype.False,
},
},
ExtensionRanges: [][2]protoreflect.FieldNumber{{1000, 536870912}},
@@ -4087,6 +4181,7 @@
Kind: protoreflect.BoolKind,
JSONName: "deprecated",
Default: protoreflect.ValueOf(bool(false)),
+ IsPacked: prototype.False,
},
{
Name: "idempotency_level",
@@ -4095,6 +4190,7 @@
Kind: protoreflect.EnumKind,
JSONName: "idempotencyLevel",
Default: protoreflect.ValueOf(string("IDEMPOTENCY_UNKNOWN")),
+ IsPacked: prototype.False,
},
{
Name: "uninterpreted_option",
@@ -4102,6 +4198,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.MessageKind,
JSONName: "uninterpretedOption",
+ IsPacked: prototype.False,
},
},
ExtensionRanges: [][2]protoreflect.FieldNumber{{1000, 536870912}},
@@ -4115,6 +4212,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.MessageKind,
JSONName: "name",
+ IsPacked: prototype.False,
},
{
Name: "identifier_value",
@@ -4122,6 +4220,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "identifierValue",
+ IsPacked: prototype.False,
},
{
Name: "positive_int_value",
@@ -4129,6 +4228,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.Uint64Kind,
JSONName: "positiveIntValue",
+ IsPacked: prototype.False,
},
{
Name: "negative_int_value",
@@ -4136,6 +4236,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.Int64Kind,
JSONName: "negativeIntValue",
+ IsPacked: prototype.False,
},
{
Name: "double_value",
@@ -4143,6 +4244,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.DoubleKind,
JSONName: "doubleValue",
+ IsPacked: prototype.False,
},
{
Name: "string_value",
@@ -4150,6 +4252,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.BytesKind,
JSONName: "stringValue",
+ IsPacked: prototype.False,
},
{
Name: "aggregate_value",
@@ -4157,6 +4260,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "aggregateValue",
+ IsPacked: prototype.False,
},
},
},
@@ -4169,6 +4273,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.MessageKind,
JSONName: "location",
+ IsPacked: prototype.False,
},
},
},
@@ -4181,6 +4286,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.MessageKind,
JSONName: "annotation",
+ IsPacked: prototype.False,
},
},
},
@@ -4193,6 +4299,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.Int32Kind,
JSONName: "start",
+ IsPacked: prototype.False,
},
{
Name: "end",
@@ -4200,6 +4307,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.Int32Kind,
JSONName: "end",
+ IsPacked: prototype.False,
},
{
Name: "options",
@@ -4207,6 +4315,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.MessageKind,
JSONName: "options",
+ IsPacked: prototype.False,
},
},
},
@@ -4219,6 +4328,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.Int32Kind,
JSONName: "start",
+ IsPacked: prototype.False,
},
{
Name: "end",
@@ -4226,6 +4336,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.Int32Kind,
JSONName: "end",
+ IsPacked: prototype.False,
},
},
},
@@ -4238,6 +4349,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.Int32Kind,
JSONName: "start",
+ IsPacked: prototype.False,
},
{
Name: "end",
@@ -4245,6 +4357,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.Int32Kind,
JSONName: "end",
+ IsPacked: prototype.False,
},
},
},
@@ -4257,6 +4370,7 @@
Cardinality: protoreflect.Required,
Kind: protoreflect.StringKind,
JSONName: "namePart",
+ IsPacked: prototype.False,
},
{
Name: "is_extension",
@@ -4264,6 +4378,7 @@
Cardinality: protoreflect.Required,
Kind: protoreflect.BoolKind,
JSONName: "isExtension",
+ IsPacked: prototype.False,
},
},
},
@@ -4276,6 +4391,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.Int32Kind,
JSONName: "path",
+ IsPacked: prototype.True,
},
{
Name: "span",
@@ -4283,6 +4399,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.Int32Kind,
JSONName: "span",
+ IsPacked: prototype.True,
},
{
Name: "leading_comments",
@@ -4290,6 +4407,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "leadingComments",
+ IsPacked: prototype.False,
},
{
Name: "trailing_comments",
@@ -4297,6 +4415,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "trailingComments",
+ IsPacked: prototype.False,
},
{
Name: "leading_detached_comments",
@@ -4304,6 +4423,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.StringKind,
JSONName: "leadingDetachedComments",
+ IsPacked: prototype.False,
},
},
},
@@ -4316,6 +4436,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.Int32Kind,
JSONName: "path",
+ IsPacked: prototype.True,
},
{
Name: "source_file",
@@ -4323,6 +4444,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "sourceFile",
+ IsPacked: prototype.False,
},
{
Name: "begin",
@@ -4330,6 +4452,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.Int32Kind,
JSONName: "begin",
+ IsPacked: prototype.False,
},
{
Name: "end",
@@ -4337,6 +4460,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.Int32Kind,
JSONName: "end",
+ IsPacked: prototype.False,
},
},
},
diff --git a/types/plugin/plugin.pb.go b/types/plugin/plugin.pb.go
index b83d34a..d3c3c76 100644
--- a/types/plugin/plugin.pb.go
+++ b/types/plugin/plugin.pb.go
@@ -498,6 +498,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.Int32Kind,
JSONName: "major",
+ IsPacked: prototype.False,
},
{
Name: "minor",
@@ -505,6 +506,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.Int32Kind,
JSONName: "minor",
+ IsPacked: prototype.False,
},
{
Name: "patch",
@@ -512,6 +514,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.Int32Kind,
JSONName: "patch",
+ IsPacked: prototype.False,
},
{
Name: "suffix",
@@ -519,6 +522,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "suffix",
+ IsPacked: prototype.False,
},
},
},
@@ -531,6 +535,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.StringKind,
JSONName: "fileToGenerate",
+ IsPacked: prototype.False,
},
{
Name: "parameter",
@@ -538,6 +543,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "parameter",
+ IsPacked: prototype.False,
},
{
Name: "proto_file",
@@ -545,6 +551,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.MessageKind,
JSONName: "protoFile",
+ IsPacked: prototype.False,
},
{
Name: "compiler_version",
@@ -552,6 +559,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.MessageKind,
JSONName: "compilerVersion",
+ IsPacked: prototype.False,
},
},
},
@@ -564,6 +572,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "error",
+ IsPacked: prototype.False,
},
{
Name: "file",
@@ -571,6 +580,7 @@
Cardinality: protoreflect.Repeated,
Kind: protoreflect.MessageKind,
JSONName: "file",
+ IsPacked: prototype.False,
},
},
},
@@ -583,6 +593,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "name",
+ IsPacked: prototype.False,
},
{
Name: "insertion_point",
@@ -590,6 +601,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "insertionPoint",
+ IsPacked: prototype.False,
},
{
Name: "content",
@@ -597,6 +609,7 @@
Cardinality: protoreflect.Optional,
Kind: protoreflect.StringKind,
JSONName: "content",
+ IsPacked: prototype.False,
},
},
},