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:
parent
62cb4145bb
commit
3596f524d4
@ -50,9 +50,14 @@ class Arguments:
|
||||
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 @@ class Arguments:
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user