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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,72137304956d9360 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-09-19 18:59:56 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!newshub.sdsu.edu!elnk-nf2-pas!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread4.news.pas.earthlink.net.POSTED!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: generic imports? void* -> generics? References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Sat, 20 Sep 2003 01:59:56 GMT NNTP-Posting-Host: 63.184.8.197 X-Complaints-To: abuse@earthlink.net X-Trace: newsread4.news.pas.earthlink.net 1064023196 63.184.8.197 (Fri, 19 Sep 2003 18:59:56 PDT) NNTP-Posting-Date: Fri, 19 Sep 2003 18:59:56 PDT Xref: archiver1.google.com comp.lang.ada:42707 Date: 2003-09-20T01:59:56+00:00 List-Id: Matthew Heaney wrote: > function To_Userdata > (L : lua_state_access; > Pos : Index) return Userdata is > > type Userdata_Access is access all Userdata; > for Userdata_Access'Storage_Size use 0; > pragma Convention (C, Userdata_Access); > > function lua_touserdata > (L : Lua_State_Access; > Pos : C.int) return Userdata_Access; --ok now > > pragma Import (C, lua_touserdata); You probably need to specify the C name: pragma Import (C, lua_touserdata, "lua_touserdata"); > pragma Convention (C, lua_touserdata); This is unnecessary. Import defines the convention. > > Result : constant Userdata_Access := > lua_touserdata(L, Pos); > begin > return Result.all; > end; Or just return Lua_Touserdata (L, Pos).all; This is probably the best way to implement it; I was going to suggest something along these lines until I saw this. Of course, this would be a generic, with type Userdata the generic formal. -- Jeff Carter "You've got the brain of a four-year-old boy, and I bet he was glad to get rid of it." Horse Feathers 47