Skip to content

Commit

Permalink
py3: ported Start to python3
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Mar 2, 2017
1 parent 742d2c1 commit 55545fb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
12 changes: 10 additions & 2 deletions src/Mod/Start/App/AppStart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#endif

#include <Base/Console.h>
#include <Base/PyObjectBase.h>
#include <Base/Interpreter.h>
#include <CXX/Extensions.hxx>
#include <CXX/Objects.hxx>
Expand All @@ -46,11 +47,18 @@ class Module : public Py::ExtensionModule<Module>

private:
};

PyObject* initModule()
{
return (new Module)->module().ptr();
}

} // namespace Start

/* Python entry */
PyMODINIT_FUNC initStart()
PyMOD_INIT_FUNC(Start)
{
new Start::Module();
PyObject* mod = Start::initModule();
Base::Console().Log("Loading Start module... done\n");
PyMOD_Return(mod);
}
15 changes: 11 additions & 4 deletions src/Mod/Start/Gui/AppStartGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,21 @@ class Module : public Py::ExtensionModule<Module>

private:
};

PyObject* initModule()
{
return (new Module)->module().ptr();
}

} // namespace StartGui


/* Python entry */
PyMODINIT_FUNC initStartGui()
PyMOD_INIT_FUNC(StartGui)
{
if (!Gui::Application::Instance) {
PyErr_SetString(PyExc_ImportError, "Cannot load Gui module in console application.");
return;
PyMOD_Return(0);
}

// load dependent module
Expand All @@ -79,7 +85,7 @@ PyMODINIT_FUNC initStartGui()
}
catch(const Base::Exception& e) {
PyErr_SetString(PyExc_ImportError, e.what());
return;
PyMOD_Return(0);
}
catch (Py::Exception& e) {
Py::Object o = Py::type(e);
Expand All @@ -95,7 +101,7 @@ PyMODINIT_FUNC initStartGui()
PyErr_Print();
}

new StartGui::Module();
PyObject* mod = StartGui::initModule();
Base::Console().Log("Loading GUI of Start module... done\n");

// instantiating the commands
Expand All @@ -104,4 +110,5 @@ PyMODINIT_FUNC initStartGui()

// add resources and reloads the translators
loadStartResource();
PyMOD_Return(mod);
}

0 comments on commit 55545fb

Please sign in to comment.