Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Unified Diff: mojom/generators/go/templates/templates.go

Issue 2045063002: [New go generator] Implement declaring unions. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojom/generators/go/templates/declarations_test.go ('k') | mojom/generators/go/translator/mojom_file.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojom/generators/go/templates/templates.go
diff --git a/mojom/generators/go/templates/templates.go b/mojom/generators/go/templates/templates.go
index fd725af0d305aec6ebf1b66bb08b48c4756a5b1a..866c9dcb2293f47120c7eb9083a0bc3af5bb9bea 100644
--- a/mojom/generators/go/templates/templates.go
+++ b/mojom/generators/go/templates/templates.go
@@ -34,6 +34,7 @@ func ExecuteTemplates(tmplFile *translator.TmplFile) string {
func init() {
// We parse the subtemplates only once.
goFileTmpl = template.New("GoFileTemplate")
+
template.Must(goFileTmpl.Parse(goFileTemplate))
template.Must(goFileTmpl.Parse(nonNullableFieldDecodingTmplText))
template.Must(goFileTmpl.Parse(fieldDecodingTmplText))
@@ -44,6 +45,11 @@ func init() {
template.Must(goFileTmpl.Parse(structDeclTmplText))
template.Must(goFileTmpl.Parse(structVersions))
template.Must(goFileTmpl.Parse(structDecodingTmplText))
+
+ template.Must(goFileTmpl.Parse(unionDeclTmplText))
+ template.Must(goFileTmpl.Parse(unionInterfaceDeclTmplText))
+ template.Must(goFileTmpl.Parse(unionFieldDeclTmplText))
+ template.Must(goFileTmpl.Parse(unknownUnionFieldDeclTmplText))
}
const goFileTemplate = `
@@ -66,5 +72,9 @@ import (
{{ template "StructDecodingTmpl" $struct }}
{{- end}}
+
+{{- range $union := $fileTmpl.Imports}}
vardhan 2016/06/08 20:45:47 hm.. did you mean $fileTmpl.Unions? and below thi
azani 2016/06/08 23:51:48 Done.
+ {{ template "UnionDecl" $struct }}
+{{- end}}
{{- end -}}
`
« no previous file with comments | « mojom/generators/go/templates/declarations_test.go ('k') | mojom/generators/go/translator/mojom_file.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698