| 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 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 raises_exceptions = True | 676 raises_exceptions = True |
| 677 requires_v8_scope = True | 677 requires_v8_scope = True |
| 678 requires_stack_info = True | 678 requires_stack_info = True |
| 679 self._cpp_impl_includes.add('"ScriptArguments.h"') | 679 self._cpp_impl_includes.add('"ScriptArguments.h"') |
| 680 self._cpp_impl_includes.add('"ScriptCallStack.h"') | 680 self._cpp_impl_includes.add('"ScriptCallStack.h"') |
| 681 cpp_arguments = ['scriptArguments', 'scriptCallStack'] | 681 cpp_arguments = ['scriptArguments', 'scriptCallStack'] |
| 682 | 682 |
| 683 if ext_attrs.get('CallWith') == 'ScriptExecutionContext': | 683 if ext_attrs.get('CallWith') == 'ScriptExecutionContext': |
| 684 raises_exceptions = True | 684 raises_exceptions = True |
| 685 requires_script_execution_context = True | 685 requires_script_execution_context = True |
| 686 cpp_arguments = ['context'] |
| 687 |
| 688 if 'ImplementedBy' in ext_attrs: |
| 689 assert needs_receiver |
| 690 cpp_arguments.append('receiver') |
| 691 self._cpp_impl_includes.add('"%s.h"' % ext_attrs['ImplementedBy']) |
| 686 | 692 |
| 687 if 'NamedConstructor' in ext_attrs: | 693 if 'NamedConstructor' in ext_attrs: |
| 688 raises_exceptions = True | 694 raises_exceptions = True |
| 689 requires_dom_window = True | 695 requires_dom_window = True |
| 690 self._cpp_impl_includes.add('"DOMWindow.h"') | 696 self._cpp_impl_includes.add('"DOMWindow.h"') |
| 691 cpp_arguments = ['document'] | 697 cpp_arguments = ['document'] |
| 692 | 698 |
| 693 if 'Reflect' in ext_attrs: | 699 if 'Reflect' in ext_attrs: |
| 694 cpp_arguments = [self._GenerateWebCoreReflectionAttributeName(node)] | 700 cpp_arguments = [self._GenerateWebCoreReflectionAttributeName(node)] |
| 695 | 701 |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 911 arguments.append('ec') | 917 arguments.append('ec') |
| 912 invocation_template = emitter.Format( | 918 invocation_template = emitter.Format( |
| 913 ' ExceptionCode ec = 0;\n' | 919 ' ExceptionCode ec = 0;\n' |
| 914 '$INVOCATION' | 920 '$INVOCATION' |
| 915 ' if (UNLIKELY(ec)) {\n' | 921 ' if (UNLIKELY(ec)) {\n' |
| 916 ' exception = DartDOMWrapper::exceptionCodeToDartException(
ec);\n' | 922 ' exception = DartDOMWrapper::exceptionCodeToDartException(
ec);\n' |
| 917 ' goto fail;\n' | 923 ' goto fail;\n' |
| 918 ' }\n', | 924 ' }\n', |
| 919 INVOCATION=invocation_template) | 925 INVOCATION=invocation_template) |
| 920 | 926 |
| 921 if 'ImplementedBy' in attributes: | |
| 922 arguments.insert(0, 'receiver') | |
| 923 self._cpp_impl_includes.add('"%s.h"' % attributes['ImplementedBy']) | |
| 924 | |
| 925 if attributes.get('CallWith') == 'ScriptExecutionContext': | |
| 926 arguments.insert(0, 'context') | |
| 927 | |
| 928 return emitter.Format(invocation_template, | 927 return emitter.Format(invocation_template, |
| 929 FUNCTION_CALL='%s(%s)' % (function_expression, ', '.join(arguments))) | 928 FUNCTION_CALL='%s(%s)' % (function_expression, ', '.join(arguments))) |
| 930 | 929 |
| 931 def _TypeInfo(self, type_name): | 930 def _TypeInfo(self, type_name): |
| 932 return self._system._type_registry.TypeInfo(type_name) | 931 return self._system._type_registry.TypeInfo(type_name) |
| 933 | 932 |
| 934 | 933 |
| 935 def _GenerateCPPIncludes(includes): | 934 def _GenerateCPPIncludes(includes): |
| 936 return ''.join(['#include %s\n' % include for include in sorted(includes)]) | 935 return ''.join(['#include %s\n' % include for include in sorted(includes)]) |
| 937 | 936 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 949 | 948 |
| 950 def _IsArgumentOptionalInWebCore(argument): | 949 def _IsArgumentOptionalInWebCore(argument): |
| 951 return IsOptional(argument) and not 'Callback' in argument.ext_attrs | 950 return IsOptional(argument) and not 'Callback' in argument.ext_attrs |
| 952 | 951 |
| 953 def _ToWebKitName(name): | 952 def _ToWebKitName(name): |
| 954 name = name[0].lower() + name[1:] | 953 name = name[0].lower() + name[1:] |
| 955 name = re.sub(r'^(hTML|uRL|jS|xML|xSLT)', lambda s: s.group(1).lower(), | 954 name = re.sub(r'^(hTML|uRL|jS|xML|xSLT)', lambda s: s.group(1).lower(), |
| 956 name) | 955 name) |
| 957 return re.sub(r'^(create|exclusive)', lambda s: 'is' + s.group(1).capitalize()
, | 956 return re.sub(r'^(create|exclusive)', lambda s: 'is' + s.group(1).capitalize()
, |
| 958 name) | 957 name) |
| OLD | NEW |