From 2cf177e5af9015d793512122276299956235d8ae Mon Sep 17 00:00:00 2001 From: Dan Sexton Date: Mon, 28 Oct 2024 12:56:45 -0400 Subject: [PATCH] feat: added proto3 optional support to fastmarshal --- cmd/protoc-gen-fastmarshal/run.go | 3 + .../templates/fieldsnippets.tmpl | 61 +- .../templates/permessage.go.tmpl | 14 +- .../templates/singlefile.go.tmpl | 14 +- .../googlev1_permessage_example.pb.go | 2 +- .../googlev2_permessage_example.pb.go | 204 +---- .../googlev1/googlev1_proto2_example.pb.go | 2 +- .../googlev2/googlev2_proto2_example.pb.go | 162 +--- .../googlev1/googlev1_proto3_example.pb.go | 2 +- .../googlev2/googlev2_proto3_example.pb.fm.go | 377 +++++++++ .../googlev2/googlev2_proto3_example.pb.go | 721 ++++++++++-------- .../googlev2/googlev2_proto3_example.proto | 21 + 12 files changed, 935 insertions(+), 648 deletions(-) diff --git a/cmd/protoc-gen-fastmarshal/run.go b/cmd/protoc-gen-fastmarshal/run.go index c6e7f44..f791491 100644 --- a/cmd/protoc-gen-fastmarshal/run.go +++ b/cmd/protoc-gen-fastmarshal/run.go @@ -8,6 +8,7 @@ import ( "text/template" "google.golang.org/protobuf/compiler/protogen" + "google.golang.org/protobuf/types/pluginpb" ) // options defines the supported configuration options for a generation request @@ -120,6 +121,8 @@ func doGenerate(opts *options) func(*protogen.Plugin) error { opts.apiVersion = protoAPIVersion("v1") } + plugin.SupportedFeatures |= uint64(pluginpb.CodeGeneratorResponse_FEATURE_PROTO3_OPTIONAL) + for _, protoFile := range plugin.Files { if !protoFile.Generate { continue diff --git a/cmd/protoc-gen-fastmarshal/templates/fieldsnippets.tmpl b/cmd/protoc-gen-fastmarshal/templates/fieldsnippets.tmpl index a45e636..c3ff086 100644 --- a/cmd/protoc-gen-fastmarshal/templates/fieldsnippets.tmpl +++ b/cmd/protoc-gen-fastmarshal/templates/fieldsnippets.tmpl @@ -1,7 +1,7 @@ {{/* SizeOfString - calculate the encoded size of a string field */}} {{ define "SizeOfString" }} {{- if ne (.Desc.Cardinality | string) "repeated" -}} - {{- if eq (.Desc.Syntax | string) "proto2" -}} + {{- if or (eq (.Desc.Syntax | string) "proto2") (ne .Desc.ContainingOneof nil) -}} if m.{{ .GoName | getSafeFieldName }} != nil { l = len(*m.{{ .GoName | getSafeFieldName }}) sz += csproto.SizeOfTagKey({{.Desc.Number}}) + csproto.SizeOfVarint(uint64(l)) + l @@ -39,7 +39,7 @@ {{/* SizeOfInt - calculate the encoded size of an integer field */}} {{ define "SizeOfInt" }} {{- if ne (.Desc.Cardinality | string) "repeated" -}} - {{- if eq (.Desc.Syntax | string) "proto2" -}} + {{- if or (eq (.Desc.Syntax | string) "proto2") (ne .Desc.ContainingOneof nil) -}} if m.{{.GoName | getSafeFieldName}} != nil { sz += csproto.SizeOfTagKey({{.Desc.Number}}) + csproto.SizeOfVarint(uint64(*m.{{.GoName | getSafeFieldName}})) } @@ -66,7 +66,7 @@ {{/* SizeOfBool - calculate the encoded size of a boolean field */}} {{ define "SizeOfBool" }} {{- if ne (.Desc.Cardinality | string) "repeated" -}} - {{- if eq (.Desc.Syntax | string) "proto2" -}} + {{- if or (eq (.Desc.Syntax | string) "proto2") (ne .Desc.ContainingOneof nil) -}} if m.{{.GoName | getSafeFieldName}} != nil { sz += csproto.SizeOfTagKey({{.Desc.Number}}) + 1 } @@ -88,7 +88,7 @@ {{/* SizeOfSInt - calculate the encoded size of a sint32 or sint64 field */}} {{ define "SizeOfSInt" }} {{- if ne (.Desc.Cardinality | string) "repeated" -}} - {{- if eq (.Desc.Syntax | string) "proto2" -}} + {{- if or (eq (.Desc.Syntax | string) "proto2") (ne .Desc.ContainingOneof nil) -}} if m.{{.GoName | getSafeFieldName}} != nil { sz += csproto.SizeOfTagKey({{.Desc.Number}}) + csproto.SizeOfZigZag(uint64(*m.{{.GoName | getSafeFieldName}})) } @@ -115,7 +115,7 @@ {{/* SizeOfFixed - calculate the encoded size of a fixed-width field */}} {{ define "SizeOfFixed" }} {{- if ne (.Desc.Cardinality | string) "repeated" -}} - {{- if eq (.Desc.Syntax | string) "proto2" -}} + {{- if or (eq (.Desc.Syntax | string) "proto2") (ne .Desc.ContainingOneof nil) -}} if m.{{.GoName | getSafeFieldName}} != nil { sz += csproto.SizeOfTagKey({{.Desc.Number}}) + {{if eq (.Desc.Kind | string) "fixed32" "sfixed32" "float"}}4{{else}}8{{end}} } @@ -330,8 +330,12 @@ } {{- end -}} {{- else -}} + {{- if eq .Desc.ContainingOneof nil -}} if m.{{.GoName | getSafeFieldName }} != 0 { - enc.{{$method}}({{.Desc.Number}}, m.{{.GoName | getSafeFieldName}}) + {{- else -}} + if m.{{.GoName | getSafeFieldName }} != nil { + {{- end -}} + enc.{{$method}}({{.Desc.Number}}, {{if ne .Desc.ContainingOneof nil}}*{{end}}m.{{.GoName | getSafeFieldName}}) } {{- end -}} {{- end -}} @@ -362,8 +366,12 @@ } {{- end -}} {{- else -}} + {{- if eq .Desc.ContainingOneof nil -}} if m.{{.GoName | getSafeFieldName}} { - enc.EncodeBool({{.Desc.Number}}, m.{{.GoName | getSafeFieldName}}) + {{- else -}} + if m.{{.GoName | getSafeFieldName }} != nil { + {{- end -}} + enc.EncodeBool({{.Desc.Number}}, {{if ne .Desc.ContainingOneof nil}}*{{end}}m.{{.GoName | getSafeFieldName}}) } {{- end -}} {{- end -}} @@ -388,8 +396,12 @@ } {{- end -}} {{- else -}} + {{- if eq .Desc.ContainingOneof nil -}} if len(m.{{.GoName | getSafeFieldName }}) > 0 { - enc.EncodeString({{.Desc.Number}}, m.{{.GoName | getSafeFieldName}}) + {{- else -}} + if m.{{.GoName | getSafeFieldName }} != nil { + {{- end -}} + enc.EncodeString({{.Desc.Number}}, {{if ne .Desc.ContainingOneof nil}}*{{end}}m.{{.GoName | getSafeFieldName}}) } {{- end -}} {{- end -}} @@ -451,7 +463,7 @@ } {{- end -}} {{- else -}} - enc.{{ $method }}({{.Desc.Number}}, {{$cast}}(m.{{.GoName | getSafeFieldName}})) + enc.{{ $method }}({{.Desc.Number}}, {{$cast}}({{if ne .Desc.ContainingOneof nil}}*{{end}}m.{{.GoName | getSafeFieldName}})) {{- end -}} {{- end -}} {{ end }} @@ -485,8 +497,12 @@ } {{- end -}} {{- else -}} + {{- if eq .Desc.ContainingOneof nil -}} if m.{{.GoName | getSafeFieldName}} != 0 { - enc.EncodeInt32({{.Desc.Number}}, int32(m.{{.GoName | getSafeFieldName}})) + {{- else -}} + if m.{{.GoName | getSafeFieldName }} != nil { + {{- end -}} + enc.EncodeInt32({{.Desc.Number}}, int32({{if ne .Desc.ContainingOneof nil}}*{{end}}m.{{.GoName | getSafeFieldName}})) } {{- end -}} {{- end -}} @@ -685,6 +701,7 @@ {{- $syntax := (.Desc.Syntax | string) -}} {{- $kind := (.Desc.Kind | string) -}} {{- $cardinality := (.Desc.Cardinality | string) -}} +{{- $isOptional := or (eq $syntax "proto2") (ne .Desc.ContainingOneof nil) -}} {{- if eq $kind "bool" -}} {{- if eq $cardinality "repeated" -}} switch wt { @@ -710,7 +727,7 @@ if v, err := dec.DecodeBool(); err != nil { return fmt.Errorf("unable to decode boolean value for field '{{.Desc.Name}}' (tag={{.Desc.Number}}): %w", err) } else { - m.{{.GoName | getSafeFieldName}} = {{if eq $syntax "proto2"}}csproto.Bool(v){{else}}v{{end}} + m.{{.GoName | getSafeFieldName}} = {{if eq $isOptional true}}csproto.Bool(v){{else}}v{{end}} } {{- end -}} {{- else if eq $kind "int32" -}} @@ -738,7 +755,7 @@ if v, err := dec.DecodeInt32(); err != nil { return fmt.Errorf("unable to decode int32 value for field '{{.Desc.Name}}' (tag={{.Desc.Number}}): %w", err) } else { - m.{{.GoName | getSafeFieldName}} = {{if eq $syntax "proto2"}}csproto.Int32(v){{else}}v{{end}} + m.{{.GoName | getSafeFieldName}} = {{if eq $isOptional true}}csproto.Int32(v){{else}}v{{end}} } {{- end -}} {{- else if eq $kind "int64" -}} @@ -766,7 +783,7 @@ if v, err := dec.DecodeInt64(); err != nil { return fmt.Errorf("unable to decode int64 value for field '{{.Desc.Name}}' (tag={{.Desc.Number}}): %w", err) } else { - m.{{.GoName | getSafeFieldName}} = {{if eq $syntax "proto2"}}csproto.Int64(v){{else}}v{{end}} + m.{{.GoName | getSafeFieldName}} = {{if eq $isOptional true}}csproto.Int64(v){{else}}v{{end}} } {{- end -}} {{- else if eq $kind "uint32" -}} @@ -794,7 +811,7 @@ if v, err := dec.DecodeUInt32(); err != nil { return fmt.Errorf("unable to decode int32 value for field '{{.Desc.Name}}' (tag={{.Desc.Number}}): %w", err) } else { - m.{{.GoName | getSafeFieldName}} = {{if eq $syntax "proto2"}}csproto.Uint32(v){{else}}v{{end}} + m.{{.GoName | getSafeFieldName}} = {{if eq $isOptional true}}csproto.Uint32(v){{else}}v{{end}} } {{- end -}} {{- else if eq $kind "uint64" -}} @@ -822,7 +839,7 @@ if v, err := dec.DecodeUInt64(); err != nil { return fmt.Errorf("unable to decode uint64 value for field '{{.Desc.Name}}' (tag={{.Desc.Number}}): %w", err) } else { - m.{{.GoName | getSafeFieldName}} = {{if eq $syntax "proto2"}}csproto.Uint64(v){{else}}v{{end}} + m.{{.GoName | getSafeFieldName}} = {{if eq $isOptional true}}csproto.Uint64(v){{else}}v{{end}} } {{- end -}} {{- else if eq $kind "enum" -}} @@ -852,7 +869,7 @@ if v, err := dec.DecodeInt32(); err != nil { return fmt.Errorf("unable to decode int32 enum value for field '{{.Desc.Name}}' (tag={{.Desc.Number}}): %w", err) } else { - {{- if eq $syntax "proto2" -}} + {{- if eq $isOptional true -}} ev := {{.Enum | getImportPrefix }}{{.Enum.GoIdent.GoName | getSafeFieldName}}(v) m.{{.GoName | getSafeFieldName}} = &ev {{- else -}} @@ -886,7 +903,7 @@ if v, err := dec.DecodeFixed{{$bitSize}}(); err != nil { return fmt.Errorf("unable to decode uint{{$bitSize}} value for field '{{.Desc.Name}}' (tag={{.Desc.Number}}): %w", err) } else { - m.{{.GoName | getSafeFieldName}} = {{if eq $syntax "proto2"}}csproto.Uint{{$bitSize}}(v){{else}}v{{end}} + m.{{.GoName | getSafeFieldName}} = {{if eq $isOptional true}}csproto.Uint{{$bitSize}}(v){{else}}v{{end}} } {{- end -}} {{- else if eq $kind "sint32" "sint64" -}} @@ -915,7 +932,7 @@ if v, err := dec.DecodeSInt{{$bitSize}}(); err != nil { return fmt.Errorf("unable to decode sint{{$bitSize}} value for field '{{.Desc.Name}}' (tag={{.Desc.Number}}): %w", err) } else { - m.{{.GoName | getSafeFieldName}} = {{if eq $syntax "proto2"}}csproto.Int{{$bitSize}}(v){{else}}v{{end}} + m.{{.GoName | getSafeFieldName}} = {{if eq $isOptional true}}csproto.Int{{$bitSize}}(v){{else}}v{{end}} } {{- end -}} {{- else if eq $kind "float" "double" -}} @@ -945,7 +962,7 @@ if v, err := dec.DecodeFloat{{$bitSize}}(); err != nil { return fmt.Errorf("unable to decode {{$kind}} value for field '{{.Desc.Name}}' (tag={{.Desc.Number}}): %w", err) } else { - m.{{.GoName | getSafeFieldName}} = {{if eq $syntax "proto2"}}csproto.Float{{$bitSize}}(v){{else}}v{{end}} + m.{{.GoName | getSafeFieldName}} = {{if eq $isOptional true}}csproto.Float{{$bitSize}}(v){{else}}v{{end}} } {{- end -}} {{- else -}} @@ -956,6 +973,7 @@ {{ define "UnmarshalString" }} {{- $syntax := (.Desc.Syntax | string) -}} {{- $cardinality := (.Desc.Cardinality | string) -}} +{{- $isOptional := or (eq $syntax "proto2") (ne .Desc.ContainingOneof nil) -}} if wt != csproto.WireTypeLengthDelimited { return fmt.Errorf("incorrect wire type %v for field '{{.Desc.Name}}' (tag={{.Desc.Number}}), expected 2 (length-delimited)", wt) } @@ -964,7 +982,7 @@ } else { {{- if eq $cardinality "repeated" -}} m.{{.GoName | getSafeFieldName}} = append(m.{{.GoName | getSafeFieldName}}, s) - {{- else if eq $syntax "proto2" -}} + {{- else if eq $isOptional true -}} m.{{.GoName | getSafeFieldName}} = csproto.String(s) {{- else -}} m.{{.GoName | getSafeFieldName}} = s @@ -986,6 +1004,7 @@ {{ define "UnmarshalSFixed" }} {{- $syntax := (.Desc.Syntax | string) -}} {{- $cardinality := (.Desc.Cardinality | string) -}} +{{- $isOptional := or (eq $syntax "proto2") (ne .Desc.ContainingOneof nil) -}} {{- $bitSize := (.Desc.Kind | string | trunc -2) -}} if wt != csproto.WireTypeFixed{{$bitSize}} { return fmt.Errorf("incorrect wire type %v for field '{{.Desc.Name}}' (tag={{.Desc.Number}}), expected {{if eq $bitSize "32" }}5 (32-bit){{else}}1 (64-bit){{end}}", wt) @@ -995,7 +1014,7 @@ } else { {{- if eq $cardinality "repeated" -}} m.{{.GoName | getSafeFieldName}}= append(m.{{.GoName | getSafeFieldName}}, int{{$bitSize}}(v)) - {{- else if eq $syntax "proto2" -}} + {{- else if eq $isOptional true -}} iv := int{{$bitSize}}(v) m.{{.GoName | getSafeFieldName}}= &iv {{- else -}} diff --git a/cmd/protoc-gen-fastmarshal/templates/permessage.go.tmpl b/cmd/protoc-gen-fastmarshal/templates/permessage.go.tmpl index 3eb2d30..8f876bd 100644 --- a/cmd/protoc-gen-fastmarshal/templates/permessage.go.tmpl +++ b/cmd/protoc-gen-fastmarshal/templates/permessage.go.tmpl @@ -38,13 +38,15 @@ func (m *{{ .Message.GoIdent.GoName }}) Size() int { var sz, l int _ = l // avoid unused variable {{ range .Message.Fields }} -{{- if eq .Desc.ContainingOneof nil }} +{{- if or (eq .Desc.ContainingOneof nil) (eq .Desc.ContainingOneof.IsSynthetic true) }} // {{ .GoName }} ({{.Desc.Kind}},{{.Desc.Cardinality}}{{if .Desc.IsPacked }},packed{{ end }}) {{ template "SizeOfField" . }} {{- end -}} {{ end }} {{ range .Message.Oneofs }} - {{- template "SizeOfOneOf" . }} +{{- if eq .Desc.IsSynthetic false }} + {{ template "SizeOfOneOf" . }} +{{ end -}} {{ end }} {{- if eq $protoSyntax "proto2" -}} {{ range getExtensions .Message }} @@ -89,14 +91,16 @@ func (m *{{ .Message.GoIdent.GoName }}) MarshalTo(dest []byte) error { _ = err _ = extVal {{ range .Message.Fields }} -{{- if eq .Desc.ContainingOneof nil }} +{{- if or (eq .Desc.ContainingOneof nil) (eq .Desc.ContainingOneof.IsSynthetic true) }} // {{ .GoName }} ({{.Desc.Number}},{{if .Desc.IsMap}}map{{else}}{{.Desc.Kind}},{{.Desc.Cardinality}}{{if .Desc.IsPacked }},packed{{ end }}{{end}}) {{ template "MarshalField" . }} {{- end -}} {{ end }} {{ range .Message.Oneofs -}} +{{- if eq .Desc.IsSynthetic false -}} // {{.GoName}} (oneof) {{ template "MarshalOneOf" . -}} +{{- end -}} {{ end }} {{- if eq $protoSyntax "proto2" -}} {{ range getExtensions .Message }} @@ -124,11 +128,13 @@ func (m *{{ .Message.GoIdent.GoName}}) Unmarshal(p []byte) error { } switch tag { {{- range .Message.Fields -}} - {{ if eq .Desc.ContainingOneof nil }}case {{ .Desc.Number }}: // {{ .GoName }} ({{if .Desc.IsMap}}map{{else}}{{.Desc.Kind}},{{.Desc.Cardinality}}{{if .Desc.IsPacked }},packed{{ end }}{{end}}) + {{ if or (eq .Desc.ContainingOneof nil) (eq .Desc.ContainingOneof.IsSynthetic true) }}case {{ .Desc.Number }}: // {{ .GoName }} ({{if .Desc.IsMap}}map{{else}}{{.Desc.Kind}},{{.Desc.Cardinality}}{{if .Desc.IsPacked }},packed{{ end }}{{end}}) {{ template "UnmarshalField" . }}{{ end }} {{ end }} {{ range .Message.Oneofs -}} + {{- if eq .Desc.IsSynthetic false -}} {{ template "UnmarshalOneOf" . -}} + {{- end -}} {{ end }} {{- if eq $protoSyntax "proto2" -}} {{ range getExtensions . }} diff --git a/cmd/protoc-gen-fastmarshal/templates/singlefile.go.tmpl b/cmd/protoc-gen-fastmarshal/templates/singlefile.go.tmpl index 90a5bcc..8615ec0 100644 --- a/cmd/protoc-gen-fastmarshal/templates/singlefile.go.tmpl +++ b/cmd/protoc-gen-fastmarshal/templates/singlefile.go.tmpl @@ -40,13 +40,15 @@ func (m *{{ .GoIdent.GoName }}) Size() int { var sz, l int _ = l // avoid unused variable {{ range .Fields }} -{{- if eq .Desc.ContainingOneof nil }} +{{- if or (eq .Desc.ContainingOneof nil) (eq .Desc.ContainingOneof.IsSynthetic true) }} // {{ .GoName }} ({{.Desc.Kind}},{{.Desc.Cardinality}}{{if .Desc.IsPacked }},packed{{ end }}) {{ template "SizeOfField" . }} {{- end -}} {{ end }} {{ range .Oneofs }} - {{- template "SizeOfOneOf" . }} +{{- if eq .Desc.IsSynthetic false }} + {{ template "SizeOfOneOf" . }} +{{ end -}} {{ end }} {{- if eq $protoSyntax "proto2" -}} {{ range getExtensions . }} @@ -91,14 +93,16 @@ func (m *{{ .GoIdent.GoName }}) MarshalTo(dest []byte) error { _ = err _ = extVal {{ range .Fields }} -{{- if eq .Desc.ContainingOneof nil }} +{{- if or (eq .Desc.ContainingOneof nil) (eq .Desc.ContainingOneof.IsSynthetic true) }} // {{ .GoName }} ({{.Desc.Number}},{{if .Desc.IsMap}}map{{else}}{{.Desc.Kind}},{{.Desc.Cardinality}}{{if .Desc.IsPacked }},packed{{ end }}{{end}}) {{ template "MarshalField" . }} {{- end -}} {{ end }} {{ range .Oneofs -}} +{{- if eq .Desc.IsSynthetic false -}} // {{.GoName}} (oneof) {{ template "MarshalOneOf" . -}} +{{- end -}} {{ end }} {{- if eq $protoSyntax "proto2" -}} {{ range getExtensions . }} @@ -126,11 +130,13 @@ func (m *{{ .GoIdent.GoName}}) Unmarshal(p []byte) error { } switch tag { {{- range .Fields -}} - {{ if eq .Desc.ContainingOneof nil }}case {{ .Desc.Number }}: // {{ .GoName }} ({{if .Desc.IsMap}}map{{else}}{{.Desc.Kind}},{{.Desc.Cardinality}}{{if .Desc.IsPacked }},packed{{ end }}{{end}}) + {{ if or (eq .Desc.ContainingOneof nil) (eq .Desc.ContainingOneof.IsSynthetic true) }}case {{ .Desc.Number }}: // {{ .GoName }} ({{if .Desc.IsMap}}map{{else}}{{.Desc.Kind}},{{.Desc.Cardinality}}{{if .Desc.IsPacked }},packed{{ end }}{{end}}) {{ template "UnmarshalField" . }}{{ end }} {{ end }} {{ range .Oneofs -}} + {{- if eq .Desc.IsSynthetic false -}} {{ template "UnmarshalOneOf" . -}} + {{- end -}} {{ end }} {{- if eq $protoSyntax "proto2" -}} {{ range getExtensions . }} diff --git a/example/permessage/googlev1/googlev1_permessage_example.pb.go b/example/permessage/googlev1/googlev1_permessage_example.pb.go index 087f61f..ec931da 100644 --- a/example/permessage/googlev1/googlev1_permessage_example.pb.go +++ b/example/permessage/googlev1/googlev1_permessage_example.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.33.0 -// protoc v5.27.0 +// protoc v5.28.3 // source: googlev1_permessage_example.proto package googlev1 diff --git a/example/permessage/googlev2/googlev2_permessage_example.pb.go b/example/permessage/googlev2/googlev2_permessage_example.pb.go index 3dac5ec..13ba8c7 100644 --- a/example/permessage/googlev2/googlev2_permessage_example.pb.go +++ b/example/permessage/googlev2/googlev2_permessage_example.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.3 // source: googlev2_permessage_example.proto package googlev2 @@ -90,11 +90,9 @@ type TestEvent struct { func (x *TestEvent) Reset() { *x = TestEvent{} - if protoimpl.UnsafeEnabled { - mi := &file_googlev2_permessage_example_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_googlev2_permessage_example_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *TestEvent) String() string { @@ -105,7 +103,7 @@ func (*TestEvent) ProtoMessage() {} func (x *TestEvent) ProtoReflect() protoreflect.Message { mi := &file_googlev2_permessage_example_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -225,11 +223,9 @@ type EmbeddedEvent struct { func (x *EmbeddedEvent) Reset() { *x = EmbeddedEvent{} - if protoimpl.UnsafeEnabled { - mi := &file_googlev2_permessage_example_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_googlev2_permessage_example_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *EmbeddedEvent) String() string { @@ -240,7 +236,7 @@ func (*EmbeddedEvent) ProtoMessage() {} func (x *EmbeddedEvent) ProtoReflect() protoreflect.Message { mi := &file_googlev2_permessage_example_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -310,11 +306,9 @@ type AllTheThings struct { func (x *AllTheThings) Reset() { *x = AllTheThings{} - if protoimpl.UnsafeEnabled { - mi := &file_googlev2_permessage_example_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_googlev2_permessage_example_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *AllTheThings) String() string { @@ -325,7 +319,7 @@ func (*AllTheThings) ProtoMessage() {} func (x *AllTheThings) ProtoReflect() protoreflect.Message { mi := &file_googlev2_permessage_example_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -493,11 +487,9 @@ type RepeatAllTheThings struct { func (x *RepeatAllTheThings) Reset() { *x = RepeatAllTheThings{} - if protoimpl.UnsafeEnabled { - mi := &file_googlev2_permessage_example_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_googlev2_permessage_example_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *RepeatAllTheThings) String() string { @@ -508,7 +500,7 @@ func (*RepeatAllTheThings) ProtoMessage() {} func (x *RepeatAllTheThings) ProtoReflect() protoreflect.Message { mi := &file_googlev2_permessage_example_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -674,11 +666,9 @@ type AllTheMaps struct { func (x *AllTheMaps) Reset() { *x = AllTheMaps{} - if protoimpl.UnsafeEnabled { - mi := &file_googlev2_permessage_example_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_googlev2_permessage_example_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *AllTheMaps) String() string { @@ -689,7 +679,7 @@ func (*AllTheMaps) ProtoMessage() {} func (x *AllTheMaps) ProtoReflect() protoreflect.Message { mi := &file_googlev2_permessage_example_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -831,11 +821,9 @@ type I18NVariable struct { func (x *I18NVariable) Reset() { *x = I18NVariable{} - if protoimpl.UnsafeEnabled { - mi := &file_googlev2_permessage_example_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_googlev2_permessage_example_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *I18NVariable) String() string { @@ -846,7 +834,7 @@ func (*I18NVariable) ProtoMessage() {} func (x *I18NVariable) ProtoReflect() protoreflect.Message { mi := &file_googlev2_permessage_example_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -911,11 +899,9 @@ type Msg struct { func (x *Msg) Reset() { *x = Msg{} - if protoimpl.UnsafeEnabled { - mi := &file_googlev2_permessage_example_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_googlev2_permessage_example_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Msg) String() string { @@ -926,7 +912,7 @@ func (*Msg) ProtoMessage() {} func (x *Msg) ProtoReflect() protoreflect.Message { mi := &file_googlev2_permessage_example_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -975,11 +961,9 @@ type TestEvent_NestedMsg struct { func (x *TestEvent_NestedMsg) Reset() { *x = TestEvent_NestedMsg{} - if protoimpl.UnsafeEnabled { - mi := &file_googlev2_permessage_example_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_googlev2_permessage_example_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *TestEvent_NestedMsg) String() string { @@ -990,7 +974,7 @@ func (*TestEvent_NestedMsg) ProtoMessage() {} func (x *TestEvent_NestedMsg) ProtoReflect() protoreflect.Message { mi := &file_googlev2_permessage_example_proto_msgTypes[7] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -1022,11 +1006,9 @@ type Msg_Tags struct { func (x *Msg_Tags) Reset() { *x = Msg_Tags{} - if protoimpl.UnsafeEnabled { - mi := &file_googlev2_permessage_example_proto_msgTypes[24] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_googlev2_permessage_example_proto_msgTypes[24] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Msg_Tags) String() string { @@ -1037,7 +1019,7 @@ func (*Msg_Tags) ProtoMessage() {} func (x *Msg_Tags) ProtoReflect() protoreflect.Message { mi := &file_googlev2_permessage_example_proto_msgTypes[24] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -1466,116 +1448,6 @@ func file_googlev2_permessage_example_proto_init() { if File_googlev2_permessage_example_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_googlev2_permessage_example_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*TestEvent); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_googlev2_permessage_example_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*EmbeddedEvent); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_googlev2_permessage_example_proto_msgTypes[2].Exporter = func(v any, i int) any { - switch v := v.(*AllTheThings); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_googlev2_permessage_example_proto_msgTypes[3].Exporter = func(v any, i int) any { - switch v := v.(*RepeatAllTheThings); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_googlev2_permessage_example_proto_msgTypes[4].Exporter = func(v any, i int) any { - switch v := v.(*AllTheMaps); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_googlev2_permessage_example_proto_msgTypes[5].Exporter = func(v any, i int) any { - switch v := v.(*I18NVariable); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_googlev2_permessage_example_proto_msgTypes[6].Exporter = func(v any, i int) any { - switch v := v.(*Msg); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_googlev2_permessage_example_proto_msgTypes[7].Exporter = func(v any, i int) any { - switch v := v.(*TestEvent_NestedMsg); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_googlev2_permessage_example_proto_msgTypes[24].Exporter = func(v any, i int) any { - switch v := v.(*Msg_Tags); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } file_googlev2_permessage_example_proto_msgTypes[0].OneofWrappers = []any{ (*TestEvent_Jedi)(nil), (*TestEvent_Sith)(nil), diff --git a/example/proto2/googlev1/googlev1_proto2_example.pb.go b/example/proto2/googlev1/googlev1_proto2_example.pb.go index ec1713a..c5dcb3a 100644 --- a/example/proto2/googlev1/googlev1_proto2_example.pb.go +++ b/example/proto2/googlev1/googlev1_proto2_example.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.33.0 -// protoc v5.27.0 +// protoc v5.28.3 // source: googlev1_proto2_example.proto package googlev1 diff --git a/example/proto2/googlev2/googlev2_proto2_example.pb.go b/example/proto2/googlev2/googlev2_proto2_example.pb.go index 0359770..08cd9c7 100644 --- a/example/proto2/googlev2/googlev2_proto2_example.pb.go +++ b/example/proto2/googlev2/googlev2_proto2_example.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.3 // source: googlev2_proto2_example.proto package googlev2 @@ -95,11 +95,9 @@ type BaseEvent struct { func (x *BaseEvent) Reset() { *x = BaseEvent{} - if protoimpl.UnsafeEnabled { - mi := &file_googlev2_proto2_example_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_googlev2_proto2_example_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *BaseEvent) String() string { @@ -110,7 +108,7 @@ func (*BaseEvent) ProtoMessage() {} func (x *BaseEvent) ProtoReflect() protoreflect.Message { mi := &file_googlev2_proto2_example_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -181,11 +179,9 @@ type TestEvent struct { func (x *TestEvent) Reset() { *x = TestEvent{} - if protoimpl.UnsafeEnabled { - mi := &file_googlev2_proto2_example_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_googlev2_proto2_example_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *TestEvent) String() string { @@ -196,7 +192,7 @@ func (*TestEvent) ProtoMessage() {} func (x *TestEvent) ProtoReflect() protoreflect.Message { mi := &file_googlev2_proto2_example_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -316,11 +312,9 @@ type EmbeddedEvent struct { func (x *EmbeddedEvent) Reset() { *x = EmbeddedEvent{} - if protoimpl.UnsafeEnabled { - mi := &file_googlev2_proto2_example_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_googlev2_proto2_example_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *EmbeddedEvent) String() string { @@ -331,7 +325,7 @@ func (*EmbeddedEvent) ProtoMessage() {} func (x *EmbeddedEvent) ProtoReflect() protoreflect.Message { mi := &file_googlev2_proto2_example_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -401,11 +395,9 @@ type AllTheThings struct { func (x *AllTheThings) Reset() { *x = AllTheThings{} - if protoimpl.UnsafeEnabled { - mi := &file_googlev2_proto2_example_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_googlev2_proto2_example_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *AllTheThings) String() string { @@ -416,7 +408,7 @@ func (*AllTheThings) ProtoMessage() {} func (x *AllTheThings) ProtoReflect() protoreflect.Message { mi := &file_googlev2_proto2_example_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -584,11 +576,9 @@ type RepeatAllTheThings struct { func (x *RepeatAllTheThings) Reset() { *x = RepeatAllTheThings{} - if protoimpl.UnsafeEnabled { - mi := &file_googlev2_proto2_example_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_googlev2_proto2_example_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *RepeatAllTheThings) String() string { @@ -599,7 +589,7 @@ func (*RepeatAllTheThings) ProtoMessage() {} func (x *RepeatAllTheThings) ProtoReflect() protoreflect.Message { mi := &file_googlev2_proto2_example_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -752,11 +742,9 @@ type EventUsingWKTs struct { func (x *EventUsingWKTs) Reset() { *x = EventUsingWKTs{} - if protoimpl.UnsafeEnabled { - mi := &file_googlev2_proto2_example_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_googlev2_proto2_example_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *EventUsingWKTs) String() string { @@ -767,7 +755,7 @@ func (*EventUsingWKTs) ProtoMessage() {} func (x *EventUsingWKTs) ProtoReflect() protoreflect.Message { mi := &file_googlev2_proto2_example_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -813,11 +801,9 @@ type TestEvent_NestedMsg struct { func (x *TestEvent_NestedMsg) Reset() { *x = TestEvent_NestedMsg{} - if protoimpl.UnsafeEnabled { - mi := &file_googlev2_proto2_example_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_googlev2_proto2_example_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *TestEvent_NestedMsg) String() string { @@ -828,7 +814,7 @@ func (*TestEvent_NestedMsg) ProtoMessage() {} func (x *TestEvent_NestedMsg) ProtoReflect() protoreflect.Message { mi := &file_googlev2_proto2_example_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -1089,94 +1075,6 @@ func file_googlev2_proto2_example_proto_init() { if File_googlev2_proto2_example_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_googlev2_proto2_example_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*BaseEvent); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - case 3: - return &v.extensionFields - default: - return nil - } - } - file_googlev2_proto2_example_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*TestEvent); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_googlev2_proto2_example_proto_msgTypes[2].Exporter = func(v any, i int) any { - switch v := v.(*EmbeddedEvent); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_googlev2_proto2_example_proto_msgTypes[3].Exporter = func(v any, i int) any { - switch v := v.(*AllTheThings); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_googlev2_proto2_example_proto_msgTypes[4].Exporter = func(v any, i int) any { - switch v := v.(*RepeatAllTheThings); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_googlev2_proto2_example_proto_msgTypes[5].Exporter = func(v any, i int) any { - switch v := v.(*EventUsingWKTs); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_googlev2_proto2_example_proto_msgTypes[6].Exporter = func(v any, i int) any { - switch v := v.(*TestEvent_NestedMsg); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } file_googlev2_proto2_example_proto_msgTypes[1].OneofWrappers = []any{ (*TestEvent_Jedi)(nil), (*TestEvent_Sith)(nil), diff --git a/example/proto3/googlev1/googlev1_proto3_example.pb.go b/example/proto3/googlev1/googlev1_proto3_example.pb.go index 7fc272c..8354e66 100644 --- a/example/proto3/googlev1/googlev1_proto3_example.pb.go +++ b/example/proto3/googlev1/googlev1_proto3_example.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.33.0 -// protoc v5.27.0 +// protoc v5.28.3 // source: googlev1_proto3_example.proto package googlev1 diff --git a/example/proto3/googlev2/googlev2_proto3_example.pb.fm.go b/example/proto3/googlev2/googlev2_proto3_example.pb.fm.go index 868e0e6..7b40627 100644 --- a/example/proto3/googlev2/googlev2_proto3_example.pb.fm.go +++ b/example/proto3/googlev2/googlev2_proto3_example.pb.fm.go @@ -3375,6 +3375,383 @@ func (m *OneOfs) Unmarshal(p []byte) error { return nil } +//------------------------------------------------------------------------------ +// Custom Protobuf size/marshal/unmarshal code for Optionals + +// Size calculates and returns the size, in bytes, required to hold the contents of m using the Protobuf +// binary encoding. +func (m *Optionals) Size() int { + // nil message is always 0 bytes + if m == nil { + return 0 + } + // return cached size, if present + if csz := int(atomic.LoadInt32(&m.sizeCache)); csz > 0 { + return csz + } + // calculate and cache + var sz, l int + _ = l // avoid unused variable + + // OptionalString (string,optional) + if m.OptionalString != nil { + l = len(*m.OptionalString) + sz += csproto.SizeOfTagKey(2) + csproto.SizeOfVarint(uint64(l)) + l + } + // OptionalBool (bool,optional) + if m.OptionalBool != nil { + sz += csproto.SizeOfTagKey(3) + 1 + } + // OptionalInt32 (int32,optional) + if m.OptionalInt32 != nil { + sz += csproto.SizeOfTagKey(4) + csproto.SizeOfVarint(uint64(*m.OptionalInt32)) + } + // OptionalInt64 (int64,optional) + if m.OptionalInt64 != nil { + sz += csproto.SizeOfTagKey(5) + csproto.SizeOfVarint(uint64(*m.OptionalInt64)) + } + // OptionalUint32 (uint32,optional) + if m.OptionalUint32 != nil { + sz += csproto.SizeOfTagKey(6) + csproto.SizeOfVarint(uint64(*m.OptionalUint32)) + } + // OptionalUint64 (uint64,optional) + if m.OptionalUint64 != nil { + sz += csproto.SizeOfTagKey(7) + csproto.SizeOfVarint(uint64(*m.OptionalUint64)) + } + // OptionalSint32 (sint32,optional) + if m.OptionalSint32 != nil { + sz += csproto.SizeOfTagKey(8) + csproto.SizeOfZigZag(uint64(*m.OptionalSint32)) + } + // OptionalSint64 (sint64,optional) + if m.OptionalSint64 != nil { + sz += csproto.SizeOfTagKey(9) + csproto.SizeOfZigZag(uint64(*m.OptionalSint64)) + } + // OptionalFixed32 (fixed32,optional) + if m.OptionalFixed32 != nil { + sz += csproto.SizeOfTagKey(10) + 4 + } + // OptionalFixed64 (fixed64,optional) + if m.OptionalFixed64 != nil { + sz += csproto.SizeOfTagKey(11) + 8 + } + // OptionalSfixed32 (sfixed32,optional) + if m.OptionalSfixed32 != nil { + sz += csproto.SizeOfTagKey(12) + 4 + } + // OptionalSfixed64 (sfixed64,optional) + if m.OptionalSfixed64 != nil { + sz += csproto.SizeOfTagKey(13) + 8 + } + // OptionalFloat (float,optional) + if m.OptionalFloat != nil { + sz += csproto.SizeOfTagKey(14) + 4 + } + // OptionalDouble (double,optional) + if m.OptionalDouble != nil { + sz += csproto.SizeOfTagKey(15) + 8 + } + // OptionalEnum (enum,optional) + if m.OptionalEnum != nil { + sz += csproto.SizeOfTagKey(16) + csproto.SizeOfVarint(uint64(*m.OptionalEnum)) + } + // OptionalBytes (bytes,optional) + if l = len(m.OptionalBytes); l > 0 { + sz += csproto.SizeOfTagKey(17) + csproto.SizeOfVarint(uint64(l)) + l + } + // OptionalMessage (message,optional) + if m.OptionalMessage != nil { + l = csproto.Size(m.OptionalMessage) + sz += csproto.SizeOfTagKey(18) + csproto.SizeOfVarint(uint64(l)) + l + } + // cache the size so it can be re-used in Marshal()/MarshalTo() + atomic.StoreInt32(&m.sizeCache, int32(sz)) + return sz +} + +// Marshal converts the contents of m to the Protobuf binary encoding and returns the result or an error. +func (m *Optionals) Marshal() ([]byte, error) { + siz := m.Size() + if siz == 0 { + return []byte{}, nil + } + buf := make([]byte, siz) + err := m.MarshalTo(buf) + return buf, err +} + +// MarshalTo converts the contents of m to the Protobuf binary encoding and writes the result to dest. +func (m *Optionals) MarshalTo(dest []byte) error { + // nil message == no-op + if m == nil { + return nil + } + var ( + enc = csproto.NewEncoder(dest) + buf []byte + err error + extVal interface{} + ) + // ensure no unused variables + _ = enc + _ = buf + _ = err + _ = extVal + + // OptionalString (2,string,optional) + if m.OptionalString != nil { + enc.EncodeString(2, *m.OptionalString) + } + // OptionalBool (3,bool,optional) + if m.OptionalBool != nil { + enc.EncodeBool(3, *m.OptionalBool) + } + // OptionalInt32 (4,int32,optional) + if m.OptionalInt32 != nil { + enc.EncodeInt32(4, *m.OptionalInt32) + } + // OptionalInt64 (5,int64,optional) + if m.OptionalInt64 != nil { + enc.EncodeInt64(5, *m.OptionalInt64) + } + // OptionalUint32 (6,uint32,optional) + if m.OptionalUint32 != nil { + enc.EncodeUInt32(6, *m.OptionalUint32) + } + // OptionalUint64 (7,uint64,optional) + if m.OptionalUint64 != nil { + enc.EncodeUInt64(7, *m.OptionalUint64) + } + // OptionalSint32 (8,sint32,optional) + if m.OptionalSint32 != nil { + enc.EncodeSInt32(8, *m.OptionalSint32) + } + // OptionalSint64 (9,sint64,optional) + if m.OptionalSint64 != nil { + enc.EncodeSInt64(9, *m.OptionalSint64) + } + // OptionalFixed32 (10,fixed32,optional) + if m.OptionalFixed32 != nil { + enc.EncodeFixed32(10, *m.OptionalFixed32) + } + // OptionalFixed64 (11,fixed64,optional) + if m.OptionalFixed64 != nil { + enc.EncodeFixed64(11, *m.OptionalFixed64) + } + // OptionalSfixed32 (12,sfixed32,optional) + enc.EncodeFixed32(12, uint32(*m.OptionalSfixed32)) + // OptionalSfixed64 (13,sfixed64,optional) + enc.EncodeFixed64(13, uint64(*m.OptionalSfixed64)) + // OptionalFloat (14,float,optional) + if m.OptionalFloat != nil { + enc.EncodeFloat32(14, *m.OptionalFloat) + } + // OptionalDouble (15,double,optional) + if m.OptionalDouble != nil { + enc.EncodeFloat64(15, *m.OptionalDouble) + } + // OptionalEnum (16,enum,optional) + if m.OptionalEnum != nil { + enc.EncodeInt32(16, int32(*m.OptionalEnum)) + } + // OptionalBytes (17,bytes,optional) + if len(m.OptionalBytes) > 0 { + enc.EncodeBytes(17, m.OptionalBytes) + } + // OptionalMessage (18,message,optional) + if m.OptionalMessage != nil { + if err = enc.EncodeNested(18, m.OptionalMessage); err != nil { + return fmt.Errorf("unable to encode message data for field 'optional_message' (tag=18): %w", err) + } + } + return nil +} + +// Unmarshal decodes a binary encoded Protobuf message from p and populates m with the result. +func (m *Optionals) Unmarshal(p []byte) error { + m.Reset() + if len(p) == 0 { + return nil + } + dec := csproto.NewDecoder(p) + for dec.More() { + tag, wt, err := dec.DecodeTag() + if err != nil { + return err + } + switch tag { + case 2: // OptionalString (string,optional) + if wt != csproto.WireTypeLengthDelimited { + return fmt.Errorf("incorrect wire type %v for field 'optional_string' (tag=2), expected 2 (length-delimited)", wt) + } + if s, err := dec.DecodeString(); err != nil { + return fmt.Errorf("unable to decode string value for field 'optional_string' (tag=2): %w", err) + } else { + m.OptionalString = csproto.String(s) + } + + case 3: // OptionalBool (bool,optional) + if wt != csproto.WireTypeVarint { + return fmt.Errorf("incorrect wire type %v for tag field 'optional_bool' (tag=3), expected 0 (varint)", wt) + } + if v, err := dec.DecodeBool(); err != nil { + return fmt.Errorf("unable to decode boolean value for field 'optional_bool' (tag=3): %w", err) + } else { + m.OptionalBool = csproto.Bool(v) + } + case 4: // OptionalInt32 (int32,optional) + if wt != csproto.WireTypeVarint { + return fmt.Errorf("incorrect wire type %v for tag field 'optional_int32' (tag=4), expected 0 (varint)", wt) + } + if v, err := dec.DecodeInt32(); err != nil { + return fmt.Errorf("unable to decode int32 value for field 'optional_int32' (tag=4): %w", err) + } else { + m.OptionalInt32 = csproto.Int32(v) + } + case 5: // OptionalInt64 (int64,optional) + if wt != csproto.WireTypeVarint { + return fmt.Errorf("incorrect wire type %v for tag field 'optional_int64' (tag=5), expected 0 (varint)", wt) + } + if v, err := dec.DecodeInt64(); err != nil { + return fmt.Errorf("unable to decode int64 value for field 'optional_int64' (tag=5): %w", err) + } else { + m.OptionalInt64 = csproto.Int64(v) + } + case 6: // OptionalUint32 (uint32,optional) + if wt != csproto.WireTypeVarint { + return fmt.Errorf("incorrect wire type %v for tag field 'optional_uint32' (tag=6), expected 0 (varint)", wt) + } + if v, err := dec.DecodeUInt32(); err != nil { + return fmt.Errorf("unable to decode int32 value for field 'optional_uint32' (tag=6): %w", err) + } else { + m.OptionalUint32 = csproto.Uint32(v) + } + case 7: // OptionalUint64 (uint64,optional) + if wt != csproto.WireTypeVarint { + return fmt.Errorf("incorrect wire type %v for tag field 'optional_uint64' (tag=7), expected 0 (varint)", wt) + } + if v, err := dec.DecodeUInt64(); err != nil { + return fmt.Errorf("unable to decode uint64 value for field 'optional_uint64' (tag=7): %w", err) + } else { + m.OptionalUint64 = csproto.Uint64(v) + } + case 8: // OptionalSint32 (sint32,optional) + if wt != csproto.WireTypeVarint { + return fmt.Errorf("incorrect wire type %v for tag field 'optional_sint32' (tag=8), expected 0 (varint)", wt) + } + if v, err := dec.DecodeSInt32(); err != nil { + return fmt.Errorf("unable to decode sint32 value for field 'optional_sint32' (tag=8): %w", err) + } else { + m.OptionalSint32 = csproto.Int32(v) + } + case 9: // OptionalSint64 (sint64,optional) + if wt != csproto.WireTypeVarint { + return fmt.Errorf("incorrect wire type %v for tag field 'optional_sint64' (tag=9), expected 0 (varint)", wt) + } + if v, err := dec.DecodeSInt64(); err != nil { + return fmt.Errorf("unable to decode sint64 value for field 'optional_sint64' (tag=9): %w", err) + } else { + m.OptionalSint64 = csproto.Int64(v) + } + case 10: // OptionalFixed32 (fixed32,optional) + if wt != csproto.WireTypeFixed32 { + return fmt.Errorf("incorrect wire type %v for tag field 'optional_fixed32' (tag=10), expected 5 (32-bit)", wt) + } + if v, err := dec.DecodeFixed32(); err != nil { + return fmt.Errorf("unable to decode uint32 value for field 'optional_fixed32' (tag=10): %w", err) + } else { + m.OptionalFixed32 = csproto.Uint32(v) + } + case 11: // OptionalFixed64 (fixed64,optional) + if wt != csproto.WireTypeFixed64 { + return fmt.Errorf("incorrect wire type %v for tag field 'optional_fixed64' (tag=11), expected 1 (64-bit)", wt) + } + if v, err := dec.DecodeFixed64(); err != nil { + return fmt.Errorf("unable to decode uint64 value for field 'optional_fixed64' (tag=11): %w", err) + } else { + m.OptionalFixed64 = csproto.Uint64(v) + } + case 12: // OptionalSfixed32 (sfixed32,optional) + if wt != csproto.WireTypeFixed32 { + return fmt.Errorf("incorrect wire type %v for field 'optional_sfixed32' (tag=12), expected 5 (32-bit)", wt) + } + if v, err := dec.DecodeFixed32(); err != nil { + return fmt.Errorf("unable to decode sfixed32 value for field 'optional_sfixed32' (tag=12): %w", err) + } else { + iv := int32(v) + m.OptionalSfixed32 = &iv + } + + case 13: // OptionalSfixed64 (sfixed64,optional) + if wt != csproto.WireTypeFixed64 { + return fmt.Errorf("incorrect wire type %v for field 'optional_sfixed64' (tag=13), expected 1 (64-bit)", wt) + } + if v, err := dec.DecodeFixed64(); err != nil { + return fmt.Errorf("unable to decode sfixed64 value for field 'optional_sfixed64' (tag=13): %w", err) + } else { + iv := int64(v) + m.OptionalSfixed64 = &iv + } + + case 14: // OptionalFloat (float,optional) + if wt != csproto.WireTypeFixed32 { + return fmt.Errorf("incorrect wire type %v for tag field 'optional_float' (tag=14), expected 5 (32-bit)", wt) + } + if v, err := dec.DecodeFloat32(); err != nil { + return fmt.Errorf("unable to decode float value for field 'optional_float' (tag=14): %w", err) + } else { + m.OptionalFloat = csproto.Float32(v) + } + case 15: // OptionalDouble (double,optional) + if wt != csproto.WireTypeFixed64 { + return fmt.Errorf("incorrect wire type %v for tag field 'optional_double' (tag=15), expected 1 (64-bit)", wt) + } + if v, err := dec.DecodeFloat64(); err != nil { + return fmt.Errorf("unable to decode double value for field 'optional_double' (tag=15): %w", err) + } else { + m.OptionalDouble = csproto.Float64(v) + } + case 16: // OptionalEnum (enum,optional) + if wt != csproto.WireTypeVarint { + return fmt.Errorf("incorrect wire type %v for tag field 'optional_enum' (tag=16), expected 0 (varint)", wt) + } + if v, err := dec.DecodeInt32(); err != nil { + return fmt.Errorf("unable to decode int32 enum value for field 'optional_enum' (tag=16): %w", err) + } else { + ev := EventType(v) + m.OptionalEnum = &ev + } + case 17: // OptionalBytes (bytes,optional) + + if wt != csproto.WireTypeLengthDelimited { + return fmt.Errorf("incorrect wire type %v for field 'optional_bytes' (tag=17), expected 2 (length-delimited)", wt) + } + if b, err := dec.DecodeBytes(); err != nil { + return fmt.Errorf("unable to decode bytes value for field 'optional_bytes' (tag=17): %w", err) + } else { + m.OptionalBytes = b + } + + case 18: // OptionalMessage (message,optional) + if wt != csproto.WireTypeLengthDelimited { + return fmt.Errorf("incorrect wire type %v for field 'optional_message' (tag=18), expected 2 (length-delimited)", wt) + } + var mm EmbeddedEvent + if err = dec.DecodeNested(&mm); err != nil { + return fmt.Errorf("unable to decode message value for field 'optional_message' (tag=18): %w", err) + } + m.OptionalMessage = &mm + + default: + if skipped, err := dec.Skip(tag, wt); err != nil { + return fmt.Errorf("invalid operation skipping tag %v: %w", tag, err) + } else { + m.unknownFields = append(m.unknownFields, skipped...) + } + } + } + return nil +} + //------------------------------------------------------------------------------ // Custom Protobuf size/marshal/unmarshal code for I18NVariable diff --git a/example/proto3/googlev2/googlev2_proto3_example.pb.go b/example/proto3/googlev2/googlev2_proto3_example.pb.go index 7a31a91..ab14275 100644 --- a/example/proto3/googlev2/googlev2_proto3_example.pb.go +++ b/example/proto3/googlev2/googlev2_proto3_example.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.3 // source: googlev2_proto3_example.proto package googlev2 @@ -99,11 +99,9 @@ type TestEvent struct { func (x *TestEvent) Reset() { *x = TestEvent{} - if protoimpl.UnsafeEnabled { - mi := &file_googlev2_proto3_example_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_googlev2_proto3_example_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *TestEvent) String() string { @@ -114,7 +112,7 @@ func (*TestEvent) ProtoMessage() {} func (x *TestEvent) ProtoReflect() protoreflect.Message { mi := &file_googlev2_proto3_example_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -285,11 +283,9 @@ type EmbeddedEvent struct { func (x *EmbeddedEvent) Reset() { *x = EmbeddedEvent{} - if protoimpl.UnsafeEnabled { - mi := &file_googlev2_proto3_example_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_googlev2_proto3_example_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *EmbeddedEvent) String() string { @@ -300,7 +296,7 @@ func (*EmbeddedEvent) ProtoMessage() {} func (x *EmbeddedEvent) ProtoReflect() protoreflect.Message { mi := &file_googlev2_proto3_example_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -370,11 +366,9 @@ type AllTheThings struct { func (x *AllTheThings) Reset() { *x = AllTheThings{} - if protoimpl.UnsafeEnabled { - mi := &file_googlev2_proto3_example_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_googlev2_proto3_example_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *AllTheThings) String() string { @@ -385,7 +379,7 @@ func (*AllTheThings) ProtoMessage() {} func (x *AllTheThings) ProtoReflect() protoreflect.Message { mi := &file_googlev2_proto3_example_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -553,11 +547,9 @@ type RepeatAllTheThings struct { func (x *RepeatAllTheThings) Reset() { *x = RepeatAllTheThings{} - if protoimpl.UnsafeEnabled { - mi := &file_googlev2_proto3_example_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_googlev2_proto3_example_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *RepeatAllTheThings) String() string { @@ -568,7 +560,7 @@ func (*RepeatAllTheThings) ProtoMessage() {} func (x *RepeatAllTheThings) ProtoReflect() protoreflect.Message { mi := &file_googlev2_proto3_example_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -721,11 +713,9 @@ type EventUsingWKTs struct { func (x *EventUsingWKTs) Reset() { *x = EventUsingWKTs{} - if protoimpl.UnsafeEnabled { - mi := &file_googlev2_proto3_example_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_googlev2_proto3_example_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *EventUsingWKTs) String() string { @@ -736,7 +726,7 @@ func (*EventUsingWKTs) ProtoMessage() {} func (x *EventUsingWKTs) ProtoReflect() protoreflect.Message { mi := &file_googlev2_proto3_example_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -784,11 +774,9 @@ type MapObject struct { func (x *MapObject) Reset() { *x = MapObject{} - if protoimpl.UnsafeEnabled { - mi := &file_googlev2_proto3_example_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_googlev2_proto3_example_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *MapObject) String() string { @@ -799,7 +787,7 @@ func (*MapObject) ProtoMessage() {} func (x *MapObject) ProtoReflect() protoreflect.Message { mi := &file_googlev2_proto3_example_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -862,11 +850,9 @@ type Maps struct { func (x *Maps) Reset() { *x = Maps{} - if protoimpl.UnsafeEnabled { - mi := &file_googlev2_proto3_example_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_googlev2_proto3_example_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Maps) String() string { @@ -877,7 +863,7 @@ func (*Maps) ProtoMessage() {} func (x *Maps) ProtoReflect() protoreflect.Message { mi := &file_googlev2_proto3_example_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -1048,11 +1034,9 @@ type OneOfs struct { func (x *OneOfs) Reset() { *x = OneOfs{} - if protoimpl.UnsafeEnabled { - mi := &file_googlev2_proto3_example_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_googlev2_proto3_example_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *OneOfs) String() string { @@ -1063,7 +1047,7 @@ func (*OneOfs) ProtoMessage() {} func (x *OneOfs) ProtoReflect() protoreflect.Message { mi := &file_googlev2_proto3_example_proto_msgTypes[7] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -1323,6 +1307,179 @@ func (*OneOfs_Timestamps) isOneOfs_Thing() {} func (*OneOfs_Objects) isOneOfs_Thing() {} +type Optionals struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + OptionalString *string `protobuf:"bytes,2,opt,name=optional_string,json=optionalString,proto3,oneof" json:"optional_string,omitempty"` + OptionalBool *bool `protobuf:"varint,3,opt,name=optional_bool,json=optionalBool,proto3,oneof" json:"optional_bool,omitempty"` + OptionalInt32 *int32 `protobuf:"varint,4,opt,name=optional_int32,json=optionalInt32,proto3,oneof" json:"optional_int32,omitempty"` + OptionalInt64 *int64 `protobuf:"varint,5,opt,name=optional_int64,json=optionalInt64,proto3,oneof" json:"optional_int64,omitempty"` + OptionalUint32 *uint32 `protobuf:"varint,6,opt,name=optional_uint32,json=optionalUint32,proto3,oneof" json:"optional_uint32,omitempty"` + OptionalUint64 *uint64 `protobuf:"varint,7,opt,name=optional_uint64,json=optionalUint64,proto3,oneof" json:"optional_uint64,omitempty"` + OptionalSint32 *int32 `protobuf:"zigzag32,8,opt,name=optional_sint32,json=optionalSint32,proto3,oneof" json:"optional_sint32,omitempty"` + OptionalSint64 *int64 `protobuf:"zigzag64,9,opt,name=optional_sint64,json=optionalSint64,proto3,oneof" json:"optional_sint64,omitempty"` + OptionalFixed32 *uint32 `protobuf:"fixed32,10,opt,name=optional_fixed32,json=optionalFixed32,proto3,oneof" json:"optional_fixed32,omitempty"` + OptionalFixed64 *uint64 `protobuf:"fixed64,11,opt,name=optional_fixed64,json=optionalFixed64,proto3,oneof" json:"optional_fixed64,omitempty"` + OptionalSfixed32 *int32 `protobuf:"fixed32,12,opt,name=optional_sfixed32,json=optionalSfixed32,proto3,oneof" json:"optional_sfixed32,omitempty"` + OptionalSfixed64 *int64 `protobuf:"fixed64,13,opt,name=optional_sfixed64,json=optionalSfixed64,proto3,oneof" json:"optional_sfixed64,omitempty"` + OptionalFloat *float32 `protobuf:"fixed32,14,opt,name=optional_float,json=optionalFloat,proto3,oneof" json:"optional_float,omitempty"` + OptionalDouble *float64 `protobuf:"fixed64,15,opt,name=optional_double,json=optionalDouble,proto3,oneof" json:"optional_double,omitempty"` + OptionalEnum *EventType `protobuf:"varint,16,opt,name=optional_enum,json=optionalEnum,proto3,enum=crowdstrike.csproto.example.proto3.googlev2.EventType,oneof" json:"optional_enum,omitempty"` + OptionalBytes []byte `protobuf:"bytes,17,opt,name=optional_bytes,json=optionalBytes,proto3,oneof" json:"optional_bytes,omitempty"` + OptionalMessage *EmbeddedEvent `protobuf:"bytes,18,opt,name=optional_message,json=optionalMessage,proto3,oneof" json:"optional_message,omitempty"` +} + +func (x *Optionals) Reset() { + *x = Optionals{} + mi := &file_googlev2_proto3_example_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Optionals) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Optionals) ProtoMessage() {} + +func (x *Optionals) ProtoReflect() protoreflect.Message { + mi := &file_googlev2_proto3_example_proto_msgTypes[8] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Optionals.ProtoReflect.Descriptor instead. +func (*Optionals) Descriptor() ([]byte, []int) { + return file_googlev2_proto3_example_proto_rawDescGZIP(), []int{8} +} + +func (x *Optionals) GetOptionalString() string { + if x != nil && x.OptionalString != nil { + return *x.OptionalString + } + return "" +} + +func (x *Optionals) GetOptionalBool() bool { + if x != nil && x.OptionalBool != nil { + return *x.OptionalBool + } + return false +} + +func (x *Optionals) GetOptionalInt32() int32 { + if x != nil && x.OptionalInt32 != nil { + return *x.OptionalInt32 + } + return 0 +} + +func (x *Optionals) GetOptionalInt64() int64 { + if x != nil && x.OptionalInt64 != nil { + return *x.OptionalInt64 + } + return 0 +} + +func (x *Optionals) GetOptionalUint32() uint32 { + if x != nil && x.OptionalUint32 != nil { + return *x.OptionalUint32 + } + return 0 +} + +func (x *Optionals) GetOptionalUint64() uint64 { + if x != nil && x.OptionalUint64 != nil { + return *x.OptionalUint64 + } + return 0 +} + +func (x *Optionals) GetOptionalSint32() int32 { + if x != nil && x.OptionalSint32 != nil { + return *x.OptionalSint32 + } + return 0 +} + +func (x *Optionals) GetOptionalSint64() int64 { + if x != nil && x.OptionalSint64 != nil { + return *x.OptionalSint64 + } + return 0 +} + +func (x *Optionals) GetOptionalFixed32() uint32 { + if x != nil && x.OptionalFixed32 != nil { + return *x.OptionalFixed32 + } + return 0 +} + +func (x *Optionals) GetOptionalFixed64() uint64 { + if x != nil && x.OptionalFixed64 != nil { + return *x.OptionalFixed64 + } + return 0 +} + +func (x *Optionals) GetOptionalSfixed32() int32 { + if x != nil && x.OptionalSfixed32 != nil { + return *x.OptionalSfixed32 + } + return 0 +} + +func (x *Optionals) GetOptionalSfixed64() int64 { + if x != nil && x.OptionalSfixed64 != nil { + return *x.OptionalSfixed64 + } + return 0 +} + +func (x *Optionals) GetOptionalFloat() float32 { + if x != nil && x.OptionalFloat != nil { + return *x.OptionalFloat + } + return 0 +} + +func (x *Optionals) GetOptionalDouble() float64 { + if x != nil && x.OptionalDouble != nil { + return *x.OptionalDouble + } + return 0 +} + +func (x *Optionals) GetOptionalEnum() EventType { + if x != nil && x.OptionalEnum != nil { + return *x.OptionalEnum + } + return EventType_EVENT_TYPE_UNDEFINED +} + +func (x *Optionals) GetOptionalBytes() []byte { + if x != nil { + return x.OptionalBytes + } + return nil +} + +func (x *Optionals) GetOptionalMessage() *EmbeddedEvent { + if x != nil { + return x.OptionalMessage + } + return nil +} + // see https://github.com/CrowdStrike/csproto/pull/124 type I18NVariable struct { state protoimpl.MessageState @@ -1338,11 +1495,9 @@ type I18NVariable struct { func (x *I18NVariable) Reset() { *x = I18NVariable{} - if protoimpl.UnsafeEnabled { - mi := &file_googlev2_proto3_example_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_googlev2_proto3_example_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *I18NVariable) String() string { @@ -1352,8 +1507,8 @@ func (x *I18NVariable) String() string { func (*I18NVariable) ProtoMessage() {} func (x *I18NVariable) ProtoReflect() protoreflect.Message { - mi := &file_googlev2_proto3_example_proto_msgTypes[8] - if protoimpl.UnsafeEnabled && x != nil { + mi := &file_googlev2_proto3_example_proto_msgTypes[9] + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -1365,7 +1520,7 @@ func (x *I18NVariable) ProtoReflect() protoreflect.Message { // Deprecated: Use I18NVariable.ProtoReflect.Descriptor instead. func (*I18NVariable) Descriptor() ([]byte, []int) { - return file_googlev2_proto3_example_proto_rawDescGZIP(), []int{8} + return file_googlev2_proto3_example_proto_rawDescGZIP(), []int{9} } func (m *I18NVariable) GetOneOfValues() isI18NVariable_OneOfValues { @@ -1418,11 +1573,9 @@ type Msg struct { func (x *Msg) Reset() { *x = Msg{} - if protoimpl.UnsafeEnabled { - mi := &file_googlev2_proto3_example_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_googlev2_proto3_example_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Msg) String() string { @@ -1432,8 +1585,8 @@ func (x *Msg) String() string { func (*Msg) ProtoMessage() {} func (x *Msg) ProtoReflect() protoreflect.Message { - mi := &file_googlev2_proto3_example_proto_msgTypes[9] - if protoimpl.UnsafeEnabled && x != nil { + mi := &file_googlev2_proto3_example_proto_msgTypes[10] + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -1445,7 +1598,7 @@ func (x *Msg) ProtoReflect() protoreflect.Message { // Deprecated: Use Msg.ProtoReflect.Descriptor instead. func (*Msg) Descriptor() ([]byte, []int) { - return file_googlev2_proto3_example_proto_rawDescGZIP(), []int{9} + return file_googlev2_proto3_example_proto_rawDescGZIP(), []int{10} } func (m *Msg) GetOneOfValues() isMsg_OneOfValues { @@ -1482,11 +1635,9 @@ type TestEvent_NestedMsg struct { func (x *TestEvent_NestedMsg) Reset() { *x = TestEvent_NestedMsg{} - if protoimpl.UnsafeEnabled { - mi := &file_googlev2_proto3_example_proto_msgTypes[10] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_googlev2_proto3_example_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *TestEvent_NestedMsg) String() string { @@ -1496,8 +1647,8 @@ func (x *TestEvent_NestedMsg) String() string { func (*TestEvent_NestedMsg) ProtoMessage() {} func (x *TestEvent_NestedMsg) ProtoReflect() protoreflect.Message { - mi := &file_googlev2_proto3_example_proto_msgTypes[10] - if protoimpl.UnsafeEnabled && x != nil { + mi := &file_googlev2_proto3_example_proto_msgTypes[11] + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -1529,11 +1680,9 @@ type Msg_Tags struct { func (x *Msg_Tags) Reset() { *x = Msg_Tags{} - if protoimpl.UnsafeEnabled { - mi := &file_googlev2_proto3_example_proto_msgTypes[30] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_googlev2_proto3_example_proto_msgTypes[31] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Msg_Tags) String() string { @@ -1543,8 +1692,8 @@ func (x *Msg_Tags) String() string { func (*Msg_Tags) ProtoMessage() {} func (x *Msg_Tags) ProtoReflect() protoreflect.Message { - mi := &file_googlev2_proto3_example_proto_msgTypes[30] - if protoimpl.UnsafeEnabled && x != nil { + mi := &file_googlev2_proto3_example_proto_msgTypes[31] + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -1556,7 +1705,7 @@ func (x *Msg_Tags) ProtoReflect() protoreflect.Message { // Deprecated: Use Msg_Tags.ProtoReflect.Descriptor instead. func (*Msg_Tags) Descriptor() ([]byte, []int) { - return file_googlev2_proto3_example_proto_rawDescGZIP(), []int{9, 0} + return file_googlev2_proto3_example_proto_rawDescGZIP(), []int{10, 0} } func (x *Msg_Tags) GetTags() []string { @@ -1956,30 +2105,108 @@ var file_googlev2_proto3_example_proto_rawDesc = []byte{ 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x76, 0x32, 0x2e, 0x4d, 0x61, 0x70, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x48, 0x00, 0x52, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, - 0x74, 0x73, 0x42, 0x07, 0x0a, 0x05, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x22, 0x55, 0x0a, 0x0c, 0x49, - 0x31, 0x38, 0x6e, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x19, 0x0a, 0x07, 0x6f, - 0x70, 0x74, 0x5f, 0x6f, 0x6e, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x06, - 0x6f, 0x70, 0x74, 0x4f, 0x6e, 0x65, 0x12, 0x19, 0x0a, 0x07, 0x6f, 0x70, 0x74, 0x5f, 0x74, 0x77, - 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x06, 0x6f, 0x70, 0x74, 0x54, 0x77, - 0x6f, 0x42, 0x0f, 0x0a, 0x0d, 0x6f, 0x6e, 0x65, 0x5f, 0x6f, 0x66, 0x5f, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x73, 0x22, 0x7f, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x12, 0x4b, 0x0a, 0x04, 0x74, 0x61, 0x67, - 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x63, 0x72, 0x6f, 0x77, 0x64, 0x73, + 0x74, 0x73, 0x42, 0x07, 0x0a, 0x05, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x22, 0xe4, 0x09, 0x0a, 0x09, + 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x73, 0x12, 0x2c, 0x0a, 0x0f, 0x6f, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x48, 0x00, 0x52, 0x0e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x53, 0x74, + 0x72, 0x69, 0x6e, 0x67, 0x88, 0x01, 0x01, 0x12, 0x28, 0x0a, 0x0d, 0x6f, 0x70, 0x74, 0x69, 0x6f, + 0x6e, 0x61, 0x6c, 0x5f, 0x62, 0x6f, 0x6f, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x48, 0x01, + 0x52, 0x0c, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x42, 0x6f, 0x6f, 0x6c, 0x88, 0x01, + 0x01, 0x12, 0x2a, 0x0a, 0x0e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x69, 0x6e, + 0x74, 0x33, 0x32, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x48, 0x02, 0x52, 0x0d, 0x6f, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x49, 0x6e, 0x74, 0x33, 0x32, 0x88, 0x01, 0x01, 0x12, 0x2a, 0x0a, + 0x0e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x03, 0x48, 0x03, 0x52, 0x0d, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, + 0x6c, 0x49, 0x6e, 0x74, 0x36, 0x34, 0x88, 0x01, 0x01, 0x12, 0x2c, 0x0a, 0x0f, 0x6f, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x75, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x18, 0x06, 0x20, 0x01, + 0x28, 0x0d, 0x48, 0x04, 0x52, 0x0e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x55, 0x69, + 0x6e, 0x74, 0x33, 0x32, 0x88, 0x01, 0x01, 0x12, 0x2c, 0x0a, 0x0f, 0x6f, 0x70, 0x74, 0x69, 0x6f, + 0x6e, 0x61, 0x6c, 0x5f, 0x75, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x18, 0x07, 0x20, 0x01, 0x28, 0x04, + 0x48, 0x05, 0x52, 0x0e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x55, 0x69, 0x6e, 0x74, + 0x36, 0x34, 0x88, 0x01, 0x01, 0x12, 0x2c, 0x0a, 0x0f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, + 0x6c, 0x5f, 0x73, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x18, 0x08, 0x20, 0x01, 0x28, 0x11, 0x48, 0x06, + 0x52, 0x0e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x53, 0x69, 0x6e, 0x74, 0x33, 0x32, + 0x88, 0x01, 0x01, 0x12, 0x2c, 0x0a, 0x0f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, + 0x73, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x18, 0x09, 0x20, 0x01, 0x28, 0x12, 0x48, 0x07, 0x52, 0x0e, + 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x53, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x88, 0x01, + 0x01, 0x12, 0x2e, 0x0a, 0x10, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x66, 0x69, + 0x78, 0x65, 0x64, 0x33, 0x32, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x07, 0x48, 0x08, 0x52, 0x0f, 0x6f, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x46, 0x69, 0x78, 0x65, 0x64, 0x33, 0x32, 0x88, 0x01, + 0x01, 0x12, 0x2e, 0x0a, 0x10, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x66, 0x69, + 0x78, 0x65, 0x64, 0x36, 0x34, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x06, 0x48, 0x09, 0x52, 0x0f, 0x6f, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x46, 0x69, 0x78, 0x65, 0x64, 0x36, 0x34, 0x88, 0x01, + 0x01, 0x12, 0x30, 0x0a, 0x11, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x73, 0x66, + 0x69, 0x78, 0x65, 0x64, 0x33, 0x32, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0f, 0x48, 0x0a, 0x52, 0x10, + 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x53, 0x66, 0x69, 0x78, 0x65, 0x64, 0x33, 0x32, + 0x88, 0x01, 0x01, 0x12, 0x30, 0x0a, 0x11, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, + 0x73, 0x66, 0x69, 0x78, 0x65, 0x64, 0x36, 0x34, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x10, 0x48, 0x0b, + 0x52, 0x10, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x53, 0x66, 0x69, 0x78, 0x65, 0x64, + 0x36, 0x34, 0x88, 0x01, 0x01, 0x12, 0x2a, 0x0a, 0x0e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, + 0x6c, 0x5f, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x02, 0x48, 0x0c, 0x52, + 0x0d, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x46, 0x6c, 0x6f, 0x61, 0x74, 0x88, 0x01, + 0x01, 0x12, 0x2c, 0x0a, 0x0f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x64, 0x6f, + 0x75, 0x62, 0x6c, 0x65, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x01, 0x48, 0x0d, 0x52, 0x0e, 0x6f, 0x70, + 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x44, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x88, 0x01, 0x01, 0x12, + 0x60, 0x0a, 0x0d, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x65, 0x6e, 0x75, 0x6d, + 0x18, 0x10, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x36, 0x2e, 0x63, 0x72, 0x6f, 0x77, 0x64, 0x73, 0x74, + 0x72, 0x69, 0x6b, 0x65, 0x2e, 0x63, 0x73, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, + 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x76, 0x32, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x48, 0x0e, + 0x52, 0x0c, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x45, 0x6e, 0x75, 0x6d, 0x88, 0x01, + 0x01, 0x12, 0x2a, 0x0a, 0x0e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x62, 0x79, + 0x74, 0x65, 0x73, 0x18, 0x11, 0x20, 0x01, 0x28, 0x0c, 0x48, 0x0f, 0x52, 0x0d, 0x6f, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x42, 0x79, 0x74, 0x65, 0x73, 0x88, 0x01, 0x01, 0x12, 0x6a, 0x0a, + 0x10, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x18, 0x12, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x3a, 0x2e, 0x63, 0x72, 0x6f, 0x77, 0x64, 0x73, 0x74, 0x72, 0x69, 0x6b, 0x65, 0x2e, 0x63, 0x73, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x2e, 0x67, 0x6f, 0x6f, - 0x67, 0x6c, 0x65, 0x76, 0x32, 0x2e, 0x4d, 0x73, 0x67, 0x2e, 0x54, 0x61, 0x67, 0x73, 0x48, 0x00, - 0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x1a, 0x1a, 0x0a, 0x04, 0x54, 0x61, 0x67, 0x73, 0x12, 0x12, - 0x0a, 0x04, 0x74, 0x61, 0x67, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x74, 0x61, - 0x67, 0x73, 0x42, 0x0f, 0x0a, 0x0d, 0x6f, 0x6e, 0x65, 0x5f, 0x6f, 0x66, 0x5f, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x73, 0x2a, 0x4d, 0x0a, 0x09, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, - 0x12, 0x18, 0x0a, 0x14, 0x45, 0x56, 0x45, 0x4e, 0x54, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, - 0x4e, 0x44, 0x45, 0x46, 0x49, 0x4e, 0x45, 0x44, 0x10, 0x00, 0x12, 0x12, 0x0a, 0x0e, 0x45, 0x56, - 0x45, 0x4e, 0x54, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4f, 0x4e, 0x45, 0x10, 0x01, 0x12, 0x12, - 0x0a, 0x0e, 0x45, 0x56, 0x45, 0x4e, 0x54, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x54, 0x57, 0x4f, - 0x10, 0x02, 0x42, 0x38, 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x43, 0x72, 0x6f, 0x77, 0x64, 0x53, 0x74, 0x72, 0x69, 0x6b, 0x65, 0x2f, 0x63, 0x73, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, 0x2f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x76, 0x32, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, + 0x67, 0x6c, 0x65, 0x76, 0x32, 0x2e, 0x45, 0x6d, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x45, 0x76, + 0x65, 0x6e, 0x74, 0x48, 0x10, 0x52, 0x0f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x4d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x88, 0x01, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x5f, 0x6f, 0x70, + 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x42, 0x10, 0x0a, + 0x0e, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x62, 0x6f, 0x6f, 0x6c, 0x42, + 0x11, 0x0a, 0x0f, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x69, 0x6e, 0x74, + 0x33, 0x32, 0x42, 0x11, 0x0a, 0x0f, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, + 0x69, 0x6e, 0x74, 0x36, 0x34, 0x42, 0x12, 0x0a, 0x10, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, + 0x61, 0x6c, 0x5f, 0x75, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x42, 0x12, 0x0a, 0x10, 0x5f, 0x6f, 0x70, + 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x75, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x42, 0x12, 0x0a, + 0x10, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x73, 0x69, 0x6e, 0x74, 0x33, + 0x32, 0x42, 0x12, 0x0a, 0x10, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x73, + 0x69, 0x6e, 0x74, 0x36, 0x34, 0x42, 0x13, 0x0a, 0x11, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, + 0x61, 0x6c, 0x5f, 0x66, 0x69, 0x78, 0x65, 0x64, 0x33, 0x32, 0x42, 0x13, 0x0a, 0x11, 0x5f, 0x6f, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x66, 0x69, 0x78, 0x65, 0x64, 0x36, 0x34, 0x42, + 0x14, 0x0a, 0x12, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x73, 0x66, 0x69, + 0x78, 0x65, 0x64, 0x33, 0x32, 0x42, 0x14, 0x0a, 0x12, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, + 0x61, 0x6c, 0x5f, 0x73, 0x66, 0x69, 0x78, 0x65, 0x64, 0x36, 0x34, 0x42, 0x11, 0x0a, 0x0f, 0x5f, + 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x42, 0x12, + 0x0a, 0x10, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x64, 0x6f, 0x75, 0x62, + 0x6c, 0x65, 0x42, 0x10, 0x0a, 0x0e, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, + 0x65, 0x6e, 0x75, 0x6d, 0x42, 0x11, 0x0a, 0x0f, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, + 0x6c, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x42, 0x13, 0x0a, 0x11, 0x5f, 0x6f, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x4a, 0x04, 0x08, 0x01, + 0x10, 0x02, 0x22, 0x55, 0x0a, 0x0c, 0x49, 0x31, 0x38, 0x6e, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, + 0x6c, 0x65, 0x12, 0x19, 0x0a, 0x07, 0x6f, 0x70, 0x74, 0x5f, 0x6f, 0x6e, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x06, 0x6f, 0x70, 0x74, 0x4f, 0x6e, 0x65, 0x12, 0x19, 0x0a, + 0x07, 0x6f, 0x70, 0x74, 0x5f, 0x74, 0x77, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, + 0x52, 0x06, 0x6f, 0x70, 0x74, 0x54, 0x77, 0x6f, 0x42, 0x0f, 0x0a, 0x0d, 0x6f, 0x6e, 0x65, 0x5f, + 0x6f, 0x66, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x22, 0x7f, 0x0a, 0x03, 0x4d, 0x73, 0x67, + 0x12, 0x4b, 0x0a, 0x04, 0x74, 0x61, 0x67, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x35, + 0x2e, 0x63, 0x72, 0x6f, 0x77, 0x64, 0x73, 0x74, 0x72, 0x69, 0x6b, 0x65, 0x2e, 0x63, 0x73, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x76, 0x32, 0x2e, 0x4d, 0x73, 0x67, + 0x2e, 0x54, 0x61, 0x67, 0x73, 0x48, 0x00, 0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x1a, 0x1a, 0x0a, + 0x04, 0x54, 0x61, 0x67, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x61, 0x67, 0x73, 0x18, 0x01, 0x20, + 0x03, 0x28, 0x09, 0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x42, 0x0f, 0x0a, 0x0d, 0x6f, 0x6e, 0x65, + 0x5f, 0x6f, 0x66, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x2a, 0x4d, 0x0a, 0x09, 0x45, 0x76, + 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x14, 0x45, 0x56, 0x45, 0x4e, 0x54, + 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x44, 0x45, 0x46, 0x49, 0x4e, 0x45, 0x44, 0x10, + 0x00, 0x12, 0x12, 0x0a, 0x0e, 0x45, 0x56, 0x45, 0x4e, 0x54, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, + 0x4f, 0x4e, 0x45, 0x10, 0x01, 0x12, 0x12, 0x0a, 0x0e, 0x45, 0x56, 0x45, 0x4e, 0x54, 0x5f, 0x54, + 0x59, 0x50, 0x45, 0x5f, 0x54, 0x57, 0x4f, 0x10, 0x02, 0x42, 0x38, 0x5a, 0x36, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x43, 0x72, 0x6f, 0x77, 0x64, 0x53, 0x74, 0x72, + 0x69, 0x6b, 0x65, 0x2f, 0x63, 0x73, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x61, 0x6d, + 0x70, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x2f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x76, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1995,7 +2222,7 @@ func file_googlev2_proto3_example_proto_rawDescGZIP() []byte { } var file_googlev2_proto3_example_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_googlev2_proto3_example_proto_msgTypes = make([]protoimpl.MessageInfo, 31) +var file_googlev2_proto3_example_proto_msgTypes = make([]protoimpl.MessageInfo, 32) var file_googlev2_proto3_example_proto_goTypes = []any{ (EventType)(0), // 0: crowdstrike.csproto.example.proto3.googlev2.EventType (*TestEvent)(nil), // 1: crowdstrike.csproto.example.proto3.googlev2.TestEvent @@ -2006,80 +2233,83 @@ var file_googlev2_proto3_example_proto_goTypes = []any{ (*MapObject)(nil), // 6: crowdstrike.csproto.example.proto3.googlev2.MapObject (*Maps)(nil), // 7: crowdstrike.csproto.example.proto3.googlev2.Maps (*OneOfs)(nil), // 8: crowdstrike.csproto.example.proto3.googlev2.OneOfs - (*I18NVariable)(nil), // 9: crowdstrike.csproto.example.proto3.googlev2.I18nVariable - (*Msg)(nil), // 10: crowdstrike.csproto.example.proto3.googlev2.Msg - (*TestEvent_NestedMsg)(nil), // 11: crowdstrike.csproto.example.proto3.googlev2.TestEvent.NestedMsg - nil, // 12: crowdstrike.csproto.example.proto3.googlev2.MapObject.AttributesEntry - nil, // 13: crowdstrike.csproto.example.proto3.googlev2.Maps.BoolsEntry - nil, // 14: crowdstrike.csproto.example.proto3.googlev2.Maps.StringsEntry - nil, // 15: crowdstrike.csproto.example.proto3.googlev2.Maps.Int32sEntry - nil, // 16: crowdstrike.csproto.example.proto3.googlev2.Maps.Int64sEntry - nil, // 17: crowdstrike.csproto.example.proto3.googlev2.Maps.Uint32sEntry - nil, // 18: crowdstrike.csproto.example.proto3.googlev2.Maps.Uint64sEntry - nil, // 19: crowdstrike.csproto.example.proto3.googlev2.Maps.Sint32sEntry - nil, // 20: crowdstrike.csproto.example.proto3.googlev2.Maps.Sint64sEntry - nil, // 21: crowdstrike.csproto.example.proto3.googlev2.Maps.Fixed32sEntry - nil, // 22: crowdstrike.csproto.example.proto3.googlev2.Maps.Fixed64sEntry - nil, // 23: crowdstrike.csproto.example.proto3.googlev2.Maps.Sfixed32sEntry - nil, // 24: crowdstrike.csproto.example.proto3.googlev2.Maps.Sfixed64sEntry - nil, // 25: crowdstrike.csproto.example.proto3.googlev2.Maps.FloatsEntry - nil, // 26: crowdstrike.csproto.example.proto3.googlev2.Maps.DoublesEntry - nil, // 27: crowdstrike.csproto.example.proto3.googlev2.Maps.NullsEntry - nil, // 28: crowdstrike.csproto.example.proto3.googlev2.Maps.StructsEntry - nil, // 29: crowdstrike.csproto.example.proto3.googlev2.Maps.TimestampsEntry - nil, // 30: crowdstrike.csproto.example.proto3.googlev2.Maps.ObjectsEntry - (*Msg_Tags)(nil), // 31: crowdstrike.csproto.example.proto3.googlev2.Msg.Tags - (*timestamppb.Timestamp)(nil), // 32: google.protobuf.Timestamp - (structpb.NullValue)(0), // 33: google.protobuf.NullValue - (*structpb.Struct)(nil), // 34: google.protobuf.Struct + (*Optionals)(nil), // 9: crowdstrike.csproto.example.proto3.googlev2.Optionals + (*I18NVariable)(nil), // 10: crowdstrike.csproto.example.proto3.googlev2.I18nVariable + (*Msg)(nil), // 11: crowdstrike.csproto.example.proto3.googlev2.Msg + (*TestEvent_NestedMsg)(nil), // 12: crowdstrike.csproto.example.proto3.googlev2.TestEvent.NestedMsg + nil, // 13: crowdstrike.csproto.example.proto3.googlev2.MapObject.AttributesEntry + nil, // 14: crowdstrike.csproto.example.proto3.googlev2.Maps.BoolsEntry + nil, // 15: crowdstrike.csproto.example.proto3.googlev2.Maps.StringsEntry + nil, // 16: crowdstrike.csproto.example.proto3.googlev2.Maps.Int32sEntry + nil, // 17: crowdstrike.csproto.example.proto3.googlev2.Maps.Int64sEntry + nil, // 18: crowdstrike.csproto.example.proto3.googlev2.Maps.Uint32sEntry + nil, // 19: crowdstrike.csproto.example.proto3.googlev2.Maps.Uint64sEntry + nil, // 20: crowdstrike.csproto.example.proto3.googlev2.Maps.Sint32sEntry + nil, // 21: crowdstrike.csproto.example.proto3.googlev2.Maps.Sint64sEntry + nil, // 22: crowdstrike.csproto.example.proto3.googlev2.Maps.Fixed32sEntry + nil, // 23: crowdstrike.csproto.example.proto3.googlev2.Maps.Fixed64sEntry + nil, // 24: crowdstrike.csproto.example.proto3.googlev2.Maps.Sfixed32sEntry + nil, // 25: crowdstrike.csproto.example.proto3.googlev2.Maps.Sfixed64sEntry + nil, // 26: crowdstrike.csproto.example.proto3.googlev2.Maps.FloatsEntry + nil, // 27: crowdstrike.csproto.example.proto3.googlev2.Maps.DoublesEntry + nil, // 28: crowdstrike.csproto.example.proto3.googlev2.Maps.NullsEntry + nil, // 29: crowdstrike.csproto.example.proto3.googlev2.Maps.StructsEntry + nil, // 30: crowdstrike.csproto.example.proto3.googlev2.Maps.TimestampsEntry + nil, // 31: crowdstrike.csproto.example.proto3.googlev2.Maps.ObjectsEntry + (*Msg_Tags)(nil), // 32: crowdstrike.csproto.example.proto3.googlev2.Msg.Tags + (*timestamppb.Timestamp)(nil), // 33: google.protobuf.Timestamp + (structpb.NullValue)(0), // 34: google.protobuf.NullValue + (*structpb.Struct)(nil), // 35: google.protobuf.Struct } var file_googlev2_proto3_example_proto_depIdxs = []int32{ 2, // 0: crowdstrike.csproto.example.proto3.googlev2.TestEvent.embedded:type_name -> crowdstrike.csproto.example.proto3.googlev2.EmbeddedEvent - 11, // 1: crowdstrike.csproto.example.proto3.googlev2.TestEvent.nested:type_name -> crowdstrike.csproto.example.proto3.googlev2.TestEvent.NestedMsg - 32, // 2: crowdstrike.csproto.example.proto3.googlev2.TestEvent.ts:type_name -> google.protobuf.Timestamp - 33, // 3: crowdstrike.csproto.example.proto3.googlev2.TestEvent.nullVal:type_name -> google.protobuf.NullValue - 32, // 4: crowdstrike.csproto.example.proto3.googlev2.TestEvent.timestamps:type_name -> google.protobuf.Timestamp - 34, // 5: crowdstrike.csproto.example.proto3.googlev2.TestEvent.structs:type_name -> google.protobuf.Struct + 12, // 1: crowdstrike.csproto.example.proto3.googlev2.TestEvent.nested:type_name -> crowdstrike.csproto.example.proto3.googlev2.TestEvent.NestedMsg + 33, // 2: crowdstrike.csproto.example.proto3.googlev2.TestEvent.ts:type_name -> google.protobuf.Timestamp + 34, // 3: crowdstrike.csproto.example.proto3.googlev2.TestEvent.nullVal:type_name -> google.protobuf.NullValue + 33, // 4: crowdstrike.csproto.example.proto3.googlev2.TestEvent.timestamps:type_name -> google.protobuf.Timestamp + 35, // 5: crowdstrike.csproto.example.proto3.googlev2.TestEvent.structs:type_name -> google.protobuf.Struct 0, // 6: crowdstrike.csproto.example.proto3.googlev2.AllTheThings.theEventType:type_name -> crowdstrike.csproto.example.proto3.googlev2.EventType 2, // 7: crowdstrike.csproto.example.proto3.googlev2.AllTheThings.theMessage:type_name -> crowdstrike.csproto.example.proto3.googlev2.EmbeddedEvent 0, // 8: crowdstrike.csproto.example.proto3.googlev2.RepeatAllTheThings.theEventTypes:type_name -> crowdstrike.csproto.example.proto3.googlev2.EventType 2, // 9: crowdstrike.csproto.example.proto3.googlev2.RepeatAllTheThings.theMessages:type_name -> crowdstrike.csproto.example.proto3.googlev2.EmbeddedEvent - 32, // 10: crowdstrike.csproto.example.proto3.googlev2.EventUsingWKTs.ts:type_name -> google.protobuf.Timestamp + 33, // 10: crowdstrike.csproto.example.proto3.googlev2.EventUsingWKTs.ts:type_name -> google.protobuf.Timestamp 0, // 11: crowdstrike.csproto.example.proto3.googlev2.EventUsingWKTs.event_type:type_name -> crowdstrike.csproto.example.proto3.googlev2.EventType - 32, // 12: crowdstrike.csproto.example.proto3.googlev2.MapObject.ts:type_name -> google.protobuf.Timestamp - 12, // 13: crowdstrike.csproto.example.proto3.googlev2.MapObject.attributes:type_name -> crowdstrike.csproto.example.proto3.googlev2.MapObject.AttributesEntry - 13, // 14: crowdstrike.csproto.example.proto3.googlev2.Maps.bools:type_name -> crowdstrike.csproto.example.proto3.googlev2.Maps.BoolsEntry - 14, // 15: crowdstrike.csproto.example.proto3.googlev2.Maps.strings:type_name -> crowdstrike.csproto.example.proto3.googlev2.Maps.StringsEntry - 15, // 16: crowdstrike.csproto.example.proto3.googlev2.Maps.int32s:type_name -> crowdstrike.csproto.example.proto3.googlev2.Maps.Int32sEntry - 16, // 17: crowdstrike.csproto.example.proto3.googlev2.Maps.int64s:type_name -> crowdstrike.csproto.example.proto3.googlev2.Maps.Int64sEntry - 17, // 18: crowdstrike.csproto.example.proto3.googlev2.Maps.uint32s:type_name -> crowdstrike.csproto.example.proto3.googlev2.Maps.Uint32sEntry - 18, // 19: crowdstrike.csproto.example.proto3.googlev2.Maps.uint64s:type_name -> crowdstrike.csproto.example.proto3.googlev2.Maps.Uint64sEntry - 19, // 20: crowdstrike.csproto.example.proto3.googlev2.Maps.sint32s:type_name -> crowdstrike.csproto.example.proto3.googlev2.Maps.Sint32sEntry - 20, // 21: crowdstrike.csproto.example.proto3.googlev2.Maps.sint64s:type_name -> crowdstrike.csproto.example.proto3.googlev2.Maps.Sint64sEntry - 21, // 22: crowdstrike.csproto.example.proto3.googlev2.Maps.fixed32s:type_name -> crowdstrike.csproto.example.proto3.googlev2.Maps.Fixed32sEntry - 22, // 23: crowdstrike.csproto.example.proto3.googlev2.Maps.fixed64s:type_name -> crowdstrike.csproto.example.proto3.googlev2.Maps.Fixed64sEntry - 23, // 24: crowdstrike.csproto.example.proto3.googlev2.Maps.sfixed32s:type_name -> crowdstrike.csproto.example.proto3.googlev2.Maps.Sfixed32sEntry - 24, // 25: crowdstrike.csproto.example.proto3.googlev2.Maps.sfixed64s:type_name -> crowdstrike.csproto.example.proto3.googlev2.Maps.Sfixed64sEntry - 25, // 26: crowdstrike.csproto.example.proto3.googlev2.Maps.floats:type_name -> crowdstrike.csproto.example.proto3.googlev2.Maps.FloatsEntry - 26, // 27: crowdstrike.csproto.example.proto3.googlev2.Maps.doubles:type_name -> crowdstrike.csproto.example.proto3.googlev2.Maps.DoublesEntry - 27, // 28: crowdstrike.csproto.example.proto3.googlev2.Maps.nulls:type_name -> crowdstrike.csproto.example.proto3.googlev2.Maps.NullsEntry - 28, // 29: crowdstrike.csproto.example.proto3.googlev2.Maps.structs:type_name -> crowdstrike.csproto.example.proto3.googlev2.Maps.StructsEntry - 29, // 30: crowdstrike.csproto.example.proto3.googlev2.Maps.timestamps:type_name -> crowdstrike.csproto.example.proto3.googlev2.Maps.TimestampsEntry - 30, // 31: crowdstrike.csproto.example.proto3.googlev2.Maps.objects:type_name -> crowdstrike.csproto.example.proto3.googlev2.Maps.ObjectsEntry - 33, // 32: crowdstrike.csproto.example.proto3.googlev2.OneOfs.nulls:type_name -> google.protobuf.NullValue - 34, // 33: crowdstrike.csproto.example.proto3.googlev2.OneOfs.structs:type_name -> google.protobuf.Struct - 32, // 34: crowdstrike.csproto.example.proto3.googlev2.OneOfs.timestamps:type_name -> google.protobuf.Timestamp + 33, // 12: crowdstrike.csproto.example.proto3.googlev2.MapObject.ts:type_name -> google.protobuf.Timestamp + 13, // 13: crowdstrike.csproto.example.proto3.googlev2.MapObject.attributes:type_name -> crowdstrike.csproto.example.proto3.googlev2.MapObject.AttributesEntry + 14, // 14: crowdstrike.csproto.example.proto3.googlev2.Maps.bools:type_name -> crowdstrike.csproto.example.proto3.googlev2.Maps.BoolsEntry + 15, // 15: crowdstrike.csproto.example.proto3.googlev2.Maps.strings:type_name -> crowdstrike.csproto.example.proto3.googlev2.Maps.StringsEntry + 16, // 16: crowdstrike.csproto.example.proto3.googlev2.Maps.int32s:type_name -> crowdstrike.csproto.example.proto3.googlev2.Maps.Int32sEntry + 17, // 17: crowdstrike.csproto.example.proto3.googlev2.Maps.int64s:type_name -> crowdstrike.csproto.example.proto3.googlev2.Maps.Int64sEntry + 18, // 18: crowdstrike.csproto.example.proto3.googlev2.Maps.uint32s:type_name -> crowdstrike.csproto.example.proto3.googlev2.Maps.Uint32sEntry + 19, // 19: crowdstrike.csproto.example.proto3.googlev2.Maps.uint64s:type_name -> crowdstrike.csproto.example.proto3.googlev2.Maps.Uint64sEntry + 20, // 20: crowdstrike.csproto.example.proto3.googlev2.Maps.sint32s:type_name -> crowdstrike.csproto.example.proto3.googlev2.Maps.Sint32sEntry + 21, // 21: crowdstrike.csproto.example.proto3.googlev2.Maps.sint64s:type_name -> crowdstrike.csproto.example.proto3.googlev2.Maps.Sint64sEntry + 22, // 22: crowdstrike.csproto.example.proto3.googlev2.Maps.fixed32s:type_name -> crowdstrike.csproto.example.proto3.googlev2.Maps.Fixed32sEntry + 23, // 23: crowdstrike.csproto.example.proto3.googlev2.Maps.fixed64s:type_name -> crowdstrike.csproto.example.proto3.googlev2.Maps.Fixed64sEntry + 24, // 24: crowdstrike.csproto.example.proto3.googlev2.Maps.sfixed32s:type_name -> crowdstrike.csproto.example.proto3.googlev2.Maps.Sfixed32sEntry + 25, // 25: crowdstrike.csproto.example.proto3.googlev2.Maps.sfixed64s:type_name -> crowdstrike.csproto.example.proto3.googlev2.Maps.Sfixed64sEntry + 26, // 26: crowdstrike.csproto.example.proto3.googlev2.Maps.floats:type_name -> crowdstrike.csproto.example.proto3.googlev2.Maps.FloatsEntry + 27, // 27: crowdstrike.csproto.example.proto3.googlev2.Maps.doubles:type_name -> crowdstrike.csproto.example.proto3.googlev2.Maps.DoublesEntry + 28, // 28: crowdstrike.csproto.example.proto3.googlev2.Maps.nulls:type_name -> crowdstrike.csproto.example.proto3.googlev2.Maps.NullsEntry + 29, // 29: crowdstrike.csproto.example.proto3.googlev2.Maps.structs:type_name -> crowdstrike.csproto.example.proto3.googlev2.Maps.StructsEntry + 30, // 30: crowdstrike.csproto.example.proto3.googlev2.Maps.timestamps:type_name -> crowdstrike.csproto.example.proto3.googlev2.Maps.TimestampsEntry + 31, // 31: crowdstrike.csproto.example.proto3.googlev2.Maps.objects:type_name -> crowdstrike.csproto.example.proto3.googlev2.Maps.ObjectsEntry + 34, // 32: crowdstrike.csproto.example.proto3.googlev2.OneOfs.nulls:type_name -> google.protobuf.NullValue + 35, // 33: crowdstrike.csproto.example.proto3.googlev2.OneOfs.structs:type_name -> google.protobuf.Struct + 33, // 34: crowdstrike.csproto.example.proto3.googlev2.OneOfs.timestamps:type_name -> google.protobuf.Timestamp 6, // 35: crowdstrike.csproto.example.proto3.googlev2.OneOfs.objects:type_name -> crowdstrike.csproto.example.proto3.googlev2.MapObject - 31, // 36: crowdstrike.csproto.example.proto3.googlev2.Msg.tags:type_name -> crowdstrike.csproto.example.proto3.googlev2.Msg.Tags - 33, // 37: crowdstrike.csproto.example.proto3.googlev2.Maps.NullsEntry.value:type_name -> google.protobuf.NullValue - 34, // 38: crowdstrike.csproto.example.proto3.googlev2.Maps.StructsEntry.value:type_name -> google.protobuf.Struct - 32, // 39: crowdstrike.csproto.example.proto3.googlev2.Maps.TimestampsEntry.value:type_name -> google.protobuf.Timestamp - 6, // 40: crowdstrike.csproto.example.proto3.googlev2.Maps.ObjectsEntry.value:type_name -> crowdstrike.csproto.example.proto3.googlev2.MapObject - 41, // [41:41] is the sub-list for method output_type - 41, // [41:41] is the sub-list for method input_type - 41, // [41:41] is the sub-list for extension type_name - 41, // [41:41] is the sub-list for extension extendee - 0, // [0:41] is the sub-list for field type_name + 0, // 36: crowdstrike.csproto.example.proto3.googlev2.Optionals.optional_enum:type_name -> crowdstrike.csproto.example.proto3.googlev2.EventType + 2, // 37: crowdstrike.csproto.example.proto3.googlev2.Optionals.optional_message:type_name -> crowdstrike.csproto.example.proto3.googlev2.EmbeddedEvent + 32, // 38: crowdstrike.csproto.example.proto3.googlev2.Msg.tags:type_name -> crowdstrike.csproto.example.proto3.googlev2.Msg.Tags + 34, // 39: crowdstrike.csproto.example.proto3.googlev2.Maps.NullsEntry.value:type_name -> google.protobuf.NullValue + 35, // 40: crowdstrike.csproto.example.proto3.googlev2.Maps.StructsEntry.value:type_name -> google.protobuf.Struct + 33, // 41: crowdstrike.csproto.example.proto3.googlev2.Maps.TimestampsEntry.value:type_name -> google.protobuf.Timestamp + 6, // 42: crowdstrike.csproto.example.proto3.googlev2.Maps.ObjectsEntry.value:type_name -> crowdstrike.csproto.example.proto3.googlev2.MapObject + 43, // [43:43] is the sub-list for method output_type + 43, // [43:43] is the sub-list for method input_type + 43, // [43:43] is the sub-list for extension type_name + 43, // [43:43] is the sub-list for extension extendee + 0, // [0:43] is the sub-list for field type_name } func init() { file_googlev2_proto3_example_proto_init() } @@ -2087,152 +2317,6 @@ func file_googlev2_proto3_example_proto_init() { if File_googlev2_proto3_example_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_googlev2_proto3_example_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*TestEvent); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_googlev2_proto3_example_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*EmbeddedEvent); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_googlev2_proto3_example_proto_msgTypes[2].Exporter = func(v any, i int) any { - switch v := v.(*AllTheThings); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_googlev2_proto3_example_proto_msgTypes[3].Exporter = func(v any, i int) any { - switch v := v.(*RepeatAllTheThings); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_googlev2_proto3_example_proto_msgTypes[4].Exporter = func(v any, i int) any { - switch v := v.(*EventUsingWKTs); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_googlev2_proto3_example_proto_msgTypes[5].Exporter = func(v any, i int) any { - switch v := v.(*MapObject); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_googlev2_proto3_example_proto_msgTypes[6].Exporter = func(v any, i int) any { - switch v := v.(*Maps); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_googlev2_proto3_example_proto_msgTypes[7].Exporter = func(v any, i int) any { - switch v := v.(*OneOfs); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_googlev2_proto3_example_proto_msgTypes[8].Exporter = func(v any, i int) any { - switch v := v.(*I18NVariable); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_googlev2_proto3_example_proto_msgTypes[9].Exporter = func(v any, i int) any { - switch v := v.(*Msg); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_googlev2_proto3_example_proto_msgTypes[10].Exporter = func(v any, i int) any { - switch v := v.(*TestEvent_NestedMsg); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_googlev2_proto3_example_proto_msgTypes[30].Exporter = func(v any, i int) any { - switch v := v.(*Msg_Tags); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } file_googlev2_proto3_example_proto_msgTypes[0].OneofWrappers = []any{ (*TestEvent_Jedi)(nil), (*TestEvent_Sith)(nil), @@ -2260,11 +2344,12 @@ func file_googlev2_proto3_example_proto_init() { (*OneOfs_Timestamps)(nil), (*OneOfs_Objects)(nil), } - file_googlev2_proto3_example_proto_msgTypes[8].OneofWrappers = []any{ + file_googlev2_proto3_example_proto_msgTypes[8].OneofWrappers = []any{} + file_googlev2_proto3_example_proto_msgTypes[9].OneofWrappers = []any{ (*I18NVariable_OptOne)(nil), (*I18NVariable_OptTwo)(nil), } - file_googlev2_proto3_example_proto_msgTypes[9].OneofWrappers = []any{ + file_googlev2_proto3_example_proto_msgTypes[10].OneofWrappers = []any{ (*Msg_Tags_)(nil), } type x struct{} @@ -2273,7 +2358,7 @@ func file_googlev2_proto3_example_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_googlev2_proto3_example_proto_rawDesc, NumEnums: 1, - NumMessages: 31, + NumMessages: 32, NumExtensions: 0, NumServices: 0, }, diff --git a/example/proto3/googlev2/googlev2_proto3_example.proto b/example/proto3/googlev2/googlev2_proto3_example.proto index 6594e21..d5494ef 100644 --- a/example/proto3/googlev2/googlev2_proto3_example.proto +++ b/example/proto3/googlev2/googlev2_proto3_example.proto @@ -147,6 +147,27 @@ message OneOfs { } } +message Optionals { + reserved 1; + optional string optional_string = 2; + optional bool optional_bool = 3; + optional int32 optional_int32 = 4; + optional int64 optional_int64 = 5; + optional uint32 optional_uint32 = 6; + optional uint64 optional_uint64 = 7; + optional sint32 optional_sint32 = 8; + optional sint64 optional_sint64 = 9; + optional fixed32 optional_fixed32 = 10; + optional fixed64 optional_fixed64 = 11; + optional sfixed32 optional_sfixed32 = 12; + optional sfixed64 optional_sfixed64 = 13; + optional float optional_float = 14; + optional double optional_double = 15; + optional EventType optional_enum = 16; + optional bytes optional_bytes = 17; + optional EmbeddedEvent optional_message = 18; +} + // see https://github.com/CrowdStrike/csproto/pull/124 message I18nVariable { oneof one_of_values {