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: Roger Pau Monné <roger.pau@xxxxxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH 03 of 27 v2] libxl: idl: use "dispose" rather than "destroy" for function to free IDL types
From: Ian Campbell <Ian.Campbell@xxxxxxxxxx>
Date: Thu, 13 Oct 2011 12:39:41 +0100
Cc: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Thu, 13 Oct 2011 04:41:17 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <CAPLaKK7-2LxN6kgE14WEVXN+6QvZZVN_qYybemZ7+CdTWPXJMw@xxxxxxxxxxxxxx>
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>
Organization: Citrix Systems, Inc.
References: <patchbomb.1318499605@xxxxxxxxxxxxxxxxxxxxx> <6bc67c8ad63e80f40003.1318499608@xxxxxxxxxxxxxxxxxxxxx> <CAPLaKK7-2LxN6kgE14WEVXN+6QvZZVN_qYybemZ7+CdTWPXJMw@xxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
On Thu, 2011-10-13 at 12:26 +0100, Roger Pau Monné wrote:
> Hello,
> 
> This patch doesn't apply clearly on current xen-unstable, gentest.py
> complains about:

Sorry, I forgot to mention that this depends (textually, not
functionally) on the "libxl: support json for pretty printing
objects" (v2) series which I posted on Friday.

Ian.
> 
> --- 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>