OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 2 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
3 # for details. All rights reserved. Use of this source code is governed by a | 3 # for details. All rights reserved. Use of this source code is governed by a |
4 # BSD-style license that can be found in the LICENSE file. | 4 # BSD-style license that can be found in the LICENSE file. |
5 | 5 |
6 from idlnode import * | 6 from idlnode import * |
7 | 7 |
8 | 8 |
9 def render(idl_node, indent_str=' '): | 9 def render(idl_node, indent_str=' '): |
10 output = [] | 10 output = [] |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 output.extend(indent_stack) | 46 output.extend(indent_stack) |
47 output.append(node) | 47 output.append(node) |
48 elif isinstance(node, list): | 48 elif isinstance(node, list): |
49 for i in range(0, len(node)): | 49 for i in range(0, len(node)): |
50 if i > 0: | 50 if i > 0: |
51 w(list_separator) | 51 w(list_separator) |
52 w(node[i]) | 52 w(node[i]) |
53 elif isinstance(node, IDLFile): | 53 elif isinstance(node, IDLFile): |
54 w(node.modules) | 54 w(node.modules) |
55 w(node.interfaces) | 55 w(node.interfaces) |
| 56 w(node.enums) |
| 57 w(node.typeDefs) |
56 elif isinstance(node, IDLModule): | 58 elif isinstance(node, IDLModule): |
57 wsp(node.annotations) | 59 wsp(node.annotations) |
58 wsp(node.ext_attrs) | 60 wsp(node.ext_attrs) |
59 wln('module %s {' % node.id) | 61 wln('module %s {' % node.id) |
60 begin_indent() | 62 begin_indent() |
61 w(node.interfaces) | 63 w(node.interfaces) |
| 64 w(node.enums) |
62 w(node.typeDefs) | 65 w(node.typeDefs) |
63 end_indent() | 66 end_indent() |
64 wln('};') | 67 wln('};') |
| 68 elif isinstance(node, IDLEnum): |
| 69 w('enum %s {}' % node.id) |
| 70 # TODO(antonm): emit values as well. |
65 elif isinstance(node, IDLInterface): | 71 elif isinstance(node, IDLInterface): |
66 if node.annotations: | 72 if node.annotations: |
67 wln(node.annotations) | 73 wln(node.annotations) |
68 if node.ext_attrs: | 74 if node.ext_attrs: |
69 wln(node.ext_attrs) | 75 wln(node.ext_attrs) |
70 w('interface %s' % node.id) | 76 w('interface %s' % node.id) |
71 begin_indent() | 77 begin_indent() |
72 begin_indent() | 78 begin_indent() |
73 if node.parents: | 79 if node.parents: |
74 wln(' :') | 80 wln(' :') |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 elif isinstance(node, IDLArgument): | 187 elif isinstance(node, IDLArgument): |
182 wsp(node.ext_attrs) | 188 wsp(node.ext_attrs) |
183 w('in ') | 189 w('in ') |
184 w('%s %s' % (node.type.id, node.id)) | 190 w('%s %s' % (node.type.id, node.id)) |
185 else: | 191 else: |
186 raise TypeError("Expected str or IDLNode but %s found" % | 192 raise TypeError("Expected str or IDLNode but %s found" % |
187 type(node)) | 193 type(node)) |
188 | 194 |
189 w(idl_node) | 195 w(idl_node) |
190 return ''.join(output) | 196 return ''.join(output) |
OLD | NEW |