py3: ported Raytracing to python3

This commit is contained in:
wmayer 2016-01-23 17:13:22 +01:00
parent a39ef71dfc
commit 125fd78fa3
3 changed files with 13 additions and 7 deletions

View File

@ -27,6 +27,7 @@
#endif
#include <Base/Console.h>
#include <Base/PyObjectBase.h>
#include <Base/Interpreter.h>
#include "RayFeature.h"
@ -40,7 +41,7 @@ namespace Raytracing {
}
PyMODINIT_FUNC initRaytracing()
PyMOD_INIT_FUNC(Raytracing)
{
// load dependent module
try {
@ -48,7 +49,7 @@ PyMODINIT_FUNC initRaytracing()
}
catch(const Base::Exception& e) {
PyErr_SetString(PyExc_ImportError, e.what());
return;
PyMOD_Return(0);
}
Raytracing::RaySegment ::init();
@ -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);
}

View File

@ -201,8 +201,10 @@ private:
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!");
}

View File

@ -51,11 +51,11 @@ 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 {
@ -63,9 +63,9 @@ PyMODINIT_FUNC initRaytracingGui()
}
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
@ -79,4 +79,6 @@ PyMODINIT_FUNC initRaytracingGui()
// add resources and reloads the translators
loadRaytracingResource();
PyMOD_Return(mod);
}