| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """The frontend for the Mojo bindings system.""" | 6 """The frontend for the Mojo bindings system.""" |
| 7 | 7 |
| 8 | 8 |
| 9 import argparse | 9 import argparse |
| 10 import hashlib | 10 import hashlib |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 ScrambleMethodOrdinals(module.interfaces, args.scrambled_message_id_salt) | 197 ScrambleMethodOrdinals(module.interfaces, args.scrambled_message_id_salt) |
| 198 | 198 |
| 199 if self._should_generate(rel_filename.path): | 199 if self._should_generate(rel_filename.path): |
| 200 AddComputedData(module) | 200 AddComputedData(module) |
| 201 for language, generator_module in generator_modules.iteritems(): | 201 for language, generator_module in generator_modules.iteritems(): |
| 202 generator = generator_module.Generator( | 202 generator = generator_module.Generator( |
| 203 module, args.output_dir, typemap=self._typemap.get(language, {}), | 203 module, args.output_dir, typemap=self._typemap.get(language, {}), |
| 204 variant=args.variant, bytecode_path=args.bytecode_path, | 204 variant=args.variant, bytecode_path=args.bytecode_path, |
| 205 for_blink=args.for_blink, | 205 for_blink=args.for_blink, |
| 206 use_once_callback=args.use_once_callback, | 206 use_once_callback=args.use_once_callback, |
| 207 use_new_js_bindings=args.use_new_js_bindings, | 207 js_bindings_mode=args.js_bindings_mode, |
| 208 export_attribute=args.export_attribute, | 208 export_attribute=args.export_attribute, |
| 209 export_header=args.export_header, | 209 export_header=args.export_header, |
| 210 generate_non_variant_code=args.generate_non_variant_code) | 210 generate_non_variant_code=args.generate_non_variant_code) |
| 211 filtered_args = [] | 211 filtered_args = [] |
| 212 if hasattr(generator_module, 'GENERATOR_PREFIX'): | 212 if hasattr(generator_module, 'GENERATOR_PREFIX'): |
| 213 prefix = '--' + generator_module.GENERATOR_PREFIX + '_' | 213 prefix = '--' + generator_module.GENERATOR_PREFIX + '_' |
| 214 filtered_args = [arg for arg in remaining_args | 214 filtered_args = [arg for arg in remaining_args |
| 215 if arg.startswith(prefix)] | 215 if arg.startswith(prefix)] |
| 216 generator.GenerateFiles(filtered_args) | 216 generator.GenerateFiles(filtered_args) |
| 217 | 217 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 "the path from which to load template bytecode; to generate template " | 329 "the path from which to load template bytecode; to generate template " |
| 330 "bytecode, run %s precompile BYTECODE_PATH" % os.path.basename( | 330 "bytecode, run %s precompile BYTECODE_PATH" % os.path.basename( |
| 331 sys.argv[0]))) | 331 sys.argv[0]))) |
| 332 generate_parser.add_argument("--for_blink", action="store_true", | 332 generate_parser.add_argument("--for_blink", action="store_true", |
| 333 help="Use WTF types as generated types for mojo " | 333 help="Use WTF types as generated types for mojo " |
| 334 "string/array/map.") | 334 "string/array/map.") |
| 335 generate_parser.add_argument( | 335 generate_parser.add_argument( |
| 336 "--use_once_callback", action="store_true", | 336 "--use_once_callback", action="store_true", |
| 337 help="Use base::OnceCallback instead of base::RepeatingCallback.") | 337 help="Use base::OnceCallback instead of base::RepeatingCallback.") |
| 338 generate_parser.add_argument( | 338 generate_parser.add_argument( |
| 339 "--use_new_js_bindings", action="store_true", | 339 "--js_bindings_mode", choices=["new", "both", "old"], default="new", |
| 340 help="Use the new module loading approach and the core API exposed by " | 340 help="This option only affects the JavaScript bindings. The value could " |
| 341 "Web IDL. This option only affects the JavaScript bindings.") | 341 "be: \"new\" - generate only the new-style JS bindings, which use the " |
| 342 "new module loading approach and the core api exposed by Web IDL; " |
| 343 "\"both\" - generate both the old- and new-style bindings; \"old\" - " |
| 344 "generate only the old-style bindings.") |
| 342 generate_parser.add_argument( | 345 generate_parser.add_argument( |
| 343 "--export_attribute", default="", | 346 "--export_attribute", default="", |
| 344 help="Optional attribute to specify on class declaration to export it " | 347 help="Optional attribute to specify on class declaration to export it " |
| 345 "for the component build.") | 348 "for the component build.") |
| 346 generate_parser.add_argument( | 349 generate_parser.add_argument( |
| 347 "--export_header", default="", | 350 "--export_header", default="", |
| 348 help="Optional header to include in the generated headers to support the " | 351 help="Optional header to include in the generated headers to support the " |
| 349 "component build.") | 352 "component build.") |
| 350 generate_parser.add_argument( | 353 generate_parser.add_argument( |
| 351 "--generate_non_variant_code", action="store_true", | 354 "--generate_non_variant_code", action="store_true", |
| (...skipping 15 matching lines...) Expand all Loading... |
| 367 "-o", "--output_dir", dest="output_dir", default=".", | 370 "-o", "--output_dir", dest="output_dir", default=".", |
| 368 help="output directory for precompiled templates") | 371 help="output directory for precompiled templates") |
| 369 precompile_parser.set_defaults(func=_Precompile) | 372 precompile_parser.set_defaults(func=_Precompile) |
| 370 | 373 |
| 371 args, remaining_args = parser.parse_known_args() | 374 args, remaining_args = parser.parse_known_args() |
| 372 return args.func(args, remaining_args) | 375 return args.func(args, remaining_args) |
| 373 | 376 |
| 374 | 377 |
| 375 if __name__ == "__main__": | 378 if __name__ == "__main__": |
| 376 sys.exit(main()) | 379 sys.exit(main()) |
| OLD | NEW |