goto except_out;
if (!PyTuple_Check(py_annlist)) {
- srd_err("Protocol decoder %s annotations should "
- "be a tuple.", dec->name);
+ srd_err("Protocol decoder %s annotations should be a tuple.",
+ dec->name);
goto err_out;
}
goto except_out;
if (!PyTuple_Check(py_ann) || PyTuple_Size(py_ann) != 2) {
- srd_err("Protocol decoder %s annotation %zd should "
- "be a tuple with two elements.",
+ srd_err("Protocol decoder %s annotation %zd should be a tuple with two elements.",
dec->name, i + 1);
goto err_out;
}
/* Convert annotation_rows to GSList of 'struct srd_decoder_annotation_row'. */
static int get_annotation_rows(struct srd_decoder *dec)
{
+ const char *py_member_name = "annotation_rows";
+
PyObject *py_ann_rows, *py_ann_row, *py_ann_classes, *py_item;
GSList *annotation_rows;
struct srd_decoder_annotation_row *ann_row;
gstate = PyGILState_Ensure();
- if (!PyObject_HasAttrString(dec->py_dec, "annotation_rows")) {
+ if (!PyObject_HasAttrString(dec->py_dec, py_member_name)) {
PyGILState_Release(gstate);
return SRD_OK;
}
annotation_rows = NULL;
- py_ann_rows = PyObject_GetAttrString(dec->py_dec, "annotation_rows");
+ py_ann_rows = PyObject_GetAttrString(dec->py_dec, py_member_name);
if (!py_ann_rows)
goto except_out;
if (!PyTuple_Check(py_ann_rows)) {
- srd_err("Protocol decoder %s annotation_rows "
- "must be a tuple.", dec->name);
+ srd_err("Protocol decoder %s %s must be a tuple.",
+ dec->name, py_member_name);
goto err_out;
}
goto except_out;
if (!PyTuple_Check(py_ann_row) || PyTuple_Size(py_ann_row) != 3) {
- srd_err("Protocol decoder %s annotation_rows "
- "must contain only tuples of 3 elements.",
- dec->name);
+ srd_err("Protocol decoder %s %s must contain only tuples of 3 elements.",
+ dec->name, py_member_name);
goto err_out;
}
ann_row = g_malloc0(sizeof(struct srd_decoder_annotation_row));
goto except_out;
if (!PyTuple_Check(py_ann_classes)) {
- srd_err("Protocol decoder %s annotation_rows tuples "
- "must have a tuple of numbers as 3rd element.",
- dec->name);
+ srd_err("Protocol decoder %s %s tuples must have a tuple of numbers as 3rd element.",
+ dec->name, py_member_name);
goto err_out;
}
goto except_out;
if (!PyLong_Check(py_item)) {
- srd_err("Protocol decoder %s annotation row "
- "class tuple must only contain numbers.",
+ srd_err("Protocol decoder %s annotation row class tuple must only contain numbers.",
dec->name);
goto err_out;
}
/* Convert logic_output_channels to GSList of 'struct srd_decoder_logic_output_channel'. */
static int get_logic_output_channels(struct srd_decoder *dec)
{
- PyObject *py_logic_out_chs, *py_logic_out_ch, *py_samplerate, *py_item;
+ PyObject *py_logic_out_chs, *py_logic_out_ch, *py_item;
GSList *logic_out_chs;
struct srd_decoder_logic_output_channel *logic_out_ch;
ssize_t i;
if (!py_logic_out_ch)
goto except_out;
- if (!PyTuple_Check(py_logic_out_ch) || PyTuple_Size(py_logic_out_ch) != 3) {
+ if (!PyTuple_Check(py_logic_out_ch) || PyTuple_Size(py_logic_out_ch) != 2) {
srd_err("Protocol decoder %s logic_output_channels "
- "must contain only tuples of 3 elements.",
+ "must contain only tuples of 2 elements.",
dec->name);
goto err_out;
}
goto except_out;
if (py_str_as_str(py_item, &logic_out_ch->desc) != SRD_OK)
goto err_out;
-
- py_samplerate = PyTuple_GetItem(py_logic_out_ch, 2);
- if (!py_samplerate)
- goto except_out;
-
- if (!PyLong_Check(py_samplerate)) {
- srd_err("Protocol decoder %s logic_output_channels tuples "
- "must have a number as 3rd element.",
- dec->name);
- goto err_out;
- }
-
- logic_out_ch->samplerate = PyLong_AsUnsignedLongLong(py_samplerate);
}
dec->logic_output_channels = logic_out_chs;
Py_DECREF(py_logic_out_chs);