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

Unified Diff: mojo/public/tools/bindings/generators/go_templates/interface.tmpl

Issue 1345263002: Generate Mojom Types in Go (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 3 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
Index: mojo/public/tools/bindings/generators/go_templates/interface.tmpl
diff --git a/mojo/public/tools/bindings/generators/go_templates/interface.tmpl b/mojo/public/tools/bindings/generators/go_templates/interface.tmpl
index 8fa02ee767f6193916ff10de483db8d94eb1b8b9..bb018eb3ee343df1f239cb0a7947331ccdfb37a3 100644
--- a/mojo/public/tools/bindings/generators/go_templates/interface.tmpl
+++ b/mojo/public/tools/bindings/generators/go_templates/interface.tmpl
@@ -3,6 +3,7 @@
// found in the LICENSE file.
{% import "struct.tmpl" as struct_macros %}
+{% import "mojom_util_macros.tmpl" as util %}
{%- macro declare_params(struct) %}
{%- for field in struct.fields -%}
@@ -35,7 +36,7 @@
-{% macro define(interface) %}
+{% macro define(interface, typepkg, pkg) %}
type {{interface|name}} interface {
{% for method in interface.methods %}
{{method|name}}{{declare_request_params(method)}}
@@ -101,9 +102,9 @@ func (p *{{interface|name}}_Proxy) Close_Proxy() {
}
{% for method in interface.methods %}
-{{struct_macros.define(method.param_struct, False)}}
+{{struct_macros.define(method.param_struct, typepkg, pkg, False)}}
{%- if method.response_parameters %}
-{{struct_macros.define(method.response_param_struct, False)}}
+{{struct_macros.define(method.response_param_struct, typepkg, pkg, False)}}
{%- endif %}
func (p *{{interface|name}}_Proxy) {{method|name}}{{declare_request_params(method)}} {
payload := &{{method.param_struct|name(False)}}{
@@ -170,6 +171,22 @@ func New{{interface|name}}Stub(r {{interface|name}}_Request, impl {{interface|na
return bindings.NewStub(connector, &{{interface|name(False)}}_Stub{connector, impl})
}
+var {{util.interfaceName(interface, typepkg, pkg)}} = {{typepkg}}MojomInterface{
+ DeclData: nil,
+ Methods: map[uint32]{{typepkg}}MojomMethod{
+{%- for method in interface.methods -%}
+ {{interface|name(False)}}_{{method|name}}_Name: {{typepkg}}MojomMethod{
+ DeclData: nil,
+ Parameters: {{util.structName(method.param_struct, typepkg, pkg)}},
+ {%- if method.response_parameters -%}
+ ResponseParams: &{{util.structName(method.response_param_struct, typepkg, pkg)}},
+ {%- endif -%}
+ },
+{%- endfor -%}
+ },
+}
+
+
func (s *{{interface|name(False)}}_Stub) Accept(message *bindings.Message) (err error) {
switch message.Header.Type {
{% for method in interface.methods %}

Powered by Google App Engine
This is Rietveld 408576698