| 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 var dart, dartx; | 5 var dart, dartx; |
| 6 (function (dart) { | 6 (function (dart) { |
| 7 'use strict'; | 7 'use strict'; |
| 8 | 8 |
| 9 const defineProperty = Object.defineProperty; | 9 const defineProperty = Object.defineProperty; |
| 10 const getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; | 10 const getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; |
| (...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 792 * These are the only properties safe to copy onto an existing public | 792 * These are the only properties safe to copy onto an existing public |
| 793 * JavaScript class. | 793 * JavaScript class. |
| 794 */ | 794 */ |
| 795 function registerExtension(jsType, dartExtType) { | 795 function registerExtension(jsType, dartExtType) { |
| 796 let extProto = dartExtType.prototype; | 796 let extProto = dartExtType.prototype; |
| 797 let jsProto = jsType.prototype; | 797 let jsProto = jsType.prototype; |
| 798 | 798 |
| 799 // Mark the JS type's instances so we can easily check for extensions. | 799 // Mark the JS type's instances so we can easily check for extensions. |
| 800 assert(jsProto[_extensionType] === void 0); | 800 assert(jsProto[_extensionType] === void 0); |
| 801 jsProto[_extensionType] = extProto; | 801 jsProto[_extensionType] = extProto; |
| 802 copyPropertiesHelper(jsProto, extProto, getOwnPropertySymbols(extProto)); | 802 |
| 803 let dartObjProto = core.Object.prototype; |
| 804 while (extProto !== dartObjProto && extProto !== jsProto) { |
| 805 copyPropertiesHelper(jsProto, extProto, getOwnPropertySymbols(extProto)); |
| 806 extProto = extProto.__proto__; |
| 807 } |
| 803 } | 808 } |
| 804 dart.registerExtension = registerExtension; | 809 dart.registerExtension = registerExtension; |
| 805 | 810 |
| 806 /** | 811 /** |
| 807 * Mark a concrete type as implementing extension methods. | 812 * Mark a concrete type as implementing extension methods. |
| 808 * For example: `class MyIter implements Iterable`. | 813 * For example: `class MyIter implements Iterable`. |
| 809 * | 814 * |
| 810 * This takes a list of names, which are the extension methods implemented. | 815 * This takes a list of names, which are the extension methods implemented. |
| 811 * It will add a forwarder, so the extension method name redirects to the | 816 * It will add a forwarder, so the extension method name redirects to the |
| 812 * normal Dart method name. For example: | 817 * normal Dart method name. For example: |
| (...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1429 | 1434 |
| 1430 // TODO(vsm): This is referenced (as init.globalState) from | 1435 // TODO(vsm): This is referenced (as init.globalState) from |
| 1431 // isolate_helper.dart. Where should it go? | 1436 // isolate_helper.dart. Where should it go? |
| 1432 // See: https://github.com/dart-lang/dev_compiler/issues/164 | 1437 // See: https://github.com/dart-lang/dev_compiler/issues/164 |
| 1433 dart.globalState = null; | 1438 dart.globalState = null; |
| 1434 | 1439 |
| 1435 /** Dart extension members. */ | 1440 /** Dart extension members. */ |
| 1436 dartx = dartx || {}; | 1441 dartx = dartx || {}; |
| 1437 } | 1442 } |
| 1438 })(dart || (dart = {})); | 1443 })(dart || (dart = {})); |
| OLD | NEW |