OLD | NEW |
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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 if (!_checkType(invocation.positionalArguments[i], parameters[i].type)) | 299 if (!_checkType(invocation.positionalArguments[i], parameters[i].type)) |
300 return false; | 300 return false; |
301 } | 301 } |
302 if (invocation.namedArguments.isNotEmpty) { | 302 if (invocation.namedArguments.isNotEmpty) { |
303 var startNamed; | 303 var startNamed; |
304 for (startNamed = parameters.length - 1; startNamed >= 0; startNamed--) { | 304 for (startNamed = parameters.length - 1; startNamed >= 0; startNamed--) { |
305 if (!parameters[startNamed].isNamed) break; | 305 if (!parameters[startNamed].isNamed) break; |
306 } | 306 } |
307 startNamed++; | 307 startNamed++; |
308 | 308 |
309 // TODO(jacobr): we are unneccessarily using an O(n^2) algorithm here. | 309 // TODO(jacobr): we are unnecessarily using an O(n^2) algorithm here. |
310 // If we have JS APIs with a lange number of named parameters we should | 310 // If we have JS APIs with a lange number of named parameters we should |
311 // optimize this. Either use a HashSet or invert this, walking over | 311 // optimize this. Either use a HashSet or invert this, walking over |
312 // parameters, querying invocation, and making sure we match | 312 // parameters, querying invocation, and making sure we match |
313 //invocation.namedArguments.size keys. | 313 //invocation.namedArguments.size keys. |
314 for (var name in invocation.namedArguments.keys) { | 314 for (var name in invocation.namedArguments.keys) { |
315 bool match = false; | 315 bool match = false; |
316 for (var j = startNamed; j < parameters.length; j++) { | 316 for (var j = startNamed; j < parameters.length; j++) { |
317 var p = parameters[j]; | 317 var p = parameters[j]; |
318 if (p.simpleName == name) { | 318 if (p.simpleName == name) { |
319 if (!_checkType( | 319 if (!_checkType( |
(...skipping 1374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1694 } else { | 1694 } else { |
1695 var ret = _interopCaptureThisExpando[f]; | 1695 var ret = _interopCaptureThisExpando[f]; |
1696 if (ret == null) { | 1696 if (ret == null) { |
1697 // TODO(jacobr): we could optimize this. | 1697 // TODO(jacobr): we could optimize this. |
1698 ret = JSFunction._createWithThis(f); | 1698 ret = JSFunction._createWithThis(f); |
1699 _interopCaptureThisExpando[f] = ret; | 1699 _interopCaptureThisExpando[f] = ret; |
1700 } | 1700 } |
1701 return ret; | 1701 return ret; |
1702 } | 1702 } |
1703 } | 1703 } |
OLD | NEW |