comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: generic imports?  void* -> generics?
Date: 20 Sep 2003 17:52:20 +0100
Date: 2003-09-20T17:52:20+01:00	[thread overview]
Message-ID: <x7vd6dvierf.fsf@smaug.pushface.org> (raw)
In-Reply-To: bkfrqe$1de3s$1@ID-25716.news.uni-berlin.de

"Nick Roberts" <nickroberts@blueyonder.co.uk> writes:

> 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.

I don't understand this, your suggestion was for Stream_Element_Array
not Root_Stream_Type'Class which is needed for 'Read ..? I can see
that you could wrap a Stream_Element_Array in a Stream, in fact quite
a neat idea! This sort of thing? (would make an interesting addition
to the BCs .. or is this stuff that everybody has known for years &
I've just missed?)

with Ada.Streams;

package Stream_Wrappers is

   type Stream_Wrapper (For_Array : access Ada.Streams.Stream_Element_Array)
   is new Ada.Streams.Root_Stream_Type with private;

   function Last (Used_In : Stream_Wrapper)
     return Ada.Streams.Stream_Element_Offset;

private

   type Stream_Wrapper (For_Array : access Ada.Streams.Stream_Element_Array)
   is new Ada.Streams.Root_Stream_Type with record
      Next_Read : Ada.Streams.Stream_Element_Offset := For_Array'First;
      Next_Write : Ada.Streams.Stream_Element_Offset := For_Array'First;
   end record;

   procedure Read
     (Stream : in out Stream_Wrapper;
      Item   : out Ada.Streams.Stream_Element_Array;
      Last   : out Ada.Streams.Stream_Element_Offset);

   procedure Write
     (Stream : in out Stream_Wrapper;
      Item   : in Ada.Streams.Stream_Element_Array);

end Stream_Wrappers;



  parent reply	other threads:[~2003-09-20 16:52 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
2003-09-19 23:12   ` chris
2003-09-20 16:52   ` Simon Wright [this message]
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