| Index: mojom/generators/go/templates/encoding.go
|
| diff --git a/mojom/generators/go/templates/encoding.go b/mojom/generators/go/templates/encoding.go
|
| index 56c6235cd8573c8705f623c4aa2c134132d4a945..df63d819903c226e427b6664b9192e766eecd58e 100644
|
| --- a/mojom/generators/go/templates/encoding.go
|
| +++ b/mojom/generators/go/templates/encoding.go
|
| @@ -11,7 +11,7 @@ import (
|
| const fieldEncodingTmplText = `
|
| {{- define "FieldEncodingTmpl" -}}
|
| {{- $info := . -}}
|
| -{{- if $info.IsNullable -}}
|
| +{{- if and (not $info.IsUnion) $info.IsNullable -}}
|
| if {{$info.Identifier}} == nil {
|
| {{- if $info.IsPointer -}}
|
| encoder.WriteNullPointer()
|
| @@ -51,6 +51,21 @@ if err := encoder.WriteHandle({{$info.Identifier}}); err != nil {
|
| if err := {{$info.Identifier}}.Encode(encoder); err != nil {
|
| return err
|
| }
|
| +{{- else if $info.IsUnion -}}
|
| +{{- if $info.IsPointer -}}
|
| +encoder.StartNestedUnion()
|
| +{{end -}}
|
| +if {{$info.Identifier}} == nil {
|
| +{{- if $info.IsNullable -}}
|
| + encoder.WriteNullUnion()
|
| +{{- else -}}
|
| + return &bindings.ValidationError{bindings.UnexpectedNullUnion, "unexpected null union"}
|
| +{{- end -}}
|
| +} else {
|
| + if err := {{$info.Identifier}}.Encode(encoder); err != nil {
|
| + return err
|
| + }
|
| +}
|
| {{- else if $info.IsArray -}}
|
| {{ $elInfo := $info.ElementEncodingInfo -}}
|
| encoder.StartArray(uint32(len({{$info.Identifier}})), {{$elInfo.BitSize}})
|
|
|