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

Unified 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, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/dom/scripts/fremontcutbuilder.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/dom/scripts/systemnative.py
diff --git a/lib/dom/scripts/systemnative.py b/lib/dom/scripts/systemnative.py
index 8bbf266cb1cbd3ff95a605c75d1022522f65c901..be080e669d0e1c55a49e9f1848c244b2f2b59786 100644
--- a/lib/dom/scripts/systemnative.py
+++ b/lib/dom/scripts/systemnative.py
@@ -302,10 +302,24 @@ class NativeImplementationGenerator(systembase.BaseGenerator):
function_expression = '%s::%s' % (self._interface_type_info.native_type(), create_function)
invocation = self._GenerateWebCoreInvocation(function_expression, arguments,
self._interface.id, self._interface.ext_attrs, raises_dom_exceptions)
+
+ runtime_check = None
+ database = self._system._database
+ if 'synthesizedV8EnabledPerContext' in self._interface.ext_attrs:
+ raises_exceptions = True
+ self._cpp_impl_includes.add('"ContextFeatures.h"')
+ runtime_check = emitter.Format(
+ ' if (ContextFeatures::$(FEATURE)Enabled(DartUtilities::domWindowForCurrentIsolate()->document())) {\n'
+ ' exception = Dart_NewString("Feature $FEATURE is not enabled");\n'
+ ' goto fail;\n'
+ ' }',
+ FEATURE=self._interface.ext_attrs['synthesizedV8EnabledPerContext'])
+
self._GenerateNativeCallback(callback_name='constructorCallback',
parameter_definitions=parameter_definitions_emitter.Fragments(),
needs_receiver=False, invocation=invocation,
- raises_exceptions=raises_exceptions)
+ raises_exceptions=raises_exceptions,
+ runtime_check=runtime_check)
def _EmitHtmlElementFactoryConstructors(self, infos, html_interface_name):
EmitHtmlElementFactoryConstructors(
@@ -900,22 +914,31 @@ class NativeImplementationGenerator(systembase.BaseGenerator):
raises_exceptions=raises_exceptions)
def _GenerateNativeCallback(self, callback_name, parameter_definitions,
- needs_receiver, invocation, raises_exceptions):
+ needs_receiver, invocation, raises_exceptions, runtime_check=None):
+
+ head = parameter_definitions
if needs_receiver:
- parameter_definitions = emitter.Format(
+ head = emitter.Format(
' $WEBCORE_CLASS_NAME* receiver = DartDOMWrapper::receiver< $WEBCORE_CLASS_NAME >(args);\n'
- ' $PARAMETER_DEFINITIONS\n',
+ '$HEAD\n',
WEBCORE_CLASS_NAME=self._interface_type_info.native_type(),
- PARAMETER_DEFINITIONS=parameter_definitions)
+ HEAD=head)
+
+ if runtime_check:
+ head = emitter.Format(
+ '$RUNTIME_CHECK\n'
+ '$HEAD\n',
+ RUNTIME_CHECK=runtime_check,
+ HEAD=head)
body = emitter.Format(
' {\n'
- '$PARAMETER_DEFINITIONS'
+ '$HEAD'
'$INVOCATION'
' return;\n'
' }\n',
- PARAMETER_DEFINITIONS=parameter_definitions,
+ HEAD=head,
INVOCATION=invocation)
if raises_exceptions:
« 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