py3: ported module init to python3
This commit is contained in:
parent
915a1b18c4
commit
76b3397762
|
@ -18,6 +18,7 @@
|
||||||
#include <CXX/Objects.hxx>
|
#include <CXX/Objects.hxx>
|
||||||
|
|
||||||
#include <Base/Console.h>
|
#include <Base/Console.h>
|
||||||
|
#include <Base/PyObjectBase.h>
|
||||||
#include "ImagePlane.h"
|
#include "ImagePlane.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,12 +44,12 @@ PyObject* initModule()
|
||||||
} // namespace Image
|
} // namespace Image
|
||||||
|
|
||||||
/* Python entry */
|
/* Python entry */
|
||||||
PyMODINIT_FUNC initImage()
|
PyMOD_INIT_FUNC(Image)
|
||||||
{
|
{
|
||||||
(void) Image::initModule();
|
PyObject* mod = Image::initModule();
|
||||||
Base::Console().Log("Loading Image module... done\n");
|
Base::Console().Log("Loading Image module... done\n");
|
||||||
|
|
||||||
Image::ImagePlane::init();
|
Image::ImagePlane::init();
|
||||||
|
|
||||||
return;
|
PyMOD_Return(mod);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,14 +37,14 @@ extern PyObject* initModule();
|
||||||
|
|
||||||
|
|
||||||
/* Python entry */
|
/* Python entry */
|
||||||
PyMODINIT_FUNC initImageGui()
|
PyMOD_INIT_FUNC(ImageGui)
|
||||||
{
|
{
|
||||||
if (!Gui::Application::Instance) {
|
if (!Gui::Application::Instance) {
|
||||||
PyErr_SetString(PyExc_ImportError, "Cannot load Gui module in console application.");
|
PyErr_SetString(PyExc_ImportError, "Cannot load Gui module in console application.");
|
||||||
return;
|
PyMOD_Return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
(void) ImageGui::initModule();
|
PyObject* mod = ImageGui::initModule();
|
||||||
Base::Console().Log("Loading GUI of Image module... done\n");
|
Base::Console().Log("Loading GUI of Image module... done\n");
|
||||||
|
|
||||||
// instantiating the commands
|
// instantiating the commands
|
||||||
|
@ -55,4 +55,6 @@ PyMODINIT_FUNC initImageGui()
|
||||||
|
|
||||||
// add resources and reloads the translators
|
// add resources and reloads the translators
|
||||||
loadImageResource();
|
loadImageResource();
|
||||||
|
|
||||||
|
PyMOD_Return(mod);
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ extern PyObject* initModule();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Python entry */
|
/* Python entry */
|
||||||
PyMODINIT_FUNC initMesh()
|
PyMOD_INIT_FUNC(Mesh)
|
||||||
{
|
{
|
||||||
PyObject* meshModule = Mesh::initModule();
|
PyObject* meshModule = Mesh::initModule();
|
||||||
Base::Console().Log("Loading Mesh module... done\n");
|
Base::Console().Log("Loading Mesh module... done\n");
|
||||||
|
@ -99,4 +99,6 @@ PyMODINIT_FUNC initMesh()
|
||||||
Mesh::Cone ::init();
|
Mesh::Cone ::init();
|
||||||
Mesh::Torus ::init();
|
Mesh::Torus ::init();
|
||||||
Mesh::Cube ::init();
|
Mesh::Cube ::init();
|
||||||
|
|
||||||
|
PyMOD_Return(meshModule);
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,11 +88,11 @@ PyObject* initModule()
|
||||||
} // namespace MeshGui
|
} // namespace MeshGui
|
||||||
|
|
||||||
/* Python entry */
|
/* Python entry */
|
||||||
PyMODINIT_FUNC initMeshGui()
|
PyMOD_INIT_FUNC(MeshGui)
|
||||||
{
|
{
|
||||||
if (!Gui::Application::Instance) {
|
if (!Gui::Application::Instance) {
|
||||||
PyErr_SetString(PyExc_ImportError, "Cannot load Gui module in console application.");
|
PyErr_SetString(PyExc_ImportError, "Cannot load Gui module in console application.");
|
||||||
return;
|
PyMOD_Return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// load dependent module
|
// load dependent module
|
||||||
|
@ -101,9 +101,9 @@ PyMODINIT_FUNC initMeshGui()
|
||||||
}
|
}
|
||||||
catch(const Base::Exception& e) {
|
catch(const Base::Exception& e) {
|
||||||
PyErr_SetString(PyExc_ImportError, e.what());
|
PyErr_SetString(PyExc_ImportError, e.what());
|
||||||
return;
|
PyMOD_Return(0);
|
||||||
}
|
}
|
||||||
(void) MeshGui::initModule();
|
PyObject* mod = MeshGui::initModule();
|
||||||
Base::Console().Log("Loading GUI of Mesh module... done\n");
|
Base::Console().Log("Loading GUI of Mesh module... done\n");
|
||||||
|
|
||||||
// Register icons
|
// Register icons
|
||||||
|
@ -154,4 +154,6 @@ PyMODINIT_FUNC initMeshGui()
|
||||||
|
|
||||||
// add resources and reloads the translators
|
// add resources and reloads the translators
|
||||||
loadMeshResource();
|
loadMeshResource();
|
||||||
|
|
||||||
|
PyMOD_Return(mod);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace Points {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Python entry */
|
/* Python entry */
|
||||||
PyMODINIT_FUNC initPoints()
|
PyMOD_INIT_FUNC(Points)
|
||||||
{
|
{
|
||||||
PyObject* pointsModule = Points::initModule();
|
PyObject* pointsModule = Points::initModule();
|
||||||
Base::Console().Log("Loading Points module... done\n");
|
Base::Console().Log("Loading Points module... done\n");
|
||||||
|
@ -60,5 +60,5 @@ PyMODINIT_FUNC initPoints()
|
||||||
Points::Structured ::init();
|
Points::Structured ::init();
|
||||||
Points::FeatureCustom ::init();
|
Points::FeatureCustom ::init();
|
||||||
Points::StructuredCustom ::init();
|
Points::StructuredCustom ::init();
|
||||||
Points::FeaturePython ::init();
|
Points::FeaturePython ::init();
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,15 +61,20 @@ public:
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
PyObject* initModule()
|
||||||
|
{
|
||||||
|
return (new Module)->module().ptr();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace PointsGui
|
} // namespace PointsGui
|
||||||
|
|
||||||
|
|
||||||
/* Python entry */
|
/* Python entry */
|
||||||
PyMODINIT_FUNC initPointsGui()
|
PyMOD_INIT_FUNC(PointsGui)
|
||||||
{
|
{
|
||||||
if (!Gui::Application::Instance) {
|
if (!Gui::Application::Instance) {
|
||||||
PyErr_SetString(PyExc_ImportError, "Cannot load Gui module in console application.");
|
PyErr_SetString(PyExc_ImportError, "Cannot load Gui module in console application.");
|
||||||
return;
|
PyMOD_Return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// load dependent module
|
// load dependent module
|
||||||
|
@ -78,11 +83,11 @@ PyMODINIT_FUNC initPointsGui()
|
||||||
}
|
}
|
||||||
catch(const Base::Exception& e) {
|
catch(const Base::Exception& e) {
|
||||||
PyErr_SetString(PyExc_ImportError, e.what());
|
PyErr_SetString(PyExc_ImportError, e.what());
|
||||||
return;
|
PyMOD_Return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Base::Console().Log("Loading GUI of Points module... done\n");
|
Base::Console().Log("Loading GUI of Points module... done\n");
|
||||||
(void)new PointsGui::Module();
|
PyObject* mod = PointsGui::initModule();
|
||||||
|
|
||||||
// instantiating the commands
|
// instantiating the commands
|
||||||
CreatePointsCommands();
|
CreatePointsCommands();
|
||||||
|
@ -98,4 +103,6 @@ PyMODINIT_FUNC initPointsGui()
|
||||||
|
|
||||||
// add resources and reloads the translators
|
// add resources and reloads the translators
|
||||||
loadPointsResource();
|
loadPointsResource();
|
||||||
|
|
||||||
|
PyMOD_Return(mod);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,20 +32,21 @@
|
||||||
#include <Gui/Language/Translator.h>
|
#include <Gui/Language/Translator.h>
|
||||||
#include <Base/Console.h>
|
#include <Base/Console.h>
|
||||||
|
|
||||||
class UnitTestModule : public Py::ExtensionModule<UnitTestModule>
|
namespace TestGui {
|
||||||
|
class Module : public Py::ExtensionModule<Module>
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UnitTestModule() : Py::ExtensionModule<UnitTestModule>("QtUnitGui")
|
Module() : Py::ExtensionModule<Module>("QtUnitGui")
|
||||||
{
|
{
|
||||||
TestGui::UnitTestDialogPy::init_type();
|
TestGui::UnitTestDialogPy::init_type();
|
||||||
add_varargs_method("UnitTest",&UnitTestModule::new_UnitTest,"UnitTest");
|
add_varargs_method("UnitTest",&Module::new_UnitTest,"UnitTest");
|
||||||
add_varargs_method("setTest",&UnitTestModule::setTest,"setTest");
|
add_varargs_method("setTest",&Module::setTest,"setTest");
|
||||||
add_varargs_method("addTest",&UnitTestModule::addTest,"addTest");
|
add_varargs_method("addTest",&Module::addTest,"addTest");
|
||||||
initialize("This module is the QtUnitGui module"); // register with Python
|
initialize("This module is the QtUnitGui module"); // register with Python
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~UnitTestModule() {}
|
virtual ~Module() {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Py::Object new_UnitTest(const Py::Tuple& args)
|
Py::Object new_UnitTest(const Py::Tuple& args)
|
||||||
|
@ -82,6 +83,13 @@ private:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
PyObject* initModule()
|
||||||
|
{
|
||||||
|
return (new Module())->module().ptr();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void loadTestResource()
|
void loadTestResource()
|
||||||
{
|
{
|
||||||
// add resources and reloads the translators
|
// add resources and reloads the translators
|
||||||
|
@ -90,15 +98,15 @@ void loadTestResource()
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Python entry */
|
/* Python entry */
|
||||||
PyMODINIT_FUNC initQtUnitGui()
|
PyMOD_INIT_FUNC(QtUnitGui)
|
||||||
{
|
{
|
||||||
// the following constructor call registers our extension module
|
// the following constructor call registers our extension module
|
||||||
// with the Python runtime system
|
// with the Python runtime system
|
||||||
(void)new UnitTestModule;
|
PyObject* mod = TestGui::initModule();
|
||||||
|
|
||||||
Base::Console().Log("Loading GUI of Test module... done\n");
|
Base::Console().Log("Loading GUI of Test module... done\n");
|
||||||
|
|
||||||
// add resources and reloads the translators
|
// add resources and reloads the translators
|
||||||
loadTestResource();
|
loadTestResource();
|
||||||
return;
|
PyMOD_Return(mod);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <Base/Console.h>
|
#include <Base/Console.h>
|
||||||
|
#include <Base/PyObjectBase.h>
|
||||||
|
|
||||||
#include <CXX/Extensions.hxx>
|
#include <CXX/Extensions.hxx>
|
||||||
#include <CXX/Objects.hxx>
|
#include <CXX/Objects.hxx>
|
||||||
|
@ -99,7 +100,7 @@ private:
|
||||||
quint16 p = server->serverPort();
|
quint16 p = server->serverPort();
|
||||||
Py::Tuple t(2);
|
Py::Tuple t(2);
|
||||||
t.setItem(0, Py::String((const char*)a.toLatin1()));
|
t.setItem(0, Py::String((const char*)a.toLatin1()));
|
||||||
t.setItem(1, Py::Int(p));
|
t.setItem(1, Py::Long(p));
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -125,15 +126,22 @@ private:
|
||||||
return Py::None();
|
return Py::None();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
PyObject* initModule()
|
||||||
|
{
|
||||||
|
return (new Module())->module().ptr();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Web
|
} // namespace Web
|
||||||
|
|
||||||
|
|
||||||
/* Python entry */
|
/* Python entry */
|
||||||
PyMODINIT_FUNC initWeb() {
|
PyMOD_INIT_FUNC(Web) {
|
||||||
|
|
||||||
// ADD YOUR CODE HERE
|
// ADD YOUR CODE HERE
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
new Web::Module();
|
PyObject* mod = Web::initModule();
|
||||||
Base::Console().Log("Loading Web module... done\n");
|
Base::Console().Log("Loading Web module... done\n");
|
||||||
|
PyMOD_Return(mod);
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,6 +100,12 @@ private:
|
||||||
return Py::None();
|
return Py::None();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
PyObject* initModule()
|
||||||
|
{
|
||||||
|
return (new Module())->module().ptr();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace WebGui
|
} // namespace WebGui
|
||||||
|
|
||||||
|
|
||||||
|
@ -108,10 +114,10 @@ PyMODINIT_FUNC initWebGui()
|
||||||
{
|
{
|
||||||
if (!Gui::Application::Instance) {
|
if (!Gui::Application::Instance) {
|
||||||
PyErr_SetString(PyExc_ImportError, "Cannot load Gui module in console application.");
|
PyErr_SetString(PyExc_ImportError, "Cannot load Gui module in console application.");
|
||||||
return;
|
PyMOD_Return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
new WebGui::Module();
|
PyObject* mod = WebGui::initModule();
|
||||||
Base::Console().Log("Loading GUI of Web module... done\n");
|
Base::Console().Log("Loading GUI of Web module... done\n");
|
||||||
|
|
||||||
// instantiating the commands
|
// instantiating the commands
|
||||||
|
@ -120,4 +126,6 @@ PyMODINIT_FUNC initWebGui()
|
||||||
|
|
||||||
// add resources and reloads the translators
|
// add resources and reloads the translators
|
||||||
loadWebResource();
|
loadWebResource();
|
||||||
|
|
||||||
|
PyMOD_Return(mod);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <Base/Console.h>
|
#include <Base/Console.h>
|
||||||
|
#include <Base/PyObjectBase.h>
|
||||||
|
|
||||||
#include <CXX/Extensions.hxx>
|
#include <CXX/Extensions.hxx>
|
||||||
#include <CXX/Objects.hxx>
|
#include <CXX/Objects.hxx>
|
||||||
|
@ -45,15 +46,23 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
PyObject* initModule()
|
||||||
|
{
|
||||||
|
return (new Module)->module().ptr();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace _TEMPLATE_
|
} // namespace _TEMPLATE_
|
||||||
|
|
||||||
|
|
||||||
/* Python entry */
|
/* Python entry */
|
||||||
PyMODINIT_FUNC init_TEMPLATE_() {
|
PyMOD_INIT_FUNC(_TEMPLATE_)
|
||||||
|
{
|
||||||
// ADD YOUR CODE HERE
|
// ADD YOUR CODE HERE
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
new _TEMPLATE_::Module();
|
PyObject* mod = _TEMPLATE_::initModule();
|
||||||
Base::Console().Log("Loading _TEMPLATE_ module... done\n");
|
Base::Console().Log("Loading _TEMPLATE_ module... done\n");
|
||||||
|
PyMOD_Return(mod);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <Base/Console.h>
|
#include <Base/Console.h>
|
||||||
|
#include <Base/PyObjectBase.h>
|
||||||
#include <Gui/Application.h>
|
#include <Gui/Application.h>
|
||||||
|
|
||||||
#include "Workbench.h"
|
#include "Workbench.h"
|
||||||
|
@ -51,15 +52,21 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
PyObject* initModule()
|
||||||
|
{
|
||||||
|
return (new Module)->module().ptr();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace _TEMPLATE_Gui
|
} // namespace _TEMPLATE_Gui
|
||||||
|
|
||||||
|
|
||||||
/* Python entry */
|
/* Python entry */
|
||||||
PyMODINIT_FUNC init_TEMPLATE_Gui()
|
PyMOD_INIT_FUNC(_TEMPLATE_Gui)
|
||||||
{
|
{
|
||||||
if (!Gui::Application::Instance) {
|
if (!Gui::Application::Instance) {
|
||||||
PyErr_SetString(PyExc_ImportError, "Cannot load Gui module in console application.");
|
PyErr_SetString(PyExc_ImportError, "Cannot load Gui module in console application.");
|
||||||
return;
|
PyMOD_Return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// instanciating the commands
|
// instanciating the commands
|
||||||
|
@ -69,6 +76,7 @@ PyMODINIT_FUNC init_TEMPLATE_Gui()
|
||||||
// ADD YOUR CODE HERE
|
// ADD YOUR CODE HERE
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
new _TEMPLATE_Gui::Module();
|
PyObject* mod = _TEMPLATE_Gui::initModule();
|
||||||
Base::Console().Log("Loading GUI of _TEMPLATE_ module... done\n");
|
Base::Console().Log("Loading GUI of _TEMPLATE_ module... done\n");
|
||||||
|
PyMOD_Return(mod);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user