Chromium Code Reviews| 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 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 545 function_expression = self._GenerateWebCoreFunctionExpression(webcore_functi on_name, attr) | 545 function_expression = self._GenerateWebCoreFunctionExpression(webcore_functi on_name, attr) |
| 546 self._GenerateNativeCallback( | 546 self._GenerateNativeCallback( |
| 547 cpp_callback_name, | 547 cpp_callback_name, |
| 548 True, | 548 True, |
| 549 function_expression, | 549 function_expression, |
| 550 attr, | 550 attr, |
| 551 [attr], | 551 [attr], |
| 552 'void', | 552 'void', |
| 553 False, | 553 False, |
| 554 'SetterRaisesException' in attr.ext_attrs, | 554 'SetterRaisesException' in attr.ext_attrs, |
| 555 requires_custom_element_callback=True) | 555 generate_custom_element_scope_if_needed=True) |
| 556 | 556 |
| 557 def AddIndexer(self, element_type): | 557 def AddIndexer(self, element_type): |
| 558 """Adds all the methods required to complete implementation of List.""" | 558 """Adds all the methods required to complete implementation of List.""" |
| 559 # We would like to simply inherit the implementation of everything except | 559 # We would like to simply inherit the implementation of everything except |
| 560 # length, [], and maybe []=. It is possible to extend from a base | 560 # length, [], and maybe []=. It is possible to extend from a base |
| 561 # array implementation class only when there is no other implementation | 561 # array implementation class only when there is no other implementation |
| 562 # inheritance. There might be no implementation inheritance other than | 562 # inheritance. There might be no implementation inheritance other than |
| 563 # DOMBaseWrapper for many classes, but there might be some where the | 563 # DOMBaseWrapper for many classes, but there might be some where the |
| 564 # array-ness is introduced by a non-root interface: | 564 # array-ness is introduced by a non-root interface: |
| 565 # | 565 # |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 714 webcore_function_name = operation.ext_attrs.get('ImplementedAs', operation.i d) | 714 webcore_function_name = operation.ext_attrs.get('ImplementedAs', operation.i d) |
| 715 function_expression = self._GenerateWebCoreFunctionExpression(webcore_functi on_name, operation, cpp_callback_name) | 715 function_expression = self._GenerateWebCoreFunctionExpression(webcore_functi on_name, operation, cpp_callback_name) |
| 716 self._GenerateNativeCallback( | 716 self._GenerateNativeCallback( |
| 717 cpp_callback_name, | 717 cpp_callback_name, |
| 718 not operation.is_static, | 718 not operation.is_static, |
| 719 function_expression, | 719 function_expression, |
| 720 operation, | 720 operation, |
| 721 arguments, | 721 arguments, |
| 722 operation.type.id, | 722 operation.type.id, |
| 723 operation.type.nullable, | 723 operation.type.nullable, |
| 724 'RaisesException' in operation.ext_attrs) | 724 'RaisesException' in operation.ext_attrs, |
| 725 generate_custom_element_scope_if_needed=True) | |
| 725 | 726 |
| 726 def _GenerateNativeCallback(self, | 727 def _GenerateNativeCallback(self, |
| 727 callback_name, | 728 callback_name, |
| 728 needs_receiver, | 729 needs_receiver, |
| 729 function_expression, | 730 function_expression, |
| 730 node, | 731 node, |
| 731 arguments, | 732 arguments, |
| 732 return_type, | 733 return_type, |
| 733 return_type_is_nullable, | 734 return_type_is_nullable, |
| 734 raises_dom_exception, | 735 raises_dom_exception, |
| 735 requires_custom_element_callback=False): | 736 generate_custom_element_scope_if_needed=False): |
| 736 | 737 |
| 737 ext_attrs = node.ext_attrs | 738 ext_attrs = node.ext_attrs |
| 738 | 739 |
| 739 cpp_arguments = [] | 740 cpp_arguments = [] |
| 740 runtime_check = None | 741 runtime_check = None |
| 741 raises_exceptions = raises_dom_exception or arguments | 742 raises_exceptions = raises_dom_exception or arguments |
| 742 needs_custom_element_callbacks = False | 743 needs_custom_element_callbacks = False |
| 743 | 744 |
| 744 # TODO(antonm): unify with ScriptState below. | 745 # TODO(antonm): unify with ScriptState below. |
| 745 requires_stack_info = (ext_attrs.get('CallWith') == 'ScriptArguments|ScriptS tate' or | 746 requires_stack_info = (ext_attrs.get('CallWith') == 'ScriptArguments|ScriptS tate' or |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 784 cpp_arguments = ['document'] | 785 cpp_arguments = ['document'] |
| 785 | 786 |
| 786 if 'ImplementedBy' in ext_attrs: | 787 if 'ImplementedBy' in ext_attrs: |
| 787 assert needs_receiver | 788 assert needs_receiver |
| 788 self._cpp_impl_includes.add('"%s.h"' % ext_attrs['ImplementedBy']) | 789 self._cpp_impl_includes.add('"%s.h"' % ext_attrs['ImplementedBy']) |
| 789 cpp_arguments.append('receiver') | 790 cpp_arguments.append('receiver') |
| 790 | 791 |
| 791 if 'Reflect' in ext_attrs: | 792 if 'Reflect' in ext_attrs: |
| 792 cpp_arguments = [self._GenerateWebCoreReflectionAttributeName(node)] | 793 cpp_arguments = [self._GenerateWebCoreReflectionAttributeName(node)] |
| 793 | 794 |
| 794 if ext_attrs.get('CustomElementCallbacks') == 'Enable' or requires_custom_el ement_callback: | 795 if generate_custom_element_scope_if_needed and (ext_attrs.get('CustomElement Callbacks', 'None') != 'None' or 'Reflect' in ext_attrs): |
|
vsm
2013/10/03 16:20:41
nit: line length
| |
| 795 self._cpp_impl_includes.add('"core/dom/CustomElementCallbackDispatcher.h"' ) | 796 self._cpp_impl_includes.add('"core/dom/CustomElementCallbackDispatcher.h"' ) |
| 796 needs_custom_element_callbacks = True | 797 needs_custom_element_callbacks = True |
| 797 | 798 |
| 798 if return_type_is_nullable: | 799 if return_type_is_nullable: |
| 799 cpp_arguments = ['isNull'] | 800 cpp_arguments = ['isNull'] |
| 800 | 801 |
| 801 v8EnabledPerContext = ext_attrs.get('synthesizedV8EnabledPerContext', ext_at trs.get('V8EnabledPerContext')) | 802 v8EnabledPerContext = ext_attrs.get('synthesizedV8EnabledPerContext', ext_at trs.get('V8EnabledPerContext')) |
| 802 v8EnabledAtRuntime = ext_attrs.get('synthesizedV8EnabledAtRuntime', ext_attr s.get('V8EnabledAtRuntime')) | 803 v8EnabledAtRuntime = ext_attrs.get('synthesizedV8EnabledAtRuntime', ext_attr s.get('V8EnabledAtRuntime')) |
| 803 assert(not (v8EnabledPerContext and v8EnabledAtRuntime)) | 804 assert(not (v8EnabledPerContext and v8EnabledAtRuntime)) |
| 804 | 805 |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1181 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argu mentCount))\n' | 1182 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argu mentCount))\n' |
| 1182 ' return func;\n', | 1183 ' return func;\n', |
| 1183 CLASS_NAME=os.path.splitext(os.path.basename(path))[0]) | 1184 CLASS_NAME=os.path.splitext(os.path.basename(path))[0]) |
| 1184 | 1185 |
| 1185 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): | 1186 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): |
| 1186 return ( | 1187 return ( |
| 1187 interface.id.endswith('Event') and | 1188 interface.id.endswith('Event') and |
| 1188 operation.id.startswith('init') and | 1189 operation.id.startswith('init') and |
| 1189 argument.ext_attrs.get('Default') == 'Undefined' and | 1190 argument.ext_attrs.get('Default') == 'Undefined' and |
| 1190 argument.type.id == 'DOMString') | 1191 argument.type.id == 'DOMString') |
| OLD | NEW |