Skip to content

Commit

Permalink
py3: ported Raytracing to python3
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Feb 28, 2017
1 parent a39ef71 commit 125fd78
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
8 changes: 5 additions & 3 deletions src/Mod/Raytracing/App/AppRaytracing.cpp
Expand Up @@ -27,6 +27,7 @@
#endif

#include <Base/Console.h>
#include <Base/PyObjectBase.h>
#include <Base/Interpreter.h>

#include "RayFeature.h"
Expand All @@ -40,15 +41,15 @@ namespace Raytracing {
}


PyMODINIT_FUNC initRaytracing()
PyMOD_INIT_FUNC(Raytracing)
{
// load dependent module
try {
Base::Interpreter().loadModule("Part");
}
catch(const Base::Exception& e) {
PyErr_SetString(PyExc_ImportError, e.what());
return;
PyMOD_Return(0);
}

Raytracing::RaySegment ::init();
Expand All @@ -58,6 +59,7 @@ PyMODINIT_FUNC initRaytracing()
Raytracing::LuxProject ::init();


(void) Raytracing::initModule();
PyObject* mod = Raytracing::initModule();
Base::Console().Log("Loading Raytracing module... done\n");
PyMOD_Return(mod);
}
2 changes: 2 additions & 0 deletions src/Mod/Raytracing/App/AppRaytracingPy.cpp
Expand Up @@ -201,8 +201,10 @@ class Module : public Py::ExtensionModule<Module>
vecs[i][l] = PyFloat_AsDouble(temp);
else if (PyLong_Check(temp))
vecs[i][l] = (double) PyLong_AsLong(temp);
#if PY_MAJOR_VERSION < 3
else if (PyInt_Check(temp))
vecs[i][l] = (double) PyInt_AsLong(temp);
#endif
else
throw Py::ValueError("Wrong parameter format, four Tuple of three floats needed!");
}
Expand Down
10 changes: 6 additions & 4 deletions src/Mod/Raytracing/Gui/AppRaytracingGui.cpp
Expand Up @@ -51,21 +51,21 @@ namespace RaytracingGui {
}


PyMODINIT_FUNC initRaytracingGui()
PyMOD_INIT_FUNC(RaytracingGui)
{
if (!Gui::Application::Instance) {
PyErr_SetString(PyExc_ImportError, "Cannot load Gui module in console application.");
return;
PyMOD_Return(0);
}

try {
Base::Interpreter().loadModule("Raytracing");
}
catch(const Base::Exception& e) {
PyErr_SetString(PyExc_ImportError, e.what());
return;
PyMOD_Return(0);
}
(void) RaytracingGui::initModule();
PyObject* mod = RaytracingGui::initModule();
Base::Console().Log("Loading GUI of Raytracing module... done\n");

// instantiating the commands
Expand All @@ -79,4 +79,6 @@ PyMODINIT_FUNC initRaytracingGui()

// add resources and reloads the translators
loadRaytracingResource();

PyMOD_Return(mod);
}

0 comments on commit 125fd78

Please sign in to comment.