Re: python/comedi

> Just to be clear, the current version in CVS (comedilib/swig/ruby) is 
> not the original you provided (comedilib/python). Frank and I made 
> several updates to it, including marking parameters as OUTPUT or INOUT 
> as noted.

Yup, my mistake. I clearly didn't check the latest CVS version. Sorry
for the confusion. People are best off using this version and ignoring
my previous posts.

The current CVS version is in comedilib/swig/ and looks like it should
work for Python as well as Ruby.

>  I couldn't make the Ruby interfaces work without those 
> changes, and I couldn't imagine how the Python interfaces would work 
> without them.

Well, almost everything except comedi_read_data_XXX worked fine :) (I
wasn't using these functions at the time, so didn't notice the problem).

> I also did a few things to sweeten the Ruby interface a little. The same 
> thing is applicable in principle to Python, although the mechanism will 
> be different. (I don't know much Python.) The key is to note that SWIG 
> puts comedilib into a module (Comedi) and also preserves the 'comedi_' 
> prefix on every function. Neither prefix is necessary to disambiguate 
> instance methods of classes in module Comedi.
 ... snip ...
> 
> module Comedi
>    class SWIG::TYPE_p_comedi_t
>      def command_test(*args)
>        comedi_command_test(self, *args)
>       end
>    end
> end

How about doing this using the SWIG %rename directive: In the comedi.i
file include:

%rename(command_test) comedi_command_test;
... and so on for each function ...

This way swig takes care of the renaming and it works for all wrapping
languages.

> I also added some stuff to raise Ruby exceptions. The general idea is to 
> make the API idiomatic in Ruby, as the original is in C. (The C-like API 
> is still there in Ruby.)

SWIG can also do exceptions but I've not investigated this aspect
further. 

cheers,
Bryan


-- 
Bryan Cole
Teraview Ltd., 302-304 Cambridge Science Park, Milton Road, Cambridge CB4 0WG, United Kingdom.
tel: +44 (1223) 435380 / 435386 (direct-dial) fax: +44 (1223) 435382

Received on 2004-03-24Z10:58:20