[OpenAFS] Re: building swig based interfaces

Andrew Deason adeason@sinenomine.net
Sun, 1 Sep 2013 17:08:50 -0500


On Sun, 01 Sep 2013 10:31:15 -0700
Russ Allbery <rra@stanford.edu> wrote:

> Gémes Géza <geza@kzsdabas.hu> writes:
> 
> > Okay, then should wrap around the command line tools then, in the
> > hope, that some day they will get rewritten to use a library I (or
> > someone else) can use? BTW. I'm fine wit it for now.

Note that this is basically how the existing AFS::Command Perl library
also works. Or at least, that was its intention; obviously it was never
ported to using a real C library, since it doesn't exist yet.

You may want to look at that for some guidance, if you want. It has some
useful extra functionality and workarounds for certain quirks and such.
Other libraries are useful to look at too, but I just mention that one
since I think it's one of the oldest.

> I think it's also worth noting that it's rather difficult to write
> high-quality bindings with SWIG, since SWIG forces the language into a
> C-like mode and doesn't give you enough flexibility to adjust the
> calling conventions to be more native to the language that you're
> binding.  By choosing to use SWIG instead of writing native bindings,
> you will limit the possible quality of the end result below where it
> could be, and it will be impossible to achieve the best quality
> without mostly throwing things out and starting again from scratch
> without SWIG.

But you can write a higher-level interface on top of the swig one, and
make it look more pythonic, ruby-like, perl-like, etc. In the above
framework, I could see swig replacing the command-line scraper, not the
entire module. 

-- 
Andrew Deason
adeason@sinenomine.net