From: Adam Beneschan <adambeneschan@gmail.com>
Subject: Re: How to import C pointers to structures?
Date: Mon, 19 May 2014 17:22:31 -0700 (PDT)
Date: 2014-05-19T17:22:31-07:00 [thread overview]
Message-ID: <146ca0d2-e2d1-49a3-bbdf-56b385db0bef@googlegroups.com> (raw)
In-Reply-To: <H3xev.1013245$ka5.998482@fx06.iad>
On Monday, May 19, 2014 5:10:14 PM UTC-7, Shark8 wrote:
> On 19-May-14 16:44, Adam Beneschan wrote:
>
> >> You generally *can't* do a real/meaningful import w/o knowing the
> >> layout.
>
> > I'm not sure that's quite true ... there are lots of situations
> > where you simply want to "pass through" a pointer, e.g. in
> > callback situations, where a function sets up a callback and says
> > "when you do the callback, please pass this pointer to it"; and
> > whoever registers the callback will take the pointer, store it
> > somewhere, and use it when it's needed, without ever trying to
> > look at what it points to.
>
> While those are /common/ cases, I would be hesitant to call them
> /general/ cases.
>
> > Unfortunately, I don't see the equivalent of "void *" anywhere in
> > Interfaces.C, which is what the sort of thing you'd want. You
> > could probably use Interfaces.C.Strings.chars_ptr (the equivalent
> > of "char *").
>
> Instantiate Interfaces.C.Pointers on a null-record or, perhaps,
> System.Address?
I wouldn't trust System.Address; there's no guarantee that the Ada implementation of this Ada type is represented the same way as a C pointer, an Ada access object, or anything else. The first idea, to instantiate Interfaces.C.Pointers, should be trustworthy--that's an excellent idea.
-- Adam
next prev parent reply other threads:[~2014-05-20 0:22 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-19 22:26 How to import C pointers to structures? Victor Porton
2014-05-19 22:33 ` Shark8
2014-05-19 22:44 ` Adam Beneschan
2014-05-20 0:10 ` Shark8
2014-05-20 0:22 ` Adam Beneschan [this message]
2014-05-20 6:36 ` Simon Wright
2014-05-20 8:29 ` björn lundin
2014-05-20 19:07 ` Per Sandberg
2014-05-22 13:37 ` Stephen Leake
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox