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

Side by Side Diff: mojo/public/tools/bindings/mojom_bindings_generator.py

Issue 2136733002: Mojo C++ bindings: add a new mode to generator to use native STL/WTF types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@67_new
Patch Set: . Created 4 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 unified diff | Download patch
OLDNEW
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 imp 10 import imp
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 os.path.abspath(args.depth)) 137 os.path.abspath(args.depth))
138 138
139 # Normalize to unix-style path here to keep the generators simpler. 139 # Normalize to unix-style path here to keep the generators simpler.
140 module.path = module.path.replace('\\', '/') 140 module.path = module.path.replace('\\', '/')
141 141
142 if self._should_generate(filename): 142 if self._should_generate(filename):
143 for language, generator_module in generator_modules.iteritems(): 143 for language, generator_module in generator_modules.iteritems():
144 generator = generator_module.Generator( 144 generator = generator_module.Generator(
145 module, args.output_dir, typemap=self._typemap.get(language, {}), 145 module, args.output_dir, typemap=self._typemap.get(language, {}),
146 variant=args.variant, bytecode_path=args.bytecode_path, 146 variant=args.variant, bytecode_path=args.bytecode_path,
147 for_blink=args.for_blink) 147 for_blink=args.for_blink,
148 use_new_wrapper_types=args.use_new_wrapper_types)
148 filtered_args = [] 149 filtered_args = []
149 if hasattr(generator_module, 'GENERATOR_PREFIX'): 150 if hasattr(generator_module, 'GENERATOR_PREFIX'):
150 prefix = '--' + generator_module.GENERATOR_PREFIX + '_' 151 prefix = '--' + generator_module.GENERATOR_PREFIX + '_'
151 filtered_args = [arg for arg in remaining_args 152 filtered_args = [arg for arg in remaining_args
152 if arg.startswith(prefix)] 153 if arg.startswith(prefix)]
153 generator.GenerateFiles(filtered_args) 154 generator.GenerateFiles(filtered_args)
154 155
155 # Save result. 156 # Save result.
156 self._processed_files[filename] = module 157 self._processed_files[filename] = module
157 return module 158 return module
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 generate_parser.add_argument("--variant", dest="variant", default=None, 250 generate_parser.add_argument("--variant", dest="variant", default=None,
250 help="output a named variant of the bindings") 251 help="output a named variant of the bindings")
251 generate_parser.add_argument( 252 generate_parser.add_argument(
252 "--bytecode_path", type=str, required=True, help=( 253 "--bytecode_path", type=str, required=True, help=(
253 "the path from which to load template bytecode; to generate template " 254 "the path from which to load template bytecode; to generate template "
254 "bytecode, run %s precompile BYTECODE_PATH" % os.path.basename( 255 "bytecode, run %s precompile BYTECODE_PATH" % os.path.basename(
255 sys.argv[0]))) 256 sys.argv[0])))
256 generate_parser.add_argument("--for_blink", action="store_true", 257 generate_parser.add_argument("--for_blink", action="store_true",
257 help="Use WTF types as generated types for mojo " 258 help="Use WTF types as generated types for mojo "
258 "string/array/map.") 259 "string/array/map.")
260 generate_parser.add_argument(
261 "--use_new_wrapper_types", action="store_true",
262 help="Map mojom array/map/string to STL (for chromium variant) or WTF "
263 "(for blink variant) types directly.")
259 generate_parser.set_defaults(func=_Generate) 264 generate_parser.set_defaults(func=_Generate)
260 265
261 precompile_parser = subparsers.add_parser("precompile", 266 precompile_parser = subparsers.add_parser("precompile",
262 description="Precompile templates for the mojom bindings generator.") 267 description="Precompile templates for the mojom bindings generator.")
263 precompile_parser.add_argument( 268 precompile_parser.add_argument(
264 "-o", "--output_dir", dest="output_dir", default=".", 269 "-o", "--output_dir", dest="output_dir", default=".",
265 help="output directory for precompiled templates") 270 help="output directory for precompiled templates")
266 precompile_parser.set_defaults(func=_Precompile) 271 precompile_parser.set_defaults(func=_Precompile)
267 272
268 args, remaining_args = parser.parse_known_args() 273 args, remaining_args = parser.parse_known_args()
269 return args.func(args, remaining_args) 274 return args.func(args, remaining_args)
270 275
271 276
272 if __name__ == "__main__": 277 if __name__ == "__main__":
273 sys.exit(main()) 278 sys.exit(main())
OLDNEW
« no previous file with comments | « mojo/public/tools/bindings/mojom.gni ('k') | mojo/public/tools/bindings/pylib/mojom/generate/generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698