| 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 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 webcore_function_name = 'svgTarget' | 507 webcore_function_name = 'svgTarget' |
| 508 else: | 508 else: |
| 509 webcore_function_name = _ToWebKitName(attr.id) | 509 webcore_function_name = _ToWebKitName(attr.id) |
| 510 if attr.type.id.startswith('SVGAnimated'): | 510 if attr.type.id.startswith('SVGAnimated'): |
| 511 webcore_function_name += 'Animated' | 511 webcore_function_name += 'Animated' |
| 512 | 512 |
| 513 function_expression = self._GenerateWebCoreFunctionExpression(webcore_functi
on_name, attr) | 513 function_expression = self._GenerateWebCoreFunctionExpression(webcore_functi
on_name, attr) |
| 514 invocation = self._GenerateWebCoreInvocation(function_expression, | 514 invocation = self._GenerateWebCoreInvocation(function_expression, |
| 515 arguments, attr.type.id, attr.ext_attrs, attr.get_raises) | 515 arguments, attr.type.id, attr.ext_attrs, attr.get_raises) |
| 516 self._GenerateNativeCallback(cpp_callback_name, parameter_definitions_emitte
r.Fragments(), | 516 self._GenerateNativeCallback(cpp_callback_name, parameter_definitions_emitte
r.Fragments(), |
| 517 True, invocation, raises_exceptions=raises_exceptions) | 517 True, invocation, raises_exceptions=raises_exceptions, runtime_check=Non
e) |
| 518 | 518 |
| 519 def _AddSetter(self, attr, html_name): | 519 def _AddSetter(self, attr, html_name): |
| 520 type_info = self._TypeInfo(attr.type.id) | 520 type_info = self._TypeInfo(attr.type.id) |
| 521 dart_declaration = 'void set %s(%s)' % (html_name, self._DartType(attr.type.
id)) | 521 dart_declaration = 'void set %s(%s)' % (html_name, self._DartType(attr.type.
id)) |
| 522 is_custom = set(['Custom', 'CustomSetter', 'V8CustomSetter']) & set(attr.ext
_attrs) | 522 is_custom = set(['Custom', 'CustomSetter', 'V8CustomSetter']) & set(attr.ext
_attrs) |
| 523 cpp_callback_name = self._GenerateNativeBinding(attr.id, 2, | 523 cpp_callback_name = self._GenerateNativeBinding(attr.id, 2, |
| 524 dart_declaration, 'Setter', is_custom) | 524 dart_declaration, 'Setter', is_custom) |
| 525 if is_custom: | 525 if is_custom: |
| 526 return | 526 return |
| 527 | 527 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 543 argument_expression = self._GenerateToNative( | 543 argument_expression = self._GenerateToNative( |
| 544 parameter_definitions_emitter, attr, 1, argument_name='value') | 544 parameter_definitions_emitter, attr, 1, argument_name='value') |
| 545 arguments.append(argument_expression) | 545 arguments.append(argument_expression) |
| 546 | 546 |
| 547 parameter_definitions = parameter_definitions_emitter.Fragments() | 547 parameter_definitions = parameter_definitions_emitter.Fragments() |
| 548 function_expression = self._GenerateWebCoreFunctionExpression(webcore_functi
on_name, attr) | 548 function_expression = self._GenerateWebCoreFunctionExpression(webcore_functi
on_name, attr) |
| 549 invocation = self._GenerateWebCoreInvocation(function_expression, | 549 invocation = self._GenerateWebCoreInvocation(function_expression, |
| 550 arguments, 'void', attr.ext_attrs, attr.set_raises) | 550 arguments, 'void', attr.ext_attrs, attr.set_raises) |
| 551 | 551 |
| 552 self._GenerateNativeCallback(cpp_callback_name, parameter_definitions_emitte
r.Fragments(), | 552 self._GenerateNativeCallback(cpp_callback_name, parameter_definitions_emitte
r.Fragments(), |
| 553 True, invocation, raises_exceptions=True) | 553 True, invocation, raises_exceptions=True, runtime_check=None) |
| 554 | 554 |
| 555 def AddIndexer(self, element_type): | 555 def AddIndexer(self, element_type): |
| 556 """Adds all the methods required to complete implementation of List.""" | 556 """Adds all the methods required to complete implementation of List.""" |
| 557 # We would like to simply inherit the implementation of everything except | 557 # We would like to simply inherit the implementation of everything except |
| 558 # get length(), [], and maybe []=. It is possible to extend from a base | 558 # get length(), [], and maybe []=. It is possible to extend from a base |
| 559 # array implementation class only when there is no other implementation | 559 # array implementation class only when there is no other implementation |
| 560 # inheritance. There might be no implementation inheritance other than | 560 # inheritance. There might be no implementation inheritance other than |
| 561 # DOMBaseWrapper for many classes, but there might be some where the | 561 # DOMBaseWrapper for many classes, but there might be some where the |
| 562 # array-ness is introduced by a non-root interface: | 562 # array-ness is introduced by a non-root interface: |
| 563 # | 563 # |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 778 | 778 |
| 779 if 'NeedsUserGestureCheck' in operation.ext_attrs: | 779 if 'NeedsUserGestureCheck' in operation.ext_attrs: |
| 780 cpp_arguments.append('DartUtilities::processingUserGesture') | 780 cpp_arguments.append('DartUtilities::processingUserGesture') |
| 781 | 781 |
| 782 function_expression = self._GenerateWebCoreFunctionExpression(webcore_functi
on_name, operation) | 782 function_expression = self._GenerateWebCoreFunctionExpression(webcore_functi
on_name, operation) |
| 783 invocation = self._GenerateWebCoreInvocation(function_expression, cpp_argume
nts, | 783 invocation = self._GenerateWebCoreInvocation(function_expression, cpp_argume
nts, |
| 784 operation.type.id, operation.ext_attrs, operation.raises) | 784 operation.type.id, operation.ext_attrs, operation.raises) |
| 785 self._GenerateNativeCallback(cpp_callback_name, | 785 self._GenerateNativeCallback(cpp_callback_name, |
| 786 parameter_definitions=parameter_definitions_emitter.Fragments(), | 786 parameter_definitions=parameter_definitions_emitter.Fragments(), |
| 787 needs_receiver=not operation.is_static, invocation=invocation, | 787 needs_receiver=not operation.is_static, invocation=invocation, |
| 788 raises_exceptions=raises_exceptions) | 788 raises_exceptions=raises_exceptions, |
| 789 runtime_check=None) |
| 789 | 790 |
| 790 def _GenerateNativeCallback(self, callback_name, parameter_definitions, | 791 def _GenerateNativeCallback(self, callback_name, parameter_definitions, |
| 791 needs_receiver, invocation, raises_exceptions, runtime_check=None): | 792 needs_receiver, invocation, raises_exceptions, runtime_check): |
| 792 | 793 |
| 793 head = parameter_definitions | 794 head = parameter_definitions |
| 794 | 795 |
| 795 if needs_receiver: | 796 if needs_receiver: |
| 796 head = emitter.Format( | 797 head = emitter.Format( |
| 797 ' $WEBCORE_CLASS_NAME* receiver = DartDOMWrapper::receiver< $WE
BCORE_CLASS_NAME >(args);\n' | 798 ' $WEBCORE_CLASS_NAME* receiver = DartDOMWrapper::receiver< $WE
BCORE_CLASS_NAME >(args);\n' |
| 798 '$HEAD\n', | 799 '$HEAD\n', |
| 799 WEBCORE_CLASS_NAME=self._interface_type_info.native_type(), | 800 WEBCORE_CLASS_NAME=self._interface_type_info.native_type(), |
| 800 HEAD=head) | 801 HEAD=head) |
| 801 | 802 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 943 | 944 |
| 944 def _IsArgumentOptionalInWebCore(argument): | 945 def _IsArgumentOptionalInWebCore(argument): |
| 945 return IsOptional(argument) and not 'Callback' in argument.ext_attrs | 946 return IsOptional(argument) and not 'Callback' in argument.ext_attrs |
| 946 | 947 |
| 947 def _ToWebKitName(name): | 948 def _ToWebKitName(name): |
| 948 name = name[0].lower() + name[1:] | 949 name = name[0].lower() + name[1:] |
| 949 name = re.sub(r'^(hTML|uRL|jS|xML|xSLT)', lambda s: s.group(1).lower(), | 950 name = re.sub(r'^(hTML|uRL|jS|xML|xSLT)', lambda s: s.group(1).lower(), |
| 950 name) | 951 name) |
| 951 return re.sub(r'^(create|exclusive)', lambda s: 'is' + s.group(1).capitalize()
, | 952 return re.sub(r'^(create|exclusive)', lambda s: 'is' + s.group(1).capitalize()
, |
| 952 name) | 953 name) |
| OLD | NEW |