+ simplify porting of Image module to Python3

This commit is contained in:
wmayer
2016-01-21 12:27:12 +01:00
parent a5b6e5d48a
commit 85d8d70411
3 changed files with 69 additions and 48 deletions

View File

@@ -14,24 +14,41 @@
# include <Python.h>
#endif
#include <CXX/Extensions.hxx>
#include <CXX/Objects.hxx>
#include <Base/Console.h>
#include "ImagePlane.h"
/* registration table */
static struct PyMethodDef Image_methods[] = {
{NULL, NULL} /* end of table marker */
namespace Image {
class Module : public Py::ExtensionModule<Module>
{
public:
Module() : Py::ExtensionModule<Module>("Image")
{
initialize("This module is the Image module."); // register with Python
}
virtual ~Module() {}
private:
};
PyObject* initModule()
{
return (new Module)->module().ptr();
}
} // namespace Image
/* Python entry */
extern "C" {
void ImageExport initImage() {
(void) Py_InitModule("Image", Image_methods); /* mod name, table ptr */
PyMODINIT_FUNC initImage()
{
(void) Image::initModule();
Base::Console().Log("Loading Image module... done\n");
Image::ImagePlane::init();
return;
}
} // extern "C"