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

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

Issue 975133003: Set Message{Is,Expects} response correctly in go bindings (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 {% import "struct.tmpl" as struct_macros %} 5 {% import "struct.tmpl" as struct_macros %}
6 6
7 {%- macro declare_params(struct) %} 7 {%- macro declare_params(struct) %}
8 {%- for field in struct.fields -%} 8 {%- for field in struct.fields -%}
9 {{field|name(False)}} {{field.kind|go_type}}{% if not loop.last %}, {% e ndif %} 9 {{field|name(False)}} {{field.kind|go_type}}{% if not loop.last %}, {% e ndif %}
10 {%- endfor %} 10 {%- endfor %}
11 {%- endmacro %} 11 {%- endmacro %}
12 12
13 13
14 14
15 {% macro declare_request_params(method) %} 15 {% macro declare_request_params(method) %}
16 ({{declare_params(method|struct_from_method)}}) 16 ({{declare_params(method|struct_from_method)}})
17 {%- if method.response_parameters|is_none_or_empty -%} 17 {%- if method.response_parameters|is_none_or_empty -%}
18 {{' (err error)'}} 18 {{' (err error)'}}
19 {%- else -%} 19 {%- else -%}
20 {{' '}}({{declare_params(method|response_struct_from_method)}}, err erro r) 20 {{' '}}({{declare_params(method|response_struct_from_method)}}, err erro r)
21 {%- endif -%} 21 {%- endif -%}
22 {% endmacro %} 22 {% endmacro %}
23 23
24 24
25 25
26 {%- macro flags(response_parameters, is_renponse) -%} 26 {%- macro flags(response_parameters, is_response) -%}
27 {%- if not response_parameters -%} 27 {%- if not response_parameters -%}
28 bindings.MessageNoFlag 28 bindings.MessageNoFlag
29 {%- elif is_parameter: -%} 29 {%- elif is_response: -%}
30 » bindings.MessageIsResponseFlag
31 {%- else -%}
30 bindings.MessageExpectsResponseFlag 32 bindings.MessageExpectsResponseFlag
31 {%- else -%}
32 bindings.MessageIsResponseFlag
33 {%- endif -%} 33 {%- endif -%}
34 {%- endmacro -%} 34 {%- endmacro -%}
35 35
36 36
37 37
38 {% macro define(interface) %} 38 {% macro define(interface) %}
39 type {{interface|name}} interface { 39 type {{interface|name}} interface {
40 {% for method in interface.methods %} 40 {% for method in interface.methods %}
41 {{method|name}}{{declare_request_params(method)}} 41 {{method|name}}{{declare_request_params(method)}}
42 {% endfor %} 42 {% endfor %}
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 return s.connector.WriteMessage(message) 156 return s.connector.WriteMessage(message)
157 {% endif %} 157 {% endif %}
158 {% endfor %} 158 {% endfor %}
159 default: 159 default:
160 return fmt.Errorf("unsupported request type %v", message.Header. Type); 160 return fmt.Errorf("unsupported request type %v", message.Header. Type);
161 } 161 }
162 return 162 return
163 } 163 }
164 164
165 {% endmacro %} 165 {% endmacro %}
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698