summaryrefslogtreecommitdiffstats
path: root/src/bindings
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2009-12-19 21:37:50 +0000
committerDavid Robillard <d@drobilla.net>2009-12-19 21:37:50 +0000
commit19045ab92aa7e996971584a0dc8780d1d58b498b (patch)
tree619c73deb7fd64ce31c5167490d1ae186dbb2695 /src/bindings
parent4613a2e15f1122ecf6830171de0ab18dc22fefff (diff)
downloadingen-19045ab92aa7e996971584a0dc8780d1d58b498b.tar.gz
ingen-19045ab92aa7e996971584a0dc8780d1d58b498b.tar.bz2
ingen-19045ab92aa7e996971584a0dc8780d1d58b498b.zip
New ingen module (library, not e.g. LV2 plugin) design.
Much cleaner interface and general usage of Ingen as a library. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2314 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/bindings')
-rw-r--r--src/bindings/ingen_bindings.cpp37
1 files changed, 21 insertions, 16 deletions
diff --git a/src/bindings/ingen_bindings.cpp b/src/bindings/ingen_bindings.cpp
index 30edb8e1..82df3f90 100644
--- a/src/bindings/ingen_bindings.cpp
+++ b/src/bindings/ingen_bindings.cpp
@@ -4,15 +4,6 @@
#include "engine/Engine.hpp"
#include "module/World.hpp"
-using namespace std;
-
-namespace Ingen {
-namespace Shared {
-
-Ingen::Shared::World* ingen_world = NULL;
-
-extern "C" {
-
bool
run(Ingen::Shared::World* world, const char* filename)
{
@@ -20,17 +11,35 @@ run(Ingen::Shared::World* world, const char* filename)
FILE* fd = fopen(filename, "r");
if (fd) {
- cerr << "EXECUTING " << filename << endl;
+ cerr << "Executing script " << filename << endl;
Py_Initialize();
PyRun_SimpleFile(fd, filename);
Py_Finalize();
return true;
} else {
- cerr << "UNABLE TO OPEN FILE " << filename << endl;
+ cerr << "Unable to open script " << filename << endl;
return false;
}
}
+struct IngenBindingsModule : public Ingen::Shared::Module {
+ void load(Ingen::Shared::World* world) {
+ world->script_runners.insert(make_pair("application/x-python", &run));
+ //lib->make_resident();
+ }
+};
+
+static IngenBindingsModule* module = NULL;
+
+extern "C" {
+
+Ingen::Shared::Module*
+ingen_module_load() {
+ if (!module)
+ module = new IngenBindingsModule();
+
+ return module;
+}
void
script_iteration(Ingen::Shared::World* world)
@@ -39,8 +48,4 @@ script_iteration(Ingen::Shared::World* world)
world->local_engine->main_iteration();
}
-
-}
-
-} // namespace Shared
-} // namespace Ingen
+} // extern "C"