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

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

Issue 443293003: Mojo: Add PRESUBMIT.py to mojo/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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
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
9 import re 8 import re
10 9
10 from . import ast
11
11 12
12 def _MapTreeForType(func, tree, type_to_map): 13 def _MapTreeForType(func, tree, type_to_map):
13 assert isinstance(type_to_map, type) 14 assert isinstance(type_to_map, type)
14 if not tree: 15 if not tree:
15 return [] 16 return []
16 return [func(subtree) for subtree in tree if isinstance(subtree, type_to_map)] 17 return [func(subtree) for subtree in tree if isinstance(subtree, type_to_map)]
17 18
18 _FIXED_ARRAY_REGEXP = re.compile(r'\[[0-9]+\]') 19 _FIXED_ARRAY_REGEXP = re.compile(r'\[[0-9]+\]')
19 20
20 def _MapKind(kind): 21 def _MapKind(kind):
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 _MapTreeForType(InterfaceToDict, tree.definition_list, ast.Interface) 142 _MapTreeForType(InterfaceToDict, tree.definition_list, ast.Interface)
142 self.mojom['enums'] = \ 143 self.mojom['enums'] = \
143 _MapTreeForType(_EnumToDict, tree.definition_list, ast.Enum) 144 _MapTreeForType(_EnumToDict, tree.definition_list, ast.Enum)
144 self.mojom['constants'] = \ 145 self.mojom['constants'] = \
145 _MapTreeForType(_ConstToDict, tree.definition_list, ast.Const) 146 _MapTreeForType(_ConstToDict, tree.definition_list, ast.Const)
146 return self.mojom 147 return self.mojom
147 148
148 149
149 def Translate(tree, name): 150 def Translate(tree, name):
150 return _MojomBuilder().Build(tree, name) 151 return _MojomBuilder().Build(tree, name)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698