| 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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 | 329 |
| 330 // Mark the JS type's instances so we can easily check for extensions. | 330 // Mark the JS type's instances so we can easily check for extensions. |
| 331 assert(jsProto[_extensionType] === void 0); | 331 assert(jsProto[_extensionType] === void 0); |
| 332 jsProto[_extensionType] = extProto; | 332 jsProto[_extensionType] = extProto; |
| 333 | 333 |
| 334 let dartObjProto = core.Object.prototype; | 334 let dartObjProto = core.Object.prototype; |
| 335 while (extProto !== dartObjProto && extProto !== jsProto) { | 335 while (extProto !== dartObjProto && extProto !== jsProto) { |
| 336 copyTheseProperties(jsProto, extProto, getOwnPropertySymbols(extProto)); | 336 copyTheseProperties(jsProto, extProto, getOwnPropertySymbols(extProto)); |
| 337 extProto = extProto.__proto__; | 337 extProto = extProto.__proto__; |
| 338 } | 338 } |
| 339 let originalSigFn = getOwnPropertyDescriptor(dartExtType, _methodSig).get; |
| 340 assert(originalSigFn); |
| 341 defineMemoizedGetter(jsType, _methodSig, originalSigFn); |
| 339 } | 342 } |
| 340 exports.registerExtension = registerExtension; | 343 exports.registerExtension = registerExtension; |
| 341 | 344 |
| 342 /** | 345 /** |
| 343 * Mark a concrete type as implementing extension methods. | 346 * Mark a concrete type as implementing extension methods. |
| 344 * For example: `class MyIter implements Iterable`. | 347 * For example: `class MyIter implements Iterable`. |
| 345 * | 348 * |
| 346 * This takes a list of names, which are the extension methods implemented. | 349 * This takes a list of names, which are the extension methods implemented. |
| 347 * It will add a forwarder, so the extension method name redirects to the | 350 * It will add a forwarder, so the extension method name redirects to the |
| 348 * normal Dart method name. For example: | 351 * normal Dart method name. For example: |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 } | 402 } |
| 400 exports.list = list; | 403 exports.list = list; |
| 401 | 404 |
| 402 function setBaseClass(derived, base) { | 405 function setBaseClass(derived, base) { |
| 403 // Link the extension to the type it's extending as a base class. | 406 // Link the extension to the type it's extending as a base class. |
| 404 derived.prototype.__proto__ = base.prototype; | 407 derived.prototype.__proto__ = base.prototype; |
| 405 } | 408 } |
| 406 exports.setBaseClass = setBaseClass; | 409 exports.setBaseClass = setBaseClass; |
| 407 | 410 |
| 408 }); | 411 }); |
| OLD | NEW |