summaryrefslogtreecommitdiffstats
path: root/swig
diff options
context:
space:
mode:
Diffstat (limited to 'swig')
-rw-r--r--swig/Makefile.am12
-rwxr-xr-xswig/lv2_list.py10
-rw-r--r--swig/slv2.i93
3 files changed, 115 insertions, 0 deletions
diff --git a/swig/Makefile.am b/swig/Makefile.am
new file mode 100644
index 0000000..6c12b26
--- /dev/null
+++ b/swig/Makefile.am
@@ -0,0 +1,12 @@
+EXTRA_DIST = slv2.i lv2_list.py
+
+if WITH_SWIG
+all:
+ swig -Wall -python slv2.i
+ gcc -fPIC -shared -I/usr/include/python2.4 slv2_wrap.c ../src/.libs/libslv2.so -o _slv2.so
+endif
+
+clean:
+ rm *.c
+ rm *.so
+ rm *.o
diff --git a/swig/lv2_list.py b/swig/lv2_list.py
new file mode 100755
index 0000000..0f6e248
--- /dev/null
+++ b/swig/lv2_list.py
@@ -0,0 +1,10 @@
+#!/usr/bin/env python
+import slv2;
+
+w = slv2.World()
+w.load_all()
+
+plugins = w.get_all_plugins()
+
+for i in range(0, plugins.size()):
+ print plugins[i].uri()
diff --git a/swig/slv2.i b/swig/slv2.i
new file mode 100644
index 0000000..b044310
--- /dev/null
+++ b/swig/slv2.i
@@ -0,0 +1,93 @@
+%module slv2
+%{
+#include "../slv2/plugin.h"
+#include "../slv2/pluginclass.h"
+#include "../slv2/pluginclasses.h"
+#include "../slv2/plugininstance.h"
+#include "../slv2/plugins.h"
+#include "../slv2/port.h"
+#include "../slv2/slv2.h"
+#include "../slv2/types.h"
+#include "../slv2/value.h"
+#include "../slv2/values.h"
+#include "../slv2/world.h"
+typedef struct { SLV2World me; } World;
+typedef struct { SLV2World world; SLV2Plugins me; } Plugins;
+typedef struct { SLV2World world; SLV2Plugin me; } Plugin;
+%}
+
+%include "../slv2/plugin.h"
+%include "../slv2/pluginclass.h"
+%include "../slv2/pluginclasses.h"
+%include "../slv2/plugininstance.h"
+%include "../slv2/plugins.h"
+%include "../slv2/port.h"
+%include "../slv2/slv2.h"
+%include "../slv2/types.h"
+%include "../slv2/value.h"
+%include "../slv2/values.h"
+%include "../slv2/world.h"
+
+typedef struct { SLV2Plugin me; } Plugin;
+%extend Plugin {
+ Plugin(SLV2Plugin p) {
+ Plugin* ret = malloc(sizeof(Plugin));
+ ret->me = p;
+ return ret;
+ }
+
+ ~Plugin() {
+ /* FIXME: free SLV2Plugin? */
+ free($self);
+ }
+
+ char* name() { return slv2_plugin_get_name($self->me); }
+ const char* uri() { return slv2_plugin_get_uri($self->me); }
+};
+
+typedef struct { SLV2Plugins me; } Plugins;
+%extend Plugins {
+ Plugins(SLV2World w, SLV2Plugins p) {
+ Plugins* ret = malloc(sizeof(Plugins));
+ ret->world = w;
+ ret->me = p;
+ return ret;
+ }
+
+ ~Plugins() {
+ slv2_plugins_free($self->world, $self->me);
+ free($self);
+ }
+
+ inline unsigned size() const { return slv2_plugins_size($self->me); }
+ inline unsigned __len__() const { return slv2_plugins_size($self->me); }
+
+ Plugin* __getitem__(unsigned i) {
+ if (i < slv2_plugins_size($self->me))
+ return new_Plugin(slv2_plugins_get_at($self->me, i));
+ else
+ return NULL;
+ }
+};
+
+typedef struct { SLV2World me; } World;
+%extend World {
+ World() {
+ World* ret = malloc(sizeof(World));
+ ret->me = slv2_world_new();
+ return ret;
+ }
+
+ ~World() {
+ slv2_world_free($self->me);
+ free($self);
+ }
+ /*World() { $self->me = slv2_world_new(); }
+ ~World() { slv2_world_free($self->me); }*/
+
+ void load_all() { slv2_world_load_all($self->me); }
+ void load_bundle(const char* path) { slv2_world_load_bundle($self->me, path); }
+ Plugins* get_all_plugins() { return new_Plugins($self->me, slv2_world_get_all_plugins($self->me)); }
+};
+
+