Browse Source

release() on module_free()

AllGroupDevicesShowHandshake
Volker Birk 6 years ago
parent
commit
1e2fa5e10f
2 changed files with 34 additions and 15 deletions
  1. +8
    -2
      src/pEpmodule.cc
  2. +26
    -13
      src/pEpmodule.hh

+ 8
- 2
src/pEpmodule.cc View File

@ -1,5 +1,4 @@
#include "pEpmodule.hh"
#include <pEp/pEpEngine.h>
#include <string>
namespace pEp {
@ -13,14 +12,21 @@ namespace pEp {
return PyUnicode_FromString(version.c_str());
}
}
void module_free(void *)
{
release(session);
}
}
using namespace pEp;
PyMODINIT_FUNC PyInit_pEp(void)
{
PEP_SESSION session;
PEP_STATUS status = init(&session);
if (status != PEP_STATUS_OK)
return NULL;
return PyModule_Create(&pEpmodule);
}

+ 26
- 13
src/pEpmodule.hh View File

@ -1,4 +1,5 @@
#include <Python.h>
#include <pEp/pEpEngine.h>
namespace pEp {
namespace PythonAdapter {
@ -6,20 +7,32 @@ namespace pEp {
PyObject *about(PyObject *self, PyObject *args);
}
}
static PyMethodDef pEpMethods[] = {
{"about", pEp::PythonAdapter::about, METH_VARARGS, "about p≡p"},
{NULL, NULL, 0, NULL}
};
static struct PyModuleDef pEpmodule = {
PyModuleDef_HEAD_INIT,
"pEp",
NULL,
-1,
pEpMethods
};
void module_free(void *);
struct module_state {
PEP_SESSION session;
};
struct PyMethodDef pEpMethods[] = {
{"about", pEp::PythonAdapter::about, METH_VARARGS, "about p≡p"},
{NULL, NULL, 0, NULL}
};
struct PyModuleDef pEpmodule = {
PyModuleDef_HEAD_INIT,
"pEp",
"p≡p Python adapter",
-1,
pEpMethods,
NULL,
NULL,
NULL,
pEp::module_free
};
PEP_SESSION session;
}
PyMODINIT_FUNC PyInit_pEp(void);

Loading…
Cancel
Save