python-cnorxz/cnorxz/core/core.cpp

47 lines
984 B
C++
Raw Normal View History

#include <Python.h>
#include "array_wrapper.h"
2024-02-08 01:01:47 +01:00
#include "range_wrapper.h"
using namespace CNORXZ;
2024-04-02 20:23:08 +02:00
static PyMethodDef cnorxz_core_methods[] = {
{ "readFile", (PyCFunction) PyCxReadFile, METH_VARARGS| METH_KEYWORDS, "Read cnorxz-formatted file." },
{ NULL, NULL, 0, NULL }
};
static PyModuleDef cnorxz_core_module = {
PyModuleDef_HEAD_INIT,
"cnorxz",
"cnorxz core module",
-1,
2024-04-02 20:23:08 +02:00
cnorxz_core_methods
};
PyMODINIT_FUNC PyInit_cnorxz()
{
PyObject* m;
2024-02-08 01:01:47 +01:00
PyTypeObject* cxarray_type = PyCxArrayBType_init();
PyTypeObject* cxrange_type = PyCxRangeType_init();
if(cxarray_type == NULL){
return NULL;
}
if(cxrange_type == NULL){
return NULL;
}
m = PyModule_Create(&cnorxz_core_module);
if(m == NULL){
return NULL;
}
2024-02-08 01:01:47 +01:00
Py_INCREF(cxarray_type);
Py_INCREF(cxrange_type);
2024-02-08 01:01:47 +01:00
PyModule_AddObject(m, "Array", (PyObject*) cxarray_type);
PyModule_AddObject(m, "Range", (PyObject*) cxrange_type);
return m;
}