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'; | |
430 return name; | 429 return name; |
431 } | 430 } |
432 | 431 |
433 function firefox$typeNameOf() { | 432 function firefox$typeNameOf() { |
434 var name = constructorNameWithFallback(this); | 433 var name = constructorNameWithFallback(this); |
435 if (name == 'Window') return 'DOMWindow'; | 434 if (name == 'Window') return 'DOMWindow'; |
436 if (name == 'Document') return 'HTMLDocument'; | 435 if (name == 'Document') return 'HTMLDocument'; |
437 if (name == 'XMLDocument') return 'Document'; | 436 if (name == 'XMLDocument') return 'Document'; |
438 if (name == 'WorkerMessageEvent') return 'MessageEvent'; | 437 if (name == 'WorkerMessageEvent') return 'MessageEvent'; |
439 return name; | 438 return name; |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
605 bound.$length = Math.max(0, funcLength - (argsLength - 1)); | 604 bound.$length = Math.max(0, funcLength - (argsLength - 1)); |
606 return bound; | 605 return bound; |
607 } else { | 606 } else { |
608 var bound = function() { | 607 var bound = function() { |
609 return func.apply(thisObj, arguments); | 608 return func.apply(thisObj, arguments); |
610 }; | 609 }; |
611 bound.$length = funcLength; | 610 bound.$length = funcLength; |
612 return bound; | 611 return bound; |
613 } | 612 } |
614 };"""; | 613 };"""; |
OLD | NEW |