+ simplify porting of MeshPart module to Python3
This commit is contained in:
@@ -26,6 +26,9 @@
|
||||
# include <Python.h>
|
||||
#endif
|
||||
|
||||
#include <CXX/Extensions.hxx>
|
||||
#include <CXX/Objects.hxx>
|
||||
|
||||
#include <Base/Console.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Language/Translator.h>
|
||||
@@ -41,20 +44,37 @@ void loadMeshPartResource()
|
||||
Gui::Translator::instance()->refresh();
|
||||
}
|
||||
|
||||
/* registration table */
|
||||
extern struct PyMethodDef MeshPartGui_Import_methods[];
|
||||
namespace MeshPartGui {
|
||||
class Module : public Py::ExtensionModule<Module>
|
||||
{
|
||||
public:
|
||||
Module() : Py::ExtensionModule<Module>("MeshPartGui")
|
||||
{
|
||||
initialize("This module is the MeshPartGui module."); // register with Python
|
||||
}
|
||||
|
||||
virtual ~Module() {}
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
PyObject* initModule()
|
||||
{
|
||||
return (new Module)->module().ptr();
|
||||
}
|
||||
|
||||
} // namespace MeshPartGui
|
||||
|
||||
|
||||
/* Python entry */
|
||||
extern "C" {
|
||||
void MeshPartGuiExport initMeshPartGui()
|
||||
PyMODINIT_FUNC initMeshPartGui()
|
||||
{
|
||||
if (!Gui::Application::Instance) {
|
||||
PyErr_SetString(PyExc_ImportError, "Cannot load Gui module in console application.");
|
||||
return;
|
||||
}
|
||||
|
||||
(void) Py_InitModule("MeshPartGui", MeshPartGui_Import_methods); /* mod name, table ptr */
|
||||
(void)MeshPartGui::initModule();
|
||||
Base::Console().Log("Loading GUI of MeshPart module... done\n");
|
||||
|
||||
// instantiating the commands
|
||||
@@ -64,5 +84,3 @@ void MeshPartGuiExport initMeshPartGui()
|
||||
// add resources and reloads the translators
|
||||
loadMeshPartResource();
|
||||
}
|
||||
|
||||
} // extern "C" {
|
||||
|
||||
Reference in New Issue
Block a user