| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2013 Google Inc. All rights reserved. | 2 # Copyright (c) 2013 Google Inc. All rights reserved. |
| 3 # | 3 # |
| 4 # Redistribution and use in source and binary forms, with or without | 4 # Redistribution and use in source and binary forms, with or without |
| 5 # modification, are permitted provided that the following conditions are | 5 # modification, are permitted provided that the following conditions are |
| 6 # met: | 6 # met: |
| 7 # | 7 # |
| 8 # * Redistributions of source code must retain the above copyright | 8 # * Redistributions of source code must retain the above copyright |
| 9 # notice, this list of conditions and the following disclaimer. | 9 # notice, this list of conditions and the following disclaimer. |
| 10 # * Redistributions in binary form must reproduce the above | 10 # * Redistributions in binary form must reproduce the above |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 | 494 |
| 495 | 495 |
| 496 def generate(input_path, output_dir): | 496 def generate(input_path, output_dir): |
| 497 fin = open(input_path, "r") | 497 fin = open(input_path, "r") |
| 498 files = load_model_from_idl(fin.read()) | 498 files = load_model_from_idl(fin.read()) |
| 499 fin.close() | 499 fin.close() |
| 500 | 500 |
| 501 cpp_includes = [] | 501 cpp_includes = [] |
| 502 cpp_lines = [] | 502 cpp_lines = [] |
| 503 used_agents = set() | 503 used_agents = set() |
| 504 # FIXME(dgozman): remove this hack once InjectedScriptHost does not use Inst
rumentingAgents. |
| 505 used_agents.add("Inspector") |
| 504 for f in files: | 506 for f in files: |
| 505 cpp_includes.append(include_header(f.header_name)) | 507 cpp_includes.append(include_header(f.header_name)) |
| 506 | 508 |
| 507 fout = open(output_dir + "/" + f.header_name + ".h", "w") | 509 fout = open(output_dir + "/" + f.header_name + ".h", "w") |
| 508 fout.write(f.generate(cpp_lines, used_agents)) | 510 fout.write(f.generate(cpp_lines, used_agents)) |
| 509 fout.close() | 511 fout.close() |
| 510 | 512 |
| 511 for agent in used_agents: | 513 for agent in used_agents: |
| 512 cpp_includes.append(include_inspector_header(agent_class_name(agent))) | 514 cpp_includes.append(include_inspector_header(agent_class_name(agent))) |
| 513 cpp_includes.append(include_header("InstrumentingAgentsInl")) | 515 cpp_includes.append(include_header("InstrumentingAgentsInl")) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 539 if not output_dirpath: | 541 if not output_dirpath: |
| 540 raise Exception("Output directory must be specified") | 542 raise Exception("Output directory must be specified") |
| 541 except Exception: | 543 except Exception: |
| 542 # Work with python 2 and 3 http://docs.python.org/py3k/howto/pyporting.html | 544 # Work with python 2 and 3 http://docs.python.org/py3k/howto/pyporting.html |
| 543 exc = sys.exc_info()[1] | 545 exc = sys.exc_info()[1] |
| 544 sys.stderr.write("Failed to parse command-line arguments: %s\n\n" % exc) | 546 sys.stderr.write("Failed to parse command-line arguments: %s\n\n" % exc) |
| 545 sys.stderr.write("Usage: <script> --output_dir <output_dir> InspectorInstrum
entation.idl\n") | 547 sys.stderr.write("Usage: <script> --output_dir <output_dir> InspectorInstrum
entation.idl\n") |
| 546 exit(1) | 548 exit(1) |
| 547 | 549 |
| 548 generate(input_path, output_dirpath) | 550 generate(input_path, output_dirpath) |
| OLD | NEW |