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

Side by Side Diff: third_party/WebKit/Source/bindings/scripts/code_generator.py

Issue 2880713002: Support combination of [OriginTrialEnabled] and [SecureContext] (Closed)
Patch Set: Rebase Created 3 years, 7 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
OLDNEW
1 # Copyright 2016 The Chromium Authors. All rights reserved. 1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 # pylint: disable=import-error,print-statement,relative-import 5 # pylint: disable=import-error,print-statement,relative-import
6 6
7 """Plumbing for a Jinja-based code generator, including CodeGeneratorBase, a bas e class for all generators.""" 7 """Plumbing for a Jinja-based code generator, including CodeGeneratorBase, a bas e class for all generators."""
8 8
9 import os 9 import os
10 import posixpath 10 import posixpath
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 51
52 52
53 # [Exposed] 53 # [Exposed]
54 def exposed_if(code, exposed_test): 54 def exposed_if(code, exposed_test):
55 if not exposed_test: 55 if not exposed_test:
56 return code 56 return code
57 return generate_indented_conditional(code, 'executionContext && (%s)' % expo sed_test) 57 return generate_indented_conditional(code, 'executionContext && (%s)' % expo sed_test)
58 58
59 59
60 # [SecureContext] 60 # [SecureContext]
61 def secure_context_if(code, secure_context_test): 61 def secure_context_if(code, secure_context_test, test_result=None):
62 if not secure_context_test: 62 if not secure_context_test:
63 return code 63 return code
64 if test_result:
65 return generate_indented_conditional(code, test_result)
64 return generate_indented_conditional(code, 'executionContext && (%s)' % secu re_context_test) 66 return generate_indented_conditional(code, 'executionContext && (%s)' % secu re_context_test)
65 67
66 68
67 # [RuntimeEnabled] 69 # [RuntimeEnabled]
68 def runtime_enabled_if(code, name): 70 def runtime_enabled_if(code, name):
69 if not name: 71 if not name:
70 return code 72 return code
71 73
72 function = v8_utilities.runtime_enabled_function(name) 74 function = v8_utilities.runtime_enabled_function(name)
73 return generate_indented_conditional(code, function) 75 return generate_indented_conditional(code, function)
74 76
75
76 def initialize_jinja_env(cache_dir): 77 def initialize_jinja_env(cache_dir):
77 jinja_env = jinja2.Environment( 78 jinja_env = jinja2.Environment(
78 loader=jinja2.FileSystemLoader(TEMPLATES_DIR), 79 loader=jinja2.FileSystemLoader(TEMPLATES_DIR),
79 # Bytecode cache is not concurrency-safe unless pre-cached: 80 # Bytecode cache is not concurrency-safe unless pre-cached:
80 # if pre-cached this is read-only, but writing creates a race condition. 81 # if pre-cached this is read-only, but writing creates a race condition.
81 bytecode_cache=jinja2.FileSystemBytecodeCache(cache_dir), 82 bytecode_cache=jinja2.FileSystemBytecodeCache(cache_dir),
82 keep_trailing_newline=True, # newline-terminate generated files 83 keep_trailing_newline=True, # newline-terminate generated files
83 lstrip_blocks=True, # so can indent control flow tags 84 lstrip_blocks=True, # so can indent control flow tags
84 trim_blocks=True) 85 trim_blocks=True)
85 jinja_env.filters.update({ 86 jinja_env.filters.update({
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 185
185 # Create a dummy file as output for the build system, 186 # Create a dummy file as output for the build system,
186 # since filenames of individual cache files are unpredictable and opaque 187 # since filenames of individual cache files are unpredictable and opaque
187 # (they are hashes of the template path, which varies based on environment) 188 # (they are hashes of the template path, which varies based on environment)
188 with open(dummy_filename, 'w') as dummy_file: 189 with open(dummy_filename, 'w') as dummy_file:
189 pass # |open| creates or touches the file 190 pass # |open| creates or touches the file
190 191
191 192
192 if __name__ == '__main__': 193 if __name__ == '__main__':
193 sys.exit(main(sys.argv)) 194 sys.exit(main(sys.argv))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698