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,1fb2c23b98beed60 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wn13feed!worldnet.att.net!164.128.36.58!news.ip-plus.net!newsfeed.ip-plus.net!news.post.ch!not-for-mail From: Martin Krischik Newsgroups: comp.lang.ada Subject: Re: Access to data indirection (newbie) Date: Tue, 27 Nov 2007 09:11:13 +0100 Organization: Swisscom IP+ (post doesn't reflect views of Swisscom) Message-ID: <474bd14a$1@news.post.ch> References: <1a812241-65fc-403a-927f-b2651b4107e3@s8g2000prg.googlegroups.com> NNTP-Posting-Host: 194.41.146.1 Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: atlas.ip-plus.net 1196151118 13055 194.41.146.1 (27 Nov 2007 08:11:58 GMT) X-Complaints-To: abuse@ip-plus.net NNTP-Posting-Date: Tue, 27 Nov 2007 08:11:58 +0000 (UTC) User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) In-Reply-To: <1a812241-65fc-403a-927f-b2651b4107e3@s8g2000prg.googlegroups.com> X-Original-NNTP-Posting-Host: w03duo.pnet.ch X-Original-Trace: 27 Nov 2007 09:11:54 +0200, w03duo.pnet.ch Xref: g2news1.google.com comp.lang.ada:18645 Date: 2007-11-27T09:11:13+01:00 List-Id: axtens schrieb: > G'day everyone > > I have a DLL which is receiving a value that is the result of a VARPTR > in VB6, so the value arriving is the address and the data desired can > be found at that address. > > So far I've gotten as far as > > function HandlePointer ( > Left : in Win32.LONG) > return Win32.LONG is > begin > > end HandlePointer; > > which is, of course, brain-dead. Fact is, though, so far as Ada is > concerned, I'm a newbie. > > So tell me, what's the syntax? > > Once you've figured that one out, tell me how I'd handle 'Left' > pointing to a record of two integers, such that I can access both > elements of the record. Your next step would be an Unchecked_Conversion: http://en.wikibooks.org/wiki/Ada_Programming/Type_System#Unchecked_conversion however - for my taste you are thinking to "Low-Level" and to "C-Like". In Ada one does not pass pointer or addresses as a pointer. Down that road lies sorrow not satisfaction. How about: type Options is (Long, Short, Whatever); type Var (Option : Options) is record case Option is Long => A_Long : Win32.LONG; Short => A_Short : Win32.SHORT; Whatever => A_Whatever_1 : Win32.LONG; A_Whatever_2 : Win32.LONG; end case; end record: pragma Unchecked_Union (Var); pragma Convention (C, Var); See: http://en.wikibooks.org/wiki/Ada_Programming/Types/record#Union type VarPtr is access all Var; pragma Convention (C, VarPtr); function HandlePointer ( Left : in VarPtr) return Win32.LONG is begin end HandlePointer; pragma Export (C, HandlePointer); or function HandlePointer ( Left : access Var) return Win32.LONG is begin end HandlePointer; pragma Export (C, HandlePointer); or function HandlePointer ( Left : in Var) return Win32.LONG is begin end HandlePointer; pragma Export (C, HandlePointer); The later might surprise you bout since the functions is declared "export c" "in Var" is passed as a pointer. Martin -- mailto://krischik@users.sourceforge.net Ada programming at: http://ada.krischik.com