| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 if output and output[-1].endswith('\n'): | 44 if output and output[-1].endswith('\n'): |
| 45 # Auto-indent. | 45 # Auto-indent. |
| 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) | |
| 55 w(node.interfaces) | 54 w(node.interfaces) |
| 56 w(node.enums) | 55 w(node.enums) |
| 57 w(node.typeDefs) | 56 w(node.typeDefs) |
| 58 elif isinstance(node, IDLModule): | 57 elif isinstance(node, IDLModule): |
| 59 wsp(node.annotations) | 58 wsp(node.annotations) |
| 60 wsp(node.ext_attrs) | 59 wsp(node.ext_attrs) |
| 61 wln('module %s {' % node.id) | 60 wln('module %s {' % node.id) |
| 62 begin_indent() | 61 begin_indent() |
| 63 w(node.interfaces) | 62 w(node.interfaces) |
| 64 w(node.enums) | 63 w(node.enums) |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 w(node.type.id) | 181 w(node.type.id) |
| 183 if node.type.nullable: | 182 if node.type.nullable: |
| 184 w('?') | 183 w('?') |
| 185 w(' %s' % node.id) | 184 w(' %s' % node.id) |
| 186 else: | 185 else: |
| 187 raise TypeError("Expected str or IDLNode but %s found" % | 186 raise TypeError("Expected str or IDLNode but %s found" % |
| 188 type(node)) | 187 type(node)) |
| 189 | 188 |
| 190 w(idl_node) | 189 w(idl_node) |
| 191 return ''.join(output) | 190 return ''.join(output) |
| OLD | NEW |