Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: Source/core/inspector/CodeGeneratorInstrumentation.py

Issue 307943002: Oilpan: Prepare moving InspectorController and InspectorAgents to oilpan. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 return include_header("core/inspector/" + name) 442 return include_header("core/inspector/" + name)
436 443
437 444
438 def generate_instrumenting_agents(used_agents): 445 def generate_instrumenting_agents(used_agents):
439 agents = list(used_agents) 446 agents = list(used_agents)
440 447
441 forward_list = [] 448 forward_list = []
442 accessor_list = [] 449 accessor_list = []
443 member_list = [] 450 member_list = []
444 init_list = [] 451 init_list = []
452 trace_list = []
445 reset_list = [] 453 reset_list = []
446 454
447 for agent in agents: 455 for agent in agents:
448 class_name, getter_name = agent_getter_signature(agent) 456 class_name, getter_name = agent_getter_signature(agent)
449 member_name = "m_" + getter_name 457 member_name = "m_" + getter_name
450 458
451 forward_list.append("class %s;" % class_name) 459 forward_list.append("class %s;" % class_name)
452 accessor_list.append(template_instrumenting_agent_accessor.substitute( 460 accessor_list.append(template_instrumenting_agent_accessor.substitute(
453 None, 461 None,
454 class_name=class_name, 462 class_name=class_name,
455 getter_name=getter_name, 463 getter_name=getter_name,
456 member_name=member_name)) 464 member_name=member_name))
457 member_list.append(" %s* %s;" % (class_name, member_name)) 465 member_list.append(" RawPtrWillBeMember<%s> %s;" % (class_name, membe r_name))
458 init_list.append("%s(0)" % member_name) 466 init_list.append("%s(nullptr)" % member_name)
459 reset_list.append("%s = 0;" % member_name) 467 trace_list.append("visitor->trace(%s);" % member_name)
468 reset_list.append("%s = nullptr;" % member_name)
460 469
461 forward_list.sort() 470 forward_list.sort()
462 accessor_list.sort() 471 accessor_list.sort()
463 member_list.sort() 472 member_list.sort()
464 init_list.sort() 473 init_list.sort()
474 trace_list.sort()
465 reset_list.sort() 475 reset_list.sort()
466 476
467 header_lines = template_instrumenting_agents_h.substitute( 477 header_lines = template_instrumenting_agents_h.substitute(
468 None, 478 None,
469 forward_list="\n".join(forward_list), 479 forward_list="\n".join(forward_list),
470 accessor_list="\n".join(accessor_list), 480 accessor_list="\n".join(accessor_list),
471 member_list="\n".join(member_list)) 481 member_list="\n".join(member_list))
472 482
473 cpp_lines = template_instrumenting_agents_cpp.substitute( 483 cpp_lines = template_instrumenting_agents_cpp.substitute(
474 None, 484 None,
475 init_list="\n , ".join(init_list), 485 init_list="\n , ".join(init_list),
486 trace_list="\n ".join(trace_list),
476 reset_list="\n ".join(reset_list)) 487 reset_list="\n ".join(reset_list))
477 488
478 return header_lines, cpp_lines 489 return header_lines, cpp_lines
479 490
480 491
481 def generate(input_path, output_dir): 492 def generate(input_path, output_dir):
482 fin = open(input_path, "r") 493 fin = open(input_path, "r")
483 files = load_model_from_idl(fin.read()) 494 files = load_model_from_idl(fin.read())
484 fin.close() 495 fin.close()
485 496
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 if not output_dirpath: 535 if not output_dirpath:
525 raise Exception("Output directory must be specified") 536 raise Exception("Output directory must be specified")
526 except Exception: 537 except Exception:
527 # Work with python 2 and 3 http://docs.python.org/py3k/howto/pyporting.html 538 # Work with python 2 and 3 http://docs.python.org/py3k/howto/pyporting.html
528 exc = sys.exc_info()[1] 539 exc = sys.exc_info()[1]
529 sys.stderr.write("Failed to parse command-line arguments: %s\n\n" % exc) 540 sys.stderr.write("Failed to parse command-line arguments: %s\n\n" % exc)
530 sys.stderr.write("Usage: <script> --output_dir <output_dir> InspectorInstrum entation.idl\n") 541 sys.stderr.write("Usage: <script> --output_dir <output_dir> InspectorInstrum entation.idl\n")
531 exit(1) 542 exit(1)
532 543
533 generate(input_path, output_dirpath) 544 generate(input_path, output_dirpath)
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/custom/V8InjectedScriptManager.cpp ('k') | Source/core/inspector/InjectedScriptHost.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698