Chromium Code Reviews| Index: tool/input_sdk/private/classes.dart |
| diff --git a/tool/input_sdk/private/classes.dart b/tool/input_sdk/private/classes.dart |
| index 7a784a4257c321f8ed92d193a05ddaca7ac5034c..fea07196580d0d4d389a7cea7a64bd59d070affc 100644 |
| --- a/tool/input_sdk/private/classes.dart |
| +++ b/tool/input_sdk/private/classes.dart |
| @@ -259,6 +259,8 @@ defineNamedConstructor(clazz, name) => JS('', '''(() => { |
| final _extensionType = JS('', 'Symbol("extensionType")'); |
| +getExtensionType(obj) => JS('', '$obj[$_extensionType]'); |
| + |
| final dartx = JS('', '{}'); |
| getExtensionSymbol(name) => JS('', '''(() => { |
| @@ -269,6 +271,15 @@ getExtensionSymbol(name) => JS('', '''(() => { |
| defineExtensionNames(names) => JS('', '$names.forEach($getExtensionSymbol)'); |
| +// Install properties in prototype order. Properties / descriptors from |
| +// more specific types should overwrite ones from less specific types. |
| +_installProperties(jsProto, extProto) => JS('', '''(() => { |
| + if (extProto !== $Object.prototype && extProto !== jsProto) { |
| + $_installProperties(jsProto, extProto.__proto__); |
| + } |
| + $copyTheseProperties(jsProto, extProto, $getOwnPropertySymbols(extProto)); |
| +})()'''); |
| + |
| /// |
| /// Copy symbols from the prototype of the source to destination. |
| /// These are the only properties safe to copy onto an existing public |
| @@ -280,13 +291,8 @@ registerExtension(jsType, dartExtType) => JS('', '''(() => { |
| // Mark the JS type's instances so we can easily check for extensions. |
| $assert_(jsProto[$_extensionType] === void 0); |
| - jsProto[$_extensionType] = extProto; |
| - |
| - let dartObjProto = $Object.prototype; |
| - while (extProto !== dartObjProto && extProto !== jsProto) { |
| - $copyTheseProperties(jsProto, extProto, $getOwnPropertySymbols(extProto)); |
| - extProto = extProto.__proto__; |
| - } |
| + jsProto[$_extensionType] = $dartExtType; |
| + $_installProperties(jsProto, extProto); |
| let originalSigFn = $getOwnPropertyDescriptor($dartExtType, $_methodSig).get; |
| $assert_(originalSigFn); |
| $defineMemoizedGetter($jsType, $_methodSig, originalSigFn); |
| @@ -345,6 +351,9 @@ canonicalMember(obj, name) => JS('', '''(() => { |
| /// Sets the type of `obj` to be `type` |
| setType(obj, type) => JS('', '''(() => { |
| $obj.__proto__ = $type.prototype; |
| + // TODO(vsm): This should be set in registerExtension, but that is only |
| + // invoked on the generic type (e.g., JSArray<dynamic>, not JSArray<int>). |
|
Jennifer Messerly
2016/02/10 00:20:30
Given a generic type T, it's possible to get its r
vsm
2016/02/11 22:36:06
I need this to go the other way around - i.e., to
Jennifer Messerly
2016/02/11 23:04:57
I'm 99% sure this should not be needed. In JavaScr
|
| + $obj.__proto__[$_extensionType] = type; |
|
Jennifer Messerly
2016/02/10 00:20:30
(possibly moot based on above comment)
I think th
vsm
2016/02/11 22:36:06
Done.
|
| return $obj; |
| })()'''); |