| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 # | 5 # |
| 6 # This module is responsible for translating a MojomFileGraph (see | 6 # This module is responsible for translating a MojomFileGraph (see |
| 7 # mojom_files.mojom) to one or more module.Module. | 7 # mojom_files.mojom) to one or more module.Module. |
| 8 # | 8 # |
| 9 # This module takes the output of the mojom parser, a MojomFileGraph and | 9 # This module takes the output of the mojom parser, a MojomFileGraph and |
| 10 # translates it to the input of the code generators, a module.Module object. | 10 # translates it to the input of the code generators, a module.Module object. |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 | 367 |
| 368 Args: | 368 Args: |
| 369 interface: {module.Interface} to be populated. | 369 interface: {module.Interface} to be populated. |
| 370 mojom_type: {UserDefinedType} referring to the MojomInterface to be | 370 mojom_type: {UserDefinedType} referring to the MojomInterface to be |
| 371 translated. | 371 translated. |
| 372 """ | 372 """ |
| 373 assert (mojom_type.tag | 373 assert (mojom_type.tag |
| 374 == mojom_types_mojom.UserDefinedType.Tags.interface_type) | 374 == mojom_types_mojom.UserDefinedType.Tags.interface_type) |
| 375 mojom_interface = mojom_type.interface_type | 375 mojom_interface = mojom_type.interface_type |
| 376 interface.attributes = self.AttributesFromMojom(mojom_interface) | 376 interface.attributes = self.AttributesFromMojom(mojom_interface) |
| 377 interface.service_name = None |
| 378 if interface.attributes: |
| 379 interface.service_name = interface.attributes.get('ServiceName') |
| 377 self.PopulateModuleOrImportedFrom(interface, mojom_interface) | 380 self.PopulateModuleOrImportedFrom(interface, mojom_interface) |
| 378 interface.name = mojom_interface.interface_name | 381 interface.name = mojom_interface.interface_name |
| 379 interface.methods = [self.MethodFromMojom(mojom_method, interface) | 382 interface.methods = [self.MethodFromMojom(mojom_method, interface) |
| 380 for mojom_method in mojom_interface.methods.itervalues()] | 383 for mojom_method in mojom_interface.methods.itervalues()] |
| 381 self.PopulateContainedDeclarationsFromMojom( | 384 self.PopulateContainedDeclarationsFromMojom( |
| 382 interface, mojom_interface.decl_data.contained_declarations) | 385 interface, mojom_interface.decl_data.contained_declarations) |
| 383 | 386 |
| 384 def MethodFromMojom(self, mojom_method, interface): | 387 def MethodFromMojom(self, mojom_method, interface): |
| 385 """Translates a mojom_types_mojom.MojomMethod to a module.Method. | 388 """Translates a mojom_types_mojom.MojomMethod to a module.Method. |
| 386 | 389 |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 | 766 |
| 764 Args: | 767 Args: |
| 765 graph: {mojom_types_mojom.MojomFileGraph} to be translated. | 768 graph: {mojom_types_mojom.MojomFileGraph} to be translated. |
| 766 | 769 |
| 767 Return: | 770 Return: |
| 768 {dict<str, module.Module>} mapping the file's name to its module.Module | 771 {dict<str, module.Module>} mapping the file's name to its module.Module |
| 769 translation for all files in graph.files. | 772 translation for all files in graph.files. |
| 770 """ | 773 """ |
| 771 return {file_name: FileTranslator(graph, file_name).Translate() | 774 return {file_name: FileTranslator(graph, file_name).Translate() |
| 772 for file_name in graph.files} | 775 for file_name in graph.files} |
| OLD | NEW |