Go bindings: Generate a CreateMessagePipeFor{{interface}} helper
This allows writing code to generate a typed InterfaceRequest/Pointer
pair for a mojom interface like 'examples.Echo' to be written as:
r, p := examples.CreateMessagePipeForEcho()
proxy := examples.NewEchoProxy(p, bindings.GetAsyncWaiter())
SomethingOrOther(r)
instead of calling bindings.CreateMessagePipeForMojoInterface() and
casting the returned values to examples.EchoRequest and
examples.EchoPointer.
R=rogulenko@google.com
Review URL: https://codereview.chromium.org/974153003
diff --git a/mojo/public/tools/bindings/generators/go_templates/interface.tmpl b/mojo/public/tools/bindings/generators/go_templates/interface.tmpl
index d41df27..808e7b0 100644
--- a/mojo/public/tools/bindings/generators/go_templates/interface.tmpl
+++ b/mojo/public/tools/bindings/generators/go_templates/interface.tmpl
@@ -45,6 +45,13 @@
type {{interface|name}}Request bindings.InterfaceRequest
type {{interface|name}}Pointer bindings.InterfacePointer
+// CreateMessagePipeFor{{interface|name}} creates a message pipe for use with the
+// {{interface|name}} interface with a {{interface|name}}Request on one end and a {{interface|name}}Pointer on the other.
+func CreateMessagePipeFor{{interface|name}}() ({{interface|name}}Request, {{interface|name}}Pointer) {
+ r, p := bindings.CreateMessagePipeForMojoInterface()
+ return {{interface|name}}Request(r), {{interface|name}}Pointer(p)
+}
+
{% for method in interface.methods %}
const {{interface|name(False)}}_{{method|name}}_Name = {{method.ordinal}}
{% endfor %}