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

Unified Diff: Source/bindings/scripts/code_generator_v8.py

Issue 420763002: IDL: DOM impl class code generation for IDL dictionaries (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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/idl_compiler.py » ('j') | Source/bindings/scripts/v8_dictionary.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 89f8fd838baf0ffcf1cee2760d0b04fc94d9fbc7..96db1d847470209808935713efd4bec0fccf2673 100644
--- a/Source/bindings/scripts/code_generator_v8.py
+++ b/Source/bindings/scripts/code_generator_v8.py
@@ -96,10 +96,11 @@ def render_template(interface_info, header_template, cpp_template,
class CodeGeneratorV8(object):
- def __init__(self, interfaces_info, cache_dir):
+ def __init__(self, interfaces_info, cache_dir, output_dir):
interfaces_info = interfaces_info or {}
self.interfaces_info = interfaces_info
self.jinja_env = initialize_jinja_env(cache_dir)
+ self.output_dir = output_dir
# Set global type info
idl_types.set_ancestors(dict(
@@ -130,6 +131,17 @@ class CodeGeneratorV8(object):
(interface_name, interface_info['component_dir'])
for interface_name, interface_info in interfaces_info.iteritems()))
+ def output_paths_for_bindings(self, definition_name):
+ header_path = posixpath.join(self.output_dir,
+ 'V8%s.h' % definition_name)
+ cpp_path = posixpath.join(self.output_dir, 'V8%s.cpp' % definition_name)
+ return header_path, cpp_path
+
+ def output_paths_for_impl(self, definition_name):
+ header_path = posixpath.join(self.output_dir, '%s.h' % definition_name)
+ cpp_path = posixpath.join(self.output_dir, '%s.cpp' % definition_name)
+ return header_path, cpp_path
+
def generate_code(self, definitions, definition_name):
"""Returns .h/.cpp code as (header_text, cpp_text)."""
# Set local type info
@@ -170,14 +182,20 @@ class CodeGeneratorV8(object):
template_context['header_includes'].add(interface_info['include_path'])
header_text, cpp_text = render_template(
interface_info, header_template, cpp_template, template_context)
- return header_text, cpp_text
+ header_path, cpp_path = self.output_paths_for_bindings(interface_name)
+ return (
+ (header_path, header_text),
+ (cpp_path, cpp_text),
+ )
def generate_dictionary_code(self, definitions, dictionary_name,
dictionary):
interface_info = self.interfaces_info[dictionary_name]
- # FIXME: Generate impl class
- return self.generate_dictionary_bindings(
+ bindings_results = self.generate_dictionary_bindings(
+ dictionary_name, interface_info, dictionary)
+ impl_results = self.generate_dictionary_impl(
dictionary_name, interface_info, dictionary)
+ return bindings_results + impl_results
def generate_dictionary_bindings(self, dictionary_name,
interface_info, dictionary):
@@ -188,7 +206,25 @@ class CodeGeneratorV8(object):
template_context['header_includes'].add(interface_info['include_path'])
header_text, cpp_text = render_template(
interface_info, header_template, cpp_template, template_context)
- return header_text, cpp_text
+ header_path, cpp_path = self.output_paths_for_bindings(dictionary_name)
+ return (
+ (header_path, header_text),
+ (cpp_path, cpp_text),
+ )
+
+ def generate_dictionary_impl(self, dictionary_name,
+ interface_info, dictionary):
+ header_template = self.jinja_env.get_template('dictionary_impl.h')
+ cpp_template = self.jinja_env.get_template('dictionary_impl.cpp')
+ template_context = v8_dictionary.dictionary_impl_context(
+ dictionary, self.interfaces_info)
+ header_text, cpp_text = render_template(
+ interface_info, header_template, cpp_template, template_context)
+ header_path, cpp_path = self.output_paths_for_impl(dictionary_name)
+ return (
+ (header_path, header_text),
+ (cpp_path, cpp_text),
+ )
def initialize_jinja_env(cache_dir):
« no previous file with comments | « no previous file | Source/bindings/scripts/idl_compiler.py » ('j') | Source/bindings/scripts/v8_dictionary.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698