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 812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 823 ' if (!scriptArguments)\n' | 823 ' if (!scriptArguments)\n' |
| 824 ' goto fail;\n' | 824 ' goto fail;\n' |
| 825 ' RefPtr<ScriptCallStack> scriptCallStack(DartUtilities::create ScriptCallStack());\n' | 825 ' RefPtr<ScriptCallStack> scriptCallStack(DartUtilities::create ScriptCallStack());\n' |
| 826 ' if (!scriptCallStack->size())\n' | 826 ' if (!scriptCallStack->size())\n' |
| 827 ' return;\n', | 827 ' return;\n', |
| 828 INDEX=len(arguments) + 1) | 828 INDEX=len(arguments) + 1) |
| 829 | 829 |
| 830 # Emit arguments. | 830 # Emit arguments. |
| 831 start_index = 1 if needs_receiver else 0 | 831 start_index = 1 if needs_receiver else 0 |
| 832 for i, argument in enumerate(arguments): | 832 for i, argument in enumerate(arguments): |
| 833 argument_template, type, cls, function = \ | |
|
podivilov
2012/08/23 08:18:04
ditto
Anton Muhin
2012/08/23 15:04:12
Done.
| |
| 834 self._TypeInfo(argument.type.id).to_native_info(argument, self._interf ace.id) | |
| 835 | |
| 836 if ((IsOptional(argument) and not self._IsArgumentOptionalInWebCore(node, argument)) or | |
| 837 (argument.ext_attrs.get('Optional') == 'DefaultIsNullString')): | |
| 838 function += 'WithNullCheck' | |
| 839 | |
| 833 argument_name = DartDomNameOfAttribute(argument) | 840 argument_name = DartDomNameOfAttribute(argument) |
| 834 argument_expression, type, cls, function = self._TypeInfo(argument.type.id ).to_native_info( | |
| 835 argument, | |
| 836 (IsOptional(argument) and not self._IsArgumentOptionalInWebCore(node, argument)) or (argument.ext_attrs.get('Optional') == 'DefaultIsNullString'), | |
| 837 argument_name, | |
| 838 self._interface.id) | |
| 839 | |
| 840 body_emitter.Emit( | 841 body_emitter.Emit( |
| 841 '\n' | 842 '\n' |
| 842 ' $TYPE $ARGUMENT_NAME = $CLS::$FUNCTION(Dart_GetNativeArgument (args, $INDEX), exception);\n' | 843 ' $TYPE $ARGUMENT_NAME = $CLS::$FUNCTION(Dart_GetNativeArgument (args, $INDEX), exception);\n' |
| 843 ' if (exception)\n' | 844 ' if (exception)\n' |
| 844 ' goto fail;\n', | 845 ' goto fail;\n', |
| 845 TYPE=type, | 846 TYPE=type, |
| 846 ARGUMENT_NAME=argument_name, | 847 ARGUMENT_NAME=argument_name, |
| 847 CLS=cls, | 848 CLS=cls, |
| 848 FUNCTION=function, | 849 FUNCTION=function, |
| 849 INDEX=start_index + i) | 850 INDEX=start_index + i) |
| 850 self._cpp_impl_includes.add('"%s.h"' % cls) | 851 self._cpp_impl_includes.add('"%s.h"' % cls) |
| 851 cpp_arguments.append(argument_expression) | 852 cpp_arguments.append(argument_template % argument_name) |
| 852 | 853 |
| 853 body_emitter.Emit('\n') | 854 body_emitter.Emit('\n') |
| 854 | 855 |
| 855 if 'NeedsUserGestureCheck' in ext_attrs: | 856 if 'NeedsUserGestureCheck' in ext_attrs: |
| 856 cpp_arguments.append('DartUtilities::processingUserGesture') | 857 cpp_arguments.append('DartUtilities::processingUserGesture') |
| 857 | 858 |
| 858 invocation_emitter = body_emitter | 859 invocation_emitter = body_emitter |
| 859 if raises_dom_exception: | 860 if raises_dom_exception: |
| 860 cpp_arguments.append('ec') | 861 cpp_arguments.append('ec') |
| 861 invocation_emitter = body_emitter.Emit( | 862 invocation_emitter = body_emitter.Emit( |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 958 parent_interface = _FindInHierarchy(database, parent_interface, test) | 959 parent_interface = _FindInHierarchy(database, parent_interface, test) |
| 959 if parent_interface: | 960 if parent_interface: |
| 960 return parent_interface | 961 return parent_interface |
| 961 | 962 |
| 962 def _ToWebKitName(name): | 963 def _ToWebKitName(name): |
| 963 name = name[0].lower() + name[1:] | 964 name = name[0].lower() + name[1:] |
| 964 name = re.sub(r'^(hTML|uRL|jS|xML|xSLT)', lambda s: s.group(1).lower(), | 965 name = re.sub(r'^(hTML|uRL|jS|xML|xSLT)', lambda s: s.group(1).lower(), |
| 965 name) | 966 name) |
| 966 return re.sub(r'^(create|exclusive)', lambda s: 'is' + s.group(1).capitalize() , | 967 return re.sub(r'^(create|exclusive)', lambda s: 'is' + s.group(1).capitalize() , |
| 967 name) | 968 name) |
| OLD | NEW |