Chromium Code Reviews| 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, _js_helper; | 5 var dart, _js_helper; |
| 6 (function (dart) { | 6 (function (dart) { |
| 7 'use strict'; | 7 'use strict'; |
| 8 | 8 |
| 9 let defineProperty = Object.defineProperty; | 9 let defineProperty = Object.defineProperty; |
| 10 let getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; | 10 let getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; |
| (...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 604 function defineLazy(to, from) { | 604 function defineLazy(to, from) { |
| 605 for (let name of getOwnNamesAndSymbols(from)) { | 605 for (let name of getOwnNamesAndSymbols(from)) { |
| 606 defineLazyProperty(to, name, getOwnPropertyDescriptor(from, name)); | 606 defineLazyProperty(to, name, getOwnPropertyDescriptor(from, name)); |
| 607 } | 607 } |
| 608 } | 608 } |
| 609 // TODO(jmesserly): these are identical, but this makes it easier to grep for. | 609 // TODO(jmesserly): these are identical, but this makes it easier to grep for. |
| 610 dart.defineLazyClass = defineLazy; | 610 dart.defineLazyClass = defineLazy; |
| 611 dart.defineLazyProperties = defineLazy; | 611 dart.defineLazyProperties = defineLazy; |
| 612 dart.defineLazyClassGeneric = defineLazyProperty; | 612 dart.defineLazyClassGeneric = defineLazyProperty; |
| 613 | 613 |
| 614 function copyPropertiesHelper(to, from, names) { | |
|
Jennifer Messerly
2015/04/23 19:33:53
hmm, not sure this is really worth a helper.
| |
| 615 for (let name of names) { | |
| 616 defineProperty(to, name, getOwnPropertyDescriptor(from, name)); | |
| 617 } | |
| 618 return to; | |
| 619 } | |
| 620 | |
| 614 /** | 621 /** |
| 615 * Copy properties from source to destination object. | 622 * Copy properties from source to destination object. |
| 616 * This operation is commonly called `mixin` in JS. | 623 * This operation is commonly called `mixin` in JS. |
| 617 */ | 624 */ |
| 618 function copyProperties(to, from) { | 625 function copyProperties(to, from) { |
| 619 for (let name of getOwnNamesAndSymbols(from)) { | 626 return copyPropertiesHelper(to, from, |
| 620 defineProperty(to, name, getOwnPropertyDescriptor(from, name)); | 627 getOwnNamesAndSymbols(from)); |
|
Jennifer Messerly
2015/04/23 19:33:53
short line? it looks like it would fit
| |
| 621 } | |
| 622 return to; | |
| 623 } | 628 } |
| 629 | |
| 630 /** | |
| 631 * Copy symbols from source to destination object. | |
| 632 * These are the only properties safe to copy onto an existing public | |
| 633 * JavaScript class. | |
| 634 */ | |
| 635 function copyPropertySymbols(to, from) { | |
| 636 return copyPropertiesHelper(to, from, getOwnPropertySymbols(from)); | |
| 637 } | |
| 638 | |
| 624 dart.copyProperties = copyProperties; | 639 dart.copyProperties = copyProperties; |
| 640 dart.copyPropertySymbols = copyPropertySymbols; | |
| 625 | 641 |
| 626 /** | 642 /** |
| 627 * This is called whenever a derived class needs to introduce a new field, | 643 * This is called whenever a derived class needs to introduce a new field, |
| 628 * shadowing a field or getter/setter pair on its parent. | 644 * shadowing a field or getter/setter pair on its parent. |
| 629 * | 645 * |
| 630 * This is important because otherwise, trying to read or write the field | 646 * This is important because otherwise, trying to read or write the field |
| 631 * would end up calling the getter or setter, and one of those might not even | 647 * would end up calling the getter or setter, and one of those might not even |
| 632 * exist, resulting in a runtime error. Even if they did exist, that's the | 648 * exist, resulting in a runtime error. Even if they did exist, that's the |
| 633 * wrong behavior if a new field was declared. | 649 * wrong behavior if a new field was declared. |
| 634 */ | 650 */ |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 858 dart.bottom = { toString() { return 'bottom'; } }; | 874 dart.bottom = { toString() { return 'bottom'; } }; |
| 859 | 875 |
| 860 dart.global = window || global; | 876 dart.global = window || global; |
| 861 dart.JsSymbol = Symbol; | 877 dart.JsSymbol = Symbol; |
| 862 | 878 |
| 863 // TODO(jmesserly): hack to bootstrap the SDK | 879 // TODO(jmesserly): hack to bootstrap the SDK |
| 864 _js_helper = _js_helper || {}; | 880 _js_helper = _js_helper || {}; |
| 865 _js_helper.checkNum = notNull; | 881 _js_helper.checkNum = notNull; |
| 866 | 882 |
| 867 })(dart || (dart = {})); | 883 })(dart || (dart = {})); |
| OLD | NEW |