]> sigrok.org Git - libsigrok.git/commitdiff
bindings/python: Add support for SR_T_MQ in Python bindings
authorvzuevskiy <redacted>
Mon, 8 Sep 2025 07:10:14 +0000 (10:10 +0300)
committerSoeren Apel <redacted>
Sun, 9 Nov 2025 21:50:12 +0000 (22:50 +0100)
bindings/python/sigrok/core/classes.i

index d22db1c150f2cca2f244bb12a16e904762590f4c..2e273c4752fb73c1628c8b4a151cdf2fe5a67dfa 100644 (file)
@@ -350,6 +350,18 @@ Glib::VariantBase python_to_variant_by_key(PyObject *input, const sigrok::Config
           return Glib::Variant< std::vector<guint64> >::create(v);
         }
     }
+    else if ((type == SR_T_MQ) && PyTuple_Check(input) && (PyTuple_Size(input) == 2)) {
+        PyObject *numObj = PyTuple_GetItem(input, 0);
+        PyObject *denomObj = PyTuple_GetItem(input, 1);
+        if ((PyInt_Check(numObj) || PyLong_Check(numObj)) && (PyInt_Check(denomObj) || PyLong_Check(denomObj))) {
+            return Glib::Variant<std::tuple<guint32, guint64>>::create(
+                std::make_tuple(
+                    (guint32)PyInt_AsLong(numObj),
+                    (guint64)PyInt_AsLong(denomObj)
+                )
+            );
+        }
+    }
     throw sigrok::Error(SR_ERR_ARG);
 }