From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37230) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYz0N-0007Wy-90 for qemu-devel@nongnu.org; Thu, 25 Feb 2016 11:43:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aYz0M-0001cn-FZ for qemu-devel@nongnu.org; Thu, 25 Feb 2016 11:43:07 -0500 Received: from roura.ac.upc.edu ([147.83.33.10]:54035 helo=roura.ac.upc.es) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYz0M-0001cT-3m for qemu-devel@nongnu.org; Thu, 25 Feb 2016 11:43:06 -0500 From: =?utf-8?b?TGx1w61z?= Vilanova Date: Thu, 25 Feb 2016 17:43:04 +0100 Message-Id: <145641858432.30295.3069911069472672646.stgit@localhost> In-Reply-To: <145641857632.30295.407142116443473458.stgit@localhost> References: <145641857632.30295.407142116443473458.stgit@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH v9 1/7] trace: Extend API to manage event arguments List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Eduardo Habkost , Stefan Hajnoczi Lets the user manage event arguments as a list, and simplifies argument concatenation. Signed-off-by: Llu=C3=ADs Vilanova Reviewed-by: Eric Blake --- scripts/tracetool/__init__.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.p= y index 181675f..0663e7f 100644 --- a/scripts/tracetool/__init__.py +++ b/scripts/tracetool/__init__.py @@ -50,9 +50,14 @@ class Arguments: Parameters ---------- args : - List of (type, name) tuples. + List of (type, name) tuples or Arguments objects. """ - self._args =3D args + self._args =3D [] + for arg in args: + if isinstance(arg, Arguments): + self._args.extend(arg._args) + else: + self._args.append(arg) =20 def copy(self): """Create a new copy.""" @@ -83,6 +88,12 @@ class Arguments: res.append((arg_type, identifier)) return Arguments(res) =20 + 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)