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

Side by Side Diff: mojo/public/bindings/parser/mojo_translate.py

Issue 60013007: Mojo: Add support for float and double types in IDL files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 | « no previous file | 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 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2013 The Chromium Authors. All rights reserved. 2 # Copyright 2013 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 """Translate parse tree to Mojom IR""" 6 """Translate parse tree to Mojom IR"""
7 7
8 8
9 import sys 9 import sys
10 10
11 11
12 def MapKind(kind): 12 def MapKind(kind):
13 # todo: add more types
14 map_to_kind = { 'bool': 'b', 13 map_to_kind = { 'bool': 'b',
15 'int8': 'i8', 14 'int8': 'i8',
16 'int16': 'i16', 15 'int16': 'i16',
17 'int32': 'i32', 16 'int32': 'i32',
18 'int64': 'i64', 17 'int64': 'i64',
19 'uint8': 'u8', 18 'uint8': 'u8',
20 'uint16': 'u16', 19 'uint16': 'u16',
21 'uint32': 'u32', 20 'uint32': 'u32',
22 'uint64': 'u64', 21 'uint64': 'u64',
22 'float': 'f',
23 'double': 'd',
23 'string': 's', 24 'string': 's',
24 'handle': 'h' } 25 'handle': 'h' }
25 if kind.endswith('[]'): 26 if kind.endswith('[]'):
26 return 'a:' + MapKind(kind[0:len(kind)-2]) 27 return 'a:' + MapKind(kind[0:len(kind)-2])
27 if kind in map_to_kind: 28 if kind in map_to_kind:
28 return map_to_kind[kind] 29 return map_to_kind[kind]
29 return 'x:' + kind 30 return 'x:' + kind
30 31
31 32
32 def MapOrdinal(ordinal): 33 def MapOrdinal(ordinal):
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 if len(sys.argv) < 2: 107 if len(sys.argv) < 2:
107 print("usage: %s filename" % (sys.argv[0])) 108 print("usage: %s filename" % (sys.argv[0]))
108 sys.exit(1) 109 sys.exit(1)
109 tree = eval(open(sys.argv[1]).read()) 110 tree = eval(open(sys.argv[1]).read())
110 result = Translate(tree) 111 result = Translate(tree)
111 print(result) 112 print(result)
112 113
113 114
114 if __name__ == '__main__': 115 if __name__ == '__main__':
115 Main() 116 Main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698