[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH 03 of 27 v2] libxl: idl: use "dispose" rather than "destroy" for function to free IDL types



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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.