OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 library _js_helper; | 5 library _js_helper; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 part 'constant_map.dart'; | 9 part 'constant_map.dart'; |
10 part 'native_helper.dart'; | 10 part 'native_helper.dart'; |
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 // apply(). It fixes http://dartbug.com/6919 | 550 // apply(). It fixes http://dartbug.com/6919 |
551 static String _fromCharCodeApply(List<int> array) { | 551 static String _fromCharCodeApply(List<int> array) { |
552 String result = ""; | 552 String result = ""; |
553 const kMaxApply = 500; | 553 const kMaxApply = 500; |
554 int end = array.length; | 554 int end = array.length; |
555 for (var i = 0; i < end; i += kMaxApply) { | 555 for (var i = 0; i < end; i += kMaxApply) { |
556 var subarray; | 556 var subarray; |
557 if (end <= kMaxApply) { | 557 if (end <= kMaxApply) { |
558 subarray = array; | 558 subarray = array; |
559 } else { | 559 } else { |
560 subarray = JS('List<int>', r'array.slice(#, #)', | 560 subarray = JS('=List', r'array.slice(#, #)', |
561 i, i + kMaxApply < end ? i + kMaxApply : end); | 561 i, i + kMaxApply < end ? i + kMaxApply : end); |
562 } | 562 } |
563 result = JS('String', '# + String.fromCharCode.apply(#, #)', | 563 result = JS('String', '# + String.fromCharCode.apply(#, #)', |
564 result, null, subarray); | 564 result, null, subarray); |
565 } | 565 } |
566 return result; | 566 return result; |
567 } | 567 } |
568 | 568 |
569 static String stringFromCodePoints(codePoints) { | 569 static String stringFromCodePoints(codePoints) { |
570 List<int> a = <int>[]; | 570 List<int> a = <int>[]; |
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1213 * // Equivalent: | 1213 * // Equivalent: |
1214 * @Returns('String') @Returns('num') @Returns('=List') | 1214 * @Returns('String') @Returns('num') @Returns('=List') |
1215 * dynamic key; | 1215 * dynamic key; |
1216 */ | 1216 */ |
1217 class Returns { | 1217 class Returns { |
1218 final String types; | 1218 final String types; |
1219 const Returns(this.types); | 1219 const Returns(this.types); |
1220 } | 1220 } |
1221 | 1221 |
1222 /** | 1222 /** |
| 1223 * A metadata annotation placed on native methods and fields of native classes |
| 1224 * to specify the JavaScript name. |
| 1225 * |
| 1226 * This example declares a Dart field + getter + setter called `$dom_title` that |
| 1227 * corresponds to the JavaScript property `title`. |
| 1228 * |
| 1229 * class Docmument native "*Foo" { |
| 1230 * @JSName('title') |
| 1231 * String $dom_title; |
| 1232 * } |
| 1233 */ |
| 1234 class JSName { |
| 1235 final String name; |
| 1236 const JSName(this.name); |
| 1237 } |
| 1238 |
| 1239 /** |
1223 * Represents the type of Null. The compiler treats this specially. | 1240 * Represents the type of Null. The compiler treats this specially. |
1224 * TODO(lrn): Null should be defined in core. It's a class, like int. | 1241 * TODO(lrn): Null should be defined in core. It's a class, like int. |
1225 * It just happens to act differently in assignability tests and, | 1242 * It just happens to act differently in assignability tests and, |
1226 * like int, can't be extended or implemented. | 1243 * like int, can't be extended or implemented. |
1227 */ | 1244 */ |
1228 class Null { | 1245 class Null { |
1229 factory Null() { | 1246 factory Null() { |
1230 throw new UnsupportedError('new Null()'); | 1247 throw new UnsupportedError('new Null()'); |
1231 } | 1248 } |
1232 } | 1249 } |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1600 var argument = typeInfo[i]; | 1617 var argument = typeInfo[i]; |
1601 if (argument == null) { | 1618 if (argument == null) { |
1602 argument = 'dynamic'; | 1619 argument = 'dynamic'; |
1603 } | 1620 } |
1604 arguments.add(argument); | 1621 arguments.add(argument); |
1605 } | 1622 } |
1606 return '$className<$arguments>'; | 1623 return '$className<$arguments>'; |
1607 } | 1624 } |
1608 | 1625 |
1609 createRuntimeType(String name) => new TypeImpl(name); | 1626 createRuntimeType(String name) => new TypeImpl(name); |
OLD | NEW |