9 PyGILState_STATE gstate;
12 gstate = PyGILState_Ensure();
15 #if PY_VERSION_HEX >= 0x03000000 16 result = PyObject_CallFunction(pneum_callback,
"y#", data, len);
18 result = PyObject_CallFunction(pneum_callback,
"s#", data, len);
25 PyGILState_Release(gstate);
36 if (!PyArg_ParseTuple(args,
"sO:set_callback", &name, &temp))
39 if (!PyCallable_Check(temp)) {
40 PyErr_SetString(PyExc_TypeError,
"parameter must be callable");
45 Py_XDECREF(pneum_callback);
46 pneum_callback = temp;
48 Py_BEGIN_ALLOW_THREADS
51 return PyLong_FromLong(rv);
58 Py_BEGIN_ALLOW_THREADS
61 return PyLong_FromLong(rv);
69 if (!PyArg_ParseTuple(args,
"s#", &data, &len))
71 Py_BEGIN_ALLOW_THREADS
75 return PyLong_FromLong(rv);
86 Py_BEGIN_ALLOW_THREADS
90 if (rv != 0) { Py_RETURN_NONE; }
91 #if PY_VERSION_HEX >= 0x03000000 92 PyObject *ret = Py_BuildValue(
"y#", data, len);
94 PyObject *ret = Py_BuildValue(
"s#", data, len);
96 if (!ret) { Py_RETURN_NONE; }
103 {
"connect",
wrap_connect, METH_VARARGS,
"Connect to the VPP API."},
104 {
"disconnect",
wrap_disconnect, METH_VARARGS,
"Disconnect from the VPP API."},
105 {
"write",
wrap_write, METH_VARARGS,
"Write data to the VPP API."},
106 {
"read",
wrap_read, METH_VARARGS,
"Read data from the VPP API."},
110 #if PY_VERSION_HEX >= 0x03000000 112 PyInit_vpp_api (
void)
118 #if PY_VERSION_HEX >= 0x03000000 119 static struct PyModuleDef vpp_api_module = {
120 # if PY_VERSION_HEX >= 0x03020000 121 PyModuleDef_HEAD_INIT,
124 PyObject_HEAD_INIT(NULL)
142 if (!PyEval_ThreadsInitialized()) {
143 PyEval_InitThreads();
146 #if PY_VERSION_HEX >= 0x03000000 147 return PyModule_Create(&vpp_api_module);
149 Py_InitModule((
char *)
"vpp_api", vpp_api_Methods);
static PyObject * wrap_disconnect(PyObject *self, PyObject *args)
int pneum_read(char **p, int *l)
int pneum_disconnect(void)
void vl_msg_api_free(void *)
static PyObject * wrap_write(PyObject *self, PyObject *args)
static PyObject * wrap_read(PyObject *self, PyObject *args)
static PyMethodDef vpp_api_Methods[]
int pneum_connect(char *name)
static PyObject * pneum_callback
int pneum_write(char *p, int l)
int wrap_pneum_callback(char *data, int len)
static PyObject * wrap_connect(PyObject *self, PyObject *args)