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 {%- macro registerType(mapping, typepkg, pkg, t) -%} |
| 6 {%- if t|identifier(pkg)|identifier_check('RegisterType') -%}{# Already printed
out #} |
| 7 {%- elif t|package != '' -%} {# Don't print. That package will do it. #} |
| 8 {%- else -%} |
| 9 {{t|identifier(pkg)|identifier_store('RegisterType')}} |
| 10 |
| 11 {%- if t|mojom_type(typepkg) != "" -%}{#- simple kind case: do nothing -#} |
| 12 {%- elif t|is_array -%} |
| 13 {{registerType(mapping, typepkg, pkg, t.kind)}} |
| 14 {%- elif t|is_map -%} |
| 15 {{registerType(mapping, typepkg, pkg, t.key_kind)}} |
| 16 {{registerType(mapping, typepkg, pkg, t.value_kind)}} |
| 17 {% elif t|is_enum %} |
| 18 {{mapping}}["{{t|mojom_type_identifier(pkg)}}"] = &{{typepkg}}UserDefinedTypeE
numType{ |
| 19 Value: {{t|mojom_type_identifier(pkg)}}(), |
| 20 } |
| 21 {% elif t|is_struct %} |
| 22 {{mapping}}["{{t|mojom_type_identifier(pkg)}}"] = &{{typepkg}}UserDefinedTypeS
tructType{ |
| 23 Value: {{t|mojom_type_identifier(pkg)}}(), |
| 24 } |
| 25 {% for field in t.fields %} |
| 26 {{registerType(mapping, typepkg, pkg, field.kind)}} |
| 27 {% endfor %} |
| 28 {% elif t|is_union %} |
| 29 {{mapping}}["{{t|mojom_type_identifier(pkg)}}"] = &{{typepkg}}UserDefinedTypeU
nionType{ |
| 30 Value: {{t|mojom_type_identifier(pkg)}}(), |
| 31 } |
| 32 {% for field in t.fields %} |
| 33 {{registerType(mapping, typepkg, pkg, field.kind)}} |
| 34 {% endfor %} |
| 35 {% elif t|is_interface %} |
| 36 {{mapping}}["{{t|mojom_type_identifier(pkg)}}"] = &{{typepkg}}UserDefinedTypeI
nterfaceType{ |
| 37 Value: {{t|mojom_type_identifier(pkg)}}(), |
| 38 } |
| 39 {% for method in t.methods %} |
| 40 {{registerType(mapping, typepkg, pkg, method.param_struct)}} |
| 41 {% if method.response_parameters -%} |
| 42 {{registerType(mapping, typepkg, pkg, method.response_param_struct)}} |
| 43 {%- endif %} |
| 44 {%- endfor %} |
| 45 {% elif t|is_interface_request -%} {# No need to register anything #} |
| 46 {%- else -%} |
| 47 ERROR: UNSUPPORTED TYPE |
| 48 {{t|identifier(pkg)}} |
| 49 {%- endif -%} |
| 50 {%- endif -%} |
| 51 {%- endmacro -%} |
OLD | NEW |