move srd_Decoder to sigrokdecode.h, and rename it in line with srd_logic
[libsigrokdecode.git] / module_sigrokdecode.c
index a3872ab53a260d92efa65fdff17e8cb25a44df69..a18583bb5ea9b6ae33ebd1e17804f1f046540a15 100644 (file)
@@ -56,7 +56,7 @@ static int convert_pyobj(struct srd_decoder_instance *di, PyObject *obj,
        }
 
        ann_id = PyLong_AsLong(py_tmp);
        }
 
        ann_id = PyLong_AsLong(py_tmp);
-       if (!(pdo = g_slist_nth_data(di->decoder->annotation, ann_id))) {
+       if (!(pdo = g_slist_nth_data(di->decoder->annotations, ann_id))) {
                srd_err("Protocol decoder %s submitted data to non-existent annotation format %d",
                                di->decoder->name, ann_id);
                return SRD_ERR_PYTHON;
                srd_err("Protocol decoder %s submitted data to non-existent annotation format %d",
                                di->decoder->name, ann_id);
                return SRD_ERR_PYTHON;
@@ -187,23 +187,19 @@ static PyMethodDef Decoder_methods[] = {
 };
 
 
 };
 
 
-typedef struct {
-       PyObject_HEAD
-} sigrok_Decoder_object;
-
-static PyTypeObject srd_Decoder_type = {
+PyTypeObject srd_Decoder_type = {
        PyVarObject_HEAD_INIT(NULL, 0)
        .tp_name = "sigrokdecode.Decoder",
        PyVarObject_HEAD_INIT(NULL, 0)
        .tp_name = "sigrokdecode.Decoder",
-       .tp_basicsize = sizeof(sigrok_Decoder_object),
+       .tp_basicsize = sizeof(srd_Decoder),
        .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
        .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
-       .tp_doc = "Sigrok Decoder object",
+       .tp_doc = "Sigrok Decoder base class",
        .tp_methods = Decoder_methods,
 };
 
 static struct PyModuleDef sigrokdecode_module = {
        PyModuleDef_HEAD_INIT,
        .m_name = "sigrokdecode",
        .tp_methods = Decoder_methods,
 };
 
 static struct PyModuleDef sigrokdecode_module = {
        PyModuleDef_HEAD_INIT,
        .m_name = "sigrokdecode",
-       .m_doc = "sigrokdecode base class",
+       .m_doc = "sigrokdecode module",
        .m_size = -1,
        .m_methods = no_methods,
 };
        .m_size = -1,
        .m_methods = no_methods,
 };
@@ -230,13 +226,13 @@ PyMODINIT_FUNC PyInit_sigrokdecode(void)
                return NULL;
 
        /* expose output types as symbols in the sigrokdecode module */
                return NULL;
 
        /* expose output types as symbols in the sigrokdecode module */
-       if(PyModule_AddObject(mod, "SRD_OUTPUT_ANN",
+       if(PyModule_AddObject(mod, "OUTPUT_ANN",
                        PyLong_FromLong(SRD_OUTPUT_ANN)) == -1)
                return NULL;
                        PyLong_FromLong(SRD_OUTPUT_ANN)) == -1)
                return NULL;
-       if(PyModule_AddObject(mod, "SRD_OUTPUT_PROTO",
+       if(PyModule_AddObject(mod, "OUTPUT_PROTO",
                        PyLong_FromLong(SRD_OUTPUT_PROTO)) == -1)
                return NULL;
                        PyLong_FromLong(SRD_OUTPUT_PROTO)) == -1)
                return NULL;
-       if(PyModule_AddObject(mod, "SRD_OUTPUT_BINARY",
+       if(PyModule_AddObject(mod, "OUTPUT_BINARY",
                        PyLong_FromLong(SRD_OUTPUT_BINARY)) == -1)
                return NULL;
 
                        PyLong_FromLong(SRD_OUTPUT_BINARY)) == -1)
                return NULL;