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

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

Issue 1677343002: mojom_types.mojom: Changes the name |interface_name| to |service_name| in struct MojomInterface. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Responds to code review. Created 4 years, 10 months 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
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 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 386
387 Args: 387 Args:
388 interface: {module.Interface} to be populated. 388 interface: {module.Interface} to be populated.
389 mojom_type: {UserDefinedType} referring to the MojomInterface to be 389 mojom_type: {UserDefinedType} referring to the MojomInterface to be
390 translated. 390 translated.
391 """ 391 """
392 assert (mojom_type.tag 392 assert (mojom_type.tag
393 == mojom_types_mojom.UserDefinedType.Tags.interface_type) 393 == mojom_types_mojom.UserDefinedType.Tags.interface_type)
394 mojom_interface = mojom_type.interface_type 394 mojom_interface = mojom_type.interface_type
395 interface.attributes = self.AttributesFromMojom(mojom_interface) 395 interface.attributes = self.AttributesFromMojom(mojom_interface)
396 interface.service_name = None 396 self.PopulateModuleOrImportedFrom(interface, mojom_interface)
397 interface.name = mojom_interface.decl_data.short_name
398 interface.spec = interface.name
399 interface.service_name = mojom_interface.service_name
397 if interface.attributes: 400 if interface.attributes:
398 interface.service_name = interface.attributes.get('ServiceName') 401 assert interface.service_name == interface.attributes.get(
399 self.PopulateModuleOrImportedFrom(interface, mojom_interface) 402 'ServiceName', None), interface.service_name
400 interface.name = mojom_interface.interface_name 403 else:
401 interface.spec = interface.name 404 assert interface.service_name is None, interface.service_name
405
402 406
403 # Translate the dictionary of methods into a list of module.Methods. 407 # Translate the dictionary of methods into a list of module.Methods.
404 # In order to have a deterministic ordering we sort by method ordinal. 408 # In order to have a deterministic ordering we sort by method ordinal.
405 # TODO(rudominer) Consider ordering by declaration order instead once 409 # TODO(rudominer) Consider ordering by declaration order instead once
406 # this field is populated by the front-end. 410 # this field is populated by the front-end.
407 interface.methods = [self.MethodFromMojom(mojom_method, interface) 411 interface.methods = [self.MethodFromMojom(mojom_method, interface)
408 for ordinal, mojom_method in sorted(mojom_interface.methods.iteritems(), 412 for ordinal, mojom_method in sorted(mojom_interface.methods.iteritems(),
409 key=operator.itemgetter(0))] 413 key=operator.itemgetter(0))]
410 self.PopulateContainedDeclarationsFromMojom( 414 self.PopulateContainedDeclarationsFromMojom(
411 interface, mojom_interface.decl_data.contained_declarations) 415 interface, mojom_interface.decl_data.contained_declarations)
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 804
801 Args: 805 Args:
802 graph: {mojom_types_mojom.MojomFileGraph} to be translated. 806 graph: {mojom_types_mojom.MojomFileGraph} to be translated.
803 807
804 Return: 808 Return:
805 {dict<str, module.Module>} mapping the file's name to its module.Module 809 {dict<str, module.Module>} mapping the file's name to its module.Module
806 translation for all files in graph.files. 810 translation for all files in graph.files.
807 """ 811 """
808 return {file_name: FileTranslator(graph, file_name).Translate() 812 return {file_name: FileTranslator(graph, file_name).Translate()
809 for file_name in graph.files} 813 for file_name in graph.files}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698