OLD | NEW |
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 # TODO(vtl): "data" is a pretty vague name. Rename it? | 5 # TODO(vtl): "data" is a pretty vague name. Rename it? |
6 | 6 |
7 import copy | 7 import copy |
8 | 8 |
9 import module as mojom | 9 import module as mojom |
10 | 10 |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 # TODO(yzshen): EnumToData() and ConstantToData() are missing. | 202 # TODO(yzshen): EnumToData() and ConstantToData() are missing. |
203 istr(2, 'enums'): [], | 203 istr(2, 'enums'): [], |
204 istr(3, 'constants'): [] | 204 istr(3, 'constants'): [] |
205 } | 205 } |
206 AddOptional(data, istr(4, 'attributes'), struct.attributes) | 206 AddOptional(data, istr(4, 'attributes'), struct.attributes) |
207 return data | 207 return data |
208 | 208 |
209 def StructFromData(module, data): | 209 def StructFromData(module, data): |
210 struct = mojom.Struct(module=module) | 210 struct = mojom.Struct(module=module) |
211 struct.name = data['name'] | 211 struct.name = data['name'] |
| 212 struct.native_only = data['native_only'] |
212 struct.spec = 'x:' + module.namespace + '.' + struct.name | 213 struct.spec = 'x:' + module.namespace + '.' + struct.name |
213 module.kinds[struct.spec] = struct | 214 module.kinds[struct.spec] = struct |
214 struct.enums = map(lambda enum: | 215 if struct.native_only: |
215 EnumFromData(module, enum, struct), data['enums']) | 216 struct.enums = [] |
216 struct.constants = map(lambda constant: | 217 struct.constants = [] |
217 ConstantFromData(module, constant, struct), data['constants']) | 218 struct.fields_data = [] |
218 # Stash fields data here temporarily. | 219 else: |
219 struct.fields_data = data['fields'] | 220 struct.enums = map(lambda enum: |
| 221 EnumFromData(module, enum, struct), data['enums']) |
| 222 struct.constants = map(lambda constant: |
| 223 ConstantFromData(module, constant, struct), data['constants']) |
| 224 # Stash fields data here temporarily. |
| 225 struct.fields_data = data['fields'] |
220 struct.attributes = data.get('attributes') | 226 struct.attributes = data.get('attributes') |
221 return struct | 227 return struct |
222 | 228 |
223 def UnionToData(union): | 229 def UnionToData(union): |
224 data = { | 230 data = { |
225 istr(0, 'name'): union.name, | 231 istr(0, 'name'): union.name, |
226 istr(1, 'fields'): map(FieldToData, union.fields) | 232 istr(1, 'fields'): map(FieldToData, union.fields) |
227 } | 233 } |
228 AddOptional(data, istr(2, 'attributes'), union.attributes) | 234 AddOptional(data, istr(2, 'attributes'), union.attributes) |
229 return data | 235 return data |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 | 485 |
480 def OrderedModuleFromData(data): | 486 def OrderedModuleFromData(data): |
481 module = ModuleFromData(data) | 487 module = ModuleFromData(data) |
482 for interface in module.interfaces: | 488 for interface in module.interfaces: |
483 next_ordinal = 0 | 489 next_ordinal = 0 |
484 for method in interface.methods: | 490 for method in interface.methods: |
485 if method.ordinal is None: | 491 if method.ordinal is None: |
486 method.ordinal = next_ordinal | 492 method.ordinal = next_ordinal |
487 next_ordinal = method.ordinal + 1 | 493 next_ordinal = method.ordinal + 1 |
488 return module | 494 return module |
OLD | NEW |