removed stray spaces

This commit is contained in:
Øyvind Saltvik 2012-08-07 14:25:13 +02:00
parent 384c81d85a
commit 6496e71026

View file

@ -334,124 +334,105 @@ telldus_tdSendRawCommand(PyObject *self, PyObject *args)
}
/*
Work in progress event callbacks
Work in progress event callbacks
*/
/*
void
telldus_deviceEventCallback(int deviceId, int method, const char *data, int callbackId, void *pyfunc)
{
PyObject * arglist;
PyObject * result;
PyGILState_STATE gstate;
PyObject * arglist;
PyObject * result;
PyGILState_STATE gstate;
gstate = PyGILState_Ensure();
gstate = PyGILState_Ensure();
// prepare the arg list to pass into the Python callback function
arglist = Py_BuildValue("llsl", deviceId, method, data, callbackId);
// now call the Python callback function
result = PyObject_CallFunction(pyfunc, "llsl", deviceId, method, data, callbackId);
// now call the Python callback function
result = PyEval_CallObject(pyfunc, arglist);
if (result == NULL) {
// something went wrong so print to stderr
PyErr_Print();
}
if (result == NULL) {
// something went wrong so print to stderr
PyErr_Print();
}
// take care of reference handling
Py_XDECREF(result);
// take care of reference handling
Py_DECREF(arglist);
Py_XDECREF(result);
PyGILState_Release(gstate);
PyGILState_Release(gstate);
return;
return;
}
void
telldus_deviceChangeEventCallback(int deviceId, int changeEvent, int changeType, int callbackId, void *pyfunc)
{
PyObject * arglist;
PyObject * result;
PyGILState_STATE gstate;
PyObject * result;
PyGILState_STATE gstate;
gstate = PyGILState_Ensure();
gstate = PyGILState_Ensure();
// prepare the arg list to pass into the Python callback function
arglist = Py_BuildValue("llll", deviceId, changeEvent, changeType, callbackId);
// now call the Python callback function
result = PyObject_CallFunction(pyfunc, "llll", deviceId, changeEvent, changeType, callbackId);
// now call the Python callback function
result = PyEval_CallObject(pyfunc, arglist);
if (result == NULL) {
// something went wrong so print to stderr
PyErr_Print();
}
if (result == NULL) {
// something went wrong so print to stderr
PyErr_Print();
}
// take care of reference handling
Py_XDECREF(result);
// take care of reference handling
Py_DECREF(arglist);
Py_XDECREF(result);
PyGILState_Release(gstate);
PyGILState_Release(gstate);
return;
return;
}
void
telldus_rawDeviceEventCallback(const char *data, int controllerId, int callbackId, void *pyfunc)
{
PyObject * arglist;
PyObject * result;
PyGILState_STATE gstate;
PyObject * result;
PyGILState_STATE gstate;
gstate = PyGILState_Ensure();
gstate = PyGILState_Ensure();
// prepare the arg list to pass into the Python callback function
arglist = Py_BuildValue("sll", data, controllerId, callbackId);
// now call the Python callback function
result = PyObject_CallFunction(pyfunc, "sll", data, controllerId, callbackId);
// now call the Python callback function
result = PyEval_CallObject(pyfunc, arglist);
if (result == NULL) {
// something went wrong so print to stderr
PyErr_Print();
}
if (result == NULL) {
// something went wrong so print to stderr
PyErr_Print();
}
// take care of reference handling
Py_XDECREF(result);
// take care of reference handling
Py_DECREF(arglist);
Py_XDECREF(result);
PyGILState_Release(gstate);
PyGILState_Release(gstate);
return;
return;
}
void
telldus_sensorEventCallback(const char *protocol, const char *model, int id, int dataType, const char *value, int timestamp, int callbackId, void *pyfunc)
{
PyObject * arglist;
PyObject * result;
PyGILState_STATE gstate;
PyObject * result;
PyGILState_STATE gstate;
gstate = PyGILState_Ensure();
gstate = PyGILState_Ensure();
// prepare the arg list to pass into the Python callback function
arglist = Py_BuildValue("ssllsll", protocol, model, id, dataType, value, timestamp, callbackId);
// now call the Python callback function
result = PyObject_CallFunction(pyfunc, "ssllsll", protocol, model, id, dataType, value, timestamp, callbackId);
// now call the Python callback function
result = PyEval_CallObject(pyfunc, arglist);
if (result == NULL) {
// something went wrong so print to stderr
PyErr_Print();
}
if (result == NULL) {
// something went wrong so print to stderr
PyErr_Print();
}
// take care of reference handling
Py_XDECREF(result);
// take care of reference handling
Py_DECREF(arglist);
Py_XDECREF(result);
PyGILState_Release(gstate);
PyGILState_Release(gstate);
return;
return;
}
static PyObject *
@ -462,7 +443,10 @@ telldus_tdRegisterDeviceEvent(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "O", &func));
return NULL;
return PyLong_FromLong((long) tdRegisterDeviceEvent((TDDeviceEvent) telldus_deviceEventCallback, &func));
// stick around till we need you
Py_INCREF(func);
return PyLong_FromLong((long) tdRegisterDeviceEvent((TDDeviceEvent) telldus_deviceEventCallback, &func));
}
static PyObject *
@ -473,7 +457,10 @@ telldus_tdRegisterDeviceChangeEvent(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "O", &func));
return NULL;
return PyLong_FromLong((long) tdRegisterDeviceChangeEvent((TDDeviceChangeEvent) telldus_deviceChangeEventCallback, &func));
// stick around till we need you
Py_INCREF(func);
return PyLong_FromLong((long) tdRegisterDeviceChangeEvent((TDDeviceChangeEvent) telldus_deviceChangeEventCallback, &func));
}
static PyObject *
@ -484,7 +471,10 @@ telldus_tdRegisterRawDeviceEvent(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "O", &func));
return NULL;
return PyLong_FromLong((long) tdRegisterRawDeviceEvent((TDRawDeviceEvent) telldus_rawDeviceEventCallback, &func));
// stick around till we need you
Py_INCREF(func);
return PyLong_FromLong((long) tdRegisterRawDeviceEvent((TDRawDeviceEvent) telldus_rawDeviceEventCallback, &func));
}
static PyObject *
@ -495,15 +485,18 @@ telldus_tdRegisterSensorEvent(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "O", &func));
return NULL;
return PyLong_FromLong((long) tdRegisterSensorEvent((TDSensorEvent) telldus_sensorEventCallback, &func));
// stick around till we need you
Py_INCREF(func);
return PyLong_FromLong((long) tdRegisterSensorEvent((TDSensorEvent) telldus_sensorEventCallback, &func));
}
*/
static PyMethodDef telldus_methods[] = {
/* The cast of the function is necessary since PyCFunction values
* only take two PyObject* parameters, and keywdarg_parrot() takes
* three.
*/
* only take two PyObject* parameters, and keywdarg_parrot() takes
* three.
*/
{"tdInit", (PyCFunction) telldus_tdInit, METH_NOARGS, "Initiate telldus."},
{"tdClose", (PyCFunction) telldus_tdClose, METH_NOARGS, "Close telldus."},
{"tdTurnOn", (PyCFunction) telldus_tdTurnOn, METH_VARARGS, "Turn on device."},