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