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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 if (agent->${name}(${params_agent})) | 108 if (agent->${name}(${params_agent})) |
109 timelineAgentId = agent->id(); | 109 timelineAgentId = agent->id(); |
110 }""") | 110 }""") |
111 | 111 |
112 | 112 |
113 template_instrumenting_agents_h = string.Template("""// Code generated from Insp
ectorInstrumentation.idl | 113 template_instrumenting_agents_h = string.Template("""// Code generated from Insp
ectorInstrumentation.idl |
114 | 114 |
115 #ifndef InstrumentingAgentsInl_h | 115 #ifndef InstrumentingAgentsInl_h |
116 #define InstrumentingAgentsInl_h | 116 #define InstrumentingAgentsInl_h |
117 | 117 |
| 118 #include "platform/heap/Handle.h" |
118 #include "wtf/FastAllocBase.h" | 119 #include "wtf/FastAllocBase.h" |
119 #include "wtf/Noncopyable.h" | 120 #include "wtf/Noncopyable.h" |
120 #include "wtf/PassRefPtr.h" | 121 #include "wtf/PassRefPtr.h" |
121 #include "wtf/RefCounted.h" | 122 #include "wtf/RefCounted.h" |
122 | 123 |
123 namespace WebCore { | 124 namespace WebCore { |
124 | 125 |
125 ${forward_list} | 126 ${forward_list} |
126 | 127 |
127 class InstrumentingAgents : public RefCounted<InstrumentingAgents> { | 128 class InstrumentingAgents : public RefCountedWillBeGarbageCollectedFinalized<Ins
trumentingAgents> { |
128 WTF_MAKE_NONCOPYABLE(InstrumentingAgents); | 129 WTF_MAKE_NONCOPYABLE(InstrumentingAgents); |
129 WTF_MAKE_FAST_ALLOCATED; | 130 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; |
130 public: | 131 public: |
131 static PassRefPtr<InstrumentingAgents> create() | 132 static PassRefPtrWillBeRawPtr<InstrumentingAgents> create() |
132 { | 133 { |
133 return adoptRef(new InstrumentingAgents()); | 134 return adoptRefWillBeNoop(new InstrumentingAgents()); |
134 } | 135 } |
135 ~InstrumentingAgents() { } | 136 ~InstrumentingAgents() { } |
| 137 void trace(Visitor*); |
136 void reset(); | 138 void reset(); |
137 | 139 |
138 ${accessor_list} | 140 ${accessor_list} |
139 | 141 |
140 private: | 142 private: |
141 InstrumentingAgents(); | 143 InstrumentingAgents(); |
142 | 144 |
143 ${member_list} | 145 ${member_list} |
144 }; | 146 }; |
145 | 147 |
146 } | 148 } |
147 | 149 |
148 #endif // !defined(InstrumentingAgentsInl_h) | 150 #endif // !defined(InstrumentingAgentsInl_h) |
149 """) | 151 """) |
150 | 152 |
151 template_instrumenting_agent_accessor = string.Template(""" | 153 template_instrumenting_agent_accessor = string.Template(""" |
152 ${class_name}* ${getter_name}() const { return ${member_name}; } | 154 ${class_name}* ${getter_name}() const { return ${member_name}; } |
153 void set${class_name}(${class_name}* agent) { ${member_name} = agent; }""") | 155 void set${class_name}(${class_name}* agent) { ${member_name} = agent; }""") |
154 | 156 |
155 template_instrumenting_agents_cpp = string.Template(""" | 157 template_instrumenting_agents_cpp = string.Template(""" |
156 InstrumentingAgents::InstrumentingAgents() | 158 InstrumentingAgents::InstrumentingAgents() |
157 : $init_list | 159 : $init_list |
158 { | 160 { |
159 } | 161 } |
160 | 162 |
| 163 void InstrumentingAgents::trace(Visitor* visitor) |
| 164 { |
| 165 $trace_list |
| 166 } |
| 167 |
161 void InstrumentingAgents::reset() | 168 void InstrumentingAgents::reset() |
162 { | 169 { |
163 $reset_list | 170 $reset_list |
164 }""") | 171 }""") |
165 | 172 |
166 | 173 |
167 | 174 |
168 def match_and_consume(pattern, source): | 175 def match_and_consume(pattern, source): |
169 match = re.match(pattern, source) | 176 match = re.match(pattern, source) |
170 if match: | 177 if match: |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 return include_header("core/inspector/" + name) | 440 return include_header("core/inspector/" + name) |
434 | 441 |
435 | 442 |
436 def generate_instrumenting_agents(used_agents): | 443 def generate_instrumenting_agents(used_agents): |
437 agents = list(used_agents) | 444 agents = list(used_agents) |
438 | 445 |
439 forward_list = [] | 446 forward_list = [] |
440 accessor_list = [] | 447 accessor_list = [] |
441 member_list = [] | 448 member_list = [] |
442 init_list = [] | 449 init_list = [] |
| 450 trace_list = [] |
443 reset_list = [] | 451 reset_list = [] |
444 | 452 |
445 for agent in agents: | 453 for agent in agents: |
446 class_name, getter_name = agent_getter_signature(agent) | 454 class_name, getter_name = agent_getter_signature(agent) |
447 member_name = "m_" + getter_name | 455 member_name = "m_" + getter_name |
448 | 456 |
449 forward_list.append("class %s;" % class_name) | 457 forward_list.append("class %s;" % class_name) |
450 accessor_list.append(template_instrumenting_agent_accessor.substitute( | 458 accessor_list.append(template_instrumenting_agent_accessor.substitute( |
451 None, | 459 None, |
452 class_name=class_name, | 460 class_name=class_name, |
453 getter_name=getter_name, | 461 getter_name=getter_name, |
454 member_name=member_name)) | 462 member_name=member_name)) |
455 member_list.append(" %s* %s;" % (class_name, member_name)) | 463 member_list.append(" RawPtrWillBeMember<%s> %s;" % (class_name, membe
r_name)) |
456 init_list.append("%s(0)" % member_name) | 464 init_list.append("%s(nullptr)" % member_name) |
457 reset_list.append("%s = 0;" % member_name) | 465 trace_list.append("visitor->trace(%s);" % member_name) |
| 466 reset_list.append("%s = nullptr;" % member_name) |
458 | 467 |
459 forward_list.sort() | 468 forward_list.sort() |
460 accessor_list.sort() | 469 accessor_list.sort() |
461 member_list.sort() | 470 member_list.sort() |
462 init_list.sort() | 471 init_list.sort() |
| 472 trace_list.sort() |
463 reset_list.sort() | 473 reset_list.sort() |
464 | 474 |
465 header_lines = template_instrumenting_agents_h.substitute( | 475 header_lines = template_instrumenting_agents_h.substitute( |
466 None, | 476 None, |
467 forward_list="\n".join(forward_list), | 477 forward_list="\n".join(forward_list), |
468 accessor_list="\n".join(accessor_list), | 478 accessor_list="\n".join(accessor_list), |
469 member_list="\n".join(member_list)) | 479 member_list="\n".join(member_list)) |
470 | 480 |
471 cpp_lines = template_instrumenting_agents_cpp.substitute( | 481 cpp_lines = template_instrumenting_agents_cpp.substitute( |
472 None, | 482 None, |
473 init_list="\n , ".join(init_list), | 483 init_list="\n , ".join(init_list), |
| 484 trace_list="\n ".join(trace_list), |
474 reset_list="\n ".join(reset_list)) | 485 reset_list="\n ".join(reset_list)) |
475 | 486 |
476 return header_lines, cpp_lines | 487 return header_lines, cpp_lines |
477 | 488 |
478 | 489 |
479 def generate(input_path, output_dir): | 490 def generate(input_path, output_dir): |
480 fin = open(input_path, "r") | 491 fin = open(input_path, "r") |
481 files = load_model_from_idl(fin.read()) | 492 files = load_model_from_idl(fin.read()) |
482 fin.close() | 493 fin.close() |
483 | 494 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 if not output_dirpath: | 533 if not output_dirpath: |
523 raise Exception("Output directory must be specified") | 534 raise Exception("Output directory must be specified") |
524 except Exception: | 535 except Exception: |
525 # Work with python 2 and 3 http://docs.python.org/py3k/howto/pyporting.html | 536 # Work with python 2 and 3 http://docs.python.org/py3k/howto/pyporting.html |
526 exc = sys.exc_info()[1] | 537 exc = sys.exc_info()[1] |
527 sys.stderr.write("Failed to parse command-line arguments: %s\n\n" % exc) | 538 sys.stderr.write("Failed to parse command-line arguments: %s\n\n" % exc) |
528 sys.stderr.write("Usage: <script> --output_dir <output_dir> InspectorInstrum
entation.idl\n") | 539 sys.stderr.write("Usage: <script> --output_dir <output_dir> InspectorInstrum
entation.idl\n") |
529 exit(1) | 540 exit(1) |
530 | 541 |
531 generate(input_path, output_dirpath) | 542 generate(input_path, output_dirpath) |
OLD | NEW |