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-20 09:54:06 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!kibo.news.demon.net!news.demon.co.uk!demon!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: generic imports? void* -> generics? Date: 20 Sep 2003 17:52:20 +0100 Organization: Pushface Sender: simon@smaug.pushface.org Message-ID: References: NNTP-Posting-Host: pogner.demon.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: news.demon.co.uk 1064076844 18274 62.49.19.209 (20 Sep 2003 16:54:04 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Sat, 20 Sep 2003 16:54:04 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 Xref: archiver1.google.com comp.lang.ada:42718 Date: 2003-09-20T17:52:20+01:00 List-Id: "Nick Roberts" 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;