+ simplify porting of Points module to Python3

This commit is contained in:
wmayer
2016-01-20 00:00:41 +01:00
parent 21504fc467
commit bb9bdb9548
3 changed files with 223 additions and 194 deletions

View File

@@ -25,6 +25,9 @@
#ifndef _PreComp_
#endif
#include <CXX/Extensions.hxx>
#include <CXX/Objects.hxx>
#include "ViewProvider.h"
#include "Workbench.h"
@@ -44,15 +47,25 @@ void loadPointsResource()
Gui::Translator::instance()->refresh();
}
namespace PointsGui {
class Module : public Py::ExtensionModule<Module>
{
public:
Module() : Py::ExtensionModule<Module>("PointsGui")
{
initialize("This module is the PointsGui module."); // register with Python
}
/* registration table */
static struct PyMethodDef PointsGui_methods[] = {
{NULL, NULL} /* end of table marker */
virtual ~Module() {}
private:
};
} // namespace PointsGui
/* Python entry */
extern "C" {
void PointsGuiExport initPointsGui()
PyMODINIT_FUNC initPointsGui()
{
if (!Gui::Application::Instance) {
PyErr_SetString(PyExc_ImportError, "Cannot load Gui module in console application.");
@@ -69,7 +82,7 @@ void PointsGuiExport initPointsGui()
}
Base::Console().Log("Loading GUI of Points module... done\n");
(void) Py_InitModule("PointsGui", PointsGui_methods); /* mod name, table ptr */
(void)new PointsGui::Module();
// instantiating the commands
CreatePointsCommands();
@@ -84,5 +97,3 @@ void PointsGuiExport initPointsGui()
// add resources and reloads the translators
loadPointsResource();
}
} // extern "C"