Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(307)

Side by Side Diff: lib/dom/scripts/systemnative.py

Issue 10636027: Support proper propagation of enabled per context and at runtime attributes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Last iteration Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « lib/dom/scripts/fremontcutbuilder.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 'synthesizedV8EnabledPerContext' 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['synthesizedV8EnabledPerContext'])
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
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
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
OLDNEW
« no previous file with comments | « lib/dom/scripts/fremontcutbuilder.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698