summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bindings/ingen_bindings.cpp44
-rw-r--r--src/bindings/ingen_bindings.hpp19
-rw-r--r--src/progs/ingen/main.cpp9
3 files changed, 71 insertions, 1 deletions
diff --git a/src/bindings/ingen_bindings.cpp b/src/bindings/ingen_bindings.cpp
new file mode 100644
index 00000000..0f96feda
--- /dev/null
+++ b/src/bindings/ingen_bindings.cpp
@@ -0,0 +1,44 @@
+#include <iostream>
+#include "python2.4/Python.h"
+#include "ingen_bindings.hpp"
+#include "../libs/engine/Engine.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)
+{
+ ingen_world = world;
+
+ FILE* fd = fopen(filename, "r");
+ if (fd) {
+ cerr << "EXECUTING " << filename << endl;
+ Py_Initialize();
+ PyRun_SimpleFile(fd, filename);
+ Py_Finalize();
+ return true;
+ } else {
+ cerr << "UNABLE TO OPEN FILE " << filename << endl;
+ return false;
+ }
+}
+
+
+void
+script_iteration(Ingen::Shared::World* world) {
+ if (world->local_engine)
+ world->local_engine->main_iteration();
+}
+
+
+}
+
+} // namespace Shared
+} // namespace Ingen
diff --git a/src/bindings/ingen_bindings.hpp b/src/bindings/ingen_bindings.hpp
new file mode 100644
index 00000000..0d501de9
--- /dev/null
+++ b/src/bindings/ingen_bindings.hpp
@@ -0,0 +1,19 @@
+#ifndef INGEN_BINDINGS_HPP
+#define INGEN_BINDINGS_HPP
+
+namespace Ingen {
+namespace Shared {
+
+
+class World;
+extern World* ingen_world;
+
+extern "C" {
+ bool run(World* world, const char* filename);
+ void script_iteration(World* world);
+}
+
+} // namespace Shared
+} // namespace Ingen
+
+#endif // INGEN_BINDINGS_HPP
diff --git a/src/progs/ingen/main.cpp b/src/progs/ingen/main.cpp
index f424eff0..eb93407b 100644
--- a/src/progs/ingen/main.cpp
+++ b/src/progs/ingen/main.cpp
@@ -32,9 +32,12 @@
#include "engine/Engine.hpp"
#include "engine/QueuedEngineInterface.hpp"
#include "serialisation/Loader.hpp"
-#include "bindings/ingen_bindings.hpp"
#include "cmdline.h"
+#ifdef WITH_BINDINGS
+#include "bindings/ingen_bindings.hpp"
+#endif
+
using namespace std;
using namespace Ingen;
@@ -202,6 +205,7 @@ main(int argc, char** argv)
/* Run a script */
if (args.run_given) {
+#ifdef WITH_BINDINGS
bool (*run_script)(Ingen::Shared::World*, const char*) = NULL;
SharedPtr<Glib::Module> bindings_module = Ingen::Shared::load_module("ingen_bindings");
if (!bindings_module)
@@ -218,6 +222,9 @@ main(int argc, char** argv)
} else {
cerr << "FAILED: " << Glib::Module::get_last_error() << endl;
}
+#else
+ cerr << "This build of ingen does not support scripting." << endl;
+#endif
/* Listen to OSC and do our own main thing. */
} else if (engine && !ran_gui) {