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

Side by Side Diff: sdk/lib/js_util/dart2js/js_util_dart2js.dart

Issue 2755483003: Make `getProperty` and `callMethod` nullable (Closed)
Patch Set: Created 3 years, 9 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 /// Utility methods to efficiently manipulate typed JSInterop objects in cases 5 /// Utility methods to efficiently manipulate typed JSInterop objects in cases
6 /// where the name to call is not known at runtime. You should only use these 6 /// where the name to call is not known at runtime. You should only use these
7 /// methods when the same effect cannot be achieved with @JS annotations. 7 /// methods when the same effect cannot be achieved with @JS annotations.
8 /// These methods would be extension methods on JSObject if Dart supported 8 /// These methods would be extension methods on JSObject if Dart supported
9 /// extension methods. 9 /// extension methods.
10 library dart.js_util; 10 library dart.js_util;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 return o; 52 return o;
53 } 53 }
54 } 54 }
55 55
56 return _convert(data); 56 return _convert(data);
57 } 57 }
58 58
59 newObject() => JS('=Object', '{}'); 59 newObject() => JS('=Object', '{}');
60 60
61 hasProperty(o, name) => JS('bool', '# in #', name, o); 61 hasProperty(o, name) => JS('bool', '# in #', name, o);
62 getProperty(o, name) => JS('Object', '#[#]', o, name); 62 getProperty(o, name) => JS('Object|Null', '#[#]', o, name);
63 setProperty(o, name, value) => JS('', '#[#]=#', o, name, value); 63 setProperty(o, name, value) => JS('', '#[#]=#', o, name, value);
64 64
65 callMethod(o, String method, List args) => 65 callMethod(o, String method, List args) =>
66 JS('Object', '#[#].apply(#, #)', o, method, o, args); 66 JS('Object|Null', '#[#].apply(#, #)', o, method, o, args);
67 67
68 instanceof(o, Function type) => JS('bool', '# instanceof #', o, type); 68 instanceof(o, Function type) => JS('bool', '# instanceof #', o, type);
69 callConstructor(Function constr, List arguments) { 69 callConstructor(Function constr, List arguments) {
70 if (arguments == null) { 70 if (arguments == null) {
71 return JS('Object', 'new #()', constr); 71 return JS('Object', 'new #()', constr);
72 } 72 }
73 73
74 if (JS('bool', '# instanceof Array', arguments)) { 74 if (JS('bool', '# instanceof Array', arguments)) {
75 int argumentCount = JS('int', '#.length', arguments); 75 int argumentCount = JS('int', '#.length', arguments);
76 switch (argumentCount) { 76 switch (argumentCount) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 // object for which there is an interceptor 117 // object for which there is an interceptor
118 return JS('Object', 'new #()', factoryFunction); 118 return JS('Object', 'new #()', factoryFunction);
119 119
120 // TODO(sra): Investigate: 120 // TODO(sra): Investigate:
121 // 121 //
122 // var jsObj = JS('', 'Object.create(#.prototype)', constr); 122 // var jsObj = JS('', 'Object.create(#.prototype)', constr);
123 // JS('', '#.apply(#, #)', constr, jsObj, 123 // JS('', '#.apply(#, #)', constr, jsObj,
124 // []..addAll(arguments.map(_convertToJS))); 124 // []..addAll(arguments.map(_convertToJS)));
125 // return _wrapToDart(jsObj); 125 // return _wrapToDart(jsObj);
126 } 126 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698