#ifdef USE_PYTHON
#include <boost/python.hpp>
namespace py = boost::python;
+extern "C" void initmussa();
#endif
using namespace boost::filesystem;
try {
#ifdef USE_PYTHON
if (opts.runAsPythonInterpeter) {
+ PyImport_AppendInittab("mussa", &initmussa);
Py_Initialize();
- py::object main_module((py::handle<>(py::borrowed(PyImport_AddModule("__main__")))));
- py::object main_namespace = main_module.attr("__dict__");
-
- py::handle<> ignored((PyRun_String(
- //"from IPython.Shell import IPShellEmbed\n"
- //"shell = IPShellEmbed(['mussa'], '')\n",
- //"import mussa\n"
- "def square(x):\n"
- " r = x * x\n"
- " print 'the square is %d' % (r)\n"
- " return r\n",
- Py_file_input,
- main_namespace.ptr(),
- main_namespace.ptr())
- ));
- py::object square = main_module.attr("square");
- int result = py::extract<int>(square(3));
- std::cout << "C++ has " << result << std::endl;
PyRun_InteractiveLoop(stdin, "mussa");
} else
#endif /* USE_PYTHON */