diff options
author | Ian Campbell <ian.campbell@citrix.com> | 2011-04-20 17:13:07 +0100 |
---|---|---|
committer | Ian Campbell <ian.campbell@citrix.com> | 2011-04-20 17:13:07 +0100 |
commit | e5855126c84c62774bb1001c9e894caf4ef90eba (patch) | |
tree | 8ca884eeae6900f8854e9c1a904667eba2f4c508 /tools/python/genwrap.py | |
parent | 442ee1681a29f049c4c7f18ace9003bd266fbe9f (diff) | |
download | xen-e5855126c84c62774bb1001c9e894caf4ef90eba.tar.gz xen-e5855126c84c62774bb1001c9e894caf4ef90eba.tar.bz2 xen-e5855126c84c62774bb1001c9e894caf4ef90eba.zip |
tools: libxl: add concept of in- and out-put only data types to IDL
This allow language bindings to only emit the relevant conversion functions.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson.citrix.com>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
Diffstat (limited to 'tools/python/genwrap.py')
-rw-r--r-- | tools/python/genwrap.py | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/tools/python/genwrap.py b/tools/python/genwrap.py index ed92b35b7b..af8d6465ff 100644 --- a/tools/python/genwrap.py +++ b/tools/python/genwrap.py @@ -42,10 +42,12 @@ def py_decls(ty): for f in ty.fields: if py_type(f.type) is not None: continue - l.append('_hidden PyObject *attrib__%s_get(%s *%s);'%(\ - fsanitize(f.type.typename), f.type.typename, f.name)) - l.append('_hidden int attrib__%s_set(PyObject *v, %s *%s);'%(\ - fsanitize(f.type.typename), f.type.typename, f.name)) + if ty.marshal_out(): + l.append('_hidden PyObject *attrib__%s_get(%s *%s);'%(\ + fsanitize(f.type.typename), f.type.typename, f.name)) + if ty.marshal_in(): + l.append('_hidden int attrib__%s_set(PyObject *v, %s *%s);'%(\ + fsanitize(f.type.typename), f.type.typename, f.name)) return '\n'.join(l) + "\n" def py_attrib_get(ty, f): @@ -128,8 +130,15 @@ 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: l.append(' { .name = "%s", '%f.name) - l.append(' .get = (getter)py_%s_%s_get, '%(ty.rawname, f.name)) - l.append(' .set = (setter)py_%s_%s_set },'%(ty.rawname, f.name)) + if ty.marshal_out(): + l.append(' .get = (getter)py_%s_%s_get, '%(ty.rawname, f.name)) + else: + l.append(' .get = (getter)NULL, ') + if ty.marshal_in(): + l.append(' .set = (setter)py_%s_%s_set,'%(ty.rawname, f.name)) + else: + l.append(' .set = (setter)NULL,') + l.append(' },') l.append(' { .name = NULL }') l.append('};') struct=""" @@ -289,8 +298,10 @@ _hidden int genwrap__ll_set(PyObject *v, long long *val, long long mask); if isinstance(ty, libxltypes.Aggregate): f.write('/* Attribute get/set functions for %s */\n'%ty.typename) for a in ty.fields: - f.write(py_attrib_get(ty,a)) - f.write(py_attrib_set(ty,a)) + if ty.marshal_out(): + f.write(py_attrib_get(ty,a)) + if ty.marshal_in(): + f.write(py_attrib_set(ty,a)) f.write(py_object_def(ty)) f.write(py_initfuncs(types)) f.close() |