- /* Get the 'decode' function name as Python callable object. */
- py_func = PyObject_GetAttrString(py_mod, "decode"); /* NEWREF */
- if (!py_func || !PyCallable_Check(py_func)) {
+ return SRD_OK;
+}
+
+struct srd_decoder_instance *srd_instance_new(const char *id)
+{
+ struct srd_decoder *dec;
+ struct srd_decoder_instance *di;
+ PyObject *py_args, *py_value;
+
+ if (!(dec = srd_get_decoder_by_id(id)))
+ return NULL;
+
+ /* TODO: Error handling. Use g_try_malloc(). */
+ di = g_malloc(sizeof(*di));
+
+ /* Create an empty Python tuple. */
+ if (!(py_args = PyTuple_New(0))) { /* NEWREF */
+ if (PyErr_Occurred())
+ PyErr_Print(); /* Returns void. */
+
+ return NULL; /* TODO: More specific error? */
+ }
+
+ /*
+ * FIXME: Pass in a unitsize that matches the selected LA.
+ * FIXME: Fill 'starttime' with something reasonable.
+ */
+ py_value = Py_BuildValue("{sssisd}",
+ "driver", "demo",
+ "unitsize", _unitsize,
+ "starttime", 129318231823.0);
+
+ /* Create an instance of the 'Decoder' class. */
+ di->py_instance = PyObject_Call(dec->py_decobj, py_args, py_value);
+ if (!di->py_instance) {