Re: C to Ada




Brian May wrote:
Are there any up-to-date utilities for converting a C *.h file into a
Ada wrapper package?

You might try the prototype SWIG 'ada' and 'gnat' modules.

These attempt to generate Ada bindings to both C and C++ libraries.
The 'ada' module is for any Ada compiler, and produces bindings based
on a 'proxy' approach. The 'gnat' compiler targets the GNAT family of
compilers, and produces Ada types and objects which are the binary
equivalent of their corresponding C/C++ types.


I don't care if it requires cleaning up by hand afterwords.

The generated bindings are pretty rough, and generally need to be
'pretty print' formatted, by gnatpp or another tool. There are also
many style 'warts', which should eventually be cleared up.



Or is it considered better to write the entire wrapper by hand?

Bindings done by hand tend to be better than the auto-generated
ones. SWIG produces very thin bindings. A decent compromise is to use
SWIG to build a thin binding, and then write a thick binding by hand,
on top of the thin.



(considering a number of C libraries that I would like to be able to
access from Ada here but with no native Ada bindings yet).

There is an example of a few SWIG 'gnat' bindings to the GNU
Scientific Library (GSL) at

svn co svn://58.163.88.116/anvil/gsl



SWIG with the 'ada' & 'gnat' modules is available via

svn co
https://svn.sourceforge.net/svnroot/gnuada/trunk/projects/swig-1.3.29


The repository code is a little out of date, but recent changes
should be committed within the next few days.



regards.

.



Relevant Pages

  • swig news (C++/Ada binding generator)
    ... commits to the GnuAda repository at ... Two SWIG modules now exist for Ada support; ... generated bindings themselves can stand a great deal of improvement. ...
    (comp.lang.ada)
  • Re: wxWindows binding
    ... >Is there an Ada wxWindows binding? ... My GNAT Ada 95 bindings to wxWindows are now here: ...
    (comp.lang.ada)
  • Re: SWIG backend for Ada
    ... >> project for Ada and Ada users! ... One of the big lacks of Ada is a fully operative tool like SWIG. ... There is a Felix bindings generator discussed on the mailing list, ...
    (comp.lang.ada)
  • Re: Extending discriminant types
    ... Because the poster states that he can compiler the code. ... I used Gnat 3.15p using Ada 95 specs. ... type Child is new KBase with null record; ...
    (comp.lang.ada)
  • Re: GNAT GPL 2005 Edition is now available
    ... I oppose Debian moving to any Ada compiler which generates ... code that has serious license restrictions. ... Why should GNAT be any different? ... Will there be *any* compilers available for Ada 2005 suitable ...
    (comp.lang.ada)