OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 List sorted(Iterable input, [compare, key]) { | 5 List sorted(Iterable input, [compare, key]) { |
6 comparator(compare, key) { | 6 comparator(compare, key) { |
7 if (compare == null && key == null) | 7 if (compare == null && key == null) |
8 return (a, b) => a.compareTo(b); | 8 return (a, b) => a.compareTo(b); |
9 if (compare == null) | 9 if (compare == null) |
10 return (a, b) => key(a).compareTo(key(b)); | 10 return (a, b) => key(a).compareTo(key(b)); |
(...skipping 30 matching lines...) Expand all Loading... |
41 Writes the given node. | 41 Writes the given node. |
42 | 42 |
43 Args: | 43 Args: |
44 node -- a string, IDLNode instance or a list of such. | 44 node -- a string, IDLNode instance or a list of such. |
45 list_separator -- if provided, and node is a list, | 45 list_separator -- if provided, and node is a list, |
46 list_separator will be written between the list items. | 46 list_separator will be written between the list items. |
47 */ | 47 */ |
48 if (node == null) { | 48 if (node == null) { |
49 return; | 49 return; |
50 } else if (node is String) { | 50 } else if (node is String) { |
51 if (output.last().endsWith('\n')) | 51 if (output.last.endsWith('\n')) |
52 output.addAll(indent_stack); | 52 output.addAll(indent_stack); |
53 output.add(node); | 53 output.add(node); |
54 } else if (node is List) { | 54 } else if (node is List) { |
55 var separator = null; | 55 var separator = null; |
56 for (var element in node) { | 56 for (var element in node) { |
57 w(separator); | 57 w(separator); |
58 separator = list_separator; | 58 separator = list_separator; |
59 w(element); | 59 w(element); |
60 } | 60 } |
61 } else if (node is IDLFile) { | 61 } else if (node is IDLFile) { |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 } else if (node is IDLTypeDef) { | 171 } else if (node is IDLTypeDef) { |
172 wln('typedef ${node.type.id} ${node.id};'); | 172 wln('typedef ${node.type.id} ${node.id};'); |
173 } else { | 173 } else { |
174 w('// $node\n'); | 174 w('// $node\n'); |
175 } | 175 } |
176 }; | 176 }; |
177 | 177 |
178 w(idl_node); | 178 w(idl_node); |
179 return Strings.concatAll(output); | 179 return Strings.concatAll(output); |
180 } | 180 } |
OLD | NEW |