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

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

Issue 397843009: Revert of DevTools: Support async call stacks for FileSystem API (part 1). (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 23 matching lines...) Expand all
34 34
35 template_h = string.Template("""// Code generated from InspectorInstrumentation. idl 35 template_h = string.Template("""// Code generated from InspectorInstrumentation. idl
36 36
37 #ifndef ${file_name}_h 37 #ifndef ${file_name}_h
38 #define ${file_name}_h 38 #define ${file_name}_h
39 39
40 ${includes} 40 ${includes}
41 41
42 namespace WebCore { 42 namespace WebCore {
43 43
44 ${forward_declarations}
45
46 namespace InspectorInstrumentation { 44 namespace InspectorInstrumentation {
47 45
48 $methods 46 $methods
49 } // namespace InspectorInstrumentation 47 } // namespace InspectorInstrumentation
50 48
51 } // namespace WebCore 49 } // namespace WebCore
52 50
53 #endif // !defined(${file_name}_h) 51 #endif // !defined(${file_name}_h)
54 """) 52 """)
55 53
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 model.append(File(match.group(1), match.group(2))) 188 model.append(File(match.group(1), match.group(2)))
191 189
192 return model 190 return model
193 191
194 192
195 class File: 193 class File:
196 def __init__(self, name, source): 194 def __init__(self, name, source):
197 self.name = name 195 self.name = name
198 self.header_name = self.name + "Inl" 196 self.header_name = self.name + "Inl"
199 self.includes = [include_inspector_header("InspectorInstrumentation")] 197 self.includes = [include_inspector_header("InspectorInstrumentation")]
200 self.forward_declarations = []
201 self.declarations = [] 198 self.declarations = []
202 for line in map(str.strip, source.split("\n")): 199 for line in map(str.strip, source.split("\n")):
203 line = re.sub("\s{2,}", " ", line).strip() # Collapse whitespace 200 line = re.sub("\s{2,}", " ", line).strip() # Collapse whitespace
204 if len(line) == 0: 201 if len(line) == 0:
205 continue 202 continue
206 if line[0] == "#": 203 if line[0] == "#":
207 self.includes.append(line) 204 self.includes.append(line)
208 elif line.startswith("class "):
209 self.forward_declarations.append(line)
210 else: 205 else:
211 self.declarations.append(Method(line)) 206 self.declarations.append(Method(line))
212 self.includes.sort() 207 self.includes.sort()
213 self.forward_declarations.sort()
214 208
215 def generate(self, cpp_lines, used_agents): 209 def generate(self, cpp_lines, used_agents):
216 header_lines = [] 210 header_lines = []
217 for declaration in self.declarations: 211 for declaration in self.declarations:
218 for agent in set(declaration.agents): 212 for agent in set(declaration.agents):
219 used_agents.add(agent) 213 used_agents.add(agent)
220 declaration.generate_header(header_lines) 214 declaration.generate_header(header_lines)
221 declaration.generate_cpp(cpp_lines) 215 declaration.generate_cpp(cpp_lines)
222 216
223 return template_h.substitute(None, 217 return template_h.substitute(None,
224 file_name=self.header_name, 218 file_name=self.header_name,
225 includes="\n".join(self.includes), 219 includes="\n".join(self.includes),
226 forward_declarations="\n".join(self.forward _declarations),
227 methods="\n".join(header_lines)) 220 methods="\n".join(header_lines))
228 221
229 222
230 class Method: 223 class Method:
231 def __init__(self, source): 224 def __init__(self, source):
232 match = re.match("(\[[\w|,|=|\s]*\])?\s?(\w*\*?) (\w*)\((.*)\)\s?;", sou rce) 225 match = re.match("(\[[\w|,|=|\s]*\])?\s?(\w*\*?) (\w*)\((.*)\)\s?;", sou rce)
233 if not match: 226 if not match:
234 sys.stderr.write("Cannot parse %s\n" % source) 227 sys.stderr.write("Cannot parse %s\n" % source)
235 sys.exit(1) 228 sys.exit(1)
236 229
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 if not output_dirpath: 522 if not output_dirpath:
530 raise Exception("Output directory must be specified") 523 raise Exception("Output directory must be specified")
531 except Exception: 524 except Exception:
532 # Work with python 2 and 3 http://docs.python.org/py3k/howto/pyporting.html 525 # Work with python 2 and 3 http://docs.python.org/py3k/howto/pyporting.html
533 exc = sys.exc_info()[1] 526 exc = sys.exc_info()[1]
534 sys.stderr.write("Failed to parse command-line arguments: %s\n\n" % exc) 527 sys.stderr.write("Failed to parse command-line arguments: %s\n\n" % exc)
535 sys.stderr.write("Usage: <script> --output_dir <output_dir> InspectorInstrum entation.idl\n") 528 sys.stderr.write("Usage: <script> --output_dir <output_dir> InspectorInstrum entation.idl\n")
536 exit(1) 529 exit(1)
537 530
538 generate(input_path, output_dirpath) 531 generate(input_path, output_dirpath)
OLDNEW
« no previous file with comments | « Source/core/inspector/AsyncCallStackTracker.cpp ('k') | Source/core/inspector/InspectorDebuggerAgent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698