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 import mojom | 5 import mojom |
6 import copy | 6 import copy |
7 | 7 |
8 # mojom_data provides a mechanism to turn mojom Modules to dictionaries and | 8 # mojom_data provides a mechanism to turn mojom Modules to dictionaries and |
9 # back again. This can be used to persist a mojom Module created progromatically | 9 # back again. This can be used to persist a mojom Module created progromatically |
10 # or to read a dictionary from code or a file. | 10 # or to read a dictionary from code or a file. |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 | 205 |
206 def MethodFromData(module, data, interface): | 206 def MethodFromData(module, data, interface): |
207 method = mojom.Method() | 207 method = mojom.Method() |
208 method.name = data['name'] | 208 method.name = data['name'] |
209 method.ordinal = data.get('ordinal') | 209 method.ordinal = data.get('ordinal') |
210 method.default = data.get('default') | 210 method.default = data.get('default') |
211 method.parameters = map(lambda parameter: | 211 method.parameters = map(lambda parameter: |
212 ParameterFromData(module, parameter, interface), data['parameters']) | 212 ParameterFromData(module, parameter, interface), data['parameters']) |
213 if data.has_key('response_parameters'): | 213 if data.has_key('response_parameters'): |
214 method.response_parameters = map( | 214 method.response_parameters = map( |
215 lambda parameter: ParameterFromData(kinds, parameter), | 215 lambda parameter: ParameterFromData(module, parameter, interface), |
216 data['response_parameters']) | 216 data['response_parameters']) |
217 return method | 217 return method |
218 | 218 |
219 def InterfaceToData(interface): | 219 def InterfaceToData(interface): |
220 return { | 220 return { |
221 istr(0, 'name'): interface.name, | 221 istr(0, 'name'): interface.name, |
222 istr(1, 'peer'): interface.peer, | 222 istr(1, 'peer'): interface.peer, |
223 istr(2, 'methods'): map(MethodToData, interface.methods) | 223 istr(2, 'methods'): map(MethodToData, interface.methods) |
224 } | 224 } |
225 | 225 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 def OrderedModuleFromData(data): | 299 def OrderedModuleFromData(data): |
300 module = ModuleFromData(data) | 300 module = ModuleFromData(data) |
301 next_interface_ordinal = 0 | 301 next_interface_ordinal = 0 |
302 for interface in module.interfaces: | 302 for interface in module.interfaces: |
303 next_ordinal = 0 | 303 next_ordinal = 0 |
304 for method in interface.methods: | 304 for method in interface.methods: |
305 if method.ordinal is None: | 305 if method.ordinal is None: |
306 method.ordinal = next_ordinal | 306 method.ordinal = next_ordinal |
307 next_ordinal = method.ordinal + 1 | 307 next_ordinal = method.ordinal + 1 |
308 return module | 308 return module |
OLD | NEW |