removed stray spaces
This commit is contained in:
parent
384c81d85a
commit
6496e71026
1 changed files with 98 additions and 105 deletions
|
@ -133,7 +133,7 @@ telldus_tdLastSentValue(PyObject *self, PyObject *args)
|
||||||
long id;
|
long id;
|
||||||
char* value;
|
char* value;
|
||||||
char* retval;
|
char* retval;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "l", &id))
|
if (!PyArg_ParseTuple(args, "l", &id))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ telldus_tdGetErrorString(PyObject *self, PyObject *args)
|
||||||
long errorno;
|
long errorno;
|
||||||
char* errorString;
|
char* errorString;
|
||||||
char* retval;
|
char* retval;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "l", &errorno))
|
if (!PyArg_ParseTuple(args, "l", &errorno))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ telldus_tdGetName(PyObject *self, PyObject *args)
|
||||||
long id;
|
long id;
|
||||||
char* name;
|
char* name;
|
||||||
char* retval;
|
char* retval;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "l", &id))
|
if (!PyArg_ParseTuple(args, "l", &id))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -208,7 +208,7 @@ telldus_tdSetName(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
long id;
|
long id;
|
||||||
char* name;
|
char* name;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "ls", &id, &name))
|
if (!PyArg_ParseTuple(args, "ls", &id, &name))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -221,7 +221,7 @@ telldus_tdGetProtocol(PyObject *self, PyObject *args)
|
||||||
long id;
|
long id;
|
||||||
char* protocol;
|
char* protocol;
|
||||||
char* retval;
|
char* retval;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "l", &id))
|
if (!PyArg_ParseTuple(args, "l", &id))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -236,7 +236,7 @@ telldus_tdSetProtocol(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
long id;
|
long id;
|
||||||
char* protocol;
|
char* protocol;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "ls", &id, &protocol))
|
if (!PyArg_ParseTuple(args, "ls", &id, &protocol))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -250,7 +250,7 @@ telldus_tdGetModel(PyObject *self, PyObject *args)
|
||||||
long id;
|
long id;
|
||||||
char* model;
|
char* model;
|
||||||
char* retval;
|
char* retval;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "l", &id))
|
if (!PyArg_ParseTuple(args, "l", &id))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -265,7 +265,7 @@ telldus_tdSetModel(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
long id;
|
long id;
|
||||||
char* model;
|
char* model;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "ls", &id, &model))
|
if (!PyArg_ParseTuple(args, "ls", &id, &model))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -281,7 +281,7 @@ telldus_tdGetDeviceParameter(PyObject *self, PyObject *args)
|
||||||
char* defaultValue;
|
char* defaultValue;
|
||||||
char* param;
|
char* param;
|
||||||
char* retval;
|
char* retval;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "lss", &id, &name, &defaultValue))
|
if (!PyArg_ParseTuple(args, "lss", &id, &name, &defaultValue))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -297,7 +297,7 @@ telldus_tdSetDeviceParameter(PyObject *self, PyObject *args)
|
||||||
long id;
|
long id;
|
||||||
char* name;
|
char* name;
|
||||||
char* value;
|
char* value;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "lss", &id, &name, &value))
|
if (!PyArg_ParseTuple(args, "lss", &id, &name, &value))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -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
|
|
||||||
arglist = Py_BuildValue("llsl", deviceId, method, data, callbackId);
|
|
||||||
|
|
||||||
// now call the Python callback function
|
// now call the Python callback function
|
||||||
result = PyEval_CallObject(pyfunc, arglist);
|
result = PyObject_CallFunction(pyfunc, "llsl", deviceId, method, data, callbackId);
|
||||||
|
|
||||||
if (result == NULL) {
|
if (result == NULL) {
|
||||||
// something went wrong so print to stderr
|
// something went wrong so print to stderr
|
||||||
PyErr_Print();
|
PyErr_Print();
|
||||||
}
|
}
|
||||||
|
|
||||||
// take care of reference handling
|
// take care of reference handling
|
||||||
Py_DECREF(arglist);
|
Py_XDECREF(result);
|
||||||
Py_XDECREF(result);
|
|
||||||
|
PyGILState_Release(gstate);
|
||||||
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
|
|
||||||
arglist = Py_BuildValue("llll", deviceId, changeEvent, changeType, callbackId);
|
|
||||||
|
|
||||||
// now call the Python callback function
|
// now call the Python callback function
|
||||||
result = PyEval_CallObject(pyfunc, arglist);
|
result = PyObject_CallFunction(pyfunc, "llll", deviceId, changeEvent, changeType, callbackId);
|
||||||
|
|
||||||
if (result == NULL) {
|
if (result == NULL) {
|
||||||
// something went wrong so print to stderr
|
// something went wrong so print to stderr
|
||||||
PyErr_Print();
|
PyErr_Print();
|
||||||
}
|
}
|
||||||
|
|
||||||
// take care of reference handling
|
// take care of reference handling
|
||||||
Py_DECREF(arglist);
|
Py_XDECREF(result);
|
||||||
Py_XDECREF(result);
|
|
||||||
|
PyGILState_Release(gstate);
|
||||||
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
|
|
||||||
arglist = Py_BuildValue("sll", data, controllerId, callbackId);
|
|
||||||
|
|
||||||
// now call the Python callback function
|
// now call the Python callback function
|
||||||
result = PyEval_CallObject(pyfunc, arglist);
|
result = PyObject_CallFunction(pyfunc, "sll", data, controllerId, callbackId);
|
||||||
|
|
||||||
if (result == NULL) {
|
if (result == NULL) {
|
||||||
// something went wrong so print to stderr
|
// something went wrong so print to stderr
|
||||||
PyErr_Print();
|
PyErr_Print();
|
||||||
}
|
}
|
||||||
|
|
||||||
// take care of reference handling
|
// take care of reference handling
|
||||||
Py_DECREF(arglist);
|
Py_XDECREF(result);
|
||||||
Py_XDECREF(result);
|
|
||||||
|
PyGILState_Release(gstate);
|
||||||
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
|
|
||||||
arglist = Py_BuildValue("ssllsll", protocol, model, id, dataType, value, timestamp, callbackId);
|
|
||||||
|
|
||||||
// now call the Python callback function
|
// now call the Python callback function
|
||||||
result = PyEval_CallObject(pyfunc, arglist);
|
result = PyObject_CallFunction(pyfunc, "ssllsll", protocol, model, id, dataType, value, timestamp, callbackId);
|
||||||
|
|
||||||
if (result == NULL) {
|
if (result == NULL) {
|
||||||
// something went wrong so print to stderr
|
// something went wrong so print to stderr
|
||||||
PyErr_Print();
|
PyErr_Print();
|
||||||
}
|
}
|
||||||
|
|
||||||
// take care of reference handling
|
// take care of reference handling
|
||||||
Py_DECREF(arglist);
|
Py_XDECREF(result);
|
||||||
Py_XDECREF(result);
|
|
||||||
|
PyGILState_Release(gstate);
|
||||||
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 *
|
||||||
|
@ -483,8 +470,11 @@ telldus_tdRegisterRawDeviceEvent(PyObject *self, PyObject *args)
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "O", &func));
|
if (!PyArg_ParseTuple(args, "O", &func));
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
// stick around till we need you
|
||||||
|
Py_INCREF(func);
|
||||||
|
|
||||||
return PyLong_FromLong((long) tdRegisterRawDeviceEvent((TDRawDeviceEvent) telldus_rawDeviceEventCallback, &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."},
|
||||||
|
@ -534,7 +527,7 @@ static PyMethodDef telldus_methods[] = {
|
||||||
{"tdRegisterDeviceChangeEvent", (PyCFunction) telldus_tdRegisterDeviceChangeEvent, METH_VARARGS, "RegisterDeviceChangeEvent comment."},
|
{"tdRegisterDeviceChangeEvent", (PyCFunction) telldus_tdRegisterDeviceChangeEvent, METH_VARARGS, "RegisterDeviceChangeEvent comment."},
|
||||||
{"tdRegisterRawDeviceEvent", (PyCFunction) telldus_tdRegisterRawDeviceEvent, METH_VARARGS, "RegisterRawDeviceEvent comment."},
|
{"tdRegisterRawDeviceEvent", (PyCFunction) telldus_tdRegisterRawDeviceEvent, METH_VARARGS, "RegisterRawDeviceEvent comment."},
|
||||||
{"tdRegisterSensorEvent", (PyCFunction) telldus_tdRegisterSensorEvent, METH_VARARGS, "RegisterSensorEvent comment."},
|
{"tdRegisterSensorEvent", (PyCFunction) telldus_tdRegisterSensorEvent, METH_VARARGS, "RegisterSensorEvent comment."},
|
||||||
|
|
||||||
*/
|
*/
|
||||||
{NULL, NULL, 0, NULL} /* sentinel */
|
{NULL, NULL, 0, NULL} /* sentinel */
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue