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

Side by Side Diff: tools/json_schema_compiler/compiler.py

Issue 1695563002: Media Galleries Partial Deprecation: Remove scan functionality. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 (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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 schema_loader = SchemaLoader( 52 schema_loader = SchemaLoader(
53 root, 53 root,
54 os.path.dirname(schema), 54 os.path.dirname(schema),
55 include_rules, 55 include_rules,
56 cpp_namespace_pattern) 56 cpp_namespace_pattern)
57 api_def = schema_loader.LoadSchema(schema) 57 api_def = schema_loader.LoadSchema(schema)
58 58
59 # If compiling the C++ model code, delete 'nocompile' nodes. 59 # If compiling the C++ model code, delete 'nocompile' nodes.
60 if generator_name == 'cpp': 60 if generator_name == 'cpp':
61 api_def = json_schema.DeleteNodes(api_def, 'nocompile') 61 api_def = json_schema.DeleteNodes(api_def, 'nocompile')
62
63 # Delete all 'nodefine' nodes. They are only for documentation.
64 api_def = json_schema.DeleteNodes(api_def, 'nodefine')
65
62 api_defs.extend(api_def) 66 api_defs.extend(api_def)
63 67
64 api_model = Model(allow_inline_enums=False) 68 api_model = Model(allow_inline_enums=False)
65 69
66 # For single-schema compilation make sure that the first (i.e. only) schema 70 # For single-schema compilation make sure that the first (i.e. only) schema
67 # is the default one. 71 # is the default one.
68 default_namespace = None 72 default_namespace = None
69 73
70 # If we have files from multiple source paths, we'll use the common parent 74 # If we have files from multiple source paths, we'll use the common parent
71 # path as the source directory. 75 # path as the source directory.
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 include_rules = [] 206 include_rules = []
203 if opts.include_rules: 207 if opts.include_rules:
204 include_rules = map(split_path_and_namespace, 208 include_rules = map(split_path_and_namespace,
205 shlex.split(opts.include_rules)) 209 shlex.split(opts.include_rules))
206 210
207 result = GenerateSchema(opts.generator, file_paths, opts.root, opts.destdir, 211 result = GenerateSchema(opts.generator, file_paths, opts.root, opts.destdir,
208 opts.namespace, opts.bundle_name, opts.impl_dir, 212 opts.namespace, opts.bundle_name, opts.impl_dir,
209 include_rules) 213 include_rules)
210 if not opts.destdir: 214 if not opts.destdir:
211 print result 215 print result
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698