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

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

Issue 395203003: Mojo: Mojom: Remove some dead code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « mojo/public/tools/bindings/pylib/mojom/parse/parser.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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 """Translates parse tree to Mojom IR.""" 5 """Translates parse tree to Mojom IR."""
6 6
7 7
8 import ast 8 import ast
9 import re 9 import re
10 10
11 11
12 def _MapTreeForName(func, tree, name):
13 assert isinstance(name, str)
14 if not tree:
15 return []
16 return [func(subtree) for subtree in tree \
17 if isinstance(subtree, tuple) and subtree[0] == name]
18
19 def _MapTreeForType(func, tree, type_to_map): 12 def _MapTreeForType(func, tree, type_to_map):
20 assert isinstance(type_to_map, type) 13 assert isinstance(type_to_map, type)
21 if not tree: 14 if not tree:
22 return [] 15 return []
23 return [func(subtree) for subtree in tree if isinstance(subtree, type_to_map)] 16 return [func(subtree) for subtree in tree if isinstance(subtree, type_to_map)]
24 17
25 _FIXED_ARRAY_REGEXP = re.compile(r'\[[0-9]+\]') 18 _FIXED_ARRAY_REGEXP = re.compile(r'\[[0-9]+\]')
26 19
27 def _MapKind(kind): 20 def _MapKind(kind):
28 map_to_kind = {'bool': 'b', 21 map_to_kind = {'bool': 'b',
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 _MapTreeForType(InterfaceToDict, tree.definition_list, ast.Interface) 141 _MapTreeForType(InterfaceToDict, tree.definition_list, ast.Interface)
149 self.mojom['enums'] = \ 142 self.mojom['enums'] = \
150 _MapTreeForType(_EnumToDict, tree.definition_list, ast.Enum) 143 _MapTreeForType(_EnumToDict, tree.definition_list, ast.Enum)
151 self.mojom['constants'] = \ 144 self.mojom['constants'] = \
152 _MapTreeForType(_ConstToDict, tree.definition_list, ast.Const) 145 _MapTreeForType(_ConstToDict, tree.definition_list, ast.Const)
153 return self.mojom 146 return self.mojom
154 147
155 148
156 def Translate(tree, name): 149 def Translate(tree, name):
157 return _MojomBuilder().Build(tree, name) 150 return _MojomBuilder().Build(tree, name)
OLDNEW
« no previous file with comments | « mojo/public/tools/bindings/pylib/mojom/parse/parser.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698