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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 elif isinstance(node, IDLModule): | 50 elif isinstance(node, IDLModule): |
51 w(node.annotations) | 51 w(node.annotations) |
52 w(node.ext_attrs) | 52 w(node.ext_attrs) |
53 wln('module %s {' % node.id) | 53 wln('module %s {' % node.id) |
54 begin_indent() | 54 begin_indent() |
55 w(node.interfaces) | 55 w(node.interfaces) |
56 w(node.typeDefs) | 56 w(node.typeDefs) |
57 end_indent() | 57 end_indent() |
58 wln('};') | 58 wln('};') |
59 elif isinstance(node, IDLInterface): | 59 elif isinstance(node, IDLInterface): |
60 w(node.annotations) | 60 wln(node.annotations) |
61 w(node.ext_attrs) | 61 wln(node.ext_attrs) |
62 w('interface %s' % node.id) | 62 w('interface %s' % node.id) |
63 begin_indent() | 63 begin_indent() |
| 64 begin_indent() |
64 if node.parents: | 65 if node.parents: |
65 wln(' :') | 66 wln(' :') |
66 w(node.parents, ',\n') | 67 w(node.parents, ',\n') |
67 wln(' {') | 68 wln(' {') |
| 69 end_indent() |
68 if node.constants: | 70 if node.constants: |
69 wln() | 71 wln() |
70 wln('/* Constants */') | 72 wln('/* Constants */') |
71 w(sort(node.constants)) | 73 w(sort(node.constants)) |
72 if node.attributes: | 74 if node.attributes: |
73 wln() | 75 wln() |
74 wln('/* Attributes */') | 76 wln('/* Attributes */') |
75 w(sort(node.attributes)) | 77 w(sort(node.attributes)) |
76 if node.operations: | 78 if node.operations: |
77 wln() | 79 wln() |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 w('in ') | 161 w('in ') |
160 if node.is_optional: | 162 if node.is_optional: |
161 w('optional ') | 163 w('optional ') |
162 w('%s %s' % (node.type.id, node.id)) | 164 w('%s %s' % (node.type.id, node.id)) |
163 else: | 165 else: |
164 raise TypeError("Expected str or IDLNode but %s found" % | 166 raise TypeError("Expected str or IDLNode but %s found" % |
165 type(node)) | 167 type(node)) |
166 | 168 |
167 w(idl_node) | 169 w(idl_node) |
168 return ''.join(output) | 170 return ''.join(output) |
OLD | NEW |