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 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 818 ' if (!scriptArguments)\n' | 818 ' if (!scriptArguments)\n' |
| 819 ' goto fail;\n' | 819 ' goto fail;\n' |
| 820 ' RefPtr<ScriptCallStack> scriptCallStack(DartUtilities::create ScriptCallStack());\n' | 820 ' RefPtr<ScriptCallStack> scriptCallStack(DartUtilities::create ScriptCallStack());\n' |
| 821 ' if (!scriptCallStack->size())\n' | 821 ' if (!scriptCallStack->size())\n' |
| 822 ' return;\n', | 822 ' return;\n', |
| 823 INDEX=len(arguments) + 1) | 823 INDEX=len(arguments) + 1) |
| 824 | 824 |
| 825 # Emit arguments. | 825 # Emit arguments. |
| 826 start_index = 1 if needs_receiver else 0 | 826 start_index = 1 if needs_receiver else 0 |
| 827 for i, argument in enumerate(arguments): | 827 for i, argument in enumerate(arguments): |
| 828 type_info = self._TypeInfo(argument.type.id) | |
| 828 argument_expression_template, type, cls, function = \ | 829 argument_expression_template, type, cls, function = \ |
| 829 self._TypeInfo(argument.type.id).to_native_info(argument, self._interf ace.id) | 830 type_info.to_native_info(argument, self._interface.id) |
| 830 | 831 |
| 831 if ((IsOptional(argument) and not self._IsArgumentOptionalInWebCore(node, argument)) or | 832 if ((IsOptional(argument) and not self._IsArgumentOptionalInWebCore(node, argument)) or |
| 832 (argument.ext_attrs.get('Optional') == 'DefaultIsNullString')): | 833 (argument.ext_attrs.get('Optional') == 'DefaultIsNullString')): |
| 833 function += 'WithNullCheck' | 834 function += 'WithNullCheck' |
| 834 | 835 |
| 835 argument_name = DartDomNameOfAttribute(argument) | 836 argument_name = DartDomNameOfAttribute(argument) |
| 837 if type_info.pass_native_by_ref(): | |
| 838 invocation_template =\ | |
| 839 ' $TYPE $ARGUMENT_NAME;\n'\ | |
|
podivilov
2012/09/14 08:06:06
nit: unnecessary trailing \
Anton Muhin
2012/09/14 12:32:58
No, it's necessary. Another option would be to pu
| |
| 840 ' $CLS::$FUNCTION($ARGUMENT_NAME, Dart_GetNativeArgument(args , $INDEX), exception);\n' | |
|
podivilov
2012/09/14 08:06:06
nit: Dart_GetNativeArgument should come first.
Anton Muhin
2012/09/14 12:32:58
Done.
| |
| 841 else: | |
| 842 invocation_template =\ | |
| 843 ' $TYPE $ARGUMENT_NAME = $CLS::$FUNCTION(Dart_GetNativeArgume nt(args, $INDEX), exception);\n' | |
| 836 body_emitter.Emit( | 844 body_emitter.Emit( |
| 837 '\n' | 845 '\n' + |
| 838 ' $TYPE $ARGUMENT_NAME = $CLS::$FUNCTION(Dart_GetNativeArgument (args, $INDEX), exception);\n' | 846 invocation_template + |
| 839 ' if (exception)\n' | 847 ' if (exception)\n' |
| 840 ' goto fail;\n', | 848 ' goto fail;\n', |
| 841 TYPE=type, | 849 TYPE=type, |
| 842 ARGUMENT_NAME=argument_name, | 850 ARGUMENT_NAME=argument_name, |
| 843 CLS=cls, | 851 CLS=cls, |
| 844 FUNCTION=function, | 852 FUNCTION=function, |
| 845 INDEX=start_index + i) | 853 INDEX=start_index + i) |
| 846 self._cpp_impl_includes.add('"%s.h"' % cls) | 854 self._cpp_impl_includes.add('"%s.h"' % cls) |
| 847 cpp_arguments.append(argument_expression_template % argument_name) | 855 cpp_arguments.append(argument_expression_template % argument_name) |
| 848 | 856 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 954 parent_interface = _FindInHierarchy(database, parent_interface, test) | 962 parent_interface = _FindInHierarchy(database, parent_interface, test) |
| 955 if parent_interface: | 963 if parent_interface: |
| 956 return parent_interface | 964 return parent_interface |
| 957 | 965 |
| 958 def _ToWebKitName(name): | 966 def _ToWebKitName(name): |
| 959 name = name[0].lower() + name[1:] | 967 name = name[0].lower() + name[1:] |
| 960 name = re.sub(r'^(hTML|uRL|jS|xML|xSLT)', lambda s: s.group(1).lower(), | 968 name = re.sub(r'^(hTML|uRL|jS|xML|xSLT)', lambda s: s.group(1).lower(), |
| 961 name) | 969 name) |
| 962 return re.sub(r'^(create|exclusive)', lambda s: 'is' + s.group(1).capitalize() , | 970 return re.sub(r'^(create|exclusive)', lambda s: 'is' + s.group(1).capitalize() , |
| 963 name) | 971 name) |
| OLD | NEW |