+ simplify porting of Image module to Python3
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user