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

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

Issue 2077113002: Handle interfaces with a ServiceName in the go bindings generator. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Fix names issue. 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 | « no previous file | mojom/generators/go/templates/interfaces_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojom/generators/go/templates/interfaces.go
diff --git a/mojom/generators/go/templates/interfaces.go b/mojom/generators/go/templates/interfaces.go
index ed95d5f49d15b2698ad3c146f22841ac037427a1..4634650f0bec5ee4f0e496ef28c9c56fee4ad28d 100644
--- a/mojom/generators/go/templates/interfaces.go
+++ b/mojom/generators/go/templates/interfaces.go
@@ -12,6 +12,14 @@ const interfaceTmplText = `
{{- define "Interface" -}}
{{$interface := . -}}
{{ template "InterfaceDecl" $interface }}
+
+{{- range $method := $interface.Methods -}}
+{{ template "Method" $method }}
+{{- end -}}
+
+{{- if $interface.ServiceName -}}
+{{ template "ServiceDecl" $interface }}
+{{- end -}}
{{- end -}}
`
@@ -87,6 +95,18 @@ func (p *{{$interface.Name}}_Proxy) Close_Proxy() {
{{- end -}}
`
+const methodTmplText = `
+{{- define "Method" -}}
+{{- $method := . -}}
+
+{{ template "MethodParams" $method }}
+
+{{ template "MethodSignature" $method }}
+
+{{ template "MethodFunction" $method }}
+{{- end -}}
+`
+
const methodOrdinalsTmplText = `
{{- define "MethodOrdinals" -}}
{{- $interface := . -}}
@@ -184,12 +204,34 @@ func (p *{{$method.Interface.Name}}_Proxy) {{ template "MethodSignature" $method
{{- end -}}
`
+const serviceDeclTmplText = `
+{{- define "ServiceDecl" -}}
+{{- $interface := . -}}
+const {{$interface.PrivateName}}_Name string = "{{$interface.ServiceName}}"
+
+func (r *{{$interface.Name}}_Request) Name() string {
+ return {{$interface.PrivateName}}_Name
+}
+
+func (p *{{$interface.Name}}_Pointer) Name() string {
+ return {{$interface.PrivateName}}_Name
+}
+
+func (f *{{$interface.Name}}_ServiceFactory) Name() string {
+ return {{$interface.PrivateName}}_Name
+}
+{{- end -}}
+`
+
func initInterfaceTemplates() {
+ template.Must(goFileTmpl.Parse(interfaceTmplText))
template.Must(goFileTmpl.Parse(interfaceDeclTmplText))
template.Must(goFileTmpl.Parse(interfaceInterfaceDeclTmplText))
template.Must(goFileTmpl.Parse(interfaceOtherDeclTmplText))
+ template.Must(goFileTmpl.Parse(serviceDeclTmplText))
template.Must(goFileTmpl.Parse(methodOrdinalsTmplText))
template.Must(goFileTmpl.Parse(methodParamsTmplText))
template.Must(goFileTmpl.Parse(methodSignatureTmplText))
template.Must(goFileTmpl.Parse(methodFuncTmplText))
+ template.Must(goFileTmpl.Parse(methodTmplText))
}
« no previous file with comments | « no previous file | mojom/generators/go/templates/interfaces_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698