| 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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 | 329 |
| 330 if self.returns_cookie: | 330 if self.returns_cookie: |
| 331 if "Timeline" in self.agents: | 331 if "Timeline" in self.agents: |
| 332 timeline_agent_id = "timelineAgentId" | 332 timeline_agent_id = "timelineAgentId" |
| 333 else: | 333 else: |
| 334 timeline_agent_id = "0" | 334 timeline_agent_id = "0" |
| 335 body_lines.append("\n return InspectorInstrumentationCookie(agent
s, %s);" % timeline_agent_id) | 335 body_lines.append("\n return InspectorInstrumentationCookie(agent
s, %s);" % timeline_agent_id) |
| 336 elif self.returns_value: | 336 elif self.returns_value: |
| 337 body_lines.append("\n return %s;" % self.default_return_value) | 337 body_lines.append("\n return %s;" % self.default_return_value) |
| 338 | 338 |
| 339 cpp_lines.append(template_outofline.substitute( | 339 generated_outofline = template_outofline.substitute( |
| 340 None, | 340 None, |
| 341 return_type=self.return_type, | 341 return_type=self.return_type, |
| 342 name=self.name, | 342 name=self.name, |
| 343 params_impl=", ".join(map(Parameter.to_str_class_and_name, self.para
ms_impl)), | 343 params_impl=", ".join(map(Parameter.to_str_class_and_name, self.para
ms_impl)), |
| 344 impl_lines="".join(body_lines))) | 344 impl_lines="".join(body_lines)) |
| 345 if generated_outofline not in cpp_lines: |
| 346 cpp_lines.append(generated_outofline) |
| 345 | 347 |
| 346 def generate_agent_call(self, agent): | 348 def generate_agent_call(self, agent): |
| 347 agent_class, agent_getter = agent_getter_signature(agent) | 349 agent_class, agent_getter = agent_getter_signature(agent) |
| 348 | 350 |
| 349 leading_param_name = self.params_impl[0].name | 351 leading_param_name = self.params_impl[0].name |
| 350 if not self.accepts_cookie: | 352 if not self.accepts_cookie: |
| 351 agent_fetch = "%s->%s()" % (leading_param_name, agent_getter) | 353 agent_fetch = "%s->%s()" % (leading_param_name, agent_getter) |
| 352 elif agent == "Timeline": | 354 elif agent == "Timeline": |
| 353 agent_fetch = "retrieveTimelineAgent(%s)" % leading_param_name | 355 agent_fetch = "retrieveTimelineAgent(%s)" % leading_param_name |
| 354 else: | 356 else: |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 if not output_dirpath: | 554 if not output_dirpath: |
| 553 raise Exception("Output directory must be specified") | 555 raise Exception("Output directory must be specified") |
| 554 except Exception: | 556 except Exception: |
| 555 # Work with python 2 and 3 http://docs.python.org/py3k/howto/pyporting.html | 557 # Work with python 2 and 3 http://docs.python.org/py3k/howto/pyporting.html |
| 556 exc = sys.exc_info()[1] | 558 exc = sys.exc_info()[1] |
| 557 sys.stderr.write("Failed to parse command-line arguments: %s\n\n" % exc) | 559 sys.stderr.write("Failed to parse command-line arguments: %s\n\n" % exc) |
| 558 sys.stderr.write("Usage: <script> --output_dir <output_dir> InspectorInstrum
entation.idl\n") | 560 sys.stderr.write("Usage: <script> --output_dir <output_dir> InspectorInstrum
entation.idl\n") |
| 559 exit(1) | 561 exit(1) |
| 560 | 562 |
| 561 generate(input_path, output_dirpath) | 563 generate(input_path, output_dirpath) |
| OLD | NEW |