| 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 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 for (let name of methodNames) { | 386 for (let name of methodNames) { |
| 387 sig[getExtensionSymbol(name)] = sig[name]; | 387 sig[getExtensionSymbol(name)] = sig[name]; |
| 388 } | 388 } |
| 389 return sig; | 389 return sig; |
| 390 }); | 390 }); |
| 391 } | 391 } |
| 392 exports.defineExtensionMembers = defineExtensionMembers; | 392 exports.defineExtensionMembers = defineExtensionMembers; |
| 393 | 393 |
| 394 function canonicalMember(obj, name) { | 394 function canonicalMember(obj, name) { |
| 395 if (obj != null && obj[_extensionType]) return dartx[name]; | 395 if (obj != null && obj[_extensionType]) return dartx[name]; |
| 396 // Check for certain names that we can't use in JS |
| 397 if (name == 'constructor' || name == 'prototype') { |
| 398 name = '+' + name; |
| 399 } |
| 396 return name; | 400 return name; |
| 397 } | 401 } |
| 398 exports.canonicalMember = canonicalMember; | 402 exports.canonicalMember = canonicalMember; |
| 399 | 403 |
| 400 /** Sets the type of `obj` to be `type` */ | 404 /** Sets the type of `obj` to be `type` */ |
| 401 function setType(obj, type) { | 405 function setType(obj, type) { |
| 402 obj.__proto__ = type.prototype; | 406 obj.__proto__ = type.prototype; |
| 403 return obj; | 407 return obj; |
| 404 } | 408 } |
| 405 | 409 |
| 406 /** Sets the element type of a list literal. */ | 410 /** Sets the element type of a list literal. */ |
| 407 function list(obj, elementType) { | 411 function list(obj, elementType) { |
| 408 return setType(obj, _interceptors.JSArray$(elementType)); | 412 return setType(obj, _interceptors.JSArray$(elementType)); |
| 409 } | 413 } |
| 410 exports.list = list; | 414 exports.list = list; |
| 411 | 415 |
| 412 function setBaseClass(derived, base) { | 416 function setBaseClass(derived, base) { |
| 413 // Link the extension to the type it's extending as a base class. | 417 // Link the extension to the type it's extending as a base class. |
| 414 derived.prototype.__proto__ = base.prototype; | 418 derived.prototype.__proto__ = base.prototype; |
| 415 } | 419 } |
| 416 exports.setBaseClass = setBaseClass; | 420 exports.setBaseClass = setBaseClass; |
| 417 | 421 |
| 418 }); | 422 }); |
| OLD | NEW |