From: Martin Ling Date: Thu, 27 Dec 2018 19:38:06 +0000 (+0100) Subject: python: Add override for Context.create_logic_packet() X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=62bd644f55b674730957be4e3dcd3d3362148cfc;p=libsigrok.git python: Add override for Context.create_logic_packet() --- diff --git a/bindings/python/sigrok/core/classes.i b/bindings/python/sigrok/core/classes.i index 63a5143e..a00efff2 100644 --- a/bindings/python/sigrok/core/classes.i +++ b/bindings/python/sigrok/core/classes.i @@ -568,5 +568,23 @@ std::map dict_to_map_options(PyObject *dict, } } +/* Create logic packet from Python buffer. */ +%extend sigrok::Context +{ + std::shared_ptr _create_logic_packet_buf(PyObject *buf, unsigned int unit_size) + { + Py_buffer view; + PyObject_GetBuffer(buf, &view, PyBUF_SIMPLE); + return $self->create_logic_packet(view.buf, view.len, unit_size); + } +} + +%pythoncode +{ + def _Context_create_logic_packet(self, buf, unit_size): + return self._create_logic_packet_buf(buf, unit_size) + + Context.create_logic_packet = _Context_create_logic_packet +} %include "doc_end.i"