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

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

Issue 429853002: IDL: Add build target for IDL dictionary impl generation in core (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
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..8fd9637c93f41ebe7ae0fd36e813657e8584e9dc 100644
--- a/Source/bindings/scripts/code_generator_v8.py
+++ b/Source/bindings/scripts/code_generator_v8.py
@@ -80,6 +80,12 @@ import v8_types
from v8_utilities import capitalize, cpp_name, conditional_string, v8_class_name
+# Code generation mode.
+MODE_BINDINGS = 1 << 0
+MODE_DICTIONARY_IMPL = 1 << 1
+MODE_ALL = MODE_BINDINGS | MODE_DICTIONARY_IMPL
+
+
def render_template(interface_info, header_template, cpp_template,
template_context):
template_context['code_generator'] = module_pyname
@@ -137,12 +143,14 @@ class CodeGeneratorV8(object):
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)
+ def output_paths_for_impl(self, definition_name, relative_dir):
+ output_dir = posixpath.join(self.output_dir, relative_dir)
+ header_path = posixpath.join(output_dir, '%s.h' % definition_name)
+ cpp_path = posixpath.join(output_dir, '%s.cpp' % definition_name)
return header_path, cpp_path
- def generate_code(self, definitions, definition_name):
+ def generate_code(self, definitions, definition_name,
+ mode=MODE_ALL):
bashi 2014/07/30 11:32:26 BTW, this is ugly. I'm now thinking that it'd be b
haraken 2014/07/30 19:57:36 That seems better to me (assuming that it won't du
"""Returns .h/.cpp code as (header_text, cpp_text)."""
# Set local type info
IdlType.set_callback_functions(definitions.callback_functions.keys())
@@ -156,7 +164,7 @@ class CodeGeneratorV8(object):
if definition_name in definitions.dictionaries:
return self.generate_dictionary_code(
definitions, definition_name,
- definitions.dictionaries[definition_name])
+ definitions.dictionaries[definition_name], mode)
raise ValueError('%s is not in IDL definitions' % definition_name)
def generate_interface_code(self, definitions, interface_name, interface):
@@ -189,13 +197,16 @@ class CodeGeneratorV8(object):
)
def generate_dictionary_code(self, definitions, dictionary_name,
- dictionary):
+ dictionary, mode):
interface_info = self.interfaces_info[dictionary_name]
- 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
+ results = set()
+ if (mode & MODE_BINDINGS) == MODE_BINDINGS:
+ results.update(self.generate_dictionary_bindings(
+ dictionary_name, interface_info, dictionary))
+ if (mode & MODE_DICTIONARY_IMPL) == MODE_DICTIONARY_IMPL:
+ results.update(self.generate_dictionary_impl(
+ dictionary_name, interface_info, dictionary))
+ return results
def generate_dictionary_bindings(self, dictionary_name,
interface_info, dictionary):
@@ -220,7 +231,8 @@ class CodeGeneratorV8(object):
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)
+ header_path, cpp_path = self.output_paths_for_impl(
+ dictionary_name, interface_info['relative_dir'])
return (
(header_path, header_text),
(cpp_path, cpp_text),

Powered by Google App Engine
This is Rietveld 408576698