| 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 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 interface.name = data['name'] | 351 interface.name = data['name'] |
| 352 interface.spec = 'x:' + module.namespace + '.' + interface.name | 352 interface.spec = 'x:' + module.namespace + '.' + interface.name |
| 353 module.kinds[interface.spec] = interface | 353 module.kinds[interface.spec] = interface |
| 354 interface.enums = map(lambda enum: | 354 interface.enums = map(lambda enum: |
| 355 EnumFromData(module, enum, interface), data['enums']) | 355 EnumFromData(module, enum, interface), data['enums']) |
| 356 interface.constants = map(lambda constant: | 356 interface.constants = map(lambda constant: |
| 357 ConstantFromData(module, constant, interface), data['constants']) | 357 ConstantFromData(module, constant, interface), data['constants']) |
| 358 # Stash methods data here temporarily. | 358 # Stash methods data here temporarily. |
| 359 interface.methods_data = data['methods'] | 359 interface.methods_data = data['methods'] |
| 360 interface.attributes = data.get('attributes') | 360 interface.attributes = data.get('attributes') |
| 361 interface.service_name = None |
| 362 if interface.attributes: |
| 363 interface.service_name = interface.attributes.get('ServiceName') |
| 361 return interface | 364 return interface |
| 362 | 365 |
| 363 def EnumFieldFromData(module, enum, data, parent_kind): | 366 def EnumFieldFromData(module, enum, data, parent_kind): |
| 364 field = mojom.EnumField() | 367 field = mojom.EnumField() |
| 365 field.name = data['name'] | 368 field.name = data['name'] |
| 366 # TODO(mpcomplete): FixupExpression should be done in the second pass, | 369 # TODO(mpcomplete): FixupExpression should be done in the second pass, |
| 367 # so constants and enums can refer to each other. | 370 # so constants and enums can refer to each other. |
| 368 # TODO(mpcomplete): But then, what if constants are initialized to an enum? Or | 371 # TODO(mpcomplete): But then, what if constants are initialized to an enum? Or |
| 369 # vice versa? | 372 # vice versa? |
| 370 if parent_kind: | 373 if parent_kind: |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 | 508 |
| 506 def OrderedModuleFromData(data): | 509 def OrderedModuleFromData(data): |
| 507 module = ModuleFromData(data) | 510 module = ModuleFromData(data) |
| 508 for interface in module.interfaces: | 511 for interface in module.interfaces: |
| 509 next_ordinal = 0 | 512 next_ordinal = 0 |
| 510 for method in interface.methods: | 513 for method in interface.methods: |
| 511 if method.ordinal is None: | 514 if method.ordinal is None: |
| 512 method.ordinal = next_ordinal | 515 method.ordinal = next_ordinal |
| 513 next_ordinal = method.ordinal + 1 | 516 next_ordinal = method.ordinal + 1 |
| 514 return module | 517 return module |
| OLD | NEW |