Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 -%} | |
| OLD | NEW |