From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,73975695cdfcb86f X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.202.168 with SMTP id kj8mr8975058pbc.1.1333445851433; Tue, 03 Apr 2012 02:37:31 -0700 (PDT) Path: r9ni13225pbh.0!nntp.google.com!news1.google.com!postnews.google.com!v22g2000vby.googlegroups.com!not-for-mail From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Re: Dispatching callback handed over to C Date: Tue, 3 Apr 2012 02:37:31 -0700 (PDT) Organization: http://groups.google.com Message-ID: <6fb83c74-b2a4-4ae8-9c89-d755b737198f@v22g2000vby.googlegroups.com> References: NNTP-Posting-Host: 213.77.7.66 Mime-Version: 1.0 X-Trace: posting.google.com 1333445851 10547 127.0.0.1 (3 Apr 2012 09:37:31 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 3 Apr 2012 09:37:31 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: v22g2000vby.googlegroups.com; posting-host=213.77.7.66; posting-account=bMuEOQoAAACUUr_ghL3RBIi5neBZ5w_S User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20100101 Firefox/11.0,gzip(gfe) Content-Type: text/plain; charset=ISO-8859-1 Date: 2012-04-03T02:37:31-07:00 List-Id: On 3 Kwi, 09:19, Natasha Kerensikova 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 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. Note that this article presents complete solution for Ada/C++ binding, but since there is a C intermediary layer involved anyway, you might consider it to be a Ada/C solution as well and use that part only if this is what you need. -- Maciej Sobczak * http://www.inspirel.com