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

Unified Diff: third_party/WebKit/Source/bindings/scripts/code_generator.py

Issue 2569923003: Refer back to Jinja templates from the C++ code generated from IDL files. (Closed)
Patch Set: Also cover templates used from code_generator_web_module.py Created 4 years 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 | third_party/WebKit/Source/bindings/scripts/code_generator_v8.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/bindings/scripts/code_generator.py
diff --git a/third_party/WebKit/Source/bindings/scripts/code_generator.py b/third_party/WebKit/Source/bindings/scripts/code_generator.py
index ad78bd34654651c03363d924814bcbcc56389540..3d7aff3be176b6aef6b3ad84b1b5e377947d5dfe 100644
--- a/third_party/WebKit/Source/bindings/scripts/code_generator.py
+++ b/third_party/WebKit/Source/bindings/scripts/code_generator.py
@@ -103,6 +103,13 @@ def normalize_and_sort_includes(include_paths):
return sorted(normalized_include_paths)
+def render_template(template, context):
+ filename = str(template.filename)
+ filename = filename[filename.rfind("third_party"):]
+ context["jinja_template_filename"] = filename
+ return template.render(context)
+
+
class CodeGeneratorBase(object):
"""Base class for jinja-powered jinja template generation.
"""
@@ -143,8 +150,8 @@ class CodeGeneratorBase(object):
template_context['cpp_includes'] = normalize_and_sort_includes(includes)
- header_text = header_template.render(template_context)
- cpp_text = cpp_template.render(template_context)
+ header_text = render_template(header_template, template_context)
+ cpp_text = render_template(cpp_template, template_context)
return header_text, cpp_text
def generate_code(self, definitions, definition_name):
« no previous file with comments | « no previous file | third_party/WebKit/Source/bindings/scripts/code_generator_v8.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698