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

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

Issue 1345263002: Generate Mojom Types in Go (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Use unexported functions instead of variables Created 5 years, 2 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 {% import "mojom_util_macros.tmpl" as util %}
6
7 {%- macro registerType(mapping, typepkg, pkg, t) -%}
azani 2015/10/12 21:13:07 t is type?
alexfandrianto 2015/10/16 21:25:49 Yes, it is a type (or kind).
azani 2015/10/19 18:27:02 Can you rename it to type or kind then?
alexfandrianto 2015/10/19 21:36:30 Done. I chose type
8 {%- if t|identifier(pkg)|identifier_check('RegisterType') -%}{# Already printed out #}
9 {%- elif t|package != '' -%} {# Don't print. That package will do it. #}
10 {%- else -%}
11 {{t|identifier(pkg)|identifier_store('RegisterType')}}
12
13 {%- if t|mojom_type(typepkg) != "" -%}{#- simple kind case: do nothing -#}
14 {%- elif t|is_array -%}
15 {{registerType(mapping, typepkg, pkg, t.kind)}}
16 {%- elif t|is_map -%}
17 {{registerType(mapping, typepkg, pkg, t.key_kind)}}
18 {{registerType(mapping, typepkg, pkg, t.value_kind)}}
19 {% elif t|is_enum %}
20 {{mapping}}["{{util.typeName(t, typepkg, pkg)}}"] = &{{typepkg}}UserDefinedTyp eEnumType{
21 Value: {{util.typeName(t, typepkg, pkg)}}(),
22 }
23 {% elif t|is_struct %}
24 {{mapping}}["{{util.typeName(t, typepkg, pkg)}}"] = &{{typepkg}}UserDefinedTyp eStructType{
25 Value: {{util.typeName(t, typepkg, pkg)}}(),
26 }
27 {% for field in t.fields %}
28 {{registerType(mapping, typepkg, pkg, field.kind)}}
29 {% endfor %}
30 {% elif t|is_union %}
31 {{mapping}}["{{util.typeName(t, typepkg, pkg)}}"] = &{{typepkg}}UserDefinedTyp eUnionType{
32 Value: {{util.typeName(t, typepkg, pkg)}}(),
33 }
34 {% for field in t.fields %}
35 {{registerType(mapping, typepkg, pkg, field.kind)}}
36 {% endfor %}
37 {% elif t|is_interface %}
38 {{mapping}}["{{util.typeName(t, typepkg, pkg)}}"] = &{{typepkg}}UserDefinedTyp eInterfaceType{
39 Value: {{util.typeName(t, typepkg, pkg)}}(),
40 }
41 {% for method in t.methods %}
42 {{registerType(mapping, typepkg, pkg, method.param_struct)}}
43 {% if method.response_parameters -%}
44 {{registerType(mapping, typepkg, pkg, method.response_param_struct)}}
45 {%- endif %}
46 {%- endfor %}
47 {% elif t|is_interface_request -%} {# No need to register anything #}
48 {%- else -%}
49 ERROR: UNSUPPORTED TYPE
50 {{t|identifier(pkg)}}
51 {%- endif -%}
52 {%- endif -%}
53 {%- endmacro -%}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698