diff options
Diffstat (limited to 'bindings/lilv.i')
-rw-r--r-- | bindings/lilv.i | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/bindings/lilv.i b/bindings/lilv.i new file mode 100644 index 0000000..f6254a7 --- /dev/null +++ b/bindings/lilv.i @@ -0,0 +1,66 @@ +%module lilv +%typedef unsigned uint32_t; +%{ +#define SWIG_FILE_WITH_INIT +#include "lilv/lilv.h" +#include "lilv/lilvmm.hpp" +%} + +%include "numpy.i" +%init %{ + import_array(); +%} +%apply (float* INPLACE_ARRAY1) {(void* data_location)} + +%feature("compactdefaultargs") %{ + lilv_plugin_get_num_ports_of_class; + get_num_ports_of_class; +%} +%varargs(3, LilvNode* node = NULL) lilv_plugin_get_num_ports_of_class; +%varargs(3, LilvNode* node = NULL) get_num_ports_of_class; +%typemap(in, numinputs=0) LilvNode *node3 ""; // Make sure it's NULL terminated + +%include "lilv/lilv.h" +%include "lilv/lilvmm.hpp" + +namespace Lilv { + +%extend Plugins { +%pythoncode %{ + def __iter__(self): + class Iterator(object): + def __init__(self, plugins): + self.plugins = plugins + self.iter = plugins.begin() + + def __next__(self): + if self.plugins.is_end(self.iter): + raise StopIteration + plugin = self.plugins.get(self.iter) + self.iter = self.plugins.next(self.iter) + return plugin + + def next(self): + "Python 2 iterator protocol" + return Iterator.__next__(self) + + return Iterator(self) + + def get_by_uri(self, *args): + """get_by_uri(self, LilvNode uri) -> PluginClass""" + ret = _lilv.Plugins_get_by_uri(self, *args) + if ret.me is None: + return None + else: + return ret +%} +}; + +%extend Node { +%pythoncode %{ + def __str__(self): + return self.get_turtle_token() +%} +}; + +} /* namespace Lilv */ |