[prev in list] [next in list] [prev in thread] [next in thread] 

List:       rpm-devel
Subject:    Re: [CVS] RPM: rpm-5_3: rpm/ CHANGES rpm/rpmio/ rpmruby.c
From:       Jeff Johnson <n3npq () mac ! com>
Date:       2010-09-20 14:45:32
Message-ID: BDF013D1-DC47-4116-A03D-554D505ED0A9 () mac ! com
[Download RAW message or body]


On Sep 20, 2010, at 10:14 AM, Eric MSP Veith wrote:
> 
> Ok, thought I'd better ask. I came to it because you mentioned automatic 
> generation.
> 

Well I mentioned automated doco generation rather than SWIG.

But I should separate my opinion from generally using SWIG; perhaps
someone can figure a way to use SWIG intelligently. I tried,
but my POV wrto RPM is rather differently uniquely specific to me.

Let me try to illustrate the SWIG issues with some examples:

libselinux uses SWIG (iirc) for python bindings. What is gained is
access to libselinux routines for doing development in python.
Python is certainly easier development than C, nothing wrong there at all.
The problem is that its common in C to return 0 on success, -1 on error.
OTOH, in python, with exceptions, the programming paradigm
for returns is often to return the same object (or nil)
so that nested functions can be used for a series of common operations.
While SWIG can certainly arrange for most any usage case, one ends
up with a complex recipe for automagic generation for lots of rather
simple getters/setters/creators/destructors. The code for all
of getters/setters/creators/destructors -- conformant with
the programmatic expectations -- usually isn't that hard
to generate directly, using cpp macros if needed.

For an alternative approach to SWIG, augeas python bindings use PYCpbject
to attach to the Augeas symbols in -laugeas. Augeas (unlike SELinux) has
an extremely well designed API, with ~10 methods of interest.
For Augeas, SWIG is overkill, and PYCobject wrappings are enough.
With languages that have -lffi, one can often call/return library
routines without the need for SWIG wrapper code generation. GPSEE
(and mozjs and other JS libraries) use -lffi rather than SWIG.

Subversion makes extensive use of SWIG, and it seems to Just Work.
But if you look at the SWIG wrappers, it appears (to me) that
there's some serious efforts that are/were involved in using
SWIG, the SWIG templates are quite complex/subtle/sophisticated/obscure.

For RPM, there's probably a usage case for SWIG for "bindings-lite".
I.e. most bindings want RDONLY access tags in headers from an rpmdb.
The methods involved are sufficiently simple that SWIG automation might
be a win because of the number of possible language bindings that
might be targeted.

73 de Jeff

______________________________________________________________________
RPM Package Manager                                    http://rpm5.org
Developer Communication List                        rpm-devel@rpm5.org
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic