|
| 1 | +/* |
| 2 | + * MIT License |
| 3 | + * |
| 4 | + * Copyright (c) 2019-2020 Tskit Developers |
| 5 | + * Copyright (c) 2015-2018 University of Oxford |
| 6 | + * |
| 7 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 8 | + * of this software and associated documentation files (the "Software"), to deal |
| 9 | + * in the Software without restriction, including without limitation the rights |
| 10 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 11 | + * copies of the Software, and to permit persons to whom the Software is |
| 12 | + * furnished to do so, subject to the following conditions: |
| 13 | + * |
| 14 | + * The above copyright notice and this permission notice shall be included in all |
| 15 | + * copies or substantial portions of the Software. |
| 16 | + * |
| 17 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 18 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 20 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 21 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 22 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 23 | + * SOFTWARE. |
| 24 | + */ |
| 25 | +// Turn off clang-formatting for this file as turning off formatting |
| 26 | +// for specific bits will make it more confusing. |
| 27 | +// clang-format off |
| 28 | + |
| 29 | +#define PY_SSIZE_T_CLEAN |
| 30 | +#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION |
| 31 | + |
| 32 | +#include <Python.h> |
| 33 | +#include <structmember.h> |
| 34 | +#include <numpy/arrayobject.h> |
| 35 | + |
| 36 | +#include "kastore.h" |
| 37 | +#include "tskit.h" |
| 38 | + |
| 39 | +#include "tskit_lwt_interface.h" |
| 40 | + |
| 41 | +static PyMethodDef lwt_methods[] = { |
| 42 | + { NULL, NULL, 0, NULL } /* sentinel */ |
| 43 | +}; |
| 44 | + |
| 45 | +static struct PyModuleDef lwt_module = { |
| 46 | + .m_base = PyModuleDef_HEAD_INIT, |
| 47 | + .m_name = "_lwt", |
| 48 | + .m_doc = "tskit LightweightTableCollection", |
| 49 | + .m_size = -1, |
| 50 | + .m_methods = lwt_methods }; |
| 51 | + |
| 52 | +PyMODINIT_FUNC |
| 53 | +PyInit__lwtc(void) |
| 54 | +{ |
| 55 | + PyObject *module = PyModule_Create(&lwt_module); |
| 56 | + if (module == NULL) { |
| 57 | + return NULL; |
| 58 | + } |
| 59 | + import_array(); |
| 60 | + if (register_lwt_class(module) != 0) { |
| 61 | + return NULL; |
| 62 | + } |
| 63 | + return module; |
| 64 | +} |
0 commit comments