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

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

Issue 540533002: Roll IDL to Dartium37 (r181268) (Closed) Base URL: https://dart.googlecode.com/svn/third_party/WebCore
Patch Set: Created 6 years, 3 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
« no previous file with comments | « core/inspector/CodeGeneratorInspectorStrings.py ('k') | core/inspector/InjectedScriptHost.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 maybe_return = "" 346 maybe_return = ""
347 else: 347 else:
348 maybe_return = "return " 348 maybe_return = "return "
349 349
350 return template.substitute( 350 return template.substitute(
351 None, 351 None,
352 name=self.name, 352 name=self.name,
353 agent_class=agent_class, 353 agent_class=agent_class,
354 agent_fetch=agent_fetch, 354 agent_fetch=agent_fetch,
355 maybe_return=maybe_return, 355 maybe_return=maybe_return,
356 params_agent=", ".join(map(Parameter.to_str_name, self.params_impl)[ 1:])) 356 params_agent=", ".join(map(Parameter.to_str_value, self.params_impl) [1:]))
357 357
358 358
359 class Parameter: 359 class Parameter:
360 def __init__(self, source): 360 def __init__(self, source):
361 self.options = [] 361 self.options = []
362 match, source = match_and_consume("\[(\w*)\]", source) 362 match, source = match_and_consume("\[(\w*)\]", source)
363 if match: 363 if match:
364 self.options.append(match.group(1)) 364 self.options.append(match.group(1))
365 365
366 parts = map(str.strip, source.split("=")) 366 parts = map(str.strip, source.split("="))
(...skipping 10 matching lines...) Expand all
377 min_type_tokens = 1 377 min_type_tokens = 1
378 378
379 if len(param_decl.split(" ")) > min_type_tokens: 379 if len(param_decl.split(" ")) > min_type_tokens:
380 parts = param_decl.split(" ") 380 parts = param_decl.split(" ")
381 self.type = " ".join(parts[:-1]) 381 self.type = " ".join(parts[:-1])
382 self.name = parts[-1] 382 self.name = parts[-1]
383 else: 383 else:
384 self.type = param_decl 384 self.type = param_decl
385 self.name = generate_param_name(self.type) 385 self.name = generate_param_name(self.type)
386 386
387 if re.match("PassRefPtr<", param_decl):
388 self.value = "%s.get()" % self.name
389 else:
390 self.value = self.name
391
392
387 def to_str_full(self): 393 def to_str_full(self):
388 if self.default_value is None: 394 if self.default_value is None:
389 return self.to_str_class_and_name() 395 return self.to_str_class_and_name()
390 return "%s %s = %s" % (self.type, self.name, self.default_value) 396 return "%s %s = %s" % (self.type, self.name, self.default_value)
391 397
392 def to_str_class_and_name(self): 398 def to_str_class_and_name(self):
393 return "%s %s" % (self.type, self.name) 399 return "%s %s" % (self.type, self.name)
394 400
395 def to_str_class(self): 401 def to_str_class(self):
396 return self.type 402 return self.type
397 403
398 def to_str_name(self): 404 def to_str_name(self):
399 return self.name 405 return self.name
400 406
407 def to_str_value(self):
408 return self.value
409
401 410
402 def generate_param_name(param_type): 411 def generate_param_name(param_type):
403 base_name = re.match("(const |PassRefPtr<)?(\w*)", param_type).group(2) 412 base_name = re.match("(const |PassRefPtr<)?(\w*)", param_type).group(2)
404 return "param" + base_name 413 return "param" + base_name
405 414
406 415
407 def agent_class_name(agent): 416 def agent_class_name(agent):
408 custom_agent_names = ["PageDebugger", "PageRuntime", "WorkerRuntime"] 417 custom_agent_names = ["PageDebugger", "PageRuntime", "WorkerRuntime"]
409 if agent in custom_agent_names: 418 if agent in custom_agent_names:
410 return "%sAgent" % agent 419 return "%sAgent" % agent
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 if not output_dirpath: 522 if not output_dirpath:
514 raise Exception("Output directory must be specified") 523 raise Exception("Output directory must be specified")
515 except Exception: 524 except Exception:
516 # 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
517 exc = sys.exc_info()[1] 526 exc = sys.exc_info()[1]
518 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)
519 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")
520 exit(1) 529 exit(1)
521 530
522 generate(input_path, output_dirpath) 531 generate(input_path, output_dirpath)
OLDNEW
« no previous file with comments | « core/inspector/CodeGeneratorInspectorStrings.py ('k') | core/inspector/InjectedScriptHost.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698