trace: Extend API to manage event arguments

Lets the user manage event arguments as a list, and simplifies argument
concatenation.

Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 145641858432.30295.3069911069472672646.stgit@localhost
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
Lluís Vilanova 2016-02-25 17:43:04 +01:00 committed by Stefan Hajnoczi
parent 62cb4145bb
commit 3596f524d4
1 changed files with 13 additions and 2 deletions

View File

@ -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."""
@ -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)