Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(479)

Side by Side Diff: mojo/public/tools/bindings/pylib/mojom/generate/mojom_translator.py

Issue 1448123002: New Mojom Compiler: Do not prepend parent kind name to enum name. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Fix mojom_translator_unittest.py. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | mojo/public/tools/bindings/pylib/mojom/generate/mojom_translator_unittest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 enum: {module.Enum} to be populated. 243 enum: {module.Enum} to be populated.
244 mojom_type: {mojom_types_mojom.Type} referring to the MojomEnum to be 244 mojom_type: {mojom_types_mojom.Type} referring to the MojomEnum to be
245 translated. 245 translated.
246 """ 246 """
247 assert mojom_type.tag == mojom_types_mojom.UserDefinedType.Tags.enum_type 247 assert mojom_type.tag == mojom_types_mojom.UserDefinedType.Tags.enum_type
248 mojom_enum = mojom_type.enum_type 248 mojom_enum = mojom_type.enum_type
249 self.PopulateUserDefinedType(enum, mojom_enum) 249 self.PopulateUserDefinedType(enum, mojom_enum)
250 if mojom_enum.decl_data.container_type_key: 250 if mojom_enum.decl_data.container_type_key:
251 parent_kind = self.UserDefinedFromTypeKey( 251 parent_kind = self.UserDefinedFromTypeKey(
252 mojom_enum.decl_data.container_type_key) 252 mojom_enum.decl_data.container_type_key)
253 enum.name = '%s.%s' % (parent_kind.name, enum.name)
254 enum.parent_kind = parent_kind 253 enum.parent_kind = parent_kind
255 enum.fields = [self.EnumFieldFromMojom(value) 254 enum.fields = [self.EnumFieldFromMojom(value)
256 for value in mojom_enum.values] 255 for value in mojom_enum.values]
257 256
258 def EnumFieldFromMojom(self, mojom_enum_value): 257 def EnumFieldFromMojom(self, mojom_enum_value):
259 """Translates an mojom_types_mojom.EnumValue to a module.EnumField. 258 """Translates an mojom_types_mojom.EnumValue to a module.EnumField.
260 259
261 mojom_enum_value: {mojom_types_mojom.EnumValue} to be translated. 260 mojom_enum_value: {mojom_types_mojom.EnumValue} to be translated.
262 261
263 Returns: 262 Returns:
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 720
722 Args: 721 Args:
723 graph: {mojom_types_mojom.MojomFileGraph} to be translated. 722 graph: {mojom_types_mojom.MojomFileGraph} to be translated.
724 723
725 Return: 724 Return:
726 {dict<str, module.Module>} mapping the file's name to its module.Module 725 {dict<str, module.Module>} mapping the file's name to its module.Module
727 translation for all files in graph.files. 726 translation for all files in graph.files.
728 """ 727 """
729 return {file_name: FileTranslator(graph, file_name).Translate() 728 return {file_name: FileTranslator(graph, file_name).Translate()
730 for file_name in graph.files} 729 for file_name in graph.files}
OLDNEW
« no previous file with comments | « no previous file | mojo/public/tools/bindings/pylib/mojom/generate/mojom_translator_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698