| 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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 constant = mojom.Constant() | 311 constant = mojom.Constant() |
| 312 constant.name = data['name'] | 312 constant.name = data['name'] |
| 313 if parent_kind: | 313 if parent_kind: |
| 314 scope = (module.namespace, parent_kind.name) | 314 scope = (module.namespace, parent_kind.name) |
| 315 else: | 315 else: |
| 316 scope = (module.namespace, ) | 316 scope = (module.namespace, ) |
| 317 # TODO(mpcomplete): maybe we should only support POD kinds. | 317 # TODO(mpcomplete): maybe we should only support POD kinds. |
| 318 constant.kind = KindFromData(module.kinds, data['kind'], scope) | 318 constant.kind = KindFromData(module.kinds, data['kind'], scope) |
| 319 constant.value = FixupExpression(module, data.get('value'), scope, None) | 319 constant.value = FixupExpression(module, data.get('value'), scope, None) |
| 320 | 320 |
| 321 value = mojom.NamedValue(module, parent_kind, constant.name) | 321 value = mojom.ConstantValue(module, parent_kind, constant) |
| 322 module.values[value.GetSpec()] = value | 322 module.values[value.GetSpec()] = value |
| 323 return constant | 323 return constant |
| 324 | 324 |
| 325 def ModuleToData(module): | 325 def ModuleToData(module): |
| 326 return { | 326 return { |
| 327 istr(0, 'name'): module.name, | 327 istr(0, 'name'): module.name, |
| 328 istr(1, 'namespace'): module.namespace, | 328 istr(1, 'namespace'): module.namespace, |
| 329 istr(2, 'structs'): map(StructToData, module.structs), | 329 istr(2, 'structs'): map(StructToData, module.structs), |
| 330 istr(3, 'interfaces'): map(InterfaceToData, module.interfaces) | 330 istr(3, 'interfaces'): map(InterfaceToData, module.interfaces) |
| 331 } | 331 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 | 374 |
| 375 def OrderedModuleFromData(data): | 375 def OrderedModuleFromData(data): |
| 376 module = ModuleFromData(data) | 376 module = ModuleFromData(data) |
| 377 for interface in module.interfaces: | 377 for interface in module.interfaces: |
| 378 next_ordinal = 0 | 378 next_ordinal = 0 |
| 379 for method in interface.methods: | 379 for method in interface.methods: |
| 380 if method.ordinal is None: | 380 if method.ordinal is None: |
| 381 method.ordinal = next_ordinal | 381 method.ordinal = next_ordinal |
| 382 next_ordinal = method.ordinal + 1 | 382 next_ordinal = method.ordinal + 1 |
| 383 return module | 383 return module |
| OLD | NEW |