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
|
/* Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 */
/* For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt */
#include "util.h"
#include "tracer.h"
#include "filedisp.h"
/* Module definition */
#define MODULE_DOC PyDoc_STR("Fast coverage tracer.")
static PyModuleDef
moduledef = {
PyModuleDef_HEAD_INIT,
"coverage.tracer",
MODULE_DOC,
-1,
NULL, /* methods */
NULL,
NULL, /* traverse */
NULL, /* clear */
NULL
};
PyObject *
PyInit_tracer(void)
{
PyObject * mod = PyModule_Create(&moduledef);
if (mod == NULL) {
return NULL;
}
#ifdef Py_GIL_DISABLED
PyUnstable_Module_SetGIL(mod, Py_MOD_GIL_NOT_USED);
#endif
if (CTracer_intern_strings() < 0) {
return NULL;
}
/* Initialize CTracer */
CTracerType.tp_new = PyType_GenericNew;
if (PyType_Ready(&CTracerType) < 0) {
Py_DECREF(mod);
return NULL;
}
Py_INCREF(&CTracerType);
if (PyModule_AddObject(mod, "CTracer", (PyObject *)&CTracerType) < 0) {
Py_DECREF(mod);
Py_DECREF(&CTracerType);
return NULL;
}
/* Initialize CFileDisposition */
CFileDispositionType.tp_new = PyType_GenericNew;
if (PyType_Ready(&CFileDispositionType) < 0) {
Py_DECREF(mod);
Py_DECREF(&CTracerType);
return NULL;
}
Py_INCREF(&CFileDispositionType);
if (PyModule_AddObject(mod, "CFileDisposition", (PyObject *)&CFileDispositionType) < 0) {
Py_DECREF(mod);
Py_DECREF(&CTracerType);
Py_DECREF(&CFileDispositionType);
return NULL;
}
return mod;
}
|