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