| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 3 # for details. All rights reserved. Use of this source code is governed by a | 3 # for details. All rights reserved. Use of this source code is governed by a |
| 4 # BSD-style license that can be found in the LICENSE file. | 4 # BSD-style license that can be found in the LICENSE file. |
| 5 | 5 |
| 6 """This module provides shared functionality for the system to generate | 6 """This module provides shared functionality for the system to generate |
| 7 dart:html APIs from the IDL database.""" | 7 dart:html APIs from the IDL database.""" |
| 8 | 8 |
| 9 import emitter | 9 import emitter |
| 10 from generator import AnalyzeOperation, ConstantOutputOrder, \ | 10 from generator import AnalyzeOperation, ConstantOutputOrder, \ |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 ' throw new ArgumentError("Incorrect number or type of arguments");
' | 275 ' throw new ArgumentError("Incorrect number or type of arguments");
' |
| 276 '\n'); | 276 '\n'); |
| 277 else: | 277 else: |
| 278 signature = signatures[0] | 278 signature = signatures[0] |
| 279 argument_count = len(signature) | 279 argument_count = len(signature) |
| 280 for argument_position, argument in list(enumerate(signature))[::-1]: | 280 for argument_position, argument in list(enumerate(signature))[::-1]: |
| 281 if is_optional(0, argument): | 281 if is_optional(0, argument): |
| 282 check = '?%s' % parameter_names[argument_position] | 282 check = '?%s' % parameter_names[argument_position] |
| 283 # argument_count instead of argument_position + 1 is used here to cove
r one | 283 # argument_count instead of argument_position + 1 is used here to cove
r one |
| 284 # complicated case with the effectively optional argument in the middl
e. | 284 # complicated case with the effectively optional argument in the middl
e. |
| 285 # Consider foo(x, [Optional] y, [Optional=DefaultIsNullString] z) | 285 # Consider foo(x, optional y, [Default=NullString] optional z) |
| 286 # (as of now it's modelled after HTMLMediaElement.webkitAddKey). | 286 # (as of now it's modelled after HTMLMediaElement.webkitAddKey). |
| 287 # y is optional in WebCore, while z is not. | 287 # y is optional in WebCore, while z is not. |
| 288 # In this case, if y was actually passed, we'd like to emit foo(x, y,
z) invocation, | 288 # In this case, if y was actually passed, we'd like to emit foo(x, y,
z) invocation, |
| 289 # not foo(x, y). | 289 # not foo(x, y). |
| 290 GenerateCall(0, argument_count, [check]) | 290 GenerateCall(0, argument_count, [check]) |
| 291 argument_count = argument_position | 291 argument_count = argument_position |
| 292 GenerateCall(0, argument_count, []) | 292 GenerateCall(0, argument_count, []) |
| 293 | 293 |
| 294 def _GenerateDispatcherBody(self, | 294 def _GenerateDispatcherBody(self, |
| 295 operations, | 295 operations, |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 walk(interface.parents) | 634 walk(interface.parents) |
| 635 else: | 635 else: |
| 636 walk(interface.parents[1:]) | 636 walk(interface.parents[1:]) |
| 637 return result | 637 return result |
| 638 | 638 |
| 639 def _DartType(self, type_name): | 639 def _DartType(self, type_name): |
| 640 return self._type_registry.DartType(type_name) | 640 return self._type_registry.DartType(type_name) |
| 641 | 641 |
| 642 def _IsPrivate(self, name): | 642 def _IsPrivate(self, name): |
| 643 return name.startswith('_') | 643 return name.startswith('_') |
| OLD | NEW |