| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package templates | 5 package templates |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "text/template" | 8 "text/template" |
| 9 ) | 9 ) |
| 10 | 10 |
| 11 const unionTmplText = ` | 11 const unionTmplText = ` |
| 12 {{- define "Union" -}} | 12 {{- define "Union" -}} |
| 13 {{- $union := . }} | 13 {{- $union := . }} |
| 14 {{ template "UnionInterfaceDecl" $union }} | 14 {{ template "UnionInterfaceDecl" $union }} |
| 15 | 15 |
| 16 {{ template "UnknownUnionFieldDecl" $union }} | 16 {{ template "UnknownUnionFieldDecl" $union }} |
| 17 {{ template "UnknownUnionFieldEncode" $union }} | 17 {{ template "UnknownUnionFieldEncode" $union }} |
| 18 | 18 |
| 19 {{- range $field := $union.Field}} | 19 {{- range $field := $union.Fields}} |
| 20 {{ template "UnionFieldDecl" $field }} | 20 {{ template "UnionFieldDecl" $field }} |
| 21 | 21 |
| 22 {{ template "UnionFieldEncode" $field }} | 22 {{ template "UnionFieldEncode" $field }} |
| 23 | 23 |
| 24 {{ template "UnionFieldDecode" $field }} | 24 {{ template "UnionFieldDecode" $field }} |
| 25 {{- end}} | 25 {{- end}} |
| 26 | 26 |
| 27 {{ template "UnionDecode" $union }} | 27 {{ template "UnionDecode" $union }} |
| 28 | 28 |
| 29 {{- end -}} | 29 {{- end -}} |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 func initUnionTemplates() { | 138 func initUnionTemplates() { |
| 139 template.Must(goFileTmpl.Parse(unionTmplText)) | 139 template.Must(goFileTmpl.Parse(unionTmplText)) |
| 140 template.Must(goFileTmpl.Parse(unionInterfaceDeclTmplText)) | 140 template.Must(goFileTmpl.Parse(unionInterfaceDeclTmplText)) |
| 141 template.Must(goFileTmpl.Parse(unionFieldDeclTmplText)) | 141 template.Must(goFileTmpl.Parse(unionFieldDeclTmplText)) |
| 142 template.Must(goFileTmpl.Parse(unknownUnionFieldDeclTmplText)) | 142 template.Must(goFileTmpl.Parse(unknownUnionFieldDeclTmplText)) |
| 143 template.Must(goFileTmpl.Parse(unknownUnionFieldEncodeTmplText)) | 143 template.Must(goFileTmpl.Parse(unknownUnionFieldEncodeTmplText)) |
| 144 template.Must(goFileTmpl.Parse(unionFieldEncodeTmplText)) | 144 template.Must(goFileTmpl.Parse(unionFieldEncodeTmplText)) |
| 145 template.Must(goFileTmpl.Parse(unionFieldDecodeTmplText)) | 145 template.Must(goFileTmpl.Parse(unionFieldDecodeTmplText)) |
| 146 template.Must(goFileTmpl.Parse(unionDecodeTmplText)) | 146 template.Must(goFileTmpl.Parse(unionDecodeTmplText)) |
| 147 } | 147 } |
| OLD | NEW |