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

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

Issue 272323003: Mojo: Implement support for |Foo&| mojom syntax (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 6 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 8 import ast
9 9
10 10
(...skipping 15 matching lines...) Expand all
26 'float': 'f', 26 'float': 'f',
27 'double': 'd', 27 'double': 'd',
28 'string': 's', 28 'string': 's',
29 'handle': 'h', 29 'handle': 'h',
30 'handle<data_pipe_consumer>': 'h:d:c', 30 'handle<data_pipe_consumer>': 'h:d:c',
31 'handle<data_pipe_producer>': 'h:d:p', 31 'handle<data_pipe_producer>': 'h:d:p',
32 'handle<message_pipe>': 'h:m', 32 'handle<message_pipe>': 'h:m',
33 'handle<shared_buffer>': 'h:s'} 33 'handle<shared_buffer>': 'h:s'}
34 if kind.endswith('[]'): 34 if kind.endswith('[]'):
35 return 'a:' + _MapKind(kind[0:len(kind)-2]) 35 return 'a:' + _MapKind(kind[0:len(kind)-2])
36 if kind.endswith('&'):
37 return 'r:' + _MapKind(kind[0:len(kind)-1])
36 if kind in map_to_kind: 38 if kind in map_to_kind:
37 return map_to_kind[kind] 39 return map_to_kind[kind]
38 return 'x:' + kind 40 return 'x:' + kind
39 41
40 def _MapAttributes(attributes): 42 def _MapAttributes(attributes):
41 if not attributes: 43 if not attributes:
42 return {} 44 return {}
43 return dict([(attribute[1], attribute[2]) 45 return dict([(attribute[1], attribute[2])
44 for attribute in attributes if attribute[0] == 'ATTRIBUTE']) 46 for attribute in attributes if attribute[0] == 'ATTRIBUTE'])
45 47
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 modules = [_MapModule(item, name) for item in tree if item[0] == 'MODULE'] 135 modules = [_MapModule(item, name) for item in tree if item[0] == 'MODULE']
134 if len(modules) != 1: 136 if len(modules) != 1:
135 raise Exception('A mojom file must contain exactly 1 module.') 137 raise Exception('A mojom file must contain exactly 1 module.')
136 self.mojom = modules[0] 138 self.mojom = modules[0]
137 self.mojom['imports'] = _MapTree(_MapImport, tree, 'IMPORT') 139 self.mojom['imports'] = _MapTree(_MapImport, tree, 'IMPORT')
138 return self.mojom 140 return self.mojom
139 141
140 142
141 def Translate(tree, name): 143 def Translate(tree, name):
142 return _MojomBuilder().Build(tree, name) 144 return _MojomBuilder().Build(tree, name)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698