| 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 if node.id: | 134 if node.id: |
| 135 w(node.id) | 135 w(node.id) |
| 136 w('(') | 136 w('(') |
| 137 w(node.arguments, ', ') | 137 w(node.arguments, ', ') |
| 138 w(')') | 138 w(')') |
| 139 elif isinstance(node, IDLAttribute): | 139 elif isinstance(node, IDLAttribute): |
| 140 wsp(node.annotations) | 140 wsp(node.annotations) |
| 141 wsp(node.ext_attrs) | 141 wsp(node.ext_attrs) |
| 142 if node.is_read_only: | 142 if node.is_read_only: |
| 143 w('readonly ') | 143 w('readonly ') |
| 144 w('attribute %s %s' % (node.type.id, node.id)) | 144 w('attribute ') |
| 145 w(node.type.id) |
| 146 if (node.type.nullable): |
| 147 w('?') |
| 148 w(' ') |
| 149 w(node.id) |
| 145 if node.raises: | 150 if node.raises: |
| 146 w(' raises (%s)' % node.raises.id) | 151 w(' raises (%s)' % node.raises.id) |
| 147 else: | 152 else: |
| 148 if node.get_raises: | 153 if node.get_raises: |
| 149 w(' getraises (%s)' % node.get_raises.id) | 154 w(' getraises (%s)' % node.get_raises.id) |
| 150 if node.set_raises: | 155 if node.set_raises: |
| 151 w(' setraises (%s)' % node.set_raises.id) | 156 w(' setraises (%s)' % node.set_raises.id) |
| 152 wln(';') | 157 wln(';') |
| 153 elif isinstance(node, IDLConstant): | 158 elif isinstance(node, IDLConstant): |
| 154 wsp(node.annotations) | 159 wsp(node.annotations) |
| 155 wsp(node.ext_attrs) | 160 wsp(node.ext_attrs) |
| 156 wln('const %s %s = %s;' % (node.type.id, node.id, node.value)) | 161 wln('const %s %s = %s;' % (node.type.id, node.id, node.value)) |
| 157 elif isinstance(node, IDLOperation): | 162 elif isinstance(node, IDLOperation): |
| 158 wsp(node.annotations) | 163 wsp(node.annotations) |
| 159 wsp(node.ext_attrs) | 164 wsp(node.ext_attrs) |
| 160 if node.is_static: | 165 if node.is_static: |
| 161 w('static ') | 166 w('static ') |
| 162 if node.specials: | 167 if node.specials: |
| 163 w(node.specials, ' ') | 168 w(node.specials, ' ') |
| 164 w(' ') | 169 w(' ') |
| 165 w('%s ' % node.type.id) | 170 w(node.type.id) |
| 171 if (node.type.nullable): |
| 172 w('?') |
| 173 w(' ') |
| 166 w(node.id) | 174 w(node.id) |
| 167 w('(') | 175 w('(') |
| 168 w(node.arguments, ', ') | 176 w(node.arguments, ', ') |
| 169 w(')') | 177 w(')') |
| 170 if node.raises: | 178 if node.raises: |
| 171 w(' raises (%s)' % node.raises.id) | 179 w(' raises (%s)' % node.raises.id) |
| 172 wln(';') | 180 wln(';') |
| 173 elif isinstance(node, IDLArgument): | 181 elif isinstance(node, IDLArgument): |
| 174 wsp(node.ext_attrs) | 182 wsp(node.ext_attrs) |
| 175 w('in ') | 183 w('in ') |
| 176 w('%s %s' % (node.type.id, node.id)) | 184 w('%s %s' % (node.type.id, node.id)) |
| 177 else: | 185 else: |
| 178 raise TypeError("Expected str or IDLNode but %s found" % | 186 raise TypeError("Expected str or IDLNode but %s found" % |
| 179 type(node)) | 187 type(node)) |
| 180 | 188 |
| 181 w(idl_node) | 189 w(idl_node) |
| 182 return ''.join(output) | 190 return ''.join(output) |
| OLD | NEW |