python: Add override for Context.create_logic_packet()

This commit is contained in:
Martin Ling 2018-12-27 20:38:06 +01:00 committed by Uwe Hermann
parent 6f7e15090e
commit 62bd644f55
1 changed files with 18 additions and 0 deletions

View File

@ -568,5 +568,23 @@ std::map<std::string, Glib::VariantBase> dict_to_map_options(PyObject *dict,
}
}
/* Create logic packet from Python buffer. */
%extend sigrok::Context
{
std::shared_ptr<Packet> _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"