Skip to content

Commit

Permalink
fix: minor bug fixes for oneofs (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsexton authored Jan 17, 2023
1 parent 5ea1e29 commit e3d70c2
Show file tree
Hide file tree
Showing 12 changed files with 1,129 additions and 151 deletions.
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

0 comments on commit e3d70c2

Please sign in to comment.