comp.lang.ada
 help / color / mirror / Atom feed
From: tojst1+@pitt.edu (Tore Joergensen)
Subject: Re: GNAT, OS/2, Libraries
Date: 1996/04/11
Date: 1996-04-11T00:00:00+00:00	[thread overview]
Message-ID: <4khkr1$5bt@usenet.srv.cis.pitt.edu> (raw)
In-Reply-To: 4khbj7$hbq@fnnews.fnal.gov

Robert Morphis (morphis@fnalv1.fnal.gov) wrote:
: sigh, I ask a question and then get more confused.  I can guess what a
: binding is but a "thin binding"?  (why do I feel like I am way over my
: head? :)

An example:
   -- This function draws a section of the segment chain.

   function GpiDrawFrom(
      a_hps         : HPS;      -- Presentation-space handle
      lFirstSegment : LONG;     -- First segment to be drawn; it must be
                                -- greater than 0
      lLastSegment  : LONG)     -- Last segment to be drawn; it must be
                                -- greater than 0
   return
      BOOL;                     -- Success indicator (rc)
   pragma Import(
      Convention => C,
      Entity     => GpiDrawFrom,
      Link_Name  => "_GpiDrawFrom");

This was a thin binding. It gives minimum overhead (I'm not sure if it will
generate more code than the same call from a C-program or not), and doesn't
add any protection. A thick binding would probably change it into a 
procedure, and raise an exception if the C-call return 0 (false). It would 
use an Ada-type that protected against values of 0 or lower for the
parameters, or maybe change the parameters completely if that was more
appropriate. One call in a thick binding may result in several calls to
the thin binding. A thick binding may use a controlled type for something,
and use the thin binding's create and delete calls as Initialize and
Finalize. A thick binding involves code, while a thin binding just give you
a name and parameter-list so you can call it from within an Ada-program.
To put it simple, a thin binding gives you Ada functions and procedures that
feels like C-functions (if it is a C-library). A thick binding will give you
Ada look and feel :-).
-- 
+-------------------------+-------------------------------------------+
| Tore B. Joergensen      | e-mail : tore@lis.pitt.edu                |
| Centre Court Villa      | web    : http://www.pitt.edu/~tojst1      |
| 5535 Centre Avenue # 6  |                                           |
| Pgh, PA 15232, USA      | Norwegian MSIS-student at Univ. of Pgh.   |
+-------------------------+-------------------------------------------+




      reply	other threads:[~1996-04-11  0:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-04-10  0:00 GNAT, OS/2, Libraries morphis
1996-04-10  0:00 ` Dale Pontius
1996-04-10  0:00 ` Tore Joergensen
1996-04-10  0:00   ` morphis
1996-04-11  0:00     ` Tore Joergensen [this message]
replies disabled

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