python: Fix mapping of vector & map attributes to Python types.

Fixes bug #382.
This commit is contained in:
Martin Ling 2014-11-11 15:29:35 +00:00 committed by Uwe Hermann
parent 062430a2fb
commit 444d6a3975
1 changed files with 16 additions and 2 deletions

View File

@ -360,11 +360,25 @@ std::map<std::string, Glib::VariantBase> dict_to_map_options(PyObject *dict,
%include "doc.i" %include "doc.i"
%define %attributevector(Class, Type, Name, Get) %define %attributevector(Class, Type, Name, Get)
%attributeval(sigrok::Class, Type, Name, Get); %rename(_ ## Get) sigrok::Class::Get;
%extend sigrok::Class
{
%pythoncode
{
Name = property(_ ## Get)
}
}
%enddef %enddef
%define %attributemap(Class, Type, Name, Get) %define %attributemap(Class, Type, Name, Get)
%attributeval(sigrok::Class, Type, Name, Get); %rename(_ ## Get) sigrok::Class::Get;
%extend sigrok::Class
{
%pythoncode
{
Name = property(fget = lambda x: x._ ## Get().asdict(), doc=_ ## Get.__doc__)
}
}
%enddef %enddef
%include "../../../swig/classes.i" %include "../../../swig/classes.i"