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

Unified Diff: Source/bindings/scripts/code_generator_v8.py

Issue 424163002: Enable the WebIDL [Exposed] annotation on an interface's members. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: missed renames Created 6 years, 4 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 | « Source/bindings/core/v8/V8WindowShell.cpp ('k') | Source/bindings/scripts/v8_attributes.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/scripts/code_generator_v8.py
diff --git a/Source/bindings/scripts/code_generator_v8.py b/Source/bindings/scripts/code_generator_v8.py
index 96db1d847470209808935713efd4bec0fccf2673..272b611c34fa69196540cdcf73c0a8ab0a1a0b36 100644
--- a/Source/bindings/scripts/code_generator_v8.py
+++ b/Source/bindings/scripts/code_generator_v8.py
@@ -239,11 +239,21 @@ def initialize_jinja_env(cache_dir):
jinja_env.filters.update({
'blink_capitalize': capitalize,
'conditional': conditional_if_endif,
+ 'exposed': exposed_if,
+ 'per_context_enabled': per_context_enabled_if,
'runtime_enabled': runtime_enabled_if,
})
return jinja_env
+def generate_indented_conditional(code, conditional):
+ # Indent if statement to level of original code
+ indent = re.match(' *', code).group(0)
+ return ('%sif (%s) {\n' % (indent, conditional) +
+ ' %s\n' % '\n '.join(code.splitlines()) +
+ '%s}\n' % indent)
+
+
# [Conditional]
def conditional_if_endif(code, conditional_string):
# Jinja2 filter to generate if/endif directive blocks
@@ -254,15 +264,25 @@ def conditional_if_endif(code, conditional_string):
'#endif // %s\n' % conditional_string)
+# [Exposed]
+def exposed_if(code, exposed_test):
+ if not exposed_test:
+ return code
+ return generate_indented_conditional(code, 'context && (%s)' % exposed_test)
+
+
+# [PerContextEnabled]
+def per_context_enabled_if(code, per_context_enabled_function):
+ if not per_context_enabled_function:
+ return code
+ return generate_indented_conditional(code, 'context && context->isDocument() && %s(toDocument(context))' % per_context_enabled_function)
+
+
# [RuntimeEnabled]
def runtime_enabled_if(code, runtime_enabled_function_name):
if not runtime_enabled_function_name:
return code
- # Indent if statement to level of original code
- indent = re.match(' *', code).group(0)
- return ('%sif (%s()) {\n' % (indent, runtime_enabled_function_name) +
- ' %s\n' % '\n '.join(code.splitlines()) +
- '%s}\n' % indent)
+ return generate_indented_conditional(code, '%s()' % runtime_enabled_function_name)
################################################################################
« no previous file with comments | « Source/bindings/core/v8/V8WindowShell.cpp ('k') | Source/bindings/scripts/v8_attributes.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698