]> sigrok.org Git - libsigrok.git/commitdiff
python: Fix mapping of vector & map attributes to Python types.
authorMartin Ling <redacted>
Tue, 11 Nov 2014 15:29:35 +0000 (15:29 +0000)
committerUwe Hermann <redacted>
Wed, 12 Nov 2014 01:27:05 +0000 (02:27 +0100)
Fixes bug #382.

bindings/python/sigrok/core/classes.i

index 3c327e4d4c50222b074961757d6cccb1d5659211..7cfdc29dd660a90148490701010c9e16b01ec647 100644 (file)
@@ -360,11 +360,25 @@ std::map<std::string, Glib::VariantBase> dict_to_map_options(PyObject *dict,
 %include "doc.i"
 
 %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
 
 %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
 
 %include "../../../swig/classes.i"