OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 """Generator for C++ structs from api json files. | 5 """Generator for C++ structs from api json files. |
6 | 6 |
7 The purpose of this tool is to remove the need for hand-written code that | 7 The purpose of this tool is to remove the need for hand-written code that |
8 converts to and from base::Value types when receiving javascript api calls. | 8 converts to and from base::Value types when receiving javascript api calls. |
9 Originally written for generating code for extension apis. Reference schemas | 9 Originally written for generating code for extension apis. Reference schemas |
10 are in chrome/common/extensions/api. | 10 are in chrome/common/extensions/api. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 os.path.dirname(schema), | 50 os.path.dirname(schema), |
51 include_rules, | 51 include_rules, |
52 cpp_namespace_pattern) | 52 cpp_namespace_pattern) |
53 api_def = schema_loader.LoadSchema(schema) | 53 api_def = schema_loader.LoadSchema(schema) |
54 | 54 |
55 # If compiling the C++ model code, delete 'nocompile' nodes. | 55 # If compiling the C++ model code, delete 'nocompile' nodes. |
56 if generator_name == 'cpp': | 56 if generator_name == 'cpp': |
57 api_def = json_schema.DeleteNodes(api_def, 'nocompile') | 57 api_def = json_schema.DeleteNodes(api_def, 'nocompile') |
58 api_defs.extend(api_def) | 58 api_defs.extend(api_def) |
59 | 59 |
60 api_model = Model() | 60 api_model = Model(allow_inline_enums=False) |
61 | 61 |
62 # For single-schema compilation make sure that the first (i.e. only) schema | 62 # For single-schema compilation make sure that the first (i.e. only) schema |
63 # is the default one. | 63 # is the default one. |
64 default_namespace = None | 64 default_namespace = None |
65 | 65 |
66 # If we have files from multiple source paths, we'll use the common parent | 66 # If we have files from multiple source paths, we'll use the common parent |
67 # path as the source directory. | 67 # path as the source directory. |
68 src_path = None | 68 src_path = None |
69 | 69 |
70 # Load the actual namespaces into the model. | 70 # Load the actual namespaces into the model. |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 | 184 |
185 include_rules = [] | 185 include_rules = [] |
186 if opts.include_rules: | 186 if opts.include_rules: |
187 include_rules = map(split_path_and_namespace, | 187 include_rules = map(split_path_and_namespace, |
188 shlex.split(opts.include_rules)) | 188 shlex.split(opts.include_rules)) |
189 | 189 |
190 result = GenerateSchema(opts.generator, file_paths, opts.root, opts.destdir, | 190 result = GenerateSchema(opts.generator, file_paths, opts.root, opts.destdir, |
191 opts.namespace, opts.impl_dir, include_rules) | 191 opts.namespace, opts.impl_dir, include_rules) |
192 if not opts.destdir: | 192 if not opts.destdir: |
193 print result | 193 print result |
OLD | NEW |