Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: minor bug fixes for oneofs #98

Merged
merged 1 commit into from
Jan 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cmd/protoc-gen-fastmarshal/templates/fieldsnippets.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@
{{ if eq $kind "bool" "int32" "int64" "uint32" "uint64" "sint32" "sint64" "fixed32" "float" "fixed64" "double" }}
enc.{{ protoNumberEncodeMethod (.Desc.Kind | string) false}}({{.Desc.Number}}, typedVal.{{.GoName | getSafeFieldName}})
{{ else if eq $kind "sfixed32" "sfixed64" }}
{{- $bitSize := (.Desc.Kind | string | trunc -2) -}}
{{- $bitSize := (.Desc.Kind | string | trunc -2) }}
enc.{{ printf "EncodeFixed%s" $bitSize }}({{.Desc.Number}}, {{ printf "uint%s" $bitSize }}(typedVal.{{.GoName | getSafeFieldName}}))
{{ else if eq $kind "enum" }}
enc.EncodeInt32({{.Desc.Number}}, int32(typedVal.{{.GoName | getSafeFieldName}}))
Expand Down Expand Up @@ -1323,7 +1323,7 @@
if v, err := dec.DecodeFixed{{$bitSize}}(); err != nil {
return fmt.Errorf("unable to decode {{$kind}} value for field '{{.Desc.Name}}' (tag={{.Desc.Number}}): %w", err)
} else {
ov.{{.GoName | getSafeFieldName}}= v
ov.{{.GoName | getSafeFieldName}}= int{{$bitSize}}(v)
}
{{- else if eq $kind "enum" -}}
if wt != csproto.WireTypeVarint {
Expand All @@ -1332,7 +1332,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 {
ov.{{.GoName | getSafeFieldName}}= {{.Enum.GoIdent.GoName | getSafeFieldName}}(v)
ov.{{.GoName | getSafeFieldName}}= {{.Enum | getImportPrefix}}{{.Enum.GoIdent.GoName | getSafeFieldName}}(v)
}
{{- else if eq $kind "string" -}}
if wt != csproto.WireTypeLengthDelimited {
Expand Down
1 change: 0 additions & 1 deletion example/permessage/gogo/gogo_permessage_example.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion example/proto2/gogo/gogo_proto2_example.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion example/proto2/googlev1/googlev1_proto2_example.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion example/proto2/googlev2/googlev2_proto2_example.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion example/proto3/gogo/gogo_proto3_example.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion example/proto3/googlev1/googlev1_proto3_example.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading