From: Ian Campbell Subject: Re: [PATCH 04/13] libxl: idl: support new "c_only" type attribute Date: Tue, 29 Nov 2011 10:27:28 +0000 Message-ID: <1322562449.20646.31.camel@zakaz.uk.xensource.com> References: <1322499580-2322-1-git-send-email-ian.jackson@eu.citrix.com> <1322499580-2322-5-git-send-email-ian.jackson@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1322499580-2322-5-git-send-email-ian.jackson@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Ian Jackson Cc: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org On Mon, 2011-11-28 at 16:59 +0000, Ian Jackson wrote: > This provides for fields in libxl datatypes which are only present in > the C version of structures. This is useful, for example, when a > libxl datatype wants to contain fields which are used by libxl > internally and which are only present in the structure to avoid > additional memory allocation inconvenience. I think "internal" or "private" would be a better description than "c". > Signed-off-by: Ian Jackson > --- > tools/libxl/gentest.py | 2 ++ > tools/libxl/libxltypes.py | 4 +++- > 2 files changed, 5 insertions(+), 1 deletions(-) > > diff --git a/tools/libxl/gentest.py b/tools/libxl/gentest.py > index 05e77cc..9b2812e 100644 > --- a/tools/libxl/gentest.py > +++ b/tools/libxl/gentest.py > @@ -56,6 +56,8 @@ def gen_rand_init(ty, v, indent = " ", parent = None): > s += "%s = rand() %% 2;\n" % v > elif ty.typename in ["char *"]: > s += "%s = rand_str();\n" % v > + elif ty.c_only: > + pass > elif ty.typename in handcoded: > raise Exception("Gen for handcoded %s" % ty.typename) > else: > diff --git a/tools/libxl/libxltypes.py b/tools/libxl/libxltypes.py > index 55056c2..dfca943 100644 > --- a/tools/libxl/libxltypes.py > +++ b/tools/libxl/libxltypes.py > @@ -33,6 +33,8 @@ class Type(object): > if self.passby not in [PASS_BY_VALUE, PASS_BY_REFERENCE]: > raise ValueError > > + self.c_only = kwargs.setdefault('c_only', False) > + > if typename is None: # Anonymous type > self.typename = None > self.rawname = None > @@ -50,7 +52,7 @@ class Type(object): > > self.autogenerate_dispose_fn = kwargs.setdefault('autogenerate_dispose_fn', True) > > - if self.typename is not None: > + if self.typename is not None and not self.c_only: > self.json_fn = kwargs.setdefault('json_fn', self.typename + "_gen_json") > else: > self.json_fn = kwargs.setdefault('json_fn', None)