| 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 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 793 ' if (!scriptArguments)\n' | 793 ' if (!scriptArguments)\n' |
| 794 ' goto fail;\n' | 794 ' goto fail;\n' |
| 795 ' RefPtr<ScriptCallStack> scriptCallStack(DartUtilities::create
ScriptCallStack());\n' | 795 ' RefPtr<ScriptCallStack> scriptCallStack(DartUtilities::create
ScriptCallStack());\n' |
| 796 ' if (!scriptCallStack->size())\n' | 796 ' if (!scriptCallStack->size())\n' |
| 797 ' return;\n', | 797 ' return;\n', |
| 798 INDEX=len(arguments) + 1) | 798 INDEX=len(arguments) + 1) |
| 799 | 799 |
| 800 # Emit arguments. | 800 # Emit arguments. |
| 801 start_index = 1 if needs_receiver else 0 | 801 start_index = 1 if needs_receiver else 0 |
| 802 for i, argument in enumerate(arguments): | 802 for i, argument in enumerate(arguments): |
| 803 type_info = self._TypeInfo(argument.type.id) | 803 argument_name = DartDomNameOfAttribute(argument) |
| 804 self._cpp_impl_includes |= set(type_info.to_native_includes()) | 804 argument_expression, type, cls, function = self._TypeInfo(argument.type.id
).to_native_info( |
| 805 cpp_arguments.append(type_info.emit_to_native( | |
| 806 body_emitter, | |
| 807 argument, | 805 argument, |
| 808 (IsOptional(argument) and not self._IsArgumentOptionalInWebCore(node,
argument)) or (argument.ext_attrs.get('Optional') == 'DefaultIsNullString'), | 806 (IsOptional(argument) and not self._IsArgumentOptionalInWebCore(node,
argument)) or (argument.ext_attrs.get('Optional') == 'DefaultIsNullString'), |
| 809 # TODO(antonm): all IDs should be renamed when database is generated. | 807 argument_name, |
| 810 # That will allow to get rid of argument_name argument altogether. | 808 self._interface.id) |
| 811 DartDomNameOfAttribute(argument), | 809 |
| 812 'Dart_GetNativeArgument(args, %i)' % (start_index + i), | 810 body_emitter.Emit( |
| 813 self._interface.id)) | 811 '\n' |
| 812 ' $TYPE $ARGUMENT_NAME = $CLS::$FUNCTION(Dart_GetNativeArgument
(args, $NO), exception);\n' |
| 813 ' if (exception)\n' |
| 814 ' goto fail;\n', |
| 815 TYPE=type, |
| 816 ARGUMENT_NAME=argument_name, |
| 817 CLS=cls, |
| 818 FUNCTION=function, |
| 819 NO=start_index + i) |
| 820 self._cpp_impl_includes.add('"%s.h"' % cls) |
| 821 cpp_arguments.append(argument_expression) |
| 814 | 822 |
| 815 body_emitter.Emit('\n') | 823 body_emitter.Emit('\n') |
| 816 | 824 |
| 817 if 'NeedsUserGestureCheck' in ext_attrs: | 825 if 'NeedsUserGestureCheck' in ext_attrs: |
| 818 cpp_arguments.append('DartUtilities::processingUserGesture'); | 826 cpp_arguments.append('DartUtilities::processingUserGesture'); |
| 819 | 827 |
| 820 invocation_emitter = body_emitter | 828 invocation_emitter = body_emitter |
| 821 if raises_dom_exception: | 829 if raises_dom_exception: |
| 822 cpp_arguments.append('ec') | 830 cpp_arguments.append('ec') |
| 823 invocation_emitter = body_emitter.Emit( | 831 invocation_emitter = body_emitter.Emit( |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 920 parent_interface = _FindInHierarchy(database, parent_interface, test) | 928 parent_interface = _FindInHierarchy(database, parent_interface, test) |
| 921 if parent_interface: | 929 if parent_interface: |
| 922 return parent_interface | 930 return parent_interface |
| 923 | 931 |
| 924 def _ToWebKitName(name): | 932 def _ToWebKitName(name): |
| 925 name = name[0].lower() + name[1:] | 933 name = name[0].lower() + name[1:] |
| 926 name = re.sub(r'^(hTML|uRL|jS|xML|xSLT)', lambda s: s.group(1).lower(), | 934 name = re.sub(r'^(hTML|uRL|jS|xML|xSLT)', lambda s: s.group(1).lower(), |
| 927 name) | 935 name) |
| 928 return re.sub(r'^(create|exclusive)', lambda s: 'is' + s.group(1).capitalize()
, | 936 return re.sub(r'^(create|exclusive)', lambda s: 'is' + s.group(1).capitalize()
, |
| 929 name) | 937 name) |
| OLD | NEW |