| Index: mojom/generators/go/templates/declarations.go
|
| diff --git a/mojom/generators/go/templates/declarations.go b/mojom/generators/go/templates/declarations.go
|
| index c16bdc4b3a121c54274a5b52d16ad55fc37e0b3f..04c3df8772a8e010a64abb61af1a910908f0720f 100644
|
| --- a/mojom/generators/go/templates/declarations.go
|
| +++ b/mojom/generators/go/templates/declarations.go
|
| @@ -14,3 +14,55 @@ type {{$struct.Name}} struct {
|
| }
|
| {{- end -}}
|
| `
|
| +
|
| +const unionDeclTmplText = `
|
| +{{- define "UnionDecl" -}}
|
| +{{- $struct := . }}
|
| +{{ template "UnionInterfaceDecl" $struct }}
|
| +
|
| +{{ template "UnknownUnionFieldDecl" $struct }}
|
| +
|
| +{{- range $field := $struct.Field}}
|
| +{{ template "UnionFieldDecl" $field }}
|
| +{{- end}}
|
| +{{- end -}}
|
| +`
|
| +
|
| +const unionInterfaceDeclTmplText = `
|
| +{{- define "UnionInterfaceDecl" -}}
|
| +{{$union := . -}}
|
| +type {{$union.Name}} interface {
|
| + Tag() uint32
|
| + Interface() interface{}
|
| + __Reflect(__SomeUnionReflect)
|
| + Encode(encoder *bindings.Encoder) error
|
| +}
|
| +
|
| +type __{{$union.Name}}Reflect struct {
|
| +{{- range $field := $union.Fields}}
|
| + {{$field.Name}} {{$field.Type}}
|
| +{{- end}}
|
| +}
|
| +{{- end -}}
|
| +`
|
| +
|
| +const unionFieldDeclTmplText = `
|
| +{{- define "UnionFieldDecl" -}}
|
| +{{$field := . -}}
|
| +{{$unionName := $field.Union.Name -}}
|
| +type {{$unionName}}{{$field.Name}} struct{ Value {{$field.Type}} }
|
| +func (u *{{$unionName}}{{$field.Name}}) Tag() uint32 { return {{$field.Tag}} }
|
| +func (u *{{$unionName}}{{$field.Name}}) Interface() interface{} { return u.Value }
|
| +func (u *{{$unionName}}{{$field.Name}}) __Reflect(__{{$unionName}}Reflect) {}
|
| +{{- end -}}
|
| +`
|
| +
|
| +const unknownUnionFieldDeclTmplText = `
|
| +{{- define "UnknownUnionFieldDecl" -}}
|
| +{{$union := . -}}
|
| +type {{$union.Name}}Unknown struct { tag uint32 }
|
| +func (u *{{$union.Name}}Unknown) Tag() uint32 { return u.tag }
|
| +func (u *{{$union.Name}}Unknown) Interface() interface{} { return nil }
|
| +func (u *{{$union.Name}}Unknown) __Reflect(__{{$union.Name}}Reflect) {}
|
| +{{- end -}}
|
| +`
|
|
|