提交 3596f524 编写于 作者: L Lluís Vilanova 提交者: Stefan Hajnoczi

trace: Extend API to manage event arguments

Lets the user manage event arguments as a list, and simplifies argument
concatenation.
Signed-off-by: NLluís Vilanova <vilanova@ac.upc.edu>
Reviewed-by: NEric Blake <eblake@redhat.com>
Message-id: 145641858432.30295.3069911069472672646.stgit@localhost
Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
上级 62cb4145
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册