comp.lang.ada
 help / color / mirror / Atom feed
From: Natasha Kerensikova <lithiumcat@gmail.com>
Subject: Re: Dispatching callback handed over to C
Date: Tue, 3 Apr 2012 12:02:57 +0000 (UTC)
Date: 2012-04-03T12:02:57+00:00	[thread overview]
Message-ID: <slrnjnlpmo.1lme.lithiumcat@sigil.instinctive.eu> (raw)
In-Reply-To: 6fb83c74-b2a4-4ae8-9c89-d755b737198f@v22g2000vby.googlegroups.com

On 2012-04-03, Maciej Sobczak <see.my.homepage@gmail.com> wrote:
> On 3 Kwi, 09:19, Natasha Kerensikova <lithium...@gmail.com> wrote:
>
>> The problem I'm facing currently is binding to a very common idiom for
>> callback in C.
>
> [...]
>
> I had to solve this poblem in the context of the YAMI4 poject and I
> managed to get the essential parts of the solution here:
>
> http://inspirel.com/articles/Polymorphic_Callbacks_Ada_Cpp.html

Thanks a lot for the solution.

It turns out this is almost what my tentative solution looked like, the
only step I missed was to use System.Address to carry the data part,
instead of some access type.

But still, I can't help but think there is one needless subprogram call
in that solution. With a way to obtain the address of the actual
subprogram the dispatching call would dispatch to, the address could be
handed over to C code so that it can call it directly.

> The callback, as seen by Ada, is polymorphic (the user sees it as a
> dipatching call). The solution does not involve any compiler-specific
> magic any more than what could be expected, so should be quite
> portable.

Actually it uses the assumption that System.Address and void* have the
same representation.

I wonder how reliable the assumption is.



Thanks for your insights,
Natasha



  reply	other threads:[~2012-04-03 12:02 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-03  7:19 Dispatching callback handed over to C Natasha Kerensikova
2012-04-03  9:04 ` Brian Drummond
2012-04-03  9:21   ` Thomas Locke
2012-04-03  9:37 ` Maciej Sobczak
2012-04-03 12:02   ` Natasha Kerensikova [this message]
2012-04-03 14:42     ` Maciej Sobczak
2012-04-03 20:20       ` Randy Brukardt
2012-04-04  7:26         ` Georg Bauhaus
2012-04-04  7:56         ` Natasha Kerensikova
2012-04-04 19:28           ` Randy Brukardt
2012-04-05  8:59             ` Natasha Kerensikova
2012-04-05 21:04               ` Randy Brukardt
2012-04-04 19:55           ` Simon Wright
2012-04-04 11:34         ` Maciej Sobczak
2012-04-04 19:16           ` Randy Brukardt
2012-04-05  7:28             ` Maciej Sobczak
2012-04-05 21:32               ` Randy Brukardt
2012-04-07  8:55                 ` Natasha Kerensikova
2012-04-07 11:32                   ` Simon Wright
2012-04-07 13:28                     ` Robert A Duff
2012-04-05  9:13             ` Natasha Kerensikova
2012-04-05 21:06               ` Randy Brukardt
2012-04-06  7:30               ` Maciej Sobczak
2012-04-06 11:41                 ` Simon Wright
2012-04-10  7:15                   ` Maciej Sobczak
replies disabled

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