46 lines
984 B
C++
46 lines
984 B
C++
|
|
#include <Python.h>
|
|
#include "array_wrapper.h"
|
|
#include "range_wrapper.h"
|
|
|
|
using namespace CNORXZ;
|
|
|
|
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,
|
|
cnorxz_core_methods
|
|
};
|
|
|
|
PyMODINIT_FUNC PyInit_cnorxz()
|
|
{
|
|
PyObject* m;
|
|
|
|
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;
|
|
}
|
|
|
|
Py_INCREF(cxarray_type);
|
|
Py_INCREF(cxrange_type);
|
|
|
|
PyModule_AddObject(m, "Array", (PyObject*) cxarray_type);
|
|
PyModule_AddObject(m, "Range", (PyObject*) cxrange_type);
|
|
|
|
return m;
|
|
}
|