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

Side by Side Diff: third_party/WebKit/Source/build/scripts/make_instrumenting_probes.py

Issue 2797253005: Revert of [instrumentation] Turn inspector override "probes" return values into output parameters. (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/build/scripts/templates/InstrumentingProbesImpl.cpp.tmpl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2017 The Chromium Authors. All rights reserved. 1 # Copyright 2017 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import ast 5 import ast
6 import optparse 6 import optparse
7 import os.path 7 import os.path
8 import re 8 import re
9 import sys 9 import sys
10 10
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 self.forward_declarations.sort() 117 self.forward_declarations.sort()
118 118
119 119
120 class Method(object): 120 class Method(object):
121 def __init__(self, source): 121 def __init__(self, source):
122 match = re.match(r"(?:(\w+\*?)\s+)?(\w+)\s*\((.*)\)\s*;", source) 122 match = re.match(r"(?:(\w+\*?)\s+)?(\w+)\s*\((.*)\)\s*;", source)
123 if not match: 123 if not match:
124 sys.stderr.write("Cannot parse %s\n" % source) 124 sys.stderr.write("Cannot parse %s\n" % source)
125 sys.exit(1) 125 sys.exit(1)
126 126
127 self.return_type = match.group(1) or ""
127 self.name = match.group(2) 128 self.name = match.group(2)
128 self.is_scoped = not match.group(1) 129 self.is_scoped = self.return_type == ""
129 if not self.is_scoped and match.group(1) != "void":
130 raise Exception("Instant probe must return void: %s" % self.name)
131 130
132 # Splitting parameters by a comma, assuming that attribute lists contain no more than one attribute. 131 # Splitting parameters by a comma, assuming that attribute lists contain no more than one attribute.
133 self.params = map(Parameter, map(str.strip, match.group(3).split(","))) 132 self.params = map(Parameter, map(str.strip, match.group(3).split(",")))
134 133
134 self.returns_value = self.return_type != "" and self.return_type != "voi d"
135 if self.return_type == "bool":
136 self.default_return_value = "false"
137 elif self.returns_value:
138 sys.stderr.write("Can only return bool: %s\n" % self.name)
139 sys.exit(1)
140
135 141
136 class Parameter(object): 142 class Parameter(object):
137 def __init__(self, source): 143 def __init__(self, source):
138 self.options = [] 144 self.options = []
139 match, source = match_and_consume(r"\[(\w*)\]", source) 145 match, source = match_and_consume(r"\[(\w*)\]", source)
140 if match: 146 if match:
141 self.options.append(match.group(1)) 147 self.options.append(match.group(1))
142 148
143 parts = map(str.strip, source.split("=")) 149 parts = map(str.strip, source.split("="))
144 self.default_value = parts[1] if len(parts) != 1 else None 150 self.default_value = parts[1] if len(parts) != 1 else None
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 unused_probes.discard(probe) 206 unused_probes.discard(probe)
201 if probe not in all_pidl_probes: 207 if probe not in all_pidl_probes:
202 raise Exception('Probe %s is not declared in PIDL file' % probe) 208 raise Exception('Probe %s is not declared in PIDL file' % probe)
203 observers_by_probe.setdefault(probe, set()).add(observer_name) 209 observers_by_probe.setdefault(probe, set()).add(observer_name)
204 if unused_probes: 210 if unused_probes:
205 raise Exception("Unused probes: %s" % unused_probes) 211 raise Exception("Unused probes: %s" % unused_probes)
206 212
207 for f in files: 213 for f in files:
208 for probe in f.declarations: 214 for probe in f.declarations:
209 probe.agents = observers_by_probe[probe.name] 215 probe.agents = observers_by_probe[probe.name]
216 if probe.returns_value and len(probe.agents) > 1:
217 raise Exception("Can only return value from a single observer: % s\n" % probe.name)
210 return all_observers 218 return all_observers
211 219
212 220
213 cmdline_parser = optparse.OptionParser() 221 cmdline_parser = optparse.OptionParser()
214 cmdline_parser.add_option("--output_dir") 222 cmdline_parser.add_option("--output_dir")
215 cmdline_parser.add_option("--config") 223 cmdline_parser.add_option("--config")
216 224
217 try: 225 try:
218 arg_options, arg_values = cmdline_parser.parse_args() 226 arg_options, arg_values = cmdline_parser.parse_args()
219 if len(arg_values) != 1: 227 if len(arg_values) != 1:
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 sink_h_file = open(output_dirpath + "/" + to_singular(base_name) + "Sink.h", "w" ) 265 sink_h_file = open(output_dirpath + "/" + to_singular(base_name) + "Sink.h", "w" )
258 sink_h_file.write(sink_h_template.render(template_context)) 266 sink_h_file.write(sink_h_template.render(template_context))
259 sink_h_file.close() 267 sink_h_file.close()
260 268
261 for f in files: 269 for f in files:
262 template_context["file"] = f 270 template_context["file"] = f
263 h_template = jinja_env.get_template("/InstrumentingProbesInl.h.tmpl") 271 h_template = jinja_env.get_template("/InstrumentingProbesInl.h.tmpl")
264 h_file = open(output_dirpath + "/" + f.header_name + ".h", "w") 272 h_file = open(output_dirpath + "/" + f.header_name + ".h", "w")
265 h_file.write(h_template.render(template_context)) 273 h_file.write(h_template.render(template_context))
266 h_file.close() 274 h_file.close()
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/build/scripts/templates/InstrumentingProbesImpl.cpp.tmpl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698