-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbinding.cpp
More file actions
111 lines (86 loc) · 3.73 KB
/
binding.cpp
File metadata and controls
111 lines (86 loc) · 3.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#include "Python.h"
#define _USE_MATH_DEFINES
#include "math.h"
#include <algorithm>
#include "binding_radardata.h"
#include "binding_radardataholder.h"
#include "binding_other.h"
static PyMethodDef pyMethods[] = {
{"test", test, METH_VARARGS,"test"},
{"radarDataAllocate", radarDataAllocate, METH_VARARGS, ""},
{"radarDataDeallocate", radarDataDeallocate, METH_VARARGS, ""},
{"radarDataLoadFile", radarDataLoadFile, METH_VARARGS, ""},
{"radarDataUpdateProperties", radarDataUpdateProperties, METH_VARARGS, ""},
{"radarDataGetStats", radarDataGetStats, METH_VARARGS, ""},
{"radarDataGetSweepInfo", radarDataGetSweepInfo, METH_VARARGS, ""},
{"radarDataRadarSpaceForLocation", radarDataRadarSpaceForLocation, METH_VARARGS, ""},
{"radarDataGetPixelForRadarSpace", radarDataGetPixelForRadarSpace, METH_VARARGS, ""},
{"radarDataHolderAllocate", radarDataHolderAllocate, METH_VARARGS, ""},
{"radarDataHolderDeallocate", radarDataHolderDeallocate, METH_VARARGS, ""},
{"radarDataHolderLoad", radarDataHolderLoad, METH_VARARGS, ""},
{"radarDataHolderUnload", radarDataHolderUnload, METH_VARARGS, ""},
{"radarDataHolderGetState", radarDataHolderGetState, METH_VARARGS, ""},
{"radarDataHolderGetProduct", radarDataHolderGetProduct, METH_VARARGS, ""},
{"radarDataHolderProductGetRadarData", radarDataHolderProductGetRadarData, METH_VARARGS, ""},
{"radarDataHolderProductIsLoaded", radarDataHolderProductIsLoaded, METH_VARARGS, ""},
{"radarDataHolderProductStartUsing", radarDataHolderProductStartUsing, METH_VARARGS, ""},
{"radarDataHolderProductStopUsing", radarDataHolderProductStopUsing, METH_VARARGS, ""},
{"recompressNexradArchive", recompressNexradArchive, METH_VARARGS, ""},
{NULL, NULL, 0, NULL} /* Sentinel */
};
static int moduleExec(PyObject *module) {
// Populate module with functions, constants, etc.
PyModule_AddFunctions(module, pyMethods);
RadarBufferObject_Type.tp_name = "openstorm_radar_native.RadarBufferType";
RadarBufferObject_Type.tp_basicsize = sizeof(RadarBufferObject);
RadarBufferObject_Type.tp_doc = PyDoc_STR("Radar Buffer Data");
RadarBufferObject_Type.tp_new = PyType_GenericNew;
RadarBufferObject_Type.tp_as_buffer = &RadarBuffer_BufferProcs;
RadarBufferObject_Type.tp_itemsize = 0;
//RadarBufferObject_Type.tp_dealloc = (destructor)myobj_dealloc,
//RadarBufferObject_Type.tp_repr = (reprfunc)myobj_repr,
RadarBufferObject_Type.tp_flags = Py_TPFLAGS_DEFAULT;
if (PyType_Ready(&RadarBufferObject_Type) < 0)
return NULL;
if(PyModule_AddObjectRef(module, "RadarBufferType", (PyObject *) &RadarBufferObject_Type) < 0) {
return NULL;
}
return 0; // Success
}
static PyModuleDef_Slot moduleSlots[] = {
{Py_mod_exec, (void*)moduleExec},
#ifdef POSSIBLY_FREE_THREADED
{Py_mod_gil, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
#endif
{0, NULL} // Sentinel
};
static struct PyModuleDef pyModule = {
PyModuleDef_HEAD_INIT,
"openstorm_radar_native", /* name of module */
NULL, /* module documentation, may be NULL */
0, /* size of per-interpreter state of the module,
or -1 if the module keeps state in global variables. */
NULL, // Methods
moduleSlots, // Slots
NULL, // Traverse
NULL, // Clear
NULL, // Free
};
PyMODINIT_FUNC
PyInit_openstorm_radar_native(void)
{
//printf("Initialized\n");
// Py_Initialize();
PyObject* m;
// m = PyModule_Create(&pyModule);
m = PyModuleDef_Init(&pyModule);
if (m == NULL)
return NULL;
// Py_INCREF(&RadarBufferObject_Type);
// if (PyModule_AddObject(m, "RadarBufferType", (PyObject *) &RadarBufferObject_Type) < 0) {
// Py_DECREF(&RadarBufferObject_Type);
// Py_DECREF(m);
// return NULL;
// }
return m;
}