| 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 systems to generate | 6 """This module provides shared functionality for the systems to generate |
| 7 native binding from the IDL database.""" | 7 native binding from the IDL database.""" |
| 8 | 8 |
| 9 import emitter | 9 import emitter |
| 10 import os | 10 import os |
| (...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 GenerateChecksAndCall(operation, position) | 658 GenerateChecksAndCall(operation, position) |
| 659 GenerateChecksAndCall(operation, len(operation.arguments)) | 659 GenerateChecksAndCall(operation, len(operation.arguments)) |
| 660 body.Emit(' throw "Incorrect number or type of arguments";\n'); | 660 body.Emit(' throw "Incorrect number or type of arguments";\n'); |
| 661 else: | 661 else: |
| 662 operation = operations[0] | 662 operation = operations[0] |
| 663 argument_count = len(operation.arguments) | 663 argument_count = len(operation.arguments) |
| 664 for position, argument in list(enumerate(operation.arguments))[::-1]: | 664 for position, argument in list(enumerate(operation.arguments))[::-1]: |
| 665 if self._IsArgumentOptionalInWebCore(operation, argument): | 665 if self._IsArgumentOptionalInWebCore(operation, argument): |
| 666 check = '%s !== _null' % argument_names[position] | 666 check = '%s !== _null' % argument_names[position] |
| 667 # argument_count instead of position + 1 is used here to cover one | 667 # argument_count instead of position + 1 is used here to cover one |
| 668 # complicated case. Consider foo(x, [Optional] y, [Optional=DefaultIs
NullString] z) | 668 # complicated case with the effectively optional argument in the middl
e. |
| 669 # Consider foo(x, [Optional] y, [Optional=DefaultIsNullString] z) |
| 669 # (as of now it's modelled after HTMLMediaElement.webkitAddKey). | 670 # (as of now it's modelled after HTMLMediaElement.webkitAddKey). |
| 670 # y is optional in WebCore, while z is not. | 671 # y is optional in WebCore, while z is not. |
| 671 # In this case, if y !== _null, we'd like to emit foo(x, y, z) invocat
ion, not | 672 # In this case, if y !== _null, we'd like to emit foo(x, y, z) invocat
ion, not |
| 672 # foo(x, y). | 673 # foo(x, y). |
| 673 GenerateCall(operation, argument_count, [check]) | 674 GenerateCall(operation, argument_count, [check]) |
| 674 argument_count = position | 675 argument_count = position |
| 675 GenerateCall(operation, argument_count, []) | 676 GenerateCall(operation, argument_count, []) |
| 676 | 677 |
| 677 def SecondaryContext(self, interface): | 678 def SecondaryContext(self, interface): |
| 678 pass | 679 pass |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 948 parent_interface = _FindInHierarchy(database, parent_interface, test) | 949 parent_interface = _FindInHierarchy(database, parent_interface, test) |
| 949 if parent_interface: | 950 if parent_interface: |
| 950 return parent_interface | 951 return parent_interface |
| 951 | 952 |
| 952 def _ToWebKitName(name): | 953 def _ToWebKitName(name): |
| 953 name = name[0].lower() + name[1:] | 954 name = name[0].lower() + name[1:] |
| 954 name = re.sub(r'^(hTML|uRL|jS|xML|xSLT)', lambda s: s.group(1).lower(), | 955 name = re.sub(r'^(hTML|uRL|jS|xML|xSLT)', lambda s: s.group(1).lower(), |
| 955 name) | 956 name) |
| 956 return re.sub(r'^(create|exclusive)', lambda s: 'is' + s.group(1).capitalize()
, | 957 return re.sub(r'^(create|exclusive)', lambda s: 'is' + s.group(1).capitalize()
, |
| 957 name) | 958 name) |
| OLD | NEW |