| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 wln('/* Constants */') | 70 wln('/* Constants */') |
| 71 w(sort(node.constants)) | 71 w(sort(node.constants)) |
| 72 if node.attributes: | 72 if node.attributes: |
| 73 wln() | 73 wln() |
| 74 wln('/* Attributes */') | 74 wln('/* Attributes */') |
| 75 w(sort(node.attributes)) | 75 w(sort(node.attributes)) |
| 76 if node.operations: | 76 if node.operations: |
| 77 wln() | 77 wln() |
| 78 wln('/* Operations */') | 78 wln('/* Operations */') |
| 79 w(sort(node.operations)) | 79 w(sort(node.operations)) |
| 80 if node.snippets: | |
| 81 wln() | |
| 82 wln('/* Snippets */') | |
| 83 w(sort(node.snippets)) | |
| 84 end_indent() | 80 end_indent() |
| 85 wln('};') | 81 wln('};') |
| 86 elif isinstance(node, IDLParentInterface): | 82 elif isinstance(node, IDLParentInterface): |
| 87 w(node.annotations) | 83 w(node.annotations) |
| 88 w(node.type.id) | 84 w(node.type.id) |
| 89 elif isinstance(node, IDLAnnotations): | 85 elif isinstance(node, IDLAnnotations): |
| 90 for (name, annotation) in sorted(node.items()): | 86 for (name, annotation) in sorted(node.items()): |
| 91 if annotation and len(annotation): | 87 if annotation and len(annotation): |
| 92 subRes = [] | 88 subRes = [] |
| 93 for (argName, argValue) in sorted(annotation.items()): | 89 for (argName, argValue) in sorted(annotation.items()): |
| (...skipping 23 matching lines...) Expand all Loading... |
| 117 w(node.ext_attrs) | 113 w(node.ext_attrs) |
| 118 if node.is_fc_getter: | 114 if node.is_fc_getter: |
| 119 w('getter ') | 115 w('getter ') |
| 120 if node.is_fc_setter: | 116 if node.is_fc_setter: |
| 121 w('setter ') | 117 w('setter ') |
| 122 wln('attribute %s %s;' % (node.type.id, node.id)) | 118 wln('attribute %s %s;' % (node.type.id, node.id)) |
| 123 elif isinstance(node, IDLConstant): | 119 elif isinstance(node, IDLConstant): |
| 124 w(node.annotations) | 120 w(node.annotations) |
| 125 w(node.ext_attrs) | 121 w(node.ext_attrs) |
| 126 wln('const %s %s = %s;' % (node.type.id, node.id, node.value)) | 122 wln('const %s %s = %s;' % (node.type.id, node.id, node.value)) |
| 127 elif isinstance(node, IDLSnippet): | |
| 128 w(node.annotations) | |
| 129 wln('snippet {%s};' % node.text) | |
| 130 elif isinstance(node, IDLOperation): | 123 elif isinstance(node, IDLOperation): |
| 131 w(node.annotations) | 124 w(node.annotations) |
| 132 w(node.ext_attrs) | 125 w(node.ext_attrs) |
| 133 if node.is_static: | 126 if node.is_static: |
| 134 w('static ') | 127 w('static ') |
| 135 if node.specials: | 128 if node.specials: |
| 136 w(node.specials, ' ') | 129 w(node.specials, ' ') |
| 137 w(' ') | 130 w(' ') |
| 138 w('%s ' % node.type.id) | 131 w('%s ' % node.type.id) |
| 139 w(node.id) | 132 w(node.id) |
| 140 w('(') | 133 w('(') |
| 141 w(node.arguments, ', ') | 134 w(node.arguments, ', ') |
| 142 wln(');') | 135 wln(');') |
| 143 elif isinstance(node, IDLArgument): | 136 elif isinstance(node, IDLArgument): |
| 144 w(node.ext_attrs) | 137 w(node.ext_attrs) |
| 145 w('in ') | 138 w('in ') |
| 146 if node.is_optional: | 139 if node.is_optional: |
| 147 w('optional ') | 140 w('optional ') |
| 148 w('%s %s' % (node.type.id, node.id)) | 141 w('%s %s' % (node.type.id, node.id)) |
| 149 else: | 142 else: |
| 150 raise TypeError("Expected str or IDLNode but %s found" % | 143 raise TypeError("Expected str or IDLNode but %s found" % |
| 151 type(node)) | 144 type(node)) |
| 152 | 145 |
| 153 w(idl_node) | 146 w(idl_node) |
| 154 return ''.join(output) | 147 return ''.join(output) |
| OLD | NEW |