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

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

Issue 680193003: IDL: Generate union type containers (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 2 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/idl_compiler.py
diff --git a/Source/bindings/scripts/idl_compiler.py b/Source/bindings/scripts/idl_compiler.py
index 33d933ba4a1423e0ce8b3d326fa7dab2434340fa..2838e7636d043f3b4c97569e8f78def50802e247 100755
--- a/Source/bindings/scripts/idl_compiler.py
+++ b/Source/bindings/scripts/idl_compiler.py
@@ -38,7 +38,7 @@ import os
import cPickle as pickle
import sys
-from code_generator_v8 import CodeGeneratorDictionaryImpl, CodeGeneratorV8
+from code_generator_v8 import CodeGeneratorDictionaryImpl, CodeGeneratorV8, CodeGeneratorUnionTypeContainers
from idl_reader import IdlReader
from utilities import read_idl_files_list_from_file, write_file, idl_filename_to_component
@@ -47,10 +47,12 @@ def parse_options():
parser = OptionParser()
parser.add_option('--cache-directory',
help='cache directory, defaults to output directory')
- parser.add_option('--generate-dictionary-impl',
+ parser.add_option('--generate-impl',
action="store_true", default=False)
parser.add_option('--output-directory')
+ parser.add_option('--dictionary-impl-output-directory')
parser.add_option('--interfaces-info-file')
+ parser.add_option('--individual-info-file')
parser.add_option('--write-file-only-if-changed', type='int')
# FIXME: We should always explicitly specify --target-component and
# remove the default behavior.
@@ -156,7 +158,7 @@ def generate_bindings(options, input_filename):
def generate_dictionary_impl(options, input_filename):
idl_compiler = IdlCompilerDictionaryImpl(
- options.output_directory,
+ options.dictionary_impl_output_directory,
cache_directory=options.cache_directory,
interfaces_info_filename=options.interfaces_info_file,
only_if_changed=options.write_file_only_if_changed)
@@ -166,12 +168,31 @@ def generate_dictionary_impl(options, input_filename):
idl_compiler.compile_file(idl_filename)
+def generate_union_type_containers(options):
+ if not (options.interfaces_info_file and options.individual_info_file):
+ raise Exception('Interfaces info is required to generate '
+ 'union types containers')
+ with open(options.interfaces_info_file) as interfaces_info_file:
+ interfaces_info = pickle.load(interfaces_info_file)
+ with open(options.individual_info_file) as individual_info_file:
+ individual_info = pickle.load(individual_info_file)
+ generator = CodeGeneratorUnionTypeContainers(
+ interfaces_info,
+ options.cache_directory,
+ options.output_directory,
+ options.target_component)
+ output_code_list = generator.generate_code(individual_info['union_types'])
+ for output_path, output_code in output_code_list:
+ write_file(output_code, output_path, options.write_file_only_if_changed)
+
+
def main():
options, input_filename = parse_options()
- if options.generate_dictionary_impl:
+ if options.generate_impl:
# |input_filename| should be a file which contains a list of IDL
# dictionary paths.
generate_dictionary_impl(options, input_filename)
+ generate_union_type_containers(options)
else:
# |input_filename| should be a path of an IDL file.
generate_bindings(options, input_filename)

Powered by Google App Engine
This is Rietveld 408576698