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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 user_defined_types = ['interfaces', 'structs', 'unions'] | 78 user_defined_types = ['interfaces', 'structs', 'unions'] |
79 for user_defined_type in user_defined_types: | 79 for user_defined_type in user_defined_types: |
80 if getattr(mojom_file.declared_mojom_objects, user_defined_type): | 80 if getattr(mojom_file.declared_mojom_objects, user_defined_type): |
81 setattr(mod, user_defined_type, [self.UserDefinedFromTypeKey(key) | 81 setattr(mod, user_defined_type, [self.UserDefinedFromTypeKey(key) |
82 for key in getattr( | 82 for key in getattr( |
83 mojom_file.declared_mojom_objects, user_defined_type)]) | 83 mojom_file.declared_mojom_objects, user_defined_type)]) |
84 if mojom_file.declared_mojom_objects.top_level_enums: | 84 if mojom_file.declared_mojom_objects.top_level_enums: |
85 mod.enums = [self.UserDefinedFromTypeKey(key) | 85 mod.enums = [self.UserDefinedFromTypeKey(key) |
86 for key in mojom_file.declared_mojom_objects.top_level_enums] | 86 for key in mojom_file.declared_mojom_objects.top_level_enums] |
87 | 87 |
| 88 mod.serialized_runtime_type_info = mojom_file.serialized_runtime_type_info |
| 89 |
88 return mod | 90 return mod |
89 | 91 |
90 def PopulateModuleMetadata(self, mod, mojom_file): | 92 def PopulateModuleMetadata(self, mod, mojom_file): |
91 """Populates some fields of a module.Module based on a MojomFile. | 93 """Populates some fields of a module.Module based on a MojomFile. |
92 | 94 |
93 Populates name, path, namespace and attributes of mod. | 95 Populates name, path, namespace and attributes of mod. |
94 | 96 |
95 Args: | 97 Args: |
96 mod: {module.Module} the module to be populated. | 98 mod: {module.Module} the module to be populated. |
97 mojom_file: {MojomFile} the file to be translated. | 99 mojom_file: {MojomFile} the file to be translated. |
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
804 | 806 |
805 Args: | 807 Args: |
806 graph: {mojom_types_mojom.MojomFileGraph} to be translated. | 808 graph: {mojom_types_mojom.MojomFileGraph} to be translated. |
807 | 809 |
808 Return: | 810 Return: |
809 {dict<str, module.Module>} mapping the file's name to its module.Module | 811 {dict<str, module.Module>} mapping the file's name to its module.Module |
810 translation for all files in graph.files. | 812 translation for all files in graph.files. |
811 """ | 813 """ |
812 return {file_name: FileTranslator(graph, file_name).Translate() | 814 return {file_name: FileTranslator(graph, file_name).Translate() |
813 for file_name in graph.files} | 815 for file_name in graph.files} |
OLD | NEW |