comp.lang.ada
 help / color / mirror / Atom feed
* SWIG backend for Ada
@ 2004-10-23  9:58 Florian Weimer
  2004-10-23 11:23 ` Marius Amado Alves
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Florian Weimer @ 2004-10-23  9:58 UTC (permalink / raw)


Is anybody developing a SWIG backend which generates Ada code?



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: SWIG backend for Ada
  2004-10-23  9:58 SWIG backend for Ada Florian Weimer
@ 2004-10-23 11:23 ` Marius Amado Alves
  2004-10-23 11:36   ` Florian Weimer
  2004-10-23 13:37 ` Dr. Adrian Wrigley
  2004-10-23 18:42 ` Guillaume Foliard
  2 siblings, 1 reply; 7+ messages in thread
From: Marius Amado Alves @ 2004-10-23 11:23 UTC (permalink / raw)
  To: comp.lang.ada

Florian Weimer wrote:
> Is anybody developing a SWIG backend which generates Ada code?

"SWIG is an interface compiler that connects programs written in C and 
C++ with scripting languages such as Perl, Python, Ruby, and Tcl." 
(swig.org)

Just curious: on which side of SWIG do you picture Ada?




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: SWIG backend for Ada
  2004-10-23 11:23 ` Marius Amado Alves
@ 2004-10-23 11:36   ` Florian Weimer
  0 siblings, 0 replies; 7+ messages in thread
From: Florian Weimer @ 2004-10-23 11:36 UTC (permalink / raw)


* Marius Amado Alves:

> Florian Weimer wrote:
>> Is anybody developing a SWIG backend which generates Ada code?
>
> "SWIG is an interface compiler that connects programs written in C and 
> C++ with scripting languages such as Perl, Python, Ruby, and Tcl." 
> (swig.org)
>
> Just curious: on which side of SWIG do you picture Ada?

I'd like to generate Ada bindings to C and C++ code.  (The other
direction would be a frontend, I think.)



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: SWIG backend for Ada
  2004-10-23  9:58 SWIG backend for Ada Florian Weimer
  2004-10-23 11:23 ` Marius Amado Alves
@ 2004-10-23 13:37 ` Dr. Adrian Wrigley
  2004-10-25 10:04   ` Alex R. Mosteo
  2004-10-23 18:42 ` Guillaume Foliard
  2 siblings, 1 reply; 7+ messages in thread
From: Dr. Adrian Wrigley @ 2004-10-23 13:37 UTC (permalink / raw)


On Sat, 23 Oct 2004 11:58:40 +0200, Florian Weimer wrote:

> Is anybody developing a SWIG backend which generates Ada code?

I briefly looked at SWIG a couple of months ago, and thought it might
be interesting.  But then other things took precedence.

Now I look at it again, I think this would be a really excellent
project for Ada and Ada users!

The project could replace cbind/c2ada, which I think is ageing
somewhat, doesn't handle C++, and has some tricky dependencies (?)
The great thing is that the Ada community can benefit from the
open source work done by people on the frontend.  As I see it,
a lot of the hard work has already been done.

The Ada language interfaces seem very good when you first learn
about them, but when it comes to practical usage, it's a significant
problem keeping packages synchronised with .h C source files.
All the strong typing, error checking etc. goes out of the window
when the .h file is changed and the Ada specification no longer matches.

One day, I would like to see full integration of the Ada compiler
(eg in gnatmake, building .ads files) with C header files so you
can write something like:

with G_Lib_Top;
-- Provide Ada specification from system C header file:
-- gets subprogram declarations and type from glibtop.h
pragma Specification (C_Header, G_Lib_Top, "glibtop.h");

procedure Test is
   Var : glibtop; -- Gets record definition from C struct
begin
   GLibTop_Init; -- Call C interface
   GLibTop_Close;
end Test;

If I have some spare time, I'll have a closer look at the SWIG
distribution, and try to see how much work it would be.
-- 
Adrian Wrigley, Cambridge, UK




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: SWIG backend for Ada
  2004-10-23  9:58 SWIG backend for Ada Florian Weimer
  2004-10-23 11:23 ` Marius Amado Alves
  2004-10-23 13:37 ` Dr. Adrian Wrigley
@ 2004-10-23 18:42 ` Guillaume Foliard
  2 siblings, 0 replies; 7+ messages in thread
From: Guillaume Foliard @ 2004-10-23 18:42 UTC (permalink / raw)


Florian Weimer wrote:

> Is anybody developing a SWIG backend which generates Ada code?

