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 /** | 5 /** |
6 * Generates JS helpers for dart:core. This used to be in a file "core.js". | 6 * Generates JS helpers for dart:core. This used to be in a file "core.js". |
7 * Having them in Dart code means we can easily control which are generated. | 7 * Having them in Dart code means we can easily control which are generated. |
8 */ | 8 */ |
9 // TODO(jmesserly): one idea to make this cleaner: put these as private "native" | 9 // TODO(jmesserly): one idea to make this cleaner: put these as private "native" |
10 // methods somewhere in a library that we import. This would be rather elegant | 10 // methods somewhere in a library that we import. This would be rather elegant |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 // below in that case. | 419 // below in that case. |
420 if (typeof(name) == 'string' && name && name != 'Object') return name; | 420 if (typeof(name) == 'string' && name && name != 'Object') return name; |
421 } | 421 } |
422 var string = Object.prototype.toString.call(obj); | 422 var string = Object.prototype.toString.call(obj); |
423 return string.substring(8, string.length - 1); | 423 return string.substring(8, string.length - 1); |
424 } | 424 } |
425 | 425 |
426 function chrome$typeNameOf() { | 426 function chrome$typeNameOf() { |
427 var name = this.constructor.name; | 427 var name = this.constructor.name; |
428 if (name == 'Window') return 'DOMWindow'; | 428 if (name == 'Window') return 'DOMWindow'; |
| 429 if (name == 'CanvasPixelArray') return 'Uint8ClampedArray'; |
429 return name; | 430 return name; |
430 } | 431 } |
431 | 432 |
432 function firefox$typeNameOf() { | 433 function firefox$typeNameOf() { |
433 var name = constructorNameWithFallback(this); | 434 var name = constructorNameWithFallback(this); |
434 if (name == 'Window') return 'DOMWindow'; | 435 if (name == 'Window') return 'DOMWindow'; |
435 if (name == 'Document') return 'HTMLDocument'; | 436 if (name == 'Document') return 'HTMLDocument'; |
436 if (name == 'XMLDocument') return 'Document'; | 437 if (name == 'XMLDocument') return 'Document'; |
437 if (name == 'WorkerMessageEvent') return 'MessageEvent'; | 438 if (name == 'WorkerMessageEvent') return 'MessageEvent'; |
438 return name; | 439 return name; |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 bound.$length = Math.max(0, funcLength - (argsLength - 1)); | 605 bound.$length = Math.max(0, funcLength - (argsLength - 1)); |
605 return bound; | 606 return bound; |
606 } else { | 607 } else { |
607 var bound = function() { | 608 var bound = function() { |
608 return func.apply(thisObj, arguments); | 609 return func.apply(thisObj, arguments); |
609 }; | 610 }; |
610 bound.$length = funcLength; | 611 bound.$length = funcLength; |
611 return bound; | 612 return bound; |
612 } | 613 } |
613 };"""; | 614 };"""; |
OLD | NEW |