From: W. Trevor King Date: Tue, 13 Mar 2012 12:31:36 +0000 (-0400) Subject: Add an `insn_array` array_class to `comedi.i`. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=1fe137aa2444e65ce1a6c848dc6cddaebc08d349;p=comedilib.git Add an `insn_array` array_class to `comedi.i`. This makes it possible to populate `comedi_insnslist_struct` for use with `comedi_do_insnlist`. I also removed my earlier re-typedefs of `sampl_array` and `lsampl_array`. I didn't understand the reason for the underlying `TypeError` when I added them. The proper way to avoid that error is to use the `.cast()` and `.frompointer()` methods. See `demo/python/insn.py` (coming soon) for details. --- diff --git a/swig/comedi.i b/swig/comedi.i index 5da6160..d9df4cb 100644 --- a/swig/comedi.i +++ b/swig/comedi.i @@ -64,19 +64,7 @@ static unsigned int cr_aref(unsigned int a){ %include "comedi.h" %include "comedilib.h" -/* These typedefs work around limitations in SWIG's array_class(). - * Without them, you get errors like: - * >>> import comedi - * >>> cmd = comedi.comedi_cmd_struct() - * >>> data = comedi.sampl_array(3) - * >>> cmd.data = data - * Traceback (most recent call last): - * ... - * TypeError: in method 'comedi_cmd_struct_data_set', argument 2 of type 'sampl_t *' - */ -typedef unsigned short sampl_array; -typedef unsigned int lsampl_array; - %array_class(unsigned int, chanlist); %array_class(sampl_t, sampl_array); %array_class(lsampl_t, lsampl_array); +%array_class(comedi_insn, insn_array);