| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 /// This library defines the operations that define and manipulate Dart | 5 /// This library defines the operations that define and manipulate Dart |
| 6 /// classes. Included in this are: | 6 /// classes. Included in this are: |
| 7 /// - Generics | 7 /// - Generics |
| 8 /// - Class metadata | 8 /// - Class metadata |
| 9 /// - Extension methods | 9 /// - Extension methods |
| 10 /// | 10 /// |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 /// JavaScript class. | 415 /// JavaScript class. |
| 416 registerExtension(jsType, dartExtType) => JS( | 416 registerExtension(jsType, dartExtType) => JS( |
| 417 '', | 417 '', |
| 418 '''(() => { | 418 '''(() => { |
| 419 // TODO(vsm): Not all registered js types are real. | 419 // TODO(vsm): Not all registered js types are real. |
| 420 if (!jsType) return; | 420 if (!jsType) return; |
| 421 | 421 |
| 422 let extProto = $dartExtType.prototype; | 422 let extProto = $dartExtType.prototype; |
| 423 let jsProto = $jsType.prototype; | 423 let jsProto = $jsType.prototype; |
| 424 | 424 |
| 425 // TODO(vsm): This sometimes doesn't exist on FF. These types will be |
| 426 // broken. |
| 427 if (!jsProto) return; |
| 428 |
| 425 // Mark the JS type's instances so we can easily check for extensions. | 429 // Mark the JS type's instances so we can easily check for extensions. |
| 426 jsProto[$_extensionType] = $dartExtType; | 430 jsProto[$_extensionType] = $dartExtType; |
| 427 $_installProperties(jsProto, extProto); | 431 $_installProperties(jsProto, extProto); |
| 428 let originalSigFn = $getOwnPropertyDescriptor($dartExtType, $_methodSig).get; | 432 let originalSigFn = $getOwnPropertyDescriptor($dartExtType, $_methodSig).get; |
| 429 $assert_(originalSigFn); | 433 $assert_(originalSigFn); |
| 430 $defineMemoizedGetter($jsType, $_methodSig, originalSigFn); | 434 $defineMemoizedGetter($jsType, $_methodSig, originalSigFn); |
| 431 })()'''); | 435 })()'''); |
| 432 | 436 |
| 433 /// | 437 /// |
| 434 /// Mark a concrete type as implementing extension methods. | 438 /// Mark a concrete type as implementing extension methods. |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 /// | 535 /// |
| 532 /// The constructor | 536 /// The constructor |
| 533 defineNamedConstructorCallable(clazz, name, ctor) => JS( | 537 defineNamedConstructorCallable(clazz, name, ctor) => JS( |
| 534 '', | 538 '', |
| 535 '''(() => { | 539 '''(() => { |
| 536 ctor.prototype = $clazz.prototype; | 540 ctor.prototype = $clazz.prototype; |
| 537 // Use defineProperty so we don't hit a property defined on Function, | 541 // Use defineProperty so we don't hit a property defined on Function, |
| 538 // like `caller` and `arguments`. | 542 // like `caller` and `arguments`. |
| 539 $defineProperty($clazz, $name, { value: ctor, configurable: true }); | 543 $defineProperty($clazz, $name, { value: ctor, configurable: true }); |
| 540 })()'''); | 544 })()'''); |
| OLD | NEW |