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

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

Issue 9834088: Make json_schema_compiler resolve type names via resolution rules. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Naming fix type_ -> type_name Created 8 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | tools/json_schema_compiler/cpp_type_generator.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 namespace = api_model.AddNamespace(target_namespace, relpath) 67 namespace = api_model.AddNamespace(target_namespace, relpath)
68 if not namespace: 68 if not namespace:
69 continue 69 continue
70 70
71 # The output filename must match the input filename for gyp to deal with it 71 # The output filename must match the input filename for gyp to deal with it
72 # properly. 72 # properly.
73 out_file = namespace.name 73 out_file = namespace.name
74 type_generator = cpp_type_generator.CppTypeGenerator( 74 type_generator = cpp_type_generator.CppTypeGenerator(
75 root_namespace, namespace, namespace.unix_name) 75 root_namespace, namespace, namespace.unix_name)
76 for referenced_namespace in api_model.namespaces.values(): 76 for referenced_namespace in api_model.namespaces.values():
77 if referenced_namespace == namespace:
78 continue
77 type_generator.AddNamespace( 79 type_generator.AddNamespace(
78 referenced_namespace, 80 referenced_namespace,
79 referenced_namespace.unix_name) 81 referenced_namespace.unix_name)
80 82
81 h_code = (h_generator.HGenerator(namespace, type_generator) 83 h_code = (h_generator.HGenerator(namespace, type_generator)
82 .Generate().Render()) 84 .Generate().Render())
83 cc_code = (cc_generator.CCGenerator(namespace, type_generator) 85 cc_code = (cc_generator.CCGenerator(namespace, type_generator)
84 .Generate().Render()) 86 .Generate().Render())
85 87
86 if dest_dir: 88 if dest_dir:
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 168
167 if not args: 169 if not args:
168 sys.exit(0) # This is OK as a no-op 170 sys.exit(0) # This is OK as a no-op
169 dest_dir = opts.destdir 171 dest_dir = opts.destdir
170 root_namespace = opts.namespace 172 root_namespace = opts.namespace
171 173
172 if opts.bundle: 174 if opts.bundle:
173 handle_bundle_schema(args, dest_dir, opts.root, root_namespace) 175 handle_bundle_schema(args, dest_dir, opts.root, root_namespace)
174 else: 176 else:
175 handle_single_schema(args[0], dest_dir, opts.root, root_namespace) 177 handle_single_schema(args[0], dest_dir, opts.root, root_namespace)
OLDNEW
« no previous file with comments | « no previous file | tools/json_schema_compiler/cpp_type_generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698