OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 library dart._interceptors; | 5 library dart._interceptors; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 import 'dart:_internal' hide Symbol; | 8 import 'dart:_internal' hide Symbol; |
9 import 'dart:_js_helper'; | 9 import 'dart:_js_helper'; |
10 import 'dart:_foreign_helper' show JS; | 10 import 'dart:_foreign_helper' show JS; |
(...skipping 28 matching lines...) Expand all Loading... |
39 Type get runtimeType => bool; | 39 Type get runtimeType => bool; |
40 } | 40 } |
41 | 41 |
42 /** | 42 /** |
43 * The supertype for JSString and JSArray. Used by the backend as to | 43 * The supertype for JSString and JSArray. Used by the backend as to |
44 * have a type mask that contains the objects that we can use the | 44 * have a type mask that contains the objects that we can use the |
45 * native JS [] operator and length on. | 45 * native JS [] operator and length on. |
46 */ | 46 */ |
47 abstract class JSIndexable<E> { | 47 abstract class JSIndexable<E> { |
48 int get length; | 48 int get length; |
49 E operator[](int index); | 49 E operator [](int index); |
50 } | 50 } |
51 | 51 |
52 /** | 52 /** |
53 * The interface implemented by JavaScript objects. These are methods in | 53 * The interface implemented by JavaScript objects. These are methods in |
54 * addition to the regular Dart Object methods like [Object.hashCode]. | 54 * addition to the regular Dart Object methods like [Object.hashCode]. |
55 * | 55 * |
56 * This is the type that should be exported by a JavaScript interop library. | 56 * This is the type that should be exported by a JavaScript interop library. |
57 */ | 57 */ |
58 abstract class JSObject { | 58 abstract class JSObject {} |
59 } | |
60 | |
61 | 59 |
62 /** | 60 /** |
63 * Interceptor base class for JavaScript objects not recognized as some more | 61 * Interceptor base class for JavaScript objects not recognized as some more |
64 * specific native type. | 62 * specific native type. |
65 */ | 63 */ |
66 abstract class JavaScriptObject extends Interceptor implements JSObject { | 64 abstract class JavaScriptObject extends Interceptor implements JSObject { |
67 const JavaScriptObject(); | 65 const JavaScriptObject(); |
68 | 66 |
69 // It would be impolite to stash a property on the object. | 67 // It would be impolite to stash a property on the object. |
70 int get hashCode => 0; | 68 int get hashCode => 0; |
71 | 69 |
72 Type get runtimeType => JSObject; | 70 Type get runtimeType => JSObject; |
73 } | 71 } |
74 | 72 |
75 | |
76 /** | 73 /** |
77 * Interceptor for plain JavaScript objects created as JavaScript object | 74 * Interceptor for plain JavaScript objects created as JavaScript object |
78 * literals or `new Object()`. | 75 * literals or `new Object()`. |
79 */ | 76 */ |
80 class PlainJavaScriptObject extends JavaScriptObject { | 77 class PlainJavaScriptObject extends JavaScriptObject { |
81 const PlainJavaScriptObject(); | 78 const PlainJavaScriptObject(); |
82 } | 79 } |
83 | 80 |
84 | |
85 /** | 81 /** |
86 * Interceptor for unclassified JavaScript objects, typically objects with a | 82 * Interceptor for unclassified JavaScript objects, typically objects with a |
87 * non-trivial prototype chain. | 83 * non-trivial prototype chain. |
88 * | 84 * |
89 * This class also serves as a fallback for unknown JavaScript exceptions. | 85 * This class also serves as a fallback for unknown JavaScript exceptions. |
90 */ | 86 */ |
91 class UnknownJavaScriptObject extends JavaScriptObject { | 87 class UnknownJavaScriptObject extends JavaScriptObject { |
92 const UnknownJavaScriptObject(); | 88 const UnknownJavaScriptObject(); |
93 | 89 |
94 String toString() => JS('String', 'String(#)', this); | 90 String toString() => JS('String', 'String(#)', this); |
95 } | 91 } |
96 | 92 |
97 // Obsolete in dart dev compiler. Added only so that the same version of | 93 // Obsolete in dart dev compiler. Added only so that the same version of |
98 // dart:html can be used in dart2js an dev compiler. | 94 // dart:html can be used in dart2js an dev compiler. |
99 // Warning: calls to these methods need to be removed before custom elements | 95 // Warning: calls to these methods need to be removed before custom elements |
100 // and cross-frame dom objects behave correctly in ddc. | 96 // and cross-frame dom objects behave correctly in ddc. |
101 // See https://github.com/dart-lang/sdk/issues/28326 | 97 // See https://github.com/dart-lang/sdk/issues/28326 |
102 findInterceptorConstructorForType(Type type) { } | 98 findInterceptorConstructorForType(Type type) {} |
103 findConstructorForNativeSubclassType(Type type, String name) { } | 99 findConstructorForNativeSubclassType(Type type, String name) {} |
104 getNativeInterceptor(object) {} | 100 getNativeInterceptor(object) {} |
105 setDispatchProperty(object, value) {} | 101 setDispatchProperty(object, value) {} |
OLD | NEW |