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

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

Issue 63763003: Mojo: Accept IDL files that lack explicit ordinals. (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
(...skipping 13 matching lines...) Expand all
24 'string': 's', 24 'string': 's',
25 'handle': 'h' } 25 'handle': 'h' }
26 if kind.endswith('[]'): 26 if kind.endswith('[]'):
27 return 'a:' + MapKind(kind[0:len(kind)-2]) 27 return 'a:' + MapKind(kind[0:len(kind)-2])
28 if kind in map_to_kind: 28 if kind in map_to_kind:
29 return map_to_kind[kind] 29 return map_to_kind[kind]
30 return 'x:' + kind 30 return 'x:' + kind
31 31
32 32
33 def MapOrdinal(ordinal): 33 def MapOrdinal(ordinal):
34 if ordinal == None:
35 return None;
34 return int(ordinal[1:]) # Strip leading '@' 36 return int(ordinal[1:]) # Strip leading '@'
35 37
36 38
37 def MapFields(fields): 39 def MapFields(fields):
38 out = [] 40 out = []
39 for field in fields: 41 for field in fields:
40 if field[0] == 'FIELD': 42 if field[0] == 'FIELD':
41 out.append({'name': field[2], 43 out.append({'name': field[2],
42 'kind': MapKind(field[1]), 44 'kind': MapKind(field[1]),
43 'ordinal': MapOrdinal(field[3])}) 45 'ordinal': MapOrdinal(field[3])})
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 if len(sys.argv) < 2: 109 if len(sys.argv) < 2:
108 print("usage: %s filename" % (sys.argv[0])) 110 print("usage: %s filename" % (sys.argv[0]))
109 sys.exit(1) 111 sys.exit(1)
110 tree = eval(open(sys.argv[1]).read()) 112 tree = eval(open(sys.argv[1]).read())
111 result = Translate(tree) 113 result = Translate(tree)
112 print(result) 114 print(result)
113 115
114 116
115 if __name__ == '__main__': 117 if __name__ == '__main__':
116 Main() 118 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