comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pogner.demon.co.uk>
Subject: Re: Conversion of access types ...
Date: 1997/05/03
Date: 1997-05-03T00:00:00+00:00	[thread overview]
Message-ID: <x7vn2qcsbn8.fsf@pogner.demon.co.uk> (raw)
In-Reply-To: 5k64m8$jv4@taxis.corp.titan.com



t_mjb@linkabit.titan.com writes:

> type F is tagged record A: Integer; end record;
> type P is access all F;

> I am trying to convert a variable of type P to an unsigned long
> (ULONG) which will allow me to pass this value on to a system
> procedure which will, when the data finally arrives at its
> destination, will be converted back into type P.

I had a similar problem (calls to my own C procedures, actually, but
equivalent) and found that I could declare the C procedure using the
Ada access types with pragma Import:

  type Connection is abstract tagged limited private;
  type Connection_P is access all Connection'Class;
  ...
  type Handler is access procedure
     (Reason : Call_Reason;
      On_The_Connection : Peripherals.Connection_P);
  pragma Convention (C, Handler);
  function Connect (Name : Interfaces.C.Char_Array;
                    The_Handler : Handler;
		    The_Closure : Connection_P)
     return Interfaces.C.Int;
  pragma Import (C, Connect, "connect");

This all works fine on GNAT-3.09 (osf, solaris, linux) but of course
there may well be stuff I've failed to understand. For example, what
would happen if the pointers were fat? Should I have a pragma
Convention (C, Connection_P); ?

-- 
Simon Wright                        Work Email: simon.j.wright@gecm.com
GEC-Marconi Radar & Defence Systems            Voice: +44(0)1705-701778
Command & Information Systems Divsion            FAX: +44(0)1705-701800




  reply	other threads:[~1997-05-03  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-04-30  0:00 Conversion of access types t_mjb
1997-05-03  0:00 ` Simon Wright [this message]
1997-05-03  0:00   ` John G. Volan
replies disabled

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