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

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 | « no previous file | 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 5170)
+++ frog/leg/lib/js_helper.dart (working copy)
@@ -1333,7 +1333,10 @@
* closure when the Dart closure is passed to the DOM.
*/
convertDartClosureToJS(closure) {
- return JS("var", @"""function() {
+ if (JS('bool', @'"$identity" in $0', closure)) {
kasperl 2012/03/08 15:06:08 The 'in' construct is probably not going to perfor
ngeoffray 2012/03/08 15:11:36 OK, I copied the test from line 1276, I'll change
ngeoffray 2012/03/08 15:24:01 There is actually a good reason why the code line
+ return JS('var', @'$0.$identity', closure);
+ }
+ var function = JS("var", @"""function() {
var dartClosure = $0;
switch (arguments.length) {
case 0: return $1(dartClosure);
@@ -1347,6 +1350,8 @@
callClosure0,
callClosure1,
callClosure2);
+ JS('void', @'$0.$identity = $1', closure, function);
+ return function;
}
/**
« no previous file with comments | « no previous file | frog/tests/native/src/NativeClosureIdentityFrogTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698