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

Unified Diff: mojo/public/tools/bindings/pylib/mojom/generate/template_expander.py

Issue 306893010: Generate java bindings for structs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Re-upload after revert Created 6 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 | « mojo/public/tools/bindings/pylib/mojom/generate/generator.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/tools/bindings/pylib/mojom/generate/template_expander.py
diff --git a/mojo/public/tools/bindings/pylib/mojom/generate/template_expander.py b/mojo/public/tools/bindings/pylib/mojom/generate/template_expander.py
index 86ea0eac0b4eef9037145b2d9c599ed43370ed6a..adf9cf78a60e1afc29fa84be071d6e95ab2afbbe 100644
--- a/mojo/public/tools/bindings/pylib/mojom/generate/template_expander.py
+++ b/mojo/public/tools/bindings/pylib/mojom/generate/template_expander.py
@@ -30,12 +30,16 @@ except ImportError:
import jinja2
-def ApplyTemplate(base_dir, path_to_template, params, filters=None, **kwargs):
+def ApplyTemplate(mojo_generator, base_dir, path_to_template, params,
+ filters=None, **kwargs):
template_directory, template_name = os.path.split(path_to_template)
path_to_templates = os.path.join(base_dir, template_directory)
loader = jinja2.FileSystemLoader([path_to_templates])
+ final_kwargs = dict(mojo_generator.GetJinjaParameters())
+ final_kwargs.update(kwargs)
jinja_env = jinja2.Environment(loader=loader, keep_trailing_newline=True,
- **kwargs)
+ **final_kwargs)
+ jinja_env.globals.update(mojo_generator.GetGlobals());
if filters:
jinja_env.filters.update(filters)
template = jinja_env.get_template(template_name)
@@ -48,7 +52,8 @@ def UseJinja(path_to_template, **kwargs):
def RealDecorator(generator):
def GeneratorInternal(*args, **kwargs2):
parameters = generator(*args, **kwargs2)
- return ApplyTemplate(base_dir, path_to_template, parameters, **kwargs)
+ return ApplyTemplate(args[0], base_dir, path_to_template, parameters,
+ **kwargs)
GeneratorInternal.func_name = generator.func_name
return GeneratorInternal
return RealDecorator
« no previous file with comments | « mojo/public/tools/bindings/pylib/mojom/generate/generator.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698