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 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 783 invocation = self._GenerateWebCoreInvocation(function_expression, cpp_argume nts, | 783 invocation = self._GenerateWebCoreInvocation(function_expression, cpp_argume nts, |
| 784 operation.type.id, operation.ext_attrs, operation.raises) | 784 operation.type.id, operation.ext_attrs, operation.raises) |
| 785 self._GenerateNativeCallback(cpp_callback_name, | 785 self._GenerateNativeCallback(cpp_callback_name, |
| 786 parameter_definitions=parameter_definitions_emitter.Fragments(), | 786 parameter_definitions=parameter_definitions_emitter.Fragments(), |
| 787 needs_receiver=not operation.is_static, invocation=invocation, | 787 needs_receiver=not operation.is_static, invocation=invocation, |
| 788 raises_exceptions=raises_exceptions) | 788 raises_exceptions=raises_exceptions) |
| 789 | 789 |
| 790 def _GenerateNativeCallback(self, callback_name, parameter_definitions, | 790 def _GenerateNativeCallback(self, callback_name, parameter_definitions, |
| 791 needs_receiver, invocation, raises_exceptions, runtime_check=None): | 791 needs_receiver, invocation, raises_exceptions, runtime_check=None): |
| 792 | 792 |
| 793 head = parameter_definitions | 793 head_emitter = emitter.Emitter() |
| 794 | 794 |
| 795 if needs_receiver: | 795 if needs_receiver: |
| 796 head = emitter.Format( | 796 head_emitter.Emit( |
| 797 ' $WEBCORE_CLASS_NAME* receiver = DartDOMWrapper::receiver< $WE BCORE_CLASS_NAME >(args);\n' | 797 ' $WEBCORE_CLASS_NAME* receiver = DartDOMWrapper::receiver< $WE BCORE_CLASS_NAME >(args);\n', |
| 798 '$HEAD\n', | 798 WEBCORE_CLASS_NAME=self._interface_type_info.native_type()) |
| 799 WEBCORE_CLASS_NAME=self._interface_type_info.native_type(), | |
| 800 HEAD=head) | |
| 801 | 799 |
| 802 if runtime_check: | 800 if runtime_check: |
| 803 head = emitter.Format( | 801 head_emitter.Emit( |
|
podivilov
2012/07/16 15:43:16
Maybe just emit(runtime_check)?
Anton Muhin
2012/07/16 15:46:45
Missing trailing \n, let's keep it as is for now.
| |
| 804 '$RUNTIME_CHECK\n' | 802 '$RUNTIME_CHECK\n', |
| 805 '$HEAD\n', | 803 RUNTIME_CHECK=runtime_check) |
|
podivilov
2012/07/16 15:43:16
Is it ok to change the order?
Anton Muhin
2012/07/16 15:46:45
That should be, but let me lift it up to keep the
| |
| 806 RUNTIME_CHECK=runtime_check, | 804 |
| 807 HEAD=head) | 805 head_emitter.Emit( |
| 806 '$PARAMETE_DEFINITIONS\n', | |
| 807 PARAMETE_DEFINITIONS=parameter_definitions) | |
| 808 | 808 |
| 809 body = emitter.Format( | 809 body = emitter.Format( |
| 810 ' {\n' | 810 ' {\n' |
| 811 '$HEAD' | 811 '$HEAD' |
| 812 '$INVOCATION' | 812 '$INVOCATION' |
| 813 ' return;\n' | 813 ' return;\n' |
| 814 ' }\n', | 814 ' }\n', |
| 815 HEAD=head, | 815 HEAD=head_emitter.Fragments(), |
| 816 INVOCATION=invocation) | 816 INVOCATION=invocation) |
| 817 | 817 |
| 818 if raises_exceptions: | 818 if raises_exceptions: |
| 819 body = emitter.Format( | 819 body = emitter.Format( |
| 820 ' Dart_Handle exception = 0;\n' | 820 ' Dart_Handle exception = 0;\n' |
| 821 '$BODY' | 821 '$BODY' |
| 822 '\n' | 822 '\n' |
| 823 'fail:\n' | 823 'fail:\n' |
| 824 ' Dart_ThrowException(exception);\n' | 824 ' Dart_ThrowException(exception);\n' |
| 825 ' ASSERT_NOT_REACHED();\n', | 825 ' ASSERT_NOT_REACHED();\n', |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 943 | 943 |
| 944 def _IsArgumentOptionalInWebCore(argument): | 944 def _IsArgumentOptionalInWebCore(argument): |
| 945 return IsOptional(argument) and not 'Callback' in argument.ext_attrs | 945 return IsOptional(argument) and not 'Callback' in argument.ext_attrs |
| 946 | 946 |
| 947 def _ToWebKitName(name): | 947 def _ToWebKitName(name): |
| 948 name = name[0].lower() + name[1:] | 948 name = name[0].lower() + name[1:] |
| 949 name = re.sub(r'^(hTML|uRL|jS|xML|xSLT)', lambda s: s.group(1).lower(), | 949 name = re.sub(r'^(hTML|uRL|jS|xML|xSLT)', lambda s: s.group(1).lower(), |
| 950 name) | 950 name) |
| 951 return re.sub(r'^(create|exclusive)', lambda s: 'is' + s.group(1).capitalize() , | 951 return re.sub(r'^(create|exclusive)', lambda s: 'is' + s.group(1).capitalize() , |
| 952 name) | 952 name) |
| OLD | NEW |