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 library dart.js; | 5 library dart.js; |
6 | 6 |
7 import 'dart:nativewrappers'; | 7 import 'dart:nativewrappers'; |
8 | 8 |
9 JsObject _cachedContext; | 9 JsObject _cachedContext; |
10 | 10 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 JsFunction.internal(); | 104 JsFunction.internal(); |
105 | 105 |
106 /** | 106 /** |
107 * Returns a [JsFunction] that captures its 'this' binding and calls [f] | 107 * Returns a [JsFunction] that captures its 'this' binding and calls [f] |
108 * with the value of this passed as the first argument. | 108 * with the value of this passed as the first argument. |
109 */ | 109 */ |
110 factory JsFunction.withThis(Function f) => _withThis(f); | 110 factory JsFunction.withThis(Function f) => _withThis(f); |
111 | 111 |
112 apply(List args, {thisArg}) native "JsFunction_apply"; | 112 apply(List args, {thisArg}) native "JsFunction_apply"; |
113 | 113 |
| 114 /** |
| 115 * Internal only version of apply which uses debugger proxies of Dart objects |
| 116 * rather than opaque handles. This method is private because it cannot be |
| 117 * efficiently implemented in Dart2Js so should only be used by internal |
| 118 * tools. |
| 119 */ |
| 120 _applyDebuggerOnly(List args, {thisArg}) native "JsFunction_applyDebuggerOnly"
; |
| 121 |
114 static JsFunction _withThis(Function f) native "JsFunction_withThis"; | 122 static JsFunction _withThis(Function f) native "JsFunction_withThis"; |
115 } | 123 } |
| 124 |
| 125 /** |
| 126 * Placeholder object for cases where we need to determine exactly how many |
| 127 * args were passed to a function. |
| 128 */ |
| 129 const _UNDEFINED = const Object(); |
| 130 |
| 131 // FIXME(jacobr): this method is a hack to work around the lack of proper dart |
| 132 // support for varargs methods. |
| 133 List _stripUndefinedArgs(List args) => |
| 134 args.takeWhile((i) => i != _UNDEFINED).toList(); |
| 135 |
| 136 /** |
| 137 * Returns a method that can be called with an arbitrary number (for n less |
| 138 * than 11) of arguments without violating Dart type checks. |
| 139 */ |
| 140 Function _wrapAsDebuggerVarArgsFunction(JsFunction jsFunction) => |
| 141 ([a1=_UNDEFINED, a2=_UNDEFINED, a3=_UNDEFINED, a4=_UNDEFINED, |
| 142 a5=_UNDEFINED, a6=_UNDEFINED, a7=_UNDEFINED, a8=_UNDEFINED, |
| 143 a9=_UNDEFINED, a10=_UNDEFINED]) => |
| 144 jsFunction._applyDebuggerOnly(_stripUndefinedArgs( |
| 145 [a1,a2,a3,a4,a5,a6,a7,a8,a9,a10])); |
OLD | NEW |