From: Martin Ling Date: Wed, 29 Oct 2014 14:36:45 +0000 (+0000) Subject: bindings: Wrap EnumValue base class. X-Git-Tag: libsigrok-0.4.0~799 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=fe4096fde6edf35d93bca8293172cf261e33ad8a;p=libsigrok.git bindings: Wrap EnumValue base class. --- diff --git a/.gitignore b/.gitignore index 6d7fdd78..0a59be65 100644 --- a/.gitignore +++ b/.gitignore @@ -49,6 +49,7 @@ bindings/cxx/doxy/ bindings/cxx/include/libsigrok/enums.hpp bindings/cxx/enums.cpp bindings/cxx/enums.timestamp +bindings/swig/enums.i # Files generated by building Python bindings *.pyc diff --git a/bindings/cxx/enums.py b/bindings/cxx/enums.py index 4f32d98e..1941f783 100644 --- a/bindings/cxx/enums.py +++ b/bindings/cxx/enums.py @@ -66,6 +66,7 @@ for compound in index.findall('compound'): header = open(os.path.join(outdirname, 'include/libsigrok/enums.hpp'), 'w') code = open(os.path.join(outdirname, 'enums.cpp'), 'w') +swig = open(os.path.join(outdirname, '../swig/enums.i'), 'w') for file in (header, code): print >> file, "/* Generated file - edit enums.py instead! */" @@ -144,3 +145,7 @@ for enum, (classname, classbrief) in classes.items(): filename = os.path.join(dirname, "%s_methods.cpp" % classname) 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>;' % ( + classname, classname, enum_name) diff --git a/bindings/swig/classes.i b/bindings/swig/classes.i index ce96c9d9..07e74573 100644 --- a/bindings/swig/classes.i +++ b/bindings/swig/classes.i @@ -273,5 +273,6 @@ typedef std::map %include "libsigrok/libsigrok.hpp" namespace sigrok { +%include "enums.i" %include "libsigrok/enums.hpp" }