diff options
Diffstat (limited to 'src/bindings')
-rw-r--r-- | src/bindings/Client.hpp | 90 | ||||
-rw-r--r-- | src/bindings/ingen.i | 16 | ||||
-rwxr-xr-x | src/bindings/test_ingen.py | 29 |
3 files changed, 133 insertions, 2 deletions
diff --git a/src/bindings/Client.hpp b/src/bindings/Client.hpp new file mode 100644 index 00000000..aeca11d7 --- /dev/null +++ b/src/bindings/Client.hpp @@ -0,0 +1,90 @@ + +/** Need a stub ClientInterface without pure virtual methods + * to allow inheritance in the script + */ +class Client : public Ingen::Shared::ClientInterface +{ +public: + //Client() : Ingen::Shared::ClientInterface() {} + + /** Wrapper for engine->register_client to appease SWIG */ + virtual void subscribe(Ingen::Shared::EngineInterface* engine) { + engine->register_client("FIXME", this); + } + + virtual void response(int32_t id, bool success, std::string msg) {} + + virtual void enable() {} + + /** Signifies the client does not wish to receive any messages until + * enable is called. Useful for performance and avoiding feedback. + */ + virtual void disable() {} + + /** Bundles are a group of messages that are guaranteed to be in an + * atomic unit with guaranteed order (eg a packet). For datagram + * protocols (like UDP) there is likely an upper limit on bundle size. + */ + virtual void bundle_begin() {} + virtual void bundle_end() {} + + /** Transfers are 'weak' bundles. These are used to break a large group + * of similar/related messages into larger chunks (solely for communication + * efficiency). A bunch of messages in a transfer will arrive as 1 or more + * bundles (so a transfer can exceep the maximum bundle (packet) size). + */ + virtual void transfer_begin() {} + virtual void transfer_end() {} + + virtual void error(std::string msg) {} + + virtual void num_plugins(uint32_t num_plugins) {} + + virtual void new_plugin(std::string uri, + std::string type_uri, + std::string name) {} + + virtual void new_patch(std::string path, uint32_t poly) {} + + virtual void new_node(std::string plugin_uri, + std::string node_path, + bool is_polyphonic, + uint32_t num_ports) {} + + virtual void new_port(std::string path, + std::string data_type, + bool is_output) {} + + virtual void patch_enabled(std::string path) {} + + virtual void patch_disabled(std::string path) {} + + virtual void patch_cleared(std::string path) {} + + virtual void object_renamed(std::string old_path, + std::string new_path) {} + + virtual void object_destroyed(std::string path) {} + + virtual void connection(std::string src_port_path, + std::string dst_port_path) {} + + virtual void disconnection(std::string src_port_path, + std::string dst_port_path) {} + + virtual void metadata_update(std::string subject_path, + std::string predicate, + Raul::Atom value) {} + + virtual void control_change(std::string port_path, + float value) {} + + virtual void program_add(std::string node_path, + uint32_t bank, + uint32_t program, + std::string program_name) {} + + virtual void program_remove(std::string node_path, + uint32_t bank, + uint32_t program) {} +}; diff --git a/src/bindings/ingen.i b/src/bindings/ingen.i index dbf5ab10..719ece20 100644 --- a/src/bindings/ingen.i +++ b/src/bindings/ingen.i @@ -1,11 +1,12 @@ %include "stl.i" -%module ingen +%module(directors="1") ingen %{ #include "../common/interface/ClientInterface.hpp" #include "../common/interface/EngineInterface.hpp" #include "../libs/module/World.hpp" /*#include "../libs/module/module.h"*/ #include "ingen_bindings.hpp" +#include "Client.hpp" namespace Ingen { namespace Shared { class World; @@ -22,7 +23,11 @@ namespace Ingen { namespace Shared { //%include "../libs/module/module.h" %include "ingen_bindings.hpp" -using namespace Ingen::Shared; +// generate directors for all classes that have virtual methods +%feature("director"); +%feature("director") Ingen::Shared::ClientInterface; +//%feature("director") Ingen::Shared::EngineInterface; + namespace Ingen { namespace Shared { class World; } } @@ -39,7 +44,14 @@ namespace Ingen { namespace Shared { } /*SLV2World slv2() { return $self->me->slv2_world; }*/ }; + } } + +%include "Client.hpp" + +%feature("director") Client; + + /*SharedPtr<Ingen::Shared::EngineInterface> engine() { return $self->me->engine; }*/ diff --git a/src/bindings/test_ingen.py b/src/bindings/test_ingen.py index 794e51ba..4109dd21 100755 --- a/src/bindings/test_ingen.py +++ b/src/bindings/test_ingen.py @@ -3,9 +3,38 @@ import ingen import time world = ingen.World() + +class PythonClient(ingen.Client): + #def __init__(self): + # ingen.Client(self) + # print "Client" + + def bundle_begin(): + print "Bundle {" + + + def new_port(self, path, data_type, is_output): + print "Port:", path, data_type, is_output + +c = PythonClient() +c.thisown = 0 +print "C OWN", c.thisown +#print c.__base__ + e = world.engine +print "E OWN", e.thisown +e.thisown = 0 +#print e e.activate() + +#e.register_client("foo", c) +c.subscribe(e) + +c.enable() +#c.new_patch("/foo/bar", 1) + + e.create_port("/I", "ingen:midi", False) e.create_port("/made", "ingen:audio", False) e.create_port("/these", "ingen:audio", False) |