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

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

Issue 12522004: Lazily load extension API schemas (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 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
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 2
3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 """Server for viewing the compiled C++ code from tools/json_schema_compiler. 6 """Server for viewing the compiled C++ code from tools/json_schema_compiler.
7 """ 7 """
8 8
9 import cc_generator 9 import cc_generator
10 import code 10 import code
11 import compiler
11 import cpp_type_generator 12 import cpp_type_generator
12 import cpp_util 13 import cpp_util
13 import h_generator 14 import h_generator
14 import idl_schema 15 import idl_schema
15 import json_schema 16 import json_schema
16 import model 17 import model
17 import optparse 18 import optparse
18 import os 19 import os
19 import sys 20 import sys
20 import urlparse 21 import urlparse
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 205
205 request_path = self._GetRequestPath(parsed_url) 206 request_path = self._GetRequestPath(parsed_url)
206 (file_root, file_ext) = os.path.splitext(request_path) 207 (file_root, file_ext) = os.path.splitext(request_path)
207 (filedir, filename) = os.path.split(file_root) 208 (filedir, filename) = os.path.split(file_root)
208 209
209 try: 210 try:
210 # Get main file. 211 # Get main file.
211 (api_def, file_path) = self._LoadModel(filedir, filename) 212 (api_def, file_path) = self._LoadModel(filedir, filename)
212 namespace = api_model.AddNamespace(api_def, file_path) 213 namespace = api_model.AddNamespace(api_def, file_path)
213 type_generator = cpp_type_generator.CppTypeGenerator( 214 type_generator = cpp_type_generator.CppTypeGenerator(
214 'previewserver::api', namespace, namespace.unix_name) 215 namespace,
216 compiler.TypeNamespaceResolver(filedir),
217 namespace.unix_name)
215 218
216 # Get the model's dependencies. 219 # Get the model's dependencies.
217 for dependency in api_def.get('dependencies', []): 220 for dependency in api_def.get('dependencies', []):
218 # Dependencies can contain : in which case they don't refer to APIs, 221 # Dependencies can contain : in which case they don't refer to APIs,
219 # rather, permissions or manifest keys. 222 # rather, permissions or manifest keys.
220 if ':' in dependency: 223 if ':' in dependency:
221 continue 224 continue
222 (api_def, file_path) = self._LoadModel(filedir, dependency) 225 (api_def, file_path) = self._LoadModel(filedir, dependency)
223 referenced_namespace = api_model.AddNamespace(api_def, file_path) 226 referenced_namespace = api_model.AddNamespace(api_def, file_path)
224 if referenced_namespace: 227 if referenced_namespace:
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 highlighters['pygments'] = pygments_highlighter.PygmentsHighlighter() 355 highlighters['pygments'] = pygments_highlighter.PygmentsHighlighter()
353 except ImportError as e: 356 except ImportError as e:
354 pass 357 pass
355 358
356 server = PreviewHTTPServer(('', int(opts.port)), 359 server = PreviewHTTPServer(('', int(opts.port)),
357 CompilerHandler, 360 CompilerHandler,
358 highlighters) 361 highlighters)
359 server.serve_forever() 362 server.serve_forever()
360 except KeyboardInterrupt: 363 except KeyboardInterrupt:
361 server.socket.close() 364 server.socket.close()
OLDNEW
« no previous file with comments | « tools/json_schema_compiler/cpp_type_generator_test.py ('k') | tools/json_schema_compiler/schema_loader.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698