diff options
author | Ian Jackson <ian.jackson@eu.citrix.com> | 2011-12-12 17:48:38 +0000 |
---|---|---|
committer | Ian Jackson <ian.jackson@eu.citrix.com> | 2011-12-12 17:48:38 +0000 |
commit | eee7480fdf1e874cc91b73e9646c487b5e02c99a (patch) | |
tree | 23008550e8df7875d0dc68be5966e40d3c2930c4 | |
parent | 46f6034c3dcd0cf221914574e4528f25804a5857 (diff) | |
download | xen-eee7480fdf1e874cc91b73e9646c487b5e02c99a.tar.gz xen-eee7480fdf1e874cc91b73e9646c487b5e02c99a.tar.bz2 xen-eee7480fdf1e874cc91b73e9646c487b5e02c99a.zip |
libxl: idl: support new "private" type attribute
This provides for fields in libxl datatypes which are only present in
the C version of structures and are used only by libxl itself. This
is useful 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.
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
-rw-r--r-- | tools/libxl/gentest.py | 2 | ||||
-rw-r--r-- | tools/libxl/libxltypes.py | 4 | ||||
-rw-r--r-- | tools/python/genwrap.py | 6 |
3 files changed, 11 insertions, 1 deletions
diff --git a/tools/libxl/gentest.py b/tools/libxl/gentest.py index 05e77cce5e..ac7a400060 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.private: + 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 55056c2750..450de88f49 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.private = kwargs.setdefault('private', 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.private: self.json_fn = kwargs.setdefault('json_fn', self.typename + "_gen_json") else: self.json_fn = kwargs.setdefault('json_fn', None) diff --git a/tools/python/genwrap.py b/tools/python/genwrap.py index d0c193d26f..a5febeeab1 100644 --- a/tools/python/genwrap.py +++ b/tools/python/genwrap.py @@ -129,6 +129,8 @@ static PyObject *Py%(rawname)s_new(PyTypeObject *type, PyObject *args, PyObject l.append('static PyGetSetDef Py%s_getset[] = {'%ty.rawname) for f in ty.fields: + if f.type.private: + continue l.append(' { .name = "%s", '%f.name) if ty.marshal_out(): l.append(' .get = (getter)py_%s_%s_get, '%(ty.rawname, f.name)) @@ -295,9 +297,13 @@ _hidden int genwrap__ll_set(PyObject *v, long long *val, long long mask); """ % tuple((' '.join(sys.argv),) + (os.path.split(decls)[-1:]),)) for ty in types: + if ty.private: + continue if isinstance(ty, libxltypes.Aggregate): f.write('/* Attribute get/set functions for %s */\n'%ty.typename) for a in ty.fields: + if a.type.private: + continue if ty.marshal_out(): f.write(py_attrib_get(ty,a)) if ty.marshal_in(): |