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

Unified Diff: frog/leg/lib/js_helper.dart

Issue 9641018: Canonicalize closures passed to native functions. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « client/tests/client/client-leg.status ('k') | frog/tests/native/src/NativeClosureIdentityFrogTest.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/leg/lib/js_helper.dart
===================================================================
--- frog/leg/lib/js_helper.dart (revision 5171)
+++ frog/leg/lib/js_helper.dart (working copy)
@@ -1273,6 +1273,8 @@
* returned unmodified.
*/
unwrapException(ex) {
+ // Note that we are checking if the object has the property. If it
+ // has, it could be set null if the thrown value is null.
ahe 2012/03/08 18:32:02 "set null" -> "null"
if (JS('bool', @'"dartException" in $0', ex)) {
return JS('Object', @'$0.dartException', ex);
} else if (JS('bool', @'$0 instanceof TypeError', ex)) {
@@ -1333,7 +1335,9 @@
* closure when the Dart closure is passed to the DOM.
*/
convertDartClosureToJS(closure) {
- return JS("var", @"""function() {
+ var function = JS('var', @'$0.$identity', closure);
+ if (JS('bool', @'!!$0', function)) return function;
+ function = JS("var", @"""function() {
var dartClosure = $0;
switch (arguments.length) {
case 0: return $1(dartClosure);
@@ -1347,6 +1351,8 @@
callClosure0,
callClosure1,
callClosure2);
+ JS('void', @'$0.$identity = $1', closure, function);
+ return function;
}
/**
« no previous file with comments | « client/tests/client/client-leg.status ('k') | frog/tests/native/src/NativeClosureIdentityFrogTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698