OLD | NEW |
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 os | 9 import os |
10 import sys | 10 import sys |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 'kind': self.MapKind(parameter[1]), | 74 'kind': self.MapKind(parameter[1]), |
75 'ordinal': self.MapOrdinal(parameter[3])}) | 75 'ordinal': self.MapOrdinal(parameter[3])}) |
76 return out | 76 return out |
77 | 77 |
78 | 78 |
79 def MapMethods(self, methods): | 79 def MapMethods(self, methods): |
80 out = [] | 80 out = [] |
81 if methods: | 81 if methods: |
82 for method in methods: | 82 for method in methods: |
83 if method[0] == 'METHOD': | 83 if method[0] == 'METHOD': |
84 out.append({'name': method[1], | 84 method_dict = {'name': method[1], |
85 'parameters': self.MapParameters(method[2]), | 85 'parameters': self.MapParameters(method[2]), |
86 'ordinal': self.MapOrdinal(method[3])}) | 86 'ordinal': self.MapOrdinal(method[3])} |
| 87 if method[4] != None: |
| 88 method_dict['response_parameters'] = self.MapParameters(method[4]) |
| 89 out.append(method_dict) |
87 return out | 90 return out |
88 | 91 |
89 | 92 |
90 def MapEnumFields(self, fields): | 93 def MapEnumFields(self, fields): |
91 out = [] | 94 out = [] |
92 for field in fields: | 95 for field in fields: |
93 if field[0] == 'ENUM_FIELD': | 96 if field[0] == 'ENUM_FIELD': |
94 out.append({'name': field[1], | 97 out.append({'name': field[1], |
95 'value': field[2]}) | 98 'value': field[2]}) |
96 return out | 99 return out |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 print("usage: %s filename" % (sys.argv[0])) | 172 print("usage: %s filename" % (sys.argv[0])) |
170 sys.exit(1) | 173 sys.exit(1) |
171 tree = eval(open(sys.argv[1]).read()) | 174 tree = eval(open(sys.argv[1]).read()) |
172 name = os.path.splitext(os.path.basename(sys.argv[1]))[0] | 175 name = os.path.splitext(os.path.basename(sys.argv[1]))[0] |
173 result = Translate(tree, name) | 176 result = Translate(tree, name) |
174 print(result) | 177 print(result) |
175 | 178 |
176 | 179 |
177 if __name__ == '__main__': | 180 if __name__ == '__main__': |
178 Main() | 181 Main() |
OLD | NEW |