Chromium Code Reviews| 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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 194 self.server.cpp_namespace_pattern) | 194 self.server.cpp_namespace_pattern) |
| 195 try: | 195 try: |
| 196 # Get main file. | 196 # Get main file. |
| 197 namespace = schema_loader.ResolveNamespace(filename) | 197 namespace = schema_loader.ResolveNamespace(filename) |
| 198 type_generator = cpp_type_generator.CppTypeGenerator( | 198 type_generator = cpp_type_generator.CppTypeGenerator( |
| 199 api_model, | 199 api_model, |
| 200 schema_loader, | 200 schema_loader, |
| 201 namespace) | 201 namespace) |
| 202 | 202 |
| 203 # Generate code | 203 # Generate code |
| 204 cpp_namespace = 'generated_api_schemas' | |
| 205 if file_ext == '.h': | 204 if file_ext == '.h': |
| 206 cpp_code = (h_generator.HGenerator(type_generator) | 205 cpp_code = (h_generator.HGenerator(type_generator) |
| 207 .Generate(namespace).Render()) | 206 .Generate(namespace).Render()) |
| 208 elif file_ext == '.cc': | 207 elif file_ext == '.cc': |
| 209 cpp_code = (cc_generator.CCGenerator(type_generator) | 208 cpp_code = (cc_generator.CCGenerator(type_generator) |
| 210 .Generate(namespace).Render()) | 209 .Generate(namespace).Render()) |
| 211 else: | 210 else: |
| 212 self.send_error(404, "File not found: %s" % request_path) | 211 self.send_error(404, "File not found: %s" % request_path) |
| 213 return | 212 return |
| 214 | 213 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 279 path = os.curdir | 278 path = os.curdir |
| 280 | 279 |
| 281 # Firstly, a .. link if this isn't the root. | 280 # Firstly, a .. link if this isn't the root. |
| 282 if not os.path.samefile(os.curdir, path): | 281 if not os.path.samefile(os.curdir, path): |
| 283 normpath = os.path.normpath(os.path.join(path, os.pardir)) | 282 normpath = os.path.normpath(os.path.join(path, os.pardir)) |
| 284 html.Append('<li><a href="/%s">%s/</a>' % (normpath, os.pardir)) | 283 html.Append('<li><a href="/%s">%s/</a>' % (normpath, os.pardir)) |
| 285 | 284 |
| 286 # Each file under path/ | 285 # Each file under path/ |
| 287 for filename in sorted(os.listdir(path)): | 286 for filename in sorted(os.listdir(path)): |
| 288 full_path = os.path.join(path, filename) | 287 full_path = os.path.join(path, filename) |
| 289 (file_root, file_ext) = os.path.splitext(full_path) | 288 file_ext = os.path.splitext(full_path)[1] |
|
not at google - send to devlin
2015/01/14 22:44:41
ditto
| |
| 290 if os.path.isdir(full_path) and not full_path.endswith('.xcodeproj'): | 289 if os.path.isdir(full_path) and not full_path.endswith('.xcodeproj'): |
| 291 html.Append('<li><a href="/%s/">%s/</a>' % (full_path, filename)) | 290 html.Append('<li><a href="/%s/">%s/</a>' % (full_path, filename)) |
| 292 elif file_ext in ['.json', '.idl']: | 291 elif file_ext in ['.json', '.idl']: |
| 293 # cc/h panes will automatically update via the hash change event. | 292 # cc/h panes will automatically update via the hash change event. |
| 294 html.Append('<li><a href="#%s">%s</a>' % | 293 html.Append('<li><a href="#%s">%s</a>' % |
| 295 (filename, filename)) | 294 (filename, filename)) |
| 296 | 295 |
| 297 html.Append('</ul>') | 296 html.Append('</ul>') |
| 298 | 297 |
| 299 return html.Render() | 298 return html.Render() |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 355 pass | 354 pass |
| 356 | 355 |
| 357 server = PreviewHTTPServer(('', int(opts.port)), | 356 server = PreviewHTTPServer(('', int(opts.port)), |
| 358 CompilerHandler, | 357 CompilerHandler, |
| 359 highlighters, | 358 highlighters, |
| 360 include_rules, | 359 include_rules, |
| 361 opts.namespace) | 360 opts.namespace) |
| 362 server.serve_forever() | 361 server.serve_forever() |
| 363 except KeyboardInterrupt: | 362 except KeyboardInterrupt: |
| 364 server.socket.close() | 363 server.socket.close() |
| OLD | NEW |