-#include "sigrokdecode.h" /* First, so we avoid a _POSIX_C_SOURCE warning. */
-#include "sigrokdecode-internal.h"
+#include "libsigrokdecode.h" /* First, so we avoid a _POSIX_C_SOURCE warning. */
+#include "libsigrokdecode-internal.h"
-static int convert_pyobj(struct srd_decoder_inst *di, PyObject *obj,
- int *ann_format, char ***ann)
+static int convert_annotation(struct srd_decoder_inst *di, PyObject *obj,
+ struct srd_proto_data *pdata)
if (!PyList_Check(obj) && !PyTuple_Check(obj)) {
srd_err("Protocol decoder %s submitted %s instead of list.",
di->decoder->name, obj->ob_type->tp_name);
return SRD_ERR_PYTHON;
}
if (!PyList_Check(obj) && !PyTuple_Check(obj)) {
srd_err("Protocol decoder %s submitted %s instead of list.",
di->decoder->name, obj->ob_type->tp_name);
return SRD_ERR_PYTHON;
}
if (PyList_Size(obj) != 2) {
srd_err("Protocol decoder %s submitted annotation list with "
"%d elements instead of 2", di->decoder->name,
if (PyList_Size(obj) != 2) {
srd_err("Protocol decoder %s submitted annotation list with "
"%d elements instead of 2", di->decoder->name,
-
- ann_id = PyLong_AsLong(py_tmp);
- if (!(pdo = g_slist_nth_data(di->decoder->annotations, ann_id))) {
+ ann_format = PyLong_AsLong(py_tmp);
+ if (!(pdo = g_slist_nth_data(di->decoder->annotations, ann_format))) {
py_tmp = PyList_GetItem(obj, 1);
if (!PyList_Check(py_tmp)) {
srd_err("Protocol decoder %s submitted annotation list, but "
"second element was not a list.", di->decoder->name);
return SRD_ERR_PYTHON;
}
py_tmp = PyList_GetItem(obj, 1);
if (!PyList_Check(py_tmp)) {
srd_err("Protocol decoder %s submitted annotation list, but "
"second element was not a list.", di->decoder->name);
return SRD_ERR_PYTHON;
}
srd_err("Protocol decoder %s submitted annotation list, but "
"second element was malformed.", di->decoder->name);
return SRD_ERR_PYTHON;
}
srd_err("Protocol decoder %s submitted annotation list, but "
"second element was malformed.", di->decoder->name);
return SRD_ERR_PYTHON;
}
struct srd_decoder_inst *di, *next_di;
struct srd_pd_output *pdo;
struct srd_proto_data *pdata;
uint64_t start_sample, end_sample;
int output_id;
struct srd_decoder_inst *di, *next_di;
struct srd_pd_output *pdo;
struct srd_proto_data *pdata;
uint64_t start_sample, end_sample;
int output_id;
}
if (!PyArg_ParseTuple(args, "KKiO", &start_sample, &end_sample,
}
if (!PyArg_ParseTuple(args, "KKiO", &start_sample, &end_sample,
/*
* This throws an exception, but by returning NULL here we let
* Python raise it. This results in a much better trace in
/*
* This throws an exception, but by returning NULL here we let
* Python raise it. This results in a much better trace in
- if (convert_pyobj(di, data, &pdata->ann_format,
- (char ***)&pdata->data) != SRD_OK) {
+ if (convert_annotation(di, py_data, pdata) != SRD_OK) {
Py_XINCREF(next_di->py_inst);
srd_spew("Sending %d-%d to instance %s",
start_sample, end_sample,
next_di->inst_id);
if (!(py_res = PyObject_CallMethod(
next_di->py_inst, "decode", "KKO", start_sample,
Py_XINCREF(next_di->py_inst);
srd_spew("Sending %d-%d to instance %s",
start_sample, end_sample,
next_di->inst_id);
if (!(py_res = PyObject_CallMethod(
next_di->py_inst, "decode", "KKO", start_sample,
- end_sample, data))) {
- catch_exception("calling %s decode(): ",
- next_di->inst_id);
+ end_sample, py_data))) {
+ srd_exception_catch("Calling %s decode(): ",
+ next_di->inst_id);
SRD_PRIV PyTypeObject srd_Decoder_type = {
PyVarObject_HEAD_INIT(NULL, 0)
.tp_name = "sigrokdecode.Decoder",
.tp_basicsize = sizeof(srd_Decoder),
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
SRD_PRIV PyTypeObject srd_Decoder_type = {
PyVarObject_HEAD_INIT(NULL, 0)
.tp_name = "sigrokdecode.Decoder",
.tp_basicsize = sizeof(srd_Decoder),
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,