From: Martin Ling Date: Tue, 11 Nov 2014 01:18:58 +0000 (+0000) Subject: bindings: Expose EnumValue::id and EnumValue::name as attributes. X-Git-Tag: libsigrok-0.4.0~798 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=189461b25193d099b8a1087d8fda97958ae31ed5;p=libsigrok.git bindings: Expose EnumValue::id and EnumValue::name as attributes. --- diff --git a/bindings/cxx/enums.py b/bindings/cxx/enums.py index 1941f783..d0b4ec44 100644 --- a/bindings/cxx/enums.py +++ b/bindings/cxx/enums.py @@ -146,6 +146,11 @@ for enum, (classname, classbrief) in classes.items(): if os.path.exists(filename): print >> code, str.join('', open(filename).readlines()) - # Instantiate EnumValue template for SWIG wrappers - print >> swig, '%%template(EnumValue%s) EnumValue<%s, enum %s>;' % ( + # Map EnumValue::id() and EnumValue::name() as SWIG attributes. + print >> swig, '%%attribute(sigrok::%s, int, id, id);' % classname + print >> swig, '%%attributestring(sigrok::%s, std::string, name, name);' % classname + + # Instantiate EnumValue template for SWIG + print >> swig, '%%template(EnumValue%s) sigrok::EnumValue;' % ( classname, classname, enum_name) + diff --git a/bindings/swig/classes.i b/bindings/swig/classes.i index 07e74573..1bbba90f 100644 --- a/bindings/swig/classes.i +++ b/bindings/swig/classes.i @@ -272,7 +272,8 @@ typedef std::map %include "libsigrok/libsigrok.hpp" -namespace sigrok { %include "enums.i" + +namespace sigrok { %include "libsigrok/enums.hpp" }