WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 4 of 9] libxl: IDL: refactor code to massage a type i

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 4 of 9] libxl: IDL: refactor code to massage a type into a function argument
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Thu, 14 Jul 2011 17:02:24 +0100
Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
Delivery-date: Thu, 14 Jul 2011 09:11:09 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1310659340@xxxxxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <patchbomb.1310659340@xxxxxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mercurial-patchbomb/1.6.4
# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1310646156 -3600
# Node ID 2c49e182becc028a95d67363dd06654c7f717eec
# Parent  3b2827da23585a7fa93d1e6fc4db4d196706ebf8
libxl: IDL: refactor code to massage a type into a function argument

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

diff -r 3b2827da2358 -r 2c49e182becc tools/libxl/gentypes.py
--- a/tools/libxl/gentypes.py   Thu Jul 14 13:22:36 2011 +0100
+++ b/tools/libxl/gentypes.py   Thu Jul 14 13:22:36 2011 +0100
@@ -84,11 +84,6 @@ def libxl_C_type_destroy(ty, v, indent =
     else:
         deref = v + "."
         
-    if ty.passby == libxltypes.PASS_BY_REFERENCE and parent is not None:
-        makeref = "&"
-    else:
-        makeref = ""
-
     s = ""
     if isinstance(ty, libxltypes.KeyedUnion):
         if parent is None:
@@ -107,7 +102,7 @@ def libxl_C_type_destroy(ty, v, indent =
                 s += libxl_C_type_destroy(f.type, deref + f.name, "", deref)
     else:
         if ty.destructor_fn is not None:
-            s += "%s(%s);\n" % (ty.destructor_fn, makeref + v)
+            s += "%s(%s);\n" % (ty.destructor_fn, ty.pass_arg(v, parent is 
None))
             
     if s != "":
         s = indent + s
diff -r 3b2827da2358 -r 2c49e182becc tools/libxl/libxltypes.py
--- a/tools/libxl/libxltypes.py Thu Jul 14 13:22:36 2011 +0100
+++ b/tools/libxl/libxltypes.py Thu Jul 14 13:22:36 2011 +0100
@@ -50,6 +50,21 @@ class Type(object):
         else:
             return "%s %s" % (self.typename, n)
         
+    def pass_arg(self, n, isref=None, passby=None):
+        if passby is None: passby = self.passby
+        if isref is None: isref = self.passby == PASS_BY_REFERENCE
+
+        if passby == PASS_BY_REFERENCE:
+            if isref:
+                return "%s" % (n)
+            else:
+                return "&%s" % (n)
+        else:
+            if isref:
+                return "*%s" % (n)
+            else:
+                return "%s" % (n)
+
 class Builtin(Type):
     """Builtin type"""
     def __init__(self, typename, **kwargs):

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel