diff options
author | David Robillard <d@drobilla.net> | 2007-07-31 15:38:31 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2007-07-31 15:38:31 +0000 |
commit | e0efa719ab0872b852a1c50108b0b3ac73abb630 (patch) | |
tree | 2048caf0d6b02ee898783f6c37681f91496ad254 | |
parent | 57cd2b32147e1b321f0569abd29f15cd7cf0184d (diff) | |
download | ingen-e0efa719ab0872b852a1c50108b0b3ac73abb630.tar.gz ingen-e0efa719ab0872b852a1c50108b0b3ac73abb630.tar.bz2 ingen-e0efa719ab0872b852a1c50108b0b3ac73abb630.zip |
First steps towards Ingen SWIG bindings.
git-svn-id: http://svn.drobilla.net/lad/ingen@661 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/bindings/Makefile.am | 28 | ||||
-rw-r--r-- | src/bindings/ingen.i | 39 | ||||
-rwxr-xr-x | src/bindings/test_ingen.py | 8 | ||||
-rw-r--r-- | src/common/interface/EngineInterface.hpp | 1 | ||||
-rw-r--r-- | src/libs/module/World.hpp | 6 | ||||
-rw-r--r-- | src/libs/module/module.cpp | 5 | ||||
-rw-r--r-- | src/libs/module/module.h | 5 |
8 files changed, 88 insertions, 6 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index c9d9fc9b..e08a97bb 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,6 +1,6 @@ EXTRA_DIST = set_dev_environment.sh -SUBDIRS = libs progs +SUBDIRS = libs progs bindings DIST_SUBDIRS = $(SUBDIRS) common diff --git a/src/bindings/Makefile.am b/src/bindings/Makefile.am new file mode 100644 index 00000000..8935eebb --- /dev/null +++ b/src/bindings/Makefile.am @@ -0,0 +1,28 @@ +FLAGS = @RAUL_CFLAGS@ @GLIBMM_CFLAGS@ -I$(top_srcdir)/ingen/src/common +LIBS = @RAUL_LIBS@ @GLIBMM_LIBS@ +AM_CXXFLAGS = -I/usr/include/python2.4 $(FLAGS) + +EXTRA_DIST = ingen.i ingen_test.py + +if WITH_SWIG +bindingsdir = $(libdir)/ingen +bindings_LTLIBRARIES = libingen_bindings.la +libingen_bindings_la_LDFLAGS = -no-undefined -module -avoid-version +libingen_bindings_la_LIBADD = @RAUL_LIBS@ @GLIBMM_LIBS@ ../libs/module/libingen_module.la +libingen_bindings_la_SOURCES = ingen_wrap.cxx + +swig: ingen.i + swig -c++ -Wall $(FLAGS) -python ingen.i + +libingen_bindings_la: swig ingen_wrap.cxx + +all-local: + ln -sf .libs/libingen_bindings.so _ingen.so + +#libtool --mode=compile g++ -fPIC -shared $(CXXFLAGS) $(FLAGS) $(LIBS) -I/usr/include/python2.4 ingen_wrap.cxx -o libingen_python.so.0.0.0 +endif + +clean-local: + rm *.cxx + rm *.so + rm *.o diff --git a/src/bindings/ingen.i b/src/bindings/ingen.i new file mode 100644 index 00000000..e9a13dc3 --- /dev/null +++ b/src/bindings/ingen.i @@ -0,0 +1,39 @@ +%include "stl.i" +%module ingen +%{ +#include "../common/interface/ClientInterface.hpp" +#include "../common/interface/EngineInterface.hpp" +#include "../libs/module/World.hpp" +#include "../libs/module/module.h" + +namespace Ingen { namespace Shared { + class World; +} } +typedef Ingen::Shared::World World; +/*struct World { + World() { me = Ingen::Shared::get_world(); } + Ingen::Shared::World* me; +};*/ +%} + +/*%ignore Ingen::Shared::EngineInterface;*/ + +%include "../common/interface/ClientInterface.hpp" +%include "../common/interface/EngineInterface.hpp" +/*%include "../libs/module/World.hpp" +%include "../libs/module/module.h"*/ +%include "../libs/module/module.h" + +using namespace Ingen::Shared; +namespace Ingen { namespace Shared { + class World; +} } +%typedef Ingen::Shared::World World; +/*struct World {};*/ +%extend World { + World() { return Ingen::Shared::get_world(); } + /*SLV2World slv2() { return $self->me->slv2_world; }*/ + +/*SharedPtr<Ingen::Shared::EngineInterface> engine() { return $self->me->engine; }*/ +}; + diff --git a/src/bindings/test_ingen.py b/src/bindings/test_ingen.py new file mode 100755 index 00000000..93d524c6 --- /dev/null +++ b/src/bindings/test_ingen.py @@ -0,0 +1,8 @@ +#!/usr/bin/env python +import ingen + +world = ingen.World() +#w = ingen.get_world() +print world +e = world.engine +print e diff --git a/src/common/interface/EngineInterface.hpp b/src/common/interface/EngineInterface.hpp index f727b1be..0ac56c7c 100644 --- a/src/common/interface/EngineInterface.hpp +++ b/src/common/interface/EngineInterface.hpp @@ -23,6 +23,7 @@ #include <raul/SharedPtr.hpp> #include "interface/ClientInterface.hpp" using std::string; +using Ingen::Shared::ClientInterface; namespace Ingen { /** Shared code used on both client side and engine side (abstract interfaces). */ diff --git a/src/libs/module/World.hpp b/src/libs/module/World.hpp index bb7ffe17..f665e6ad 100644 --- a/src/libs/module/World.hpp +++ b/src/libs/module/World.hpp @@ -32,6 +32,8 @@ namespace Ingen { namespace Shared { +class EngineInterface; + /** The "world" all Ingen modules may share. * @@ -47,7 +49,9 @@ struct World { #ifdef HAVE_SLV2 SLV2World slv2_world; #endif - Raul::RDF::World rdf_world; + Raul::RDF::World* rdf_world; + + EngineInterface* engine; }; diff --git a/src/libs/module/module.cpp b/src/libs/module/module.cpp index 7584ebc7..4e342670 100644 --- a/src/libs/module/module.cpp +++ b/src/libs/module/module.cpp @@ -33,8 +33,9 @@ get_world() { if (!world) { world = new World(); + world->rdf_world = new Raul::RDF::World(); #ifdef HAVE_SLV2 - world->slv2_world = slv2_world_new_using_rdf_world(world->rdf_world.world()); + world->slv2_world = slv2_world_new_using_rdf_world(world->rdf_world->world()); slv2_world_load_all(world->slv2_world); #endif } @@ -49,7 +50,7 @@ destroy_world() #ifdef HAVE_SLV2 slv2_world_free(world->slv2_world); #endif - + delete world->rdf_world; delete world; world = NULL; } diff --git a/src/libs/module/module.h b/src/libs/module/module.h index 6c809f7e..48bdeedf 100644 --- a/src/libs/module/module.h +++ b/src/libs/module/module.h @@ -20,14 +20,15 @@ #include "World.hpp" #include "Module.hpp" +#include "raul/SharedPtr.hpp" namespace Ingen { namespace Shared { extern "C" { - World* get_world(); - void destroy_world(); + World* get_world(); + void destroy_world(); } |