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-changelog

[Xen-changelog] [xen-unstable] libxl: IDL: refactor code to massage a ty

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] libxl: IDL: refactor code to massage a type into a function argument
From: Xen patchbot-unstable <patchbot@xxxxxxx>
Date: Fri, 15 Jul 2011 06:11:14 +0100
Delivery-date: Thu, 14 Jul 2011 22:13:23 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1310646156 -3600
# Node ID 1e703a6ad764d820dc2d5a70d36b567237ee9aaf
# Parent  4bb89ae75a3a2288b4996908fc11b71d36a169d3
libxl: IDL: refactor code to massage a type into a function argument

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
---


diff -r 4bb89ae75a3a -r 1e703a6ad764 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 @@
     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 @@
                 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 4bb89ae75a3a -r 1e703a6ad764 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 @@
         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-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] libxl: IDL: refactor code to massage a type into a function argument, Xen patchbot-unstable <=