From: "Dr. Adrian Wrigley" <amtw@linuxchip.demon.co.uk.uk.uk>
Subject: Re: C bindings, Interfaces.C.Pointers etc.
Date: Thu, 13 May 2004 16:26:57 +0100
Date: 2004-05-13T16:26:57+01:00 [thread overview]
Message-ID: <pan.2004.05.13.15.26.57.932055@linuxchip.demon.co.uk.uk.uk> (raw)
In-Reply-To: te9oc.16468$Hs1.1407@newsread2.news.pas.earthlink.net
On Tue, 11 May 2004 18:48:57 +0000, Jeffrey Carter wrote:
> -- struct node { int index; double value; };
> type Node_Info is record
> Index : Interfaces.C.Int;
> Value : Interfaces.C.Double;
> end record;
> pragma Convention (C, Node_Info);
>
> -- struct problem { node **x; };
> type Node_Ptr is access all Node_Info;
> pragma Convention (C, Node_Ptr);
> type Node_Ptr_Ptr is access all Node_Ptr;
> pragma Convention (C, Node_Ptr_Ptr);
> type Problem_Info is record
> X : Node_Ptr_Ptr;
> end record;
> pragma Convention (C, Problem_Info);
>
> This compiles fine. This is an exact duplicate of the C declarations. To
> deal with this using a higher level Ada abstraction, you'd wrap
> something around this to provide that abstraction.
I hadn't thought of doing this - it doesn't seem to provide easy answers
for allocation and indexing though. In this application, I am building
data structures for use by a C/C++ library. The wrapper you're
suggesting (I guess) is for accessing elements of the arrays,
and allocating/freeing them. I'd have to check that the additional
code didn't impose excessive overheads.
The solution I have adopted in the end is based on my idea (4),
mentioned by tmoran and Martin Chrischik (see other messages).
Thanks!
--
Adrian
next prev parent reply other threads:[~2004-05-13 15:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-05-11 13:14 C bindings, Interfaces.C.Pointers etc Dr. Adrian Wrigley
2004-05-11 18:17 ` tmoran
2004-05-11 18:48 ` Jeffrey Carter
2004-05-12 4:50 ` Simon Wright
2004-05-13 15:26 ` Dr. Adrian Wrigley [this message]
2004-05-12 6:30 ` Martin Krischik
2004-05-13 15:56 ` Dr. Adrian Wrigley
2004-05-13 17:37 ` Martin Krischik
2004-05-13 22:42 ` Jeffrey Carter
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox