| 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 |
| 11 import systembase | 11 import systembase |
| 12 from generator import * | 12 from generator import * |
| 13 | 13 |
| 14 _dart_custom_members = set([ | |
| 15 'Window.webkitCancelAnimationFrame', | |
| 16 'Window.webkitRequestAnimationFrame', | |
| 17 ]) | |
| 18 | 14 |
| 19 class NativeImplementationSystem(systembase.System): | 15 class NativeImplementationSystem(systembase.System): |
| 20 | 16 |
| 21 def __init__(self, options): | 17 def __init__(self, options): |
| 22 super(NativeImplementationSystem, self).__init__(options) | 18 super(NativeImplementationSystem, self).__init__(options) |
| 23 self._cpp_header_files = [] | 19 self._cpp_header_files = [] |
| 24 self._cpp_impl_files = [] | 20 self._cpp_impl_files = [] |
| 25 | 21 |
| 26 def ImplementationGenerator(self, interface): | 22 def ImplementationGenerator(self, interface): |
| 27 return NativeImplementationGenerator(self, interface) | 23 return NativeImplementationGenerator(self, interface) |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 'Callback', True) | 535 'Callback', True) |
| 540 | 536 |
| 541 def _HasNativeIndexSetter(self): | 537 def _HasNativeIndexSetter(self): |
| 542 return 'CustomIndexedSetter' in self._interface.ext_attrs | 538 return 'CustomIndexedSetter' in self._interface.ext_attrs |
| 543 | 539 |
| 544 def _EmitNativeIndexSetter(self, element_type): | 540 def _EmitNativeIndexSetter(self, element_type): |
| 545 dart_declaration = 'void operator[]=(int index, %s value)' % element_type | 541 dart_declaration = 'void operator[]=(int index, %s value)' % element_type |
| 546 self._GenerateNativeBinding('numericIndexSetter', 3, dart_declaration, | 542 self._GenerateNativeBinding('numericIndexSetter', 3, dart_declaration, |
| 547 'Callback', True) | 543 'Callback', True) |
| 548 | 544 |
| 549 def _HasCustomImplementation(self, member_name): | |
| 550 member_name = '%s.%s' % (self._html_interface_name, member_name) | |
| 551 return member_name in _dart_custom_members | |
| 552 | |
| 553 def AddOperation(self, info, html_name): | 545 def AddOperation(self, info, html_name): |
| 554 """ | 546 """ |
| 555 Arguments: | 547 Arguments: |
| 556 info: An OperationInfo object. | 548 info: An OperationInfo object. |
| 557 """ | 549 """ |
| 558 | 550 |
| 559 if self._HasCustomImplementation(info.name): | |
| 560 return | |
| 561 | |
| 562 operation = info.operations[0] | 551 operation = info.operations[0] |
| 563 | 552 |
| 564 if 'CheckSecurityForNode' in operation.ext_attrs: | 553 if 'CheckSecurityForNode' in operation.ext_attrs: |
| 565 # FIXME: exclude from interface as well. | 554 # FIXME: exclude from interface as well. |
| 566 return | 555 return |
| 567 | 556 |
| 568 is_custom = 'Custom' in operation.ext_attrs | 557 is_custom = 'Custom' in operation.ext_attrs |
| 569 has_optional_arguments = any(self._IsArgumentOptionalInWebCore(operation, ar
gument) for argument in operation.arguments) | 558 has_optional_arguments = any(self._IsArgumentOptionalInWebCore(operation, ar
gument) for argument in operation.arguments) |
| 570 needs_dispatcher = not is_custom and (len(info.operations) > 1 or has_option
al_arguments) | 559 needs_dispatcher = not is_custom and (len(info.operations) > 1 or has_option
al_arguments) |
| 571 | 560 |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 949 parent_interface = _FindInHierarchy(database, parent_interface, test) | 938 parent_interface = _FindInHierarchy(database, parent_interface, test) |
| 950 if parent_interface: | 939 if parent_interface: |
| 951 return parent_interface | 940 return parent_interface |
| 952 | 941 |
| 953 def _ToWebKitName(name): | 942 def _ToWebKitName(name): |
| 954 name = name[0].lower() + name[1:] | 943 name = name[0].lower() + name[1:] |
| 955 name = re.sub(r'^(hTML|uRL|jS|xML|xSLT)', lambda s: s.group(1).lower(), | 944 name = re.sub(r'^(hTML|uRL|jS|xML|xSLT)', lambda s: s.group(1).lower(), |
| 956 name) | 945 name) |
| 957 return re.sub(r'^(create|exclusive)', lambda s: 'is' + s.group(1).capitalize()
, | 946 return re.sub(r'^(create|exclusive)', lambda s: 'is' + s.group(1).capitalize()
, |
| 958 name) | 947 name) |
| OLD | NEW |