130,131c130
< * Load and initialize all of the python parts of M5, including Swig
< * and the embedded module importer.
---
> * Load and initialize all of the python parts of M5.
155,188d153
< EmbeddedSwig::EmbeddedSwig(void (*init_func)(), const string& _context)
< : initFunc(init_func), context(_context)
< {
< getList().push_back(this);
< }
<
< list<EmbeddedSwig *> &
< EmbeddedSwig::getList()
< {
< static list<EmbeddedSwig *> the_list;
< return the_list;
< }
<
< void
< EmbeddedSwig::initAll()
< {
< char* old_context = _Py_PackageContext;
< // initialize SWIG modules. initFunc() is autogenerated and calls
< // all of the individual swig initialization functions.
< for (auto i : getList()) {
< // to ensure that the loaded modules are placed in the right
< // package we have to be a bit unorthodox and directly
< // manipulate the package context since swig simply calls
< // Py_InitModule with nothing but the module name of the
< // wrapper
< char* cstr = new char[i->context.size() + 1];
< strcpy(cstr, i->context.c_str());
< _Py_PackageContext = cstr;
< i->initFunc();
< delete[] cstr;
< }
< _Py_PackageContext = old_context;
< }
<
268d232
< EmbeddedSwig::initAll();