From 19045ab92aa7e996971584a0dc8780d1d58b498b Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 19 Dec 2009 21:37:50 +0000 Subject: 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 --- src/bindings/ingen_bindings.cpp | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) (limited to 'src/bindings') 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" -- cgit v1.2.1