OLD | NEW |
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 |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 | 183 |
184 request_path = self._GetRequestPath(parsed_url) | 184 request_path = self._GetRequestPath(parsed_url) |
185 (file_root, file_ext) = os.path.splitext(request_path) | 185 (file_root, file_ext) = os.path.splitext(request_path) |
186 (filedir, filename) = os.path.split(file_root) | 186 (filedir, filename) = os.path.split(file_root) |
187 json_file_path = os.path.normpath(file_root + '.json') | 187 json_file_path = os.path.normpath(file_root + '.json') |
188 | 188 |
189 try: | 189 try: |
190 # Get main json file | 190 # Get main json file |
191 api_defs = json_schema.Load(json_file_path) | 191 api_defs = json_schema.Load(json_file_path) |
192 namespace = api_model.AddNamespace(api_defs[0], json_file_path) | 192 namespace = api_model.AddNamespace(api_defs[0], json_file_path) |
193 if not namespace: | |
194 body.Append("<pre>Target file %s is marked nocompile</pre>" % | |
195 json_file_path) | |
196 return | |
197 type_generator = cpp_type_generator.CppTypeGenerator( | 193 type_generator = cpp_type_generator.CppTypeGenerator( |
198 'preview::api', namespace, namespace.unix_name) | 194 'previewserver::api', namespace, namespace.unix_name) |
199 | 195 |
200 # Get json file depedencies | 196 # Get json file depedencies |
201 for dependency in api_defs[0].get('dependencies', []): | 197 for dependency in api_defs[0].get('dependencies', []): |
202 json_file_path = os.path.join(filedir, dependency + '.json') | 198 json_file_path = os.path.join(filedir, dependency + '.json') |
203 api_defs = json_schema.Load(json_file_path) | 199 api_defs = json_schema.Load(json_file_path) |
204 referenced_namespace = api_model.AddNamespace(api_defs[0], | 200 referenced_namespace = api_model.AddNamespace(api_defs[0], |
205 json_file_path) | 201 json_file_path) |
206 if referenced_namespace: | 202 if referenced_namespace: |
207 type_generator.AddNamespace(referenced_namespace, | 203 type_generator.AddNamespace(referenced_namespace, |
208 cpp_util.Classname(referenced_namespace.name).lower()) | 204 cpp_util.Classname(referenced_namespace.name).lower()) |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 print('') | 323 print('') |
328 server = PreviewHTTPServer(('', int(opts.port)), CompilerHandler, | 324 server = PreviewHTTPServer(('', int(opts.port)), CompilerHandler, |
329 { | 325 { |
330 'pygments': pygments_highlighter.PygmentsHighlighter(), | 326 'pygments': pygments_highlighter.PygmentsHighlighter(), |
331 'hilite': hilite_me_highlighter.HiliteMeHighlighter(), | 327 'hilite': hilite_me_highlighter.HiliteMeHighlighter(), |
332 'none': none_highlighter.NoneHighlighter(), | 328 'none': none_highlighter.NoneHighlighter(), |
333 }) | 329 }) |
334 server.serve_forever() | 330 server.serve_forever() |
335 except KeyboardInterrupt: | 331 except KeyboardInterrupt: |
336 server.socket.close() | 332 server.socket.close() |
OLD | NEW |