| 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 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 arguments, | 730 arguments, |
| 731 return_type, | 731 return_type, |
| 732 return_type_is_nullable, | 732 return_type_is_nullable, |
| 733 raises_dom_exception): | 733 raises_dom_exception): |
| 734 | 734 |
| 735 ext_attrs = node.ext_attrs | 735 ext_attrs = node.ext_attrs |
| 736 | 736 |
| 737 cpp_arguments = [] | 737 cpp_arguments = [] |
| 738 runtime_check = None | 738 runtime_check = None |
| 739 raises_exceptions = raises_dom_exception or arguments | 739 raises_exceptions = raises_dom_exception or arguments |
| 740 needs_custom_element_callbacks = False |
| 740 | 741 |
| 741 # TODO(antonm): unify with ScriptState below. | 742 # TODO(antonm): unify with ScriptState below. |
| 742 requires_stack_info = (ext_attrs.get('CallWith') == 'ScriptArguments|ScriptS
tate' or | 743 requires_stack_info = (ext_attrs.get('CallWith') == 'ScriptArguments|ScriptS
tate' or |
| 743 ext_attrs.get('ConstructorCallWith') == 'ScriptArgume
nts|ScriptState' or | 744 ext_attrs.get('ConstructorCallWith') == 'ScriptArgume
nts|ScriptState' or |
| 744 ext_attrs.get('CallWith') == 'ScriptArguments&ScriptS
tate' or | 745 ext_attrs.get('CallWith') == 'ScriptArguments&ScriptS
tate' or |
| 745 ext_attrs.get('ConstructorCallWith') == 'ScriptArgume
nts&ScriptState') | 746 ext_attrs.get('ConstructorCallWith') == 'ScriptArgume
nts&ScriptState') |
| 746 if requires_stack_info: | 747 if requires_stack_info: |
| 747 raises_exceptions = True | 748 raises_exceptions = True |
| 748 cpp_arguments = ['&state', 'scriptArguments.release()'] | 749 cpp_arguments = ['&state', 'scriptArguments.release()'] |
| 749 # WebKit uses scriptArguments to reconstruct last argument, so | 750 # WebKit uses scriptArguments to reconstruct last argument, so |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 assert needs_receiver | 785 assert needs_receiver |
| 785 self._cpp_impl_includes.add('"%s.h"' % ext_attrs['ImplementedBy']) | 786 self._cpp_impl_includes.add('"%s.h"' % ext_attrs['ImplementedBy']) |
| 786 cpp_arguments.append('receiver') | 787 cpp_arguments.append('receiver') |
| 787 | 788 |
| 788 if 'Reflect' in ext_attrs: | 789 if 'Reflect' in ext_attrs: |
| 789 cpp_arguments = [self._GenerateWebCoreReflectionAttributeName(node)] | 790 cpp_arguments = [self._GenerateWebCoreReflectionAttributeName(node)] |
| 790 | 791 |
| 791 if return_type_is_nullable: | 792 if return_type_is_nullable: |
| 792 cpp_arguments = ['isNull'] | 793 cpp_arguments = ['isNull'] |
| 793 | 794 |
| 795 if ext_attrs.get('CustomElementCallbacks') == 'Enable': |
| 796 self._cpp_impl_includes.add('"core/dom/CustomElementCallbackDispatcher.h"'
) |
| 797 needs_custom_element_callbacks = True |
| 798 |
| 794 v8EnabledPerContext = ext_attrs.get('synthesizedV8EnabledPerContext', ext_at
trs.get('V8EnabledPerContext')) | 799 v8EnabledPerContext = ext_attrs.get('synthesizedV8EnabledPerContext', ext_at
trs.get('V8EnabledPerContext')) |
| 795 v8EnabledAtRuntime = ext_attrs.get('synthesizedV8EnabledAtRuntime', ext_attr
s.get('V8EnabledAtRuntime')) | 800 v8EnabledAtRuntime = ext_attrs.get('synthesizedV8EnabledAtRuntime', ext_attr
s.get('V8EnabledAtRuntime')) |
| 796 assert(not (v8EnabledPerContext and v8EnabledAtRuntime)) | 801 assert(not (v8EnabledPerContext and v8EnabledAtRuntime)) |
| 797 | 802 |
| 798 if v8EnabledPerContext: | 803 if v8EnabledPerContext: |
| 799 raises_exceptions = True | 804 raises_exceptions = True |
| 800 self._cpp_impl_includes.add('"ContextFeatures.h"') | 805 self._cpp_impl_includes.add('"ContextFeatures.h"') |
| 801 self._cpp_impl_includes.add('"DOMWindow.h"') | 806 self._cpp_impl_includes.add('"DOMWindow.h"') |
| 802 runtime_check = emitter.Format( | 807 runtime_check = emitter.Format( |
| 803 ' if (!ContextFeatures::$(FEATURE)Enabled(DartUtilities::domWin
dowForCurrentIsolate()->document())) {\n' | 808 ' if (!ContextFeatures::$(FEATURE)Enabled(DartUtilities::domWin
dowForCurrentIsolate()->document())) {\n' |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 903 '\n' | 908 '\n' |
| 904 ' Dart_Handle customArgument = Dart_GetNativeArgument(args, $IN
DEX);\n' | 909 ' Dart_Handle customArgument = Dart_GetNativeArgument(args, $IN
DEX);\n' |
| 905 ' RefPtr<ScriptArguments> scriptArguments(DartUtilities::create
ScriptArguments(customArgument, exception));\n' | 910 ' RefPtr<ScriptArguments> scriptArguments(DartUtilities::create
ScriptArguments(customArgument, exception));\n' |
| 906 ' if (!scriptArguments)\n' | 911 ' if (!scriptArguments)\n' |
| 907 ' goto fail;\n' | 912 ' goto fail;\n' |
| 908 ' RefPtr<ScriptCallStack> scriptCallStack(DartUtilities::create
ScriptCallStack());\n' | 913 ' RefPtr<ScriptCallStack> scriptCallStack(DartUtilities::create
ScriptCallStack());\n' |
| 909 ' if (!scriptCallStack->size())\n' | 914 ' if (!scriptCallStack->size())\n' |
| 910 ' return;\n', | 915 ' return;\n', |
| 911 INDEX=len(arguments) + 1) | 916 INDEX=len(arguments) + 1) |
| 912 | 917 |
| 918 if needs_custom_element_callbacks: |
| 919 body_emitter.Emit(' CustomElementCallbackDispatcher::CallbackDelive
ryScope deliveryScope;\n'); |
| 920 |
| 913 # Emit arguments. | 921 # Emit arguments. |
| 914 start_index = 1 if needs_receiver else 0 | 922 start_index = 1 if needs_receiver else 0 |
| 915 for i, argument in enumerate(arguments): | 923 for i, argument in enumerate(arguments): |
| 916 type_info = self._TypeInfo(argument.type.id) | 924 type_info = self._TypeInfo(argument.type.id) |
| 917 self._cpp_impl_includes |= set(type_info.conversion_includes()) | 925 self._cpp_impl_includes |= set(type_info.conversion_includes()) |
| 918 argument_expression_template, type, cls, function = \ | 926 argument_expression_template, type, cls, function = \ |
| 919 type_info.to_native_info(argument, self._interface.id) | 927 type_info.to_native_info(argument, self._interface.id) |
| 920 | 928 |
| 921 def AllowsNull(): | 929 def AllowsNull(): |
| 922 # TODO(vsm): HTMLSelectElement's indexed setter treats a null as a remov
e. | 930 # TODO(vsm): HTMLSelectElement's indexed setter treats a null as a remov
e. |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1171 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argu
mentCount))\n' | 1179 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argu
mentCount))\n' |
| 1172 ' return func;\n', | 1180 ' return func;\n', |
| 1173 CLASS_NAME=os.path.splitext(os.path.basename(path))[0]) | 1181 CLASS_NAME=os.path.splitext(os.path.basename(path))[0]) |
| 1174 | 1182 |
| 1175 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): | 1183 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): |
| 1176 return ( | 1184 return ( |
| 1177 interface.id.endswith('Event') and | 1185 interface.id.endswith('Event') and |
| 1178 operation.id.startswith('init') and | 1186 operation.id.startswith('init') and |
| 1179 argument.ext_attrs.get('Default') == 'Undefined' and | 1187 argument.ext_attrs.get('Default') == 'Undefined' and |
| 1180 argument.type.id == 'DOMString') | 1188 argument.type.id == 'DOMString') |
| OLD | NEW |