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 writeMojomType(typepkg, type, pkg, exported=true, topLevel=true) -%} | 5 {%- macro writeMojomType(typepkg, type, pkg, exported=true, topLevel=true) -%} |
6 {%- if type|identifier|identifier_check('WriteMojomType') -%} {#- Already printe
d out -#} | 6 {%- if type|identifier|identifier_check('WriteMojomType') -%} {#- Already printe
d out -#} |
7 {{writeTypeTypeReference(typepkg, type, pkg)}} | 7 {{writeTypeTypeReference(typepkg, type, pkg)}} |
8 {%- else -%} | 8 {%- else -%} |
9 | 9 |
10 {%- if type|mojom_type(typepkg) != "" -%}{#- simple kind case -#} | 10 {%- if type|mojom_type(typepkg) != "" -%}{#- simple kind case -#} |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 {%- if type|package != '' -%}{{type|package}}.{%- endif -%}ID_{{type|mojom_type_
identifier}} | 61 {%- if type|package != '' -%}{{type|package}}.{%- endif -%}ID_{{type|mojom_type_
identifier}} |
62 {%- endmacro -%} | 62 {%- endmacro -%} |
63 | 63 |
64 | 64 |
65 {%- macro writeMojomTypeDef(typepkg, type, pkg, exported=True) -%} | 65 {%- macro writeMojomTypeDef(typepkg, type, pkg, exported=True) -%} |
66 {%- if should_gen_mojom_types -%} | 66 {%- if should_gen_mojom_types -%} |
67 {%- if type|is_enum -%} | 67 {%- if type|is_enum -%} |
68 // String names and labels used by the MojomEnum types. | 68 // String names and labels used by the MojomEnum types. |
69 var ( | 69 var ( |
70 enumName_{{type|name}} = "{{type|name}}" | 70 enumName_{{type|name}} = "{{type|name}}" |
| 71 enumFullIdentifier_{{type|name}} = "{{type|fullidentifier}}" |
71 {% for field in type.fields %} | 72 {% for field in type.fields %} |
72 enumFieldName_{{type|name}}_{{field|name}} = "{{field|name}}" | 73 enumFieldName_{{type|name}}_{{field|name}} = "{{field|name}}" |
73 {% endfor %} | 74 {% endfor %} |
74 ) | 75 ) |
75 | 76 |
76 func {{type|mojom_type_identifier}}() {{typepkg}}MojomEnum { | 77 func {{type|mojom_type_identifier}}() {{typepkg}}MojomEnum { |
77 return {{ writeMojomType(typepkg, type, pkg, exported) }} | 78 return {{ writeMojomType(typepkg, type, pkg, exported) }} |
78 } | 79 } |
79 {%- elif type|is_struct -%} | 80 {%- elif type|is_struct -%} |
80 // String names and labels used by the MojomStruct types. | 81 // String names and labels used by the MojomStruct types. |
81 var ( | 82 var ( |
82 structName_{{type|name}} = "{{type|name}}" | 83 structName_{{type|name}} = "{{type|name}}" |
| 84 structFullIdentifier_{{type|name}} = "{{type|fullidentifier}}" |
83 {% for field in type.fields %} | 85 {% for field in type.fields %} |
84 structFieldName_{{type|name}}_{{field|name}} = "{{field|name}}" | 86 structFieldName_{{type|name}}_{{field|name}} = "{{field|name}}" |
85 {% endfor %} | 87 {% endfor %} |
86 ) | 88 ) |
87 | 89 |
88 func {{type|mojom_type_identifier}}() {{typepkg}}MojomStruct { | 90 func {{type|mojom_type_identifier}}() {{typepkg}}MojomStruct { |
89 return {{ writeMojomType(typepkg, type, pkg, exported) }} | 91 return {{ writeMojomType(typepkg, type, pkg, exported) }} |
90 } | 92 } |
91 {%- elif type|is_union -%} | 93 {%- elif type|is_union -%} |
92 // String names and labels used by the MojomUnion types. | 94 // String names and labels used by the MojomUnion types. |
93 var ( | 95 var ( |
94 unionName_{{type|name}} = "{{type|name}}" | 96 unionName_{{type|name}} = "{{type|name}}" |
| 97 unionFullIdentifier_{{type|name}} = "{{type|fullidentifier}}" |
95 {% for field in type.fields %} | 98 {% for field in type.fields %} |
96 unionFieldName_{{type|name}}_{{field|name}} = "{{field|name}}" | 99 unionFieldName_{{type|name}}_{{field|name}} = "{{field|name}}" |
97 {% endfor %} | 100 {% endfor %} |
98 ) | 101 ) |
99 | 102 |
100 func {{type|mojom_type_identifier}}() {{typepkg}}MojomUnion { | 103 func {{type|mojom_type_identifier}}() {{typepkg}}MojomUnion { |
101 return {{ writeMojomType(typepkg, type, pkg, exported) }} | 104 return {{ writeMojomType(typepkg, type, pkg, exported) }} |
102 } | 105 } |
103 {%- elif type|is_interface -%} | 106 {%- elif type|is_interface -%} |
104 var ( | 107 var ( |
105 interfaceName_{{type|name}} = "{{type|name}}" | 108 interfaceName_{{type|name}} = "{{type|name}}" |
| 109 interfaceFullIdentifier_{{type|name}} = "{{type|fullidentifier}}" |
106 {% for method in type.methods %} | 110 {% for method in type.methods %} |
107 interfaceMethodName_{{type|name}}_{{method|name}} = "{{method|name}}" | 111 interfaceMethodName_{{type|name}}_{{method|name}} = "{{method|name}}" |
108 {% endfor %} | 112 {% endfor %} |
109 ) | 113 ) |
110 | 114 |
111 func {{type|mojom_type_identifier}}() {{typepkg}}MojomInterface { | 115 func {{type|mojom_type_identifier}}() {{typepkg}}MojomInterface { |
112 responseParamsMap := make(map[string]*{{typepkg}}MojomStruct) | 116 responseParamsMap := make(map[string]*{{typepkg}}MojomStruct) |
113 _ = responseParamsMap // To avoid the declared but unused compiler error | 117 _ = responseParamsMap // To avoid the declared but unused compiler error |
114 {% for method in type.methods %} | 118 {% for method in type.methods %} |
115 {% if method|has_response %} | 119 {% if method|has_response %} |
116 mstruct_{{method|name}} := {{method.response_param_struct|mojom_type_identifie
r}}() | 120 mstruct_{{method|name}} := {{method.response_param_struct|mojom_type_identifie
r}}() |
117 responseParamsMap[interfaceMethodName_{{type|name}}_{{method|name}}] = &mstruc
t_{{method|name}} | 121 responseParamsMap[interfaceMethodName_{{type|name}}_{{method|name}}] = &mstruc
t_{{method|name}} |
118 {% endif %} | 122 {% endif %} |
119 {% endfor %} | 123 {% endfor %} |
120 return {{typepkg}}MojomInterface{ | 124 return {{typepkg}}MojomInterface{ |
121 DeclData: &{{typepkg}}DeclarationData{ | 125 DeclData: &{{typepkg}}DeclarationData{ |
122 ShortName: &interfaceName_{{type|name}}, | 126 ShortName: &interfaceName_{{type|name}}, |
| 127 FullIdentifier: &interfaceFullIdentifier_{{type|name}}, |
123 }, | 128 }, |
124 Methods: map[uint32]{{typepkg}}MojomMethod{ | 129 Methods: map[uint32]{{typepkg}}MojomMethod{ |
125 {%- for method in type.methods -%} | 130 {%- for method in type.methods -%} |
126 {{type|name(False)}}_{{method|name}}_Name: {{typepkg}}MojomMethod{ | 131 {{type|name(False)}}_{{method|name}}_Name: {{typepkg}}MojomMethod{ |
127 DeclData: &{{typepkg}}DeclarationData{ | 132 DeclData: &{{typepkg}}DeclarationData{ |
128 ShortName: &interfaceMethodName_{{type|name}}_{{method|name}}, | 133 ShortName: &interfaceMethodName_{{type|name}}_{{method|name}}, |
129 }, | 134 }, |
130 Parameters: {{method.param_struct|mojom_type_identifier}}(), | 135 Parameters: {{method.param_struct|mojom_type_identifier}}(), |
131 ResponseParams: responseParamsMap[interfaceMethodName_{{type|name}}_{{me
thod|name}}], | 136 ResponseParams: responseParamsMap[interfaceMethodName_{{type|name}}_{{me
thod|name}}], |
132 }, | 137 }, |
(...skipping 30 matching lines...) Expand all Loading... |
163 KeyType: {{writeMojomType(typepkg, type.key_kind, pkg, exported, false)}}, | 168 KeyType: {{writeMojomType(typepkg, type.key_kind, pkg, exported, false)}}, |
164 ValueType: {{writeMojomType(typepkg, type.value_kind, pkg, exported, false
)}}, | 169 ValueType: {{writeMojomType(typepkg, type.value_kind, pkg, exported, false
)}}, |
165 }, | 170 }, |
166 } | 171 } |
167 {%- endmacro -%} | 172 {%- endmacro -%} |
168 | 173 |
169 {%- macro writeMojomEnumType(typepkg, type, pkg, exported) -%} | 174 {%- macro writeMojomEnumType(typepkg, type, pkg, exported) -%} |
170 {{typepkg}}MojomEnum{ | 175 {{typepkg}}MojomEnum{ |
171 DeclData: &{{typepkg}}DeclarationData{ | 176 DeclData: &{{typepkg}}DeclarationData{ |
172 ShortName: &enumName_{{type|name}}, | 177 ShortName: &enumName_{{type|name}}, |
| 178 FullIdentifier: &enumFullIdentifier_{{type|name}}, |
173 }, | 179 }, |
174 Values: []{{typepkg}}EnumValue{ | 180 Values: []{{typepkg}}EnumValue{ |
175 {%- for field in type.fields -%} | 181 {%- for field in type.fields -%} |
176 {{typepkg}}EnumValue{ | 182 {{typepkg}}EnumValue{ |
177 DeclData: &{{typepkg}}DeclarationData{ | 183 DeclData: &{{typepkg}}DeclarationData{ |
178 ShortName: &enumFieldName_{{type|name}}_{{field|name}}, | 184 ShortName: &enumFieldName_{{type|name}}_{{field|name}}, |
179 }, | 185 }, |
180 EnumTypeKey: {{writePackagedTypeID(typepkg, type, pkg)}}, | 186 EnumTypeKey: {{writePackagedTypeID(typepkg, type, pkg)}}, |
181 IntValue: int32({{field.numeric_value}}), | 187 IntValue: int32({{field.numeric_value}}), |
182 }, | 188 }, |
183 {%- endfor -%} | 189 {%- endfor -%} |
184 }, | 190 }, |
185 } | 191 } |
186 {%- endmacro -%} | 192 {%- endmacro -%} |
187 | 193 |
188 | 194 |
189 {%- macro writeMojomStructType(typepkg, type, pkg, exported) -%} | 195 {%- macro writeMojomStructType(typepkg, type, pkg, exported) -%} |
190 {{typepkg}}MojomStruct{ | 196 {{typepkg}}MojomStruct{ |
191 DeclData: &{{typepkg}}DeclarationData{ | 197 DeclData: &{{typepkg}}DeclarationData{ |
192 ShortName: &structName_{{type|name}}, | 198 ShortName: &structName_{{type|name}}, |
| 199 FullIdentifier: &structFullIdentifier_{{type|name}}, |
193 }, | 200 }, |
194 {%- if type|is_nullable -%} | 201 {%- if type|is_nullable -%} |
195 Nullable: true, | 202 Nullable: true, |
196 {%- endif -%} | 203 {%- endif -%} |
197 Fields: []{{typepkg}}StructField{ | 204 Fields: []{{typepkg}}StructField{ |
198 {%- for field in type.fields -%} | 205 {%- for field in type.fields -%} |
199 {{typepkg}}StructField{ | 206 {{typepkg}}StructField{ |
200 DeclData: &{{typepkg}}DeclarationData{ | 207 DeclData: &{{typepkg}}DeclarationData{ |
201 ShortName: &structFieldName_{{type|name}}_{{field|name}}, | 208 ShortName: &structFieldName_{{type|name}}_{{field|name}}, |
202 }, | 209 }, |
203 Type: {{writeMojomType(typepkg, field.kind, pkg, exported, false)}}, | 210 Type: {{writeMojomType(typepkg, field.kind, pkg, exported, false)}}, |
204 }, | 211 }, |
205 {%- endfor -%} | 212 {%- endfor -%} |
206 }, | 213 }, |
207 } | 214 } |
208 {%- endmacro -%} | 215 {%- endmacro -%} |
209 | 216 |
210 | 217 |
211 {%- macro writeMojomUnionType(typepkg, type, pkg, exported) -%} | 218 {%- macro writeMojomUnionType(typepkg, type, pkg, exported) -%} |
212 {{typepkg}}MojomUnion{ | 219 {{typepkg}}MojomUnion{ |
213 DeclData: &{{typepkg}}DeclarationData{ | 220 DeclData: &{{typepkg}}DeclarationData{ |
214 ShortName: &unionName_{{type|name}}, | 221 ShortName: &unionName_{{type|name}}, |
| 222 FullIdentifier: &unionFullIdentifier_{{type|name}}, |
215 }, | 223 }, |
216 {%- if type|is_nullable -%} | 224 {%- if type|is_nullable -%} |
217 Nullable: true, | 225 Nullable: true, |
218 {%- endif -%} | 226 {%- endif -%} |
219 Fields: []{{typepkg}}UnionField{ | 227 Fields: []{{typepkg}}UnionField{ |
220 {%- for field in type.fields -%} | 228 {%- for field in type.fields -%} |
221 {{typepkg}}UnionField{ | 229 {{typepkg}}UnionField{ |
222 DeclData: &{{typepkg}}DeclarationData{ | 230 DeclData: &{{typepkg}}DeclarationData{ |
223 ShortName: &unionFieldName_{{type|name}}_{{field|name}}, | 231 ShortName: &unionFieldName_{{type|name}}_{{field|name}}, |
224 }, | 232 }, |
225 Type: {{writeMojomType(typepkg, field.kind, pkg, exported, false)}}, | 233 Type: {{writeMojomType(typepkg, field.kind, pkg, exported, false)}}, |
226 Tag: {{field.ordinal}}, | 234 Tag: {{field.ordinal}}, |
227 }, | 235 }, |
228 {%- endfor -%} | 236 {%- endfor -%} |
229 }, | 237 }, |
230 } | 238 } |
231 {%- endmacro -%} | 239 {%- endmacro -%} |
OLD | NEW |