| 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 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 module.imports = map( | 377 module.imports = map( |
| 378 lambda import_data: ImportFromData(module, import_data), | 378 lambda import_data: ImportFromData(module, import_data), |
| 379 data['imports']) | 379 data['imports']) |
| 380 | 380 |
| 381 # First pass collects kinds. | 381 # First pass collects kinds. |
| 382 module.enums = map( | 382 module.enums = map( |
| 383 lambda enum: EnumFromData(module, enum, None), data['enums']) | 383 lambda enum: EnumFromData(module, enum, None), data['enums']) |
| 384 module.structs = map( | 384 module.structs = map( |
| 385 lambda struct: StructFromData(module, struct), data['structs']) | 385 lambda struct: StructFromData(module, struct), data['structs']) |
| 386 module.unions = map( | 386 module.unions = map( |
| 387 lambda union: UnionFromData(module, union), data.get('unions', [])) | 387 lambda union: UnionFromData(module, struct), data.get('unions', [])) |
| 388 module.interfaces = map( | 388 module.interfaces = map( |
| 389 lambda interface: InterfaceFromData(module, interface), | 389 lambda interface: InterfaceFromData(module, interface), |
| 390 data['interfaces']) | 390 data['interfaces']) |
| 391 module.constants = map( | 391 module.constants = map( |
| 392 lambda constant: ConstantFromData(module, constant, None), | 392 lambda constant: ConstantFromData(module, constant, None), |
| 393 data['constants']) | 393 data['constants']) |
| 394 | 394 |
| 395 # Second pass expands fields and methods. This allows fields and parameters | 395 # Second pass expands fields and methods. This allows fields and parameters |
| 396 # to refer to kinds defined anywhere in the mojom. | 396 # to refer to kinds defined anywhere in the mojom. |
| 397 for struct in module.structs: | 397 for struct in module.structs: |
| (...skipping 13 matching lines...) Expand all Loading... |
| 411 | 411 |
| 412 def OrderedModuleFromData(data): | 412 def OrderedModuleFromData(data): |
| 413 module = ModuleFromData(data) | 413 module = ModuleFromData(data) |
| 414 for interface in module.interfaces: | 414 for interface in module.interfaces: |
| 415 next_ordinal = 0 | 415 next_ordinal = 0 |
| 416 for method in interface.methods: | 416 for method in interface.methods: |
| 417 if method.ordinal is None: | 417 if method.ordinal is None: |
| 418 method.ordinal = next_ordinal | 418 method.ordinal = next_ordinal |
| 419 next_ordinal = method.ordinal + 1 | 419 next_ordinal = method.ordinal + 1 |
| 420 return module | 420 return module |
| OLD | NEW |