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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,47957cb8c33729e5 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!newsread.com!newsprint.newsread.com!news-hog.berkeley.edu!ucberkeley!newshub.sdsu.edu!elnk-nf2-pas!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread1.news.pas.earthlink.net.POSTED!a6202946!not-for-mail From: Jeffrey Carter Organization: jrcarter commercial-at acm [period | full stop] org User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Thick Ada bindings to C Win32 References: <2vjnfbF2lioiaU1@uni-berlin.de> <1Ucld.25101$KJ6.2286@newsread1.news.pas.earthlink.net> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Fri, 26 Nov 2004 19:19:49 GMT NNTP-Posting-Host: 63.184.104.253 X-Complaints-To: abuse@earthlink.net X-Trace: newsread1.news.pas.earthlink.net 1101496789 63.184.104.253 (Fri, 26 Nov 2004 11:19:49 PST) NNTP-Posting-Date: Fri, 26 Nov 2004 11:19:49 PST Xref: g2news1.google.com comp.lang.ada:6519 Date: 2004-11-26T19:19:49+00:00 List-Id: Brian May wrote: >>>>>>"Jeffrey" == Jeffrey Carter writes: > > Jeffrey> Assuming that Lp[c?]void is a convention-C access type, > Jeffrey> you can safely convert between convention-C access types > Jeffrey> using Unchecked_Conversion. Your best bet may be to > Jeffrey> declare such an access type designating a Byte_Array > Jeffrey> (maybe you want Storage_Array here?), declare Item_Buffer > Jeffrey> aliased, store its 'Unchecked_Access in a variable of the > Jeffrey> appropriate type, and convert it to the Win32 access > Jeffrey> type. > > The most obvious problem is as soon as I make Item_Buffer aliased, I > need to make a complete copy of it. I don't see that a copy is necessary: type Buf_Ptr is access all Buffer; pragma Convention (C, Buf_Ptr); function To_Lpcvoid is new Ada.Unchecked_Conversion (Source => Buf_Ptr, Target => Win32.Lpcvoid); Item_Buffer : aliased Buffer ...; Ada_Ptr : Buf_Ptr := Buffer'Unchecked_Access; Win_Ptr : Win32.Lpcvoid := To_Lpcvoid (Ada_Ptr); and call the operation with Win_Ptr; > Maybe the best approach might be: > > function To_LPCVOID is new > Ada.Unchecked_Conversion (System.Address, Win32.LPCVOID); There's no guarantee that an Ada Address has the same representation as a convention-C access value. -- Jeff Carter "There's no messiah here. There's a mess all right, but no messiah." Monty Python's Life of Brian 84