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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
275 /// JavaScript class. | 275 /// JavaScript class. |
276 /// | 276 /// |
277 registerExtension(jsType, dartExtType) => JS('', '''(() => { | 277 registerExtension(jsType, dartExtType) => JS('', '''(() => { |
278 let extProto = $dartExtType.prototype; | 278 let extProto = $dartExtType.prototype; |
279 let jsProto = $jsType.prototype; | 279 let jsProto = $jsType.prototype; |
280 | 280 |
281 // Mark the JS type's instances so we can easily check for extensions. | 281 // Mark the JS type's instances so we can easily check for extensions. |
282 $assert_(jsProto[$_extensionType] === void 0); | 282 $assert_(jsProto[$_extensionType] === void 0); |
283 jsProto[$_extensionType] = extProto; | 283 jsProto[$_extensionType] = extProto; |
284 | 284 |
285 // TODO(ochafik): Fix this (DO NOT SUBMIT) | |
286 //let dartObjProto = require('dart/core').Object.prototype; // \$Object.protot ype; | |
vsm
2016/01/26 14:09:41
Remove?
ochafik
2016/01/26 16:27:37
Done.
| |
285 let dartObjProto = $Object.prototype; | 287 let dartObjProto = $Object.prototype; |
286 while (extProto !== dartObjProto && extProto !== jsProto) { | 288 while (extProto !== dartObjProto && extProto !== jsProto) { |
287 $copyTheseProperties(jsProto, extProto, $getOwnPropertySymbols(extProto)); | 289 $copyTheseProperties(jsProto, extProto, $getOwnPropertySymbols(extProto)); |
288 extProto = extProto.__proto__; | 290 extProto = extProto.__proto__; |
289 } | 291 } |
290 let originalSigFn = $getOwnPropertyDescriptor($dartExtType, $_methodSig).get; | 292 let originalSigFn = $getOwnPropertyDescriptor($dartExtType, $_methodSig).get; |
291 $assert_(originalSigFn); | 293 $assert_(originalSigFn); |
292 $defineMemoizedGetter($jsType, $_methodSig, originalSigFn); | 294 $defineMemoizedGetter($jsType, $_methodSig, originalSigFn); |
293 })()'''); | 295 })()'''); |
294 | 296 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
349 })()'''); | 351 })()'''); |
350 | 352 |
351 /// Sets the element type of a list literal. | 353 /// Sets the element type of a list literal. |
352 list(obj, elementType) => | 354 list(obj, elementType) => |
353 JS('', '$setType($obj, ${getGenericClass(JSArray)}($elementType))'); | 355 JS('', '$setType($obj, ${getGenericClass(JSArray)}($elementType))'); |
354 | 356 |
355 setBaseClass(derived, base) => JS('', '''(() => { | 357 setBaseClass(derived, base) => JS('', '''(() => { |
356 // Link the extension to the type it's extending as a base class. | 358 // Link the extension to the type it's extending as a base class. |
357 $derived.prototype.__proto__ = $base.prototype; | 359 $derived.prototype.__proto__ = $base.prototype; |
358 })()'''); | 360 })()'''); |
OLD | NEW |