Skip to content

Commit

Permalink
trace: Extend API to manage event arguments
Browse files Browse the repository at this point in the history
Lets the user manage event arguments as a list, and simplifies argument
concatenation.

Signed-off-by: Lluís Vilanova <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Message-id: 145641858432.30295.3069911069472672646.stgit@localhost
Signed-off-by: Stefan Hajnoczi <[email protected]>
  • Loading branch information
Lluís Vilanova authored and stefanhaRH committed Mar 1, 2016
1 parent 62cb414 commit 3596f52
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions scripts/tracetool/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,14 @@ def __init__(self, args):
Parameters
----------
args :
List of (type, name) tuples.
List of (type, name) tuples or Arguments objects.
"""
self._args = args
self._args = []
for arg in args:
if isinstance(arg, Arguments):
self._args.extend(arg._args)
else:
self._args.append(arg)

def copy(self):
"""Create a new copy."""
Expand Down Expand Up @@ -83,6 +88,12 @@ def build(arg_str):
res.append((arg_type, identifier))
return Arguments(res)

def __getitem__(self, index):
if isinstance(index, slice):
return Arguments(self._args[index])
else:
return self._args[index]

def __iter__(self):
"""Iterate over the (type, name) pairs."""
return iter(self._args)
Expand Down

0 comments on commit 3596f52

Please sign in to comment.