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 dart._foreign_helper; | 5 library dart._foreign_helper; |
6 | 6 |
7 /** | 7 /** |
8 * Emits a JavaScript code fragment parameterized by arguments. | 8 * Emits a JavaScript code fragment parameterized by arguments. |
9 * | 9 * |
10 * Hash characters `#` in the [codeTemplate] are replaced in left-to-right order | 10 * Hash characters `#` in the [codeTemplate] are replaced in left-to-right order |
(...skipping 17 matching lines...) Expand all Loading... |
28 * The [typeDescription] is a [String] which contains a union of types separated | 28 * The [typeDescription] is a [String] which contains a union of types separated |
29 * by vertical bar `|` symbols, e.g. `"num|String"` describes the union of | 29 * by vertical bar `|` symbols, e.g. `"num|String"` describes the union of |
30 * numbers and Strings. There is no type in Dart that is this precise. The | 30 * numbers and Strings. There is no type in Dart that is this precise. The |
31 * Dart alternative would be `Object` or `dynamic`, but these types imply that | 31 * Dart alternative would be `Object` or `dynamic`, but these types imply that |
32 * the JS-code might also be creating instances of all the DOM types. If `null` | 32 * the JS-code might also be creating instances of all the DOM types. If `null` |
33 * is possible, it must be specified explicitly, e.g. `"String|Null"`. | 33 * is possible, it must be specified explicitly, e.g. `"String|Null"`. |
34 * [typeDescription] has several extensions to help describe the behavior more | 34 * [typeDescription] has several extensions to help describe the behavior more |
35 * accurately. In addition to the union type already described: | 35 * accurately. In addition to the union type already described: |
36 * | 36 * |
37 * + `=Object` is a plain JavaScript object. Some DOM methods return instances | 37 * + `=Object` is a plain JavaScript object. Some DOM methods return instances |
38 * that have no corresponing Dart type (e.g. cross-frame documents), | 38 * that have no corresponding Dart type (e.g. cross-frame documents), |
39 * `=Object` can be used to describe these untyped' values. | 39 * `=Object` can be used to describe these untyped' values. |
40 * | 40 * |
41 * + `var` (or empty string). If the entire [typeDescription] is `var` (or | 41 * + `var` (or empty string). If the entire [typeDescription] is `var` (or |
42 * empty string) then the type is `dynamic` but the code is known to not | 42 * empty string) then the type is `dynamic` but the code is known to not |
43 * create any instances. | 43 * create any instances. |
44 * | 44 * |
45 * Examples: | 45 * Examples: |
46 * | 46 * |
47 * // Parent window might be an opaque cross-frame window. | 47 * // Parent window might be an opaque cross-frame window. |
48 * var thing = JS('=Object|Window', '#.parent', myWindow); | 48 * var thing = JS('=Object|Window', '#.parent', myWindow); |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 class _Rest { | 302 class _Rest { |
303 const _Rest(); | 303 const _Rest(); |
304 } | 304 } |
305 | 305 |
306 const _Rest rest = const _Rest(); | 306 const _Rest rest = const _Rest(); |
307 | 307 |
308 dynamic spread(args) { | 308 dynamic spread(args) { |
309 throw new StateError('The spread function cannot be called, ' | 309 throw new StateError('The spread function cannot be called, ' |
310 'it should be compiled away.'); | 310 'it should be compiled away.'); |
311 } | 311 } |
OLD | NEW |