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

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

Issue 2970003002: Add code generation for ConditionalFeatures bindings code (Closed)
Patch Set: Move awkward dependency into scripts.gni with its counterpart Created 3 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: 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 c9d7946ab760a5f61bb6d4c27bbfe7d942db9d22..37da45b0894d8ab59bb359a6889e8ca09a4986d4 100644
--- a/third_party/WebKit/Source/bindings/scripts/code_generator.py
+++ b/third_party/WebKit/Source/bindings/scripts/code_generator.py
@@ -121,21 +121,6 @@ class CodeGeneratorBase(object):
self.info_provider = info_provider
self.jinja_env = initialize_jinja_env(cache_dir)
self.output_dir = output_dir
- self.set_global_type_info()
-
- def should_generate_code(self, definitions):
- return definitions.interfaces or definitions.dictionaries
-
- def set_global_type_info(self):
- interfaces_info = self.info_provider.interfaces_info
- set_ancestors(interfaces_info['ancestors'])
- IdlType.set_callback_interfaces(interfaces_info['callback_interfaces'])
- IdlType.set_dictionaries(interfaces_info['dictionaries'])
- IdlType.set_enums(self.info_provider.enumerations)
- IdlType.set_callback_functions(self.info_provider.callback_functions)
- IdlType.set_implemented_as_interfaces(interfaces_info['implemented_as_interfaces'])
- IdlType.set_garbage_collected_types(interfaces_info['garbage_collected_interfaces'])
- set_component_dirs(interfaces_info['component_dirs'])
def render_template(self, include_paths, header_template, cpp_template,
template_context, component=None):
@@ -157,6 +142,29 @@ class CodeGeneratorBase(object):
cpp_text = render_template(cpp_template, template_context)
return header_text, cpp_text
+
+class IDLCodeGeneratorBase(CodeGeneratorBase):
Yuki 2017/07/14 03:30:07 Is this just a refactoring? Does this make sense?
iclelland 2017/07/14 18:25:04 I wanted to reuse some of the functionality from C
+ """Base class for code generators which create bindings implementations from
+ IDL files.
+ """
+ def __init__(self, generator_name, info_provider, cache_dir, output_dir):
+ super(IDLCodeGeneratorBase, self).__init__(generator_name, info_provider, cache_dir, output_dir)
+ self.set_global_type_info()
+
+ def should_generate_code(self, definitions):
+ return definitions.interfaces or definitions.dictionaries
+
+ def set_global_type_info(self):
+ interfaces_info = self.info_provider.interfaces_info
+ set_ancestors(interfaces_info['ancestors'])
+ IdlType.set_callback_interfaces(interfaces_info['callback_interfaces'])
+ IdlType.set_dictionaries(interfaces_info['dictionaries'])
+ IdlType.set_enums(self.info_provider.enumerations)
+ IdlType.set_callback_functions(self.info_provider.callback_functions)
+ IdlType.set_implemented_as_interfaces(interfaces_info['implemented_as_interfaces'])
+ IdlType.set_garbage_collected_types(interfaces_info['garbage_collected_interfaces'])
+ set_component_dirs(interfaces_info['component_dirs'])
+
def generate_code(self, definitions, definition_name):
"""Invokes code generation. The [definitions] argument is a list of definitions,
and the [definition_name] is the name of the definition

Powered by Google App Engine
This is Rietveld 408576698