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

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

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

Powered by Google App Engine
This is Rietveld 408576698