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

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

Issue 2855263002: Mojo bindings: support generating identifers using different style rules for different target langu…
Patch Set: . Created 3 years, 7 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 # 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 """Convert parse tree to AST. 5 """Convert parse tree to AST.
6 6
7 This module converts the parse tree to the AST we use for code generation. The 7 This module converts the parse tree to the AST we use for code generation. The
8 main entry point is OrderedModule, which gets passed the parser 8 main entry point is OrderedModule, which gets passed the parser
9 representation of a mojom file. When called it's assumed that all imports have 9 representation of a mojom file. When called it's assumed that all imports have
10 already been parsed and converted to ASTs before. 10 already been parsed and converted to ASTs before.
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 kind = copy.copy(original_kind) 228 kind = copy.copy(original_kind)
229 # |shared_definition| is used to store various properties (see 229 # |shared_definition| is used to store various properties (see
230 # |AddSharedProperty()| in module.py), including |imported_from|. We don't 230 # |AddSharedProperty()| in module.py), including |imported_from|. We don't
231 # want the copy to share these with the original, so copy it if necessary. 231 # want the copy to share these with the original, so copy it if necessary.
232 if hasattr(original_kind, 'shared_definition'): 232 if hasattr(original_kind, 'shared_definition'):
233 kind.shared_definition = copy.copy(original_kind.shared_definition) 233 kind.shared_definition = copy.copy(original_kind.shared_definition)
234 kind.imported_from = imported_from 234 kind.imported_from = imported_from
235 return kind 235 return kind
236 236
237 def _Import(module, import_module): 237 def _Import(module, import_module):
238 # TODO(yzshen): It seems redundant to have an extra layer. All the information
239 # is in |import_module| already.
238 import_item = {} 240 import_item = {}
239 import_item['module_name'] = import_module.name 241 import_item['module_name'] = import_module.name
240 import_item['namespace'] = import_module.namespace 242 import_item['namespace'] = import_module.namespace
241 import_item['module'] = import_module 243 import_item['module'] = import_module
242 244
243 # Copy the struct kinds from our imports into the current module. 245 # Copy the struct kinds from our imports into the current module.
244 importable_kinds = (mojom.Struct, mojom.Union, mojom.Enum, mojom.Interface) 246 importable_kinds = (mojom.Struct, mojom.Union, mojom.Enum, mojom.Interface)
245 for kind in import_module.kinds.itervalues(): 247 for kind in import_module.kinds.itervalues():
246 if (isinstance(kind, importable_kinds) and 248 if (isinstance(kind, importable_kinds) and
247 kind.imported_from is None): 249 kind.imported_from is None):
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 {mojom.Module} An AST for the mojom. 632 {mojom.Module} An AST for the mojom.
631 """ 633 """
632 module = _Module(tree, name, imports) 634 module = _Module(tree, name, imports)
633 for interface in module.interfaces: 635 for interface in module.interfaces:
634 next_ordinal = 0 636 next_ordinal = 0
635 for method in interface.methods: 637 for method in interface.methods:
636 if method.ordinal is None: 638 if method.ordinal is None:
637 method.ordinal = next_ordinal 639 method.ordinal = next_ordinal
638 next_ordinal = method.ordinal + 1 640 next_ordinal = method.ordinal + 1
639 return module 641 return module
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698