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