From: "Nick Roberts" <nickroberts@blueyonder.co.uk>
Subject: Re: generic imports? void* -> generics?
Date: Fri, 19 Sep 2003 22:18:04 +0100
Date: 2003-09-19T22:18:04+01:00 [thread overview]
Message-ID: <bkfrqe$1de3s$1@ID-25716.news.uni-berlin.de> (raw)
In-Reply-To: FBIab.3309$DM5.35123@newsfep4-glfd.server.ntli.net
"chris" <spamoff.danx@ntlworld.com> wrote in message
news:FBIab.3309$DM5.35123@newsfep4-glfd.server.ntli.net...
> Should the following C code be mapped to a generic?
>
> void *lua_touserdata (Lua_State* L, int pos)
Not directly. I would suggest that you take the following approach.
package Stream_C_Pointers is new Interfaces.C.Pointers(
Index => Ada.Streams.Stream_Element_Offset,
Element => Ada.Streams.Stream_Element,
Element_Array => Ada.Streams.Stream_Element_Array );
subtype Stream_C_Pointer is Stream_C_Pointers.Pointer;
use Stream_C_Pointers;
function LUA_To_User_Data (State: access LUA_State;
Pos: Interfaces.C.int) returns
Stream_C_Pointer;
pragma Import(C,LUA_To_User_Data,"lua_touserdata");
The general idea is that Ada code is able to read a variable from the memory
area returned by this C function, interpreted as a stream array so that the
variable's stream-oriented Read procedure or Input function can be used
directly. There could well be difficulties associated with writing data
using C code and then reading it using (stream-oriented) Ada code.
You may well wish to wrap all this up in a package or a generic package, at
a higher level of organisation.
Hope this helps. I'd be happy to give more detail if you wish.
--
Nick Roberts
Jabber: debater@charente.de [ICQ: 159718630]
next prev parent reply other threads:[~2003-09-19 21:18 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-09-19 19:20 generic imports? void* -> generics? chris
2003-09-19 20:46 ` chris
2003-09-19 21:18 ` Nick Roberts [this message]
2003-09-19 23:12 ` chris
2003-09-20 16:52 ` Simon Wright
2003-09-22 21:30 ` Randy Brukardt
2003-09-23 5:45 ` Simon Wright
2003-09-23 19:07 ` Randy Brukardt
2003-09-23 20:28 ` Simon Wright
2003-09-24 18:16 ` Randy Brukardt
2003-09-19 22:40 ` Matthew Heaney
2003-09-19 23:01 ` chris
2003-09-20 1:59 ` Jeffrey Carter
2003-09-20 13:52 ` Matthew Heaney
2003-09-23 22:39 ` chris
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox