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

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: address comments Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/bindings/scripts/v8_attributes.py » ('j') | Source/bindings/scripts/v8_attributes.py » ('J')
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..5fc6678f9613fff18036db7fb732e465f36e81e6 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,
+ 'custom_exposed': custom_exposed_if,
haraken 2014/07/30 16:32:03 "custom" is a bit confusing since "custom" implies
Peter Beverloo 2014/07/31 19:02:21 Done.
+ '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 custom_exposed_if(code, custom_exposed_rules):
+ if not custom_exposed_rules:
+ return code
+ return generate_indented_conditional(code, 'context && (%s)' % custom_exposed_rules)
Jens Widell 2014/07/30 16:48:45 Can 'context' really be null? When does that happe
Peter Beverloo 2014/07/31 19:02:21 I'm not sure. The check existed in installPerConte
+
+
+# [PerContextEnabled]
+def per_context_enabled_if(code, per_context_enabled_function):
+ if not per_context_enabled_function:
+ return code
+ return generate_indented_conditional(code, '%s(impl->document())' % 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 | « no previous file | Source/bindings/scripts/v8_attributes.py » ('j') | Source/bindings/scripts/v8_attributes.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698