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

Re: [Xen-devel] [PATCH 03 of 27 v2] libxl: idl: use "dispose" rather tha

To: Ian Campbell <ian.campbell@xxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH 03 of 27 v2] libxl: idl: use "dispose" rather than "destroy" for function to free IDL types
From: Roger Pau Monné <roger.pau@xxxxxxxxxxxxx>
Date: Thu, 13 Oct 2011 13:26:56 +0200
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Thu, 13 Oct 2011 04:28:47 -0700
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=f/zCWIjmcOWBmdCLaP6GDxxOPWZP4jtl1qQgJOs5KNA=; b=HbTOou8YeyQEDx4LhS9E44hb6oB0aPuEFCf+wRqBRUp9K6/EUm6ILTFVX5F4iJu3tk UbZ4Z1MJ4yYqsjvO5SqbxWoBdTNqV1NcdQnO1gBhlkxmjTyGM2OABm4gcUuFxnQXmork kNaQrbzQ7hKSFwQe5RZj+A7ua+5mY1iX87ysI=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <6bc67c8ad63e80f40003.1318499608@xxxxxxxxxxxxxxxxxxxxx>
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.1318499605@xxxxxxxxxxxxxxxxxxxxx> <6bc67c8ad63e80f40003.1318499608@xxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Hello,

This patch doesn't apply clearly on current xen-unstable, gentest.py
complains about:

--- gentest.py
+++ gentest.py
@@ -256,8 +256,8 @@ int main(int argc, char **argv)
         f.write("    printf(\"%%s: %%s\\n\", \"%s\", s);\n" % ty.typename)
         f.write("    if (s == NULL) abort();\n")
         f.write("    free(s);\n")
-        if ty.destructor_fn is not None:
-            f.write("    %s(&%s_val);\n" % (ty.destructor_fn, ty.typename))
+        if ty.dispose_fn is not None:
+            f.write("    %s(&%s_val);\n" % (ty.dispose_fn, ty.typename))
         f.write("\n")

     f.write("    printf(\"Testing Enumerations\\n\");\n")

And I had to apply the following to gentypes.py and libxltypes.py,
since some hunks failed:

diff -r eedf352110c5 tools/libxl/gentypes.py
--- a/tools/libxl/gentypes.py   Thu Oct 13 10:47:18 2011 +0100
+++ b/tools/libxl/gentypes.py   Thu Oct 13 13:19:39 2011 +0200
@@ -75,7 +75,7 @@ def libxl_C_type_define(ty, indent = "")
         raise NotImplementedError("%s" % type(ty))
     return s.replace("\n", "\n%s" % indent)

-def libxl_C_type_destroy(ty, v, indent = "    ", parent = None):
+def libxl_C_type_dispose(ty, v, indent = "    ", parent = None):

     s = ""
     if isinstance(ty, libxltypes.KeyedUnion):
@@ -165,8 +165,8 @@ if __name__ == '__main__':

     for ty in types:
         f.write(libxl_C_type_define(ty) + ";\n")
-        if ty.destructor_fn is not None:
-            f.write("void %s(%s);\n" % (ty.destructor_fn, ty.make_arg("p")))
+        if ty.dispose_fn is not None:
+            f.write("void %s(%s);\n" % (ty.dispose_fn, ty.make_arg("p")))
         if isinstance(ty, libxltypes.Enumeration):
             f.write("const char *%s_to_string(%s);\n" % (ty.typename,
ty.make_arg("p")))
             f.write("int %s_from_string(const char *s, %s);\n" %
(ty.typename, ty.make_arg("e", passby=libxltypes.PASS_BY_REFERENCE)))
[51310 refs]
loki# hg qdiff
diff -r eedf352110c5 tools/libxl/gentypes.py
--- a/tools/libxl/gentypes.py   Thu Oct 13 10:47:18 2011 +0100
+++ b/tools/libxl/gentypes.py   Thu Oct 13 13:25:30 2011 +0200
@@ -75,7 +75,7 @@ def libxl_C_type_define(ty, indent = "")
         raise NotImplementedError("%s" % type(ty))
     return s.replace("\n", "\n%s" % indent)

-def libxl_C_type_destroy(ty, v, indent = "    ", parent = None):
+def libxl_C_type_dispose(ty, v, indent = "    ", parent = None):

     s = ""
     if isinstance(ty, libxltypes.KeyedUnion):
@@ -165,8 +165,8 @@ if __name__ == '__main__':

     for ty in types:
         f.write(libxl_C_type_define(ty) + ";\n")
-        if ty.destructor_fn is not None:
-            f.write("void %s(%s);\n" % (ty.destructor_fn, ty.make_arg("p")))
+        if ty.dispose_fn is not None:
+            f.write("void %s(%s);\n" % (ty.dispose_fn, ty.make_arg("p")))
         if isinstance(ty, libxltypes.Enumeration):
             f.write("const char *%s_to_string(%s);\n" % (ty.typename,
ty.make_arg("p")))
             f.write("int %s_from_string(const char *s, %s);\n" %
(ty.typename, ty.make_arg("e", passby=libxltypes.PASS_BY_REFERENCE)))
diff -r eedf352110c5 tools/libxl/libxltypes.py
--- a/tools/libxl/libxltypes.py Thu Oct 13 10:47:18 2011 +0100
+++ b/tools/libxl/libxltypes.py Thu Oct 13 13:25:30 2011 +0200
@@ -81,14 +81,14 @@ class Type(object):
 class Builtin(Type):
     """Builtin type"""
     def __init__(self, typename, **kwargs):
-        kwargs.setdefault('destructor_fn', None)
-        kwargs.setdefault('autogenerate_destructor', False)
+        kwargs.setdefault('dispose_fn', None)
+        kwargs.setdefault('autogenerate_dispose_fn', False)
         Type.__init__(self, typename, **kwargs)

 class Number(Builtin):
     def __init__(self, ctype, **kwargs):
         kwargs.setdefault('namespace', None)
-        kwargs.setdefault('destructor_fn', None)
+        kwargs.setdefault('dispose_fn', None)
         kwargs.setdefault('signed', False)
         self.signed = kwargs['signed']
         Builtin.__init__(self, ctype, **kwargs)
@@ -230,7 +230,9 @@ uint16 = UInt(16)
 uint32 = UInt(32)
 uint64 = UInt(64)

-string = Builtin("char *", namespace = None, destructor_fn = "free")
+string = Builtin("char *", namespace = None, dispose_fn = "free",
+                  json_fn = "libxl__string_gen_json",
+                  autogenerate_json = False)

 class OrderedDict(dict):
     """A dictionary which remembers insertion order.

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

<Prev in Thread] Current Thread [Next in Thread>