Chromium Code Reviews| 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) |
| ################################################################################ |