I tried a few month ago. I've done very few. I've just added an empty Ada
module in the framework. I can dig my hard drive if you want.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: SWIG backend for Ada
  2004-10-23 13:37 ` Dr. Adrian Wrigley
@ 2004-10-25 10:04   ` Alex R. Mosteo
  2004-10-26  0:26     ` Dr. Adrian Wrigley
  0 siblings, 1 reply; 7+ messages in thread
From: Alex R. Mosteo @ 2004-10-25 10:04 UTC (permalink / raw)


Dr. Adrian Wrigley wrote:
> On Sat, 23 Oct 2004 11:58:40 +0200, Florian Weimer wrote:
> 
> 
>>Is anybody developing a SWIG backend which generates Ada code?
> 
> 
> I briefly looked at SWIG a couple of months ago, and thought it might
> be interesting.  But then other things took precedence.
> 
> Now I look at it again, I think this would be a really excellent
> project for Ada and Ada users!

Indeed. One of the big lacks of Ada is a fully operative tool like SWIG. 
If open source projects which use SWIG to provide python, java and other 
bindings start including Ada ones, coupled with the 3.4 gcc-ada, will 
significally increase Ada awareness.

> The project could replace cbind/c2ada, which I think is ageing
> somewhat, doesn't handle C++, and has some tricky dependencies (?)
> The great thing is that the Ada community can benefit from the
> open source work done by people on the frontend.  As I see it,
> a lot of the hard work has already been done.

All my tries at using c2ada have been unsuccesful. The first problem is 
obtaining the latest version, which seems not to be hosted anywhere. 
Last time I got it from a kind reader of this ngroup (Weimer?). After 
adjusting the makefiles (no autoconf), my gcc puked at the use of Bool 
as an enumeration element in the C code. I don't know if it is now a 
reserved word or what. I only know of the bool type in C++, but then it 
has been years since my last serious development in C/C++.

After modifying the above and compiling, everything I got were empty 
packages...

These difficulties are surely surmountable if you have the time. In my 
case it was a hobby project and I ended doing something else. What I 
mean is that the Interfaces.C packages aren't enough and something else 
would be a blessing for the casual users in need of some C library.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: SWIG backend for Ada
  2004-10-25 10:04   ` Alex R. Mosteo
@ 2004-10-26  0:26     ` Dr. Adrian Wrigley
  0 siblings, 0 replies; 7+ messages in thread
From: Dr. Adrian Wrigley @ 2004-10-26  0:26 UTC (permalink / raw)


On Mon, 25 Oct 2004 12:04:21 +0200, Alex R. Mosteo wrote:

> Dr. Adrian Wrigley wrote:
...
>> Now I look at it again, I think this would be a really excellent
>> project for Ada and Ada users!
> 
> Indeed. One of the big lacks of Ada is a fully operative tool like SWIG. 
> If open source projects which use SWIG to provide python, java and other 
> bindings start including Ada ones, coupled with the 3.4 gcc-ada, will 
> significally increase Ada awareness.

I see an Ada backend to SWIG as being another way of geting Ada
exposure closer the mainstream.  I think of the GtkAda and Glade UI
builder as bringing similar benefits.  We need tools and approaches
which integrate rather than alienate the mainstream.

> All my tries at using c2ada have been unsuccesful. The first problem is 
> obtaining the latest version, which seems not to be hosted anywhere. 

I didn't get very far myself either :(

I had a closer look at SWIG, and built myself a simple Ada binding
generator demo, based around the (obsolescent) 1.1p5 source.  It was very
simple to output correct function and procedure declarations, and
variables with appropriate pragma imports. But getting proper type
declarations, enumerations macro/functions and additional #includes looked
much more involved.

The 1.3 version is completely different - the project looks like
it has been rewritten mainly in C (from the original C++).

There is a Felix bindings generator discussed on the mailing list,
which looks like it is semanticly similar to an Ada specification.
Maybe this would be a good starting point?  There's also a
Modula3 interface generator, which might help (being another
compiled language with Pascal inspired syntax).

I suggested in my previous message that I'd like to see a thin bindings
generator as a standard part of the build process with Gnat.  It is
clear that this won't always be able to be completely automatic.
Somehow you need to work out which types and functions go into
which specifications when there are several header files each using
other header files, with some in common.  And then you need to
resolve the confusion in C between pointers, arrays, out and in
out parameters, and pass by reference.  But I think it can be done
well enough to beat the labour/bug intensive approach currently
necessitated.

At the moment, I only have time to dabble in projects like this, but
if I get inspired and make progress, I'll drop a note in this group!
-- 
Adrian




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2004-10-26  0:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-23  9:58 SWIG backend for Ada Florian Weimer
2004-10-23 11:23 ` Marius Amado Alves
2004-10-23 11:36   ` Florian Weimer
2004-10-23 13:37 ` Dr. Adrian Wrigley
2004-10-25 10:04   ` Alex R. Mosteo
2004-10-26  0:26     ` Dr. Adrian Wrigley
2004-10-23 18:42 ` Guillaume Foliard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox