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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 295 | 295 |
| 296 # Process constructor arguments. | 296 # Process constructor arguments. |
| 297 for (i, argument) in enumerate(constructor_info.idl_args): | 297 for (i, argument) in enumerate(constructor_info.idl_args): |
| 298 argument_expression = self._GenerateToNative( | 298 argument_expression = self._GenerateToNative( |
| 299 parameter_definitions_emitter, argument, i) | 299 parameter_definitions_emitter, argument, i) |
| 300 arguments.append(argument_expression) | 300 arguments.append(argument_expression) |
| 301 | 301 |
| 302 function_expression = '%s::%s' % (self._interface_type_info.native_type(), c reate_function) | 302 function_expression = '%s::%s' % (self._interface_type_info.native_type(), c reate_function) |
| 303 invocation = self._GenerateWebCoreInvocation(function_expression, arguments, | 303 invocation = self._GenerateWebCoreInvocation(function_expression, arguments, |
| 304 self._interface.id, self._interface.ext_attrs, raises_dom_exceptions) | 304 self._interface.id, self._interface.ext_attrs, raises_dom_exceptions) |
| 305 | |
| 306 runtime_check = None | |
| 307 database = self._system._database | |
| 308 if 'synthesized-V8EnabledPerContext' in self._interface.ext_attrs: | |
| 309 raises_exceptions = True | |
| 310 self._cpp_impl_includes.add('"ContextFeatures.h"') | |
| 311 runtime_check = emitter.Format( | |
| 312 ' if (ContextFeatures::$(FEATURE)Enabled(DartUtilities::domWind owForCurrentIsolate()->document())) {\n' | |
| 313 ' exception = Dart_NewString("Feature $FEATURE is not enabl ed");\n' | |
| 314 ' goto fail;\n' | |
| 315 ' }', | |
| 316 FEATURE=self._interface.ext_attrs['V8EnabledPerContext']) | |
|
podivilov
2012/06/25 17:44:42
shouldn't that be synthesized-*?
Anton Muhin
2012/06/25 17:46:41
Thanks! Done.
On 2012/06/25 17:44:42, podivilov
| |
| 317 | |
| 305 self._GenerateNativeCallback(callback_name='constructorCallback', | 318 self._GenerateNativeCallback(callback_name='constructorCallback', |
| 306 parameter_definitions=parameter_definitions_emitter.Fragments(), | 319 parameter_definitions=parameter_definitions_emitter.Fragments(), |
| 307 needs_receiver=False, invocation=invocation, | 320 needs_receiver=False, invocation=invocation, |
| 308 raises_exceptions=raises_exceptions) | 321 raises_exceptions=raises_exceptions, |
| 322 runtime_check=runtime_check) | |
| 309 | 323 |
| 310 def _EmitHtmlElementFactoryConstructors(self, infos, html_interface_name): | 324 def _EmitHtmlElementFactoryConstructors(self, infos, html_interface_name): |
| 311 EmitHtmlElementFactoryConstructors( | 325 EmitHtmlElementFactoryConstructors( |
| 312 self._system._EmitterForFactoryProviderBody( | 326 self._system._EmitterForFactoryProviderBody( |
| 313 infos[0].factory_provider_name), | 327 infos[0].factory_provider_name), |
| 314 infos, | 328 infos, |
| 315 html_interface_name, | 329 html_interface_name, |
| 316 html_interface_name) | 330 html_interface_name) |
| 317 | 331 |
| 318 def _GenerateEvents(self): | 332 def _GenerateEvents(self): |
| (...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 893 | 907 |
| 894 function_expression = self._GenerateWebCoreFunctionExpression(webcore_functi on_name, operation) | 908 function_expression = self._GenerateWebCoreFunctionExpression(webcore_functi on_name, operation) |
| 895 invocation = self._GenerateWebCoreInvocation(function_expression, cpp_argume nts, | 909 invocation = self._GenerateWebCoreInvocation(function_expression, cpp_argume nts, |
| 896 operation.type.id, operation.ext_attrs, operation.raises) | 910 operation.type.id, operation.ext_attrs, operation.raises) |
| 897 self._GenerateNativeCallback(cpp_callback_name, | 911 self._GenerateNativeCallback(cpp_callback_name, |
| 898 parameter_definitions=parameter_definitions_emitter.Fragments(), | 912 parameter_definitions=parameter_definitions_emitter.Fragments(), |
| 899 needs_receiver=not operation.is_static, invocation=invocation, | 913 needs_receiver=not operation.is_static, invocation=invocation, |
| 900 raises_exceptions=raises_exceptions) | 914 raises_exceptions=raises_exceptions) |
| 901 | 915 |
| 902 def _GenerateNativeCallback(self, callback_name, parameter_definitions, | 916 def _GenerateNativeCallback(self, callback_name, parameter_definitions, |
| 903 needs_receiver, invocation, raises_exceptions): | 917 needs_receiver, invocation, raises_exceptions, runtime_check=None): |
| 918 | |
| 919 head = parameter_definitions | |
| 904 | 920 |
| 905 if needs_receiver: | 921 if needs_receiver: |
| 906 parameter_definitions = emitter.Format( | 922 head = emitter.Format( |
| 907 ' $WEBCORE_CLASS_NAME* receiver = DartDOMWrapper::receiver< $WE BCORE_CLASS_NAME >(args);\n' | 923 ' $WEBCORE_CLASS_NAME* receiver = DartDOMWrapper::receiver< $WE BCORE_CLASS_NAME >(args);\n' |
| 908 ' $PARAMETER_DEFINITIONS\n', | 924 '$HEAD\n', |
| 909 WEBCORE_CLASS_NAME=self._interface_type_info.native_type(), | 925 WEBCORE_CLASS_NAME=self._interface_type_info.native_type(), |
| 910 PARAMETER_DEFINITIONS=parameter_definitions) | 926 HEAD=head) |
| 927 | |
| 928 if runtime_check: | |
| 929 head = emitter.Format( | |
| 930 '$RUNTIME_CHECK\n' | |
| 931 '$HEAD\n', | |
| 932 RUNTIME_CHECK=runtime_check, | |
| 933 HEAD=head) | |
| 911 | 934 |
| 912 body = emitter.Format( | 935 body = emitter.Format( |
| 913 ' {\n' | 936 ' {\n' |
| 914 '$PARAMETER_DEFINITIONS' | 937 '$HEAD' |
| 915 '$INVOCATION' | 938 '$INVOCATION' |
| 916 ' return;\n' | 939 ' return;\n' |
| 917 ' }\n', | 940 ' }\n', |
| 918 PARAMETER_DEFINITIONS=parameter_definitions, | 941 HEAD=head, |
| 919 INVOCATION=invocation) | 942 INVOCATION=invocation) |
| 920 | 943 |
| 921 if raises_exceptions: | 944 if raises_exceptions: |
| 922 body = emitter.Format( | 945 body = emitter.Format( |
| 923 ' Dart_Handle exception = 0;\n' | 946 ' Dart_Handle exception = 0;\n' |
| 924 '$BODY' | 947 '$BODY' |
| 925 '\n' | 948 '\n' |
| 926 'fail:\n' | 949 'fail:\n' |
| 927 ' Dart_ThrowException(exception);\n' | 950 ' Dart_ThrowException(exception);\n' |
| 928 ' ASSERT_NOT_REACHED();\n', | 951 ' ASSERT_NOT_REACHED();\n', |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1049 continue | 1072 continue |
| 1050 parent_interface = database.GetInterface(parent.type.id) | 1073 parent_interface = database.GetInterface(parent.type.id) |
| 1051 if callback(parent_interface): | 1074 if callback(parent_interface): |
| 1052 return parent_interface | 1075 return parent_interface |
| 1053 parent_interface = _FindParent(parent_interface, database, callback) | 1076 parent_interface = _FindParent(parent_interface, database, callback) |
| 1054 if parent_interface: | 1077 if parent_interface: |
| 1055 return parent_interface | 1078 return parent_interface |
| 1056 | 1079 |
| 1057 def _IsArgumentOptionalInWebCore(argument): | 1080 def _IsArgumentOptionalInWebCore(argument): |
| 1058 return IsOptional(argument) and not 'Callback' in argument.ext_attrs | 1081 return IsOptional(argument) and not 'Callback' in argument.ext_attrs |
| OLD | NEW |