Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(572)

Side by Side Diff: sdk/lib/js/dartium/js_dartium.dart

Issue 1428593002: Deprecate new internal Dartium/JsInterop APIs that are public (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 /** 5 /**
6 * Support for interoperating with JavaScript. 6 * Support for interoperating with JavaScript.
7 * 7 *
8 * This library provides access to JavaScript objects from Dart, allowing 8 * This library provides access to JavaScript objects from Dart, allowing
9 * Dart code to get and set properties, and call methods of JavaScript objects 9 * Dart code to get and set properties, and call methods of JavaScript objects
10 * and invoke JavaScript functions. The library takes care of converting 10 * and invoke JavaScript functions. The library takes care of converting
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 _members.add(mirror); 200 _members.add(mirror);
201 } 201 }
202 202
203 final List<mirrors.DeclarationMirror> _members; 203 final List<mirrors.DeclarationMirror> _members;
204 } 204 }
205 205
206 /** 206 /**
207 * Temporary method that we hope to remove at some point. This method should 207 * Temporary method that we hope to remove at some point. This method should
208 * generally only be called by machine generated code. 208 * generally only be called by machine generated code.
209 */ 209 */
210
211 void registerJsInterfaces([List<Type> classes]) { 210 void registerJsInterfaces([List<Type> classes]) {
212 // This method is now obsolete in Dartium. 211 // This method is now obsolete in Dartium.
213 } 212 }
214 213
215 void _registerJsInterfaces(List<Type> classes) { 214 void _registerJsInterfaces(List<Type> classes) {
216 for (Type type in classes) { 215 for (Type type in classes) {
217 if (!_jsInterfaceTypes.add(type)) continue; // Already registered. 216 if (!_jsInterfaceTypes.add(type)) continue; // Already registered.
218 mirrors.ClassMirror typeMirror = mirrors.reflectType(type); 217 mirrors.ClassMirror typeMirror = mirrors.reflectType(type);
219 typeMirror.declarations.forEach((symbol, declaration) { 218 typeMirror.declarations.forEach((symbol, declaration) {
220 if (declaration is mirrors.MethodMirror || 219 if (declaration is mirrors.MethodMirror ||
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 } 293 }
295 return name; 294 return name;
296 } 295 }
297 296
298 final _JS_LIBRARY_PREFIX = "js_library"; 297 final _JS_LIBRARY_PREFIX = "js_library";
299 final _UNDEFINED_VAR = "_UNDEFINED_JS_CONST"; 298 final _UNDEFINED_VAR = "_UNDEFINED_JS_CONST";
300 299
301 String _accessJsPath(String path) => 300 String _accessJsPath(String path) =>
302 "${_JS_LIBRARY_PREFIX}.context${path.split(".").map((p) => "['$p']").join('' )}"; 301 "${_JS_LIBRARY_PREFIX}.context${path.split(".").map((p) => "['$p']").join('' )}";
303 302
303 @Deprecated("Internal Use Only")
304 void addMemberHelper(mirrors.MethodMirror declaration, String path, StringBuffer sb, {bool isStatic: false, String memberName}) { 304 void addMemberHelper(mirrors.MethodMirror declaration, String path, StringBuffer sb, {bool isStatic: false, String memberName}) {
305 var jsName = _getJsMemberName(declaration); 305 var jsName = _getJsMemberName(declaration);
306 path = (path != null && path.isNotEmpty) ? "${path}.${jsName}" : jsName; 306 path = (path != null && path.isNotEmpty) ? "${path}.${jsName}" : jsName;
307 var name = memberName != null ? memberName : _getDeclarationName(declaration); 307 var name = memberName != null ? memberName : _getDeclarationName(declaration);
308 if (declaration.isConstructor) { 308 if (declaration.isConstructor) {
309 sb.write("factory"); 309 sb.write("factory");
310 } else if (isStatic) { 310 } else if (isStatic) {
311 sb.write("static"); 311 sb.write("static");
312 } else { 312 } else {
313 sb.write("patch"); 313 sb.write("patch");
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 || wrapped is html.Node 710 || wrapped is html.Node
711 || wrapped is TypedData 711 || wrapped is TypedData
712 || wrapped is html.Window) ? wrapped : o; 712 || wrapped is html.Window) ? wrapped : o;
713 } 713 }
714 714
715 /** 715 /**
716 * Get the dart wrapper object for object. Top-level so we 716 * Get the dart wrapper object for object. Top-level so we
717 * we can access it from other libraries without it being 717 * we can access it from other libraries without it being
718 * a public instance field on JsObject. 718 * a public instance field on JsObject.
719 */ 719 */
720 @Deprecated("Internal Use Only")
720 getDartHtmlWrapperFor(JsObject object) => object._dartHtmlWrapper; 721 getDartHtmlWrapperFor(JsObject object) => object._dartHtmlWrapper;
721 722
722 /** 723 /**
723 * Set the dart wrapper object for object. Top-level so we 724 * Set the dart wrapper object for object. Top-level so we
724 * we can access it from other libraries without it being 725 * we can access it from other libraries without it being
725 * a public instance field on JsObject. 726 * a public instance field on JsObject.
726 */ 727 */
728 @Deprecated("Internal Use Only")
727 void setDartHtmlWrapperFor(JsObject object, wrapper) { 729 void setDartHtmlWrapperFor(JsObject object, wrapper) {
728 object._dartHtmlWrapper = wrapper; 730 object._dartHtmlWrapper = wrapper;
729 } 731 }
730 732
731 /** 733 /**
732 * Used by callMethod to get the JS object for each argument passed if the 734 * Used by callMethod to get the JS object for each argument passed if the
733 * argument is a Dart class instance that delegates to a DOM object. See 735 * argument is a Dart class instance that delegates to a DOM object. See
734 * wrap_jso defined in dart:html. 736 * wrap_jso defined in dart:html.
735 */ 737 */
738 @Deprecated("Internal Use Only")
736 unwrap_jso(dartClass_instance) { 739 unwrap_jso(dartClass_instance) {
737 if (dartClass_instance is html.DartHtmlDomObject) 740 if (dartClass_instance is html.DartHtmlDomObject)
738 return dartClass_instance.blink_jsObject; 741 return dartClass_instance.blink_jsObject;
739 else 742 else
740 return dartClass_instance; 743 return dartClass_instance;
741 } 744 }
742 745
743 /** 746 /**
744 * Proxies a JavaScript object to Dart. 747 * Proxies a JavaScript object to Dart.
745 * 748 *
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
970 } 973 }
971 return ret; 974 return ret;
972 } 975 }
973 } 976 }
974 977
975 _callMethod(String name, List args) native "JsObject_callMethod"; 978 _callMethod(String name, List args) native "JsObject_callMethod";
976 } 979 }
977 980
978 // JavaScript interop methods that do not automatically wrap to dart:html types. 981 // JavaScript interop methods that do not automatically wrap to dart:html types.
979 // Warning: this API is not exposed to dart:js. 982 // Warning: this API is not exposed to dart:js.
983 @Deprecated("Internal Use Only")
980 class JsNative { 984 class JsNative {
981 static getProperty(JsObject o, name) { 985 static getProperty(JsObject o, name) {
982 return o._operator_getter(name); 986 return o._operator_getter(name);
983 } 987 }
984 988
985 static callMethod(JsObject o, String method, List args) { 989 static callMethod(JsObject o, String method, List args) {
986 return o._callMethod(method, args); 990 return o._callMethod(method, args);
987 } 991 }
988 992
989 static getArrayIndex(JsArray array, int index) { 993 static getArrayIndex(JsArray array, int index) {
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1156 */ 1160 */
1157 Function _wrapAsDebuggerVarArgsFunction(JsFunction jsFunction) => 1161 Function _wrapAsDebuggerVarArgsFunction(JsFunction jsFunction) =>
1158 ([a1 = _UNDEFINED, a2 = _UNDEFINED, a3 = _UNDEFINED, a4 = _UNDEFINED, 1162 ([a1 = _UNDEFINED, a2 = _UNDEFINED, a3 = _UNDEFINED, a4 = _UNDEFINED,
1159 a5 = _UNDEFINED, a6 = _UNDEFINED, a7 = _UNDEFINED, a8 = _UNDEFINED, 1163 a5 = _UNDEFINED, a6 = _UNDEFINED, a7 = _UNDEFINED, a8 = _UNDEFINED,
1160 a9 = _UNDEFINED, a10 = _UNDEFINED]) => jsFunction._applyDebuggerOnly( 1164 a9 = _UNDEFINED, a10 = _UNDEFINED]) => jsFunction._applyDebuggerOnly(
1161 _stripUndefinedArgs([a1, a2, a3, a4, a5, a6, a7, a8, a9, a10])); 1165 _stripUndefinedArgs([a1, a2, a3, a4, a5, a6, a7, a8, a9, a10]));
1162 1166
1163 // This method is a no-op in Dartium. 1167 // This method is a no-op in Dartium.
1164 // TODO(jacobr): tag methods so we can throw if a Dart method is passed to 1168 // TODO(jacobr): tag methods so we can throw if a Dart method is passed to
1165 // JavaScript using the new interop without calling allowInterop. 1169 // JavaScript using the new interop without calling allowInterop.
1170 @Deprecated("Internal Use Only")
1166 Function allowInterop(Function f) => f; 1171 Function allowInterop(Function f) => f;
1167 1172
1168 Expando<JsFunction> _interopCaptureThisExpando = new Expando<JsFunction>(); 1173 Expando<JsFunction> _interopCaptureThisExpando = new Expando<JsFunction>();
1169 1174
1175 @Deprecated("Internal Use Only")
1170 Function allowInteropCaptureThis(Function f) { 1176 Function allowInteropCaptureThis(Function f) {
1171 if (f is JsFunction) { 1177 if (f is JsFunction) {
1172 // Behavior when the function is already a JS function is unspecified. 1178 // Behavior when the function is already a JS function is unspecified.
1173 throw new ArgumentError( 1179 throw new ArgumentError(
1174 "Function is already a JS function so cannot capture this."); 1180 "Function is already a JS function so cannot capture this.");
1175 return f; 1181 return f;
1176 } else { 1182 } else {
1177 var ret = _interopCaptureThisExpando[f]; 1183 var ret = _interopCaptureThisExpando[f];
1178 if (ret == null) { 1184 if (ret == null) {
1179 ret = new JsFunction.withThis(f); 1185 ret = new JsFunction.withThis(f);
1180 _interopCaptureThisExpando[f] = ret; 1186 _interopCaptureThisExpando[f] = ret;
1181 } 1187 }
1182 return ret; 1188 return ret;
1183 } 1189 }
1184 } 1190 }
OLDNEW
« no previous file with comments | « sdk/lib/indexed_db/dartium/indexed_db_dartium.dart ('k') | sdk/lib/svg/dartium/svg_dartium.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698