OLD | NEW |
---|---|
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (C) 2013 Google Inc. All rights reserved. | 2 # Copyright (C) 2013 Google Inc. All rights reserved. |
3 # | 3 # |
4 # Redistribution and use in source and binary forms, with or without | 4 # Redistribution and use in source and binary forms, with or without |
5 # modification, are permitted provided that the following conditions are | 5 # modification, are permitted provided that the following conditions are |
6 # met: | 6 # met: |
7 # | 7 # |
8 # * Redistributions of source code must retain the above copyright | 8 # * Redistributions of source code must retain the above copyright |
9 # notice, this list of conditions and the following disclaimer. | 9 # notice, this list of conditions and the following disclaimer. |
10 # * Redistributions in binary form must reproduce the above | 10 # * Redistributions in binary form must reproduce the above |
(...skipping 20 matching lines...) Expand all Loading... | |
31 | 31 |
32 Design doc: http://www.chromium.org/developers/design-documents/idl-compiler | 32 Design doc: http://www.chromium.org/developers/design-documents/idl-compiler |
33 """ | 33 """ |
34 | 34 |
35 import abc | 35 import abc |
36 from optparse import OptionParser | 36 from optparse import OptionParser |
37 import os | 37 import os |
38 import cPickle as pickle | 38 import cPickle as pickle |
39 import sys | 39 import sys |
40 | 40 |
41 from code_generator_v8 import CodeGeneratorDictionaryImpl, CodeGeneratorV8, Code GeneratorUnionType | 41 from code_generator_v8 import CodeGeneratorDictionaryImpl, CodeGeneratorV8, Code GeneratorUnionType, CodeGeneratorCallbackFunction # pylint: disable=W0403 |
peria
2016/09/20 02:47:06
Pylint warns this line because it was edited in th
lkawai
2016/09/20 08:15:06
Acknowledged.
| |
42 from idl_reader import IdlReader | 42 from idl_reader import IdlReader |
43 from utilities import create_component_info_provider, read_idl_files_list_from_f ile, write_file, idl_filename_to_component | 43 from utilities import create_component_info_provider, read_idl_files_list_from_f ile, write_file, idl_filename_to_component |
44 | 44 |
45 | 45 |
46 def parse_options(): | 46 def parse_options(): |
47 parser = OptionParser() | 47 parser = OptionParser() |
48 parser.add_option('--cache-directory', | 48 parser.add_option('--cache-directory', |
49 help='cache directory, defaults to output directory') | 49 help='cache directory, defaults to output directory') |
50 parser.add_option('--generate-impl', | 50 parser.add_option('--generate-impl', |
51 action="store_true", default=False) | 51 action="store_true", default=False) |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
180 generator = CodeGeneratorUnionType( | 180 generator = CodeGeneratorUnionType( |
181 info_provider, | 181 info_provider, |
182 options.cache_directory, | 182 options.cache_directory, |
183 options.output_directory, | 183 options.output_directory, |
184 options.target_component) | 184 options.target_component) |
185 output_code_list = generator.generate_code() | 185 output_code_list = generator.generate_code() |
186 for output_path, output_code in output_code_list: | 186 for output_path, output_code in output_code_list: |
187 write_file(output_code, output_path, options.write_file_only_if_changed) | 187 write_file(output_code, output_path, options.write_file_only_if_changed) |
188 | 188 |
189 | 189 |
190 def generate_callback_function_impl(options): | |
191 info_provider = create_component_info_provider( | |
192 options.info_dir, options.target_component) | |
193 generator = CodeGeneratorCallbackFunction( | |
194 info_provider, | |
195 options.cache_directory, | |
196 options.output_directory, | |
197 options.target_component) | |
198 output_code_list = generator.generate_code() | |
199 for output_path, output_code in output_code_list: | |
200 write_file(output_code, output_path, options.write_file_only_if_changed) | |
201 | |
202 | |
190 def main(): | 203 def main(): |
191 options, input_filename = parse_options() | 204 options, input_filename = parse_options() |
192 if options.generate_impl: | 205 if options.generate_impl: |
193 # |input_filename| should be a file which contains a list of IDL | 206 # |input_filename| should be a file which contains a list of IDL |
194 # dictionary paths. | 207 # dictionary paths. |
195 generate_dictionary_impl(options, input_filename) | 208 generate_dictionary_impl(options, input_filename) |
196 generate_union_type_containers(options) | 209 generate_union_type_containers(options) |
210 generate_callback_function_impl(options) | |
197 else: | 211 else: |
198 # |input_filename| should be a path of an IDL file. | 212 # |input_filename| should be a path of an IDL file. |
199 generate_bindings(options, input_filename) | 213 generate_bindings(options, input_filename) |
200 | 214 |
201 | 215 |
202 if __name__ == '__main__': | 216 if __name__ == '__main__': |
203 sys.exit(main()) | 217 sys.exit(main()) |
OLD | NEW |