From 3fe8e6baac051d80906c6fac6c18c04c8df9ce4a Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Mon, 20 Dec 2010 14:50:21 +0000 Subject: [PATCH] Add sampl_t and lsampl_t array_class()es to comedi.i. This makes it easier (possible?) to setup comedi_insn_struct and comedi_cmd_struct instances. Patch from W. Trevor King. --- swig/comedi.i | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/swig/comedi.i b/swig/comedi.i index 5819975..5da6160 100644 --- a/swig/comedi.i +++ b/swig/comedi.i @@ -55,8 +55,6 @@ static unsigned int cr_aref(unsigned int a){ } %} -%array_class(unsigned int, chanlist); - #ifdef SWIGRUBY %typemap(argout) comedi_cmd *INOUT(VALUE info) { $result = output_helper($result, $arg); @@ -66,3 +64,19 @@ 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); -- 2.26.2