comp.lang.ada
 help / color / mirror / Atom feed
From: stt@houdini.camb.inmet.com (Tucker Taft)
Subject: Re: win32ada design question/problem
Date: 1998/11/16
Date: 1998-11-16T00:00:00+00:00	[thread overview]
Message-ID: <F2J8Bw.5yn.0.-s@inmet.camb.inmet.com> (raw)
In-Reply-To: ubtm7cxj0.fsf@gsfc.nasa.gov

Stephen Leake (Stephen.Leake@gsfc.nasa.gov) wrote:
: dennison@telepath.com writes:

: > In article <364C5EDE.4F402D13@elca-matrix.ch>,
: >   Mats.Weber@elca-matrix.ch wrote:
: > > I just had a look at the win32ada binding and found that I could not use
: > > it as I would like. Lets take this function as an example:
: > >
: > > >     function WriteFile(hFile                 : Win32.Winnt.HANDLE;
: > > >                        lpBuffer              : Win32.LPCVOID;
: > > >                        nNumberOfBytesToWrite : Win32.DWORD;
: > > >                        lpNumberOfBytesWritten: Win32.LPDWORD;
: > > >                        lpOverlapped          : Win32.Winbase.LPOVERLAPPED)
: > > >                                                return Win32.BOOL;
: > (snip)
: > > Of course I can use 'Unchecked_Access to circumvent this, but then I
: > > don't think that the binding is well designed if it requires
: > > 'Unchecked_Access all over the place in code that uses it.
: > 
: > It wasn't designed at all. (by Ada folk, anway) Its a *thin* binding. If you
: > want something that doesn't require unchecked programming to use, then you
: > want a thick binding.

: While I agree it wasn't well designed, I don't agree you need to go to
: a thick binding. The binding should use 'out' parameter modes in the
: places where C uses pointers to achieve output parameters. Most
: compilers will map an 'out' parameter to a C pointer, since that's
: what 'by reference' means.

The real problem was that the Win32 API was big enough that it
wasn't feasible to do the binding by hand.  Furthermore, even
if doing it by hand, you have to know what each pointer parameter
"means."  That isn't always obvious from just the C spec,
and becoming an expert in all of these interfaces is
a big job.  For example, representing a C pointer parameter as an Ada 
'out' or 'in out' parameter is inappropriate if the C pointer is allowed
to be null.  In fact, it was the allowance for null which forced
the use of named, rather than anonymous, access types in several
places.

In any case, if someone has the time and energy to produce a 
well-thought-out thin binding, all power to you.  The Win32 binding
we produced was done using a tool, and it reflects the limitations
of the information present in a C prototype.

: -- Stephe

--
-Tucker Taft   stt@inmet.com   http://www.inmet.com/~stt/
Intermetrics, Inc.  Burlington, MA  USA
An AverStar Company




  reply	other threads:[~1998-11-16  0:00 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-11-13  0:00 win32ada design question/problem Mats Weber
1998-11-13  0:00 ` dennison
1998-11-16  0:00   ` Stephen Leake
1998-11-16  0:00     ` Tucker Taft [this message]
1998-11-17  0:00     ` dennison
1998-11-17  0:00       ` Mats Weber
1998-11-17  0:00         ` dennison
1998-11-17  0:00           ` Mats Weber
1998-11-17  0:00           ` Tucker Taft
1998-11-18  0:00             ` Tom Moran
1998-11-18  0:00               ` dennison
1998-11-13  0:00 ` Tom Moran
1998-11-16  0:00   ` Mats Weber
1998-11-18  0:00     ` Tom Moran
1998-11-18  0:00       ` dennison
1998-11-19  0:00       ` Mats Weber
1998-11-19  0:00         ` dennison
1998-11-19  0:00           ` David Botton
1998-11-19  0:00         ` David Botton
1998-11-19  0:00           ` Mats Weber
1998-11-23  0:00             ` Marin David Condic
1998-11-19  0:00       ` Mats Weber
1998-11-27  0:00     ` Roga Danar
  -- strict thread matches above, loose matches on Subject: below --
1998-11-19  0:00 tmoran
1998-11-19  0:00 ` dennison
1998-11-19  0:00   ` Tom Moran
1998-11-20  0:00     ` dennison
1998-11-20  0:00       ` Tom Moran
1998-11-23  0:00     ` Marin David Condic
1998-11-23  0:00       ` Mats Weber
1998-11-24  0:00         ` dennison
replies disabled

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