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,64ebc6f079364493 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-01-23 22:03:47 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeed.berkeley.edu!ucberkeley!intgwpad.nntp.telstra.net!news.telstra.net!news-server.bigpond.net.au!not-for-mail From: "Greg Bek" Newsgroups: comp.lang.ada References: <3c4e2839.2139458@news.tc.umn.edu> Subject: Re: Reading from a saved stream X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4807.1700 Message-ID: <5tN38.5197$Ni2.34177@news-server.bigpond.net.au> Date: Thu, 24 Jan 2002 06:03:45 GMT NNTP-Posting-Host: 144.136.170.160 X-Complaints-To: news@bigpond.net.au X-Trace: news-server.bigpond.net.au 1011852225 144.136.170.160 (Thu, 24 Jan 2002 17:03:45 EST) NNTP-Posting-Date: Thu, 24 Jan 2002 17:03:45 EST Organization: BigPond Internet Services (http://www.bigpond.net.au) Xref: archiver1.google.com comp.lang.ada:19269 Date: 2002-01-24T06:03:45+00:00 List-Id: Paul, The code looks right and as far as I can tell this is an Apex bug (I tested on more than one platform) and the bug appears to be on the reading side of the code. I tested on our current internal build and the program works correctly. I suggest you contact Rational support so that they open a case log and correctly track the issue. Greg Bek gab@rational.com wrote in message news:3c4e2839.2139458@news.tc.umn.edu... > Is the attached pattern legal & portable Ada? I believe > so but a compiler upgrade from Rational Apex 3.0.0b > to Rational Apex 4.0.0b resulted in the following > questionable output for the Stream_Save main procedure: > > Received Move Command with Speed = 259 > Speed should be = 999 > > The dispatching works OK but the transferred data looks odd. > > I would like to know if this is more likely a regression > bug or if Rational is following the standard leading to > an unexpected outcome. The results are independent of > the OS by the way. Also, the same behavior occurs if the > base class is not labelled abstract. > > We have spent a lot of effort creating streamable classes and > to hit this issue has got me second-guessing this particular idiom. > Any comments are appreciated. > > thanks, > Paul Pukite > > :::::::::::::: > base.1.ada > :::::::::::::: > package Base is > > type Selection is (Zero, One, Two, Three); > > type Item is abstract tagged > record > Menu : Integer := 1; > Enum : Selection := Three; > end record; > -- Primitive op > procedure Input (Msg : in Item) is abstract; > > end Base; > :::::::::::::: > gizmo.1.ada > :::::::::::::: > with Base; > package Gizmo is > pragma Elaborate_Body; > > type Move is new Base.Item with > record > Speed : Integer := 1; > end record; > procedure Input (Obj : in Move); > > end Gizmo; > :::::::::::::: > gizmo.2.ada > :::::::::::::: > with Text_Io; > > package body Gizmo is > > procedure Input (Obj : in Move) is > begin > Text_Io.Put_Line ("Received Move Command with Speed =" & > Integer'Image (Obj.Speed)); > end Input; > > end Gizmo; > :::::::::::::: > stream_save.2.ada > :::::::::::::: > with Ada.Streams.Stream_Io; > with Text_Io; > with Base; > with Gizmo; > > procedure Stream_Save is > Stream_File_Name : constant String := "stream.out"; > > procedure Save (Cmd : in Base.Item'Class) is > File : Ada.Streams.Stream_Io.File_Type; > S : Ada.Streams.Stream_Io.Stream_Access; > begin > Ada.Streams.Stream_Io.Create (File, Name => Stream_File_Name); > S := Ada.Streams.Stream_Io.Stream (File); > Base.Item'Class'Output (S, Cmd); > Ada.Streams.Stream_Io.Close (File); > end Save; > > procedure Play_Back is > File : Ada.Streams.Stream_Io.File_Type; > S : Ada.Streams.Stream_Io.Stream_Access; > begin > Ada.Streams.Stream_Io.Open > (File, Ada.Streams.Stream_Io.In_File, Stream_File_Name); > S := Ada.Streams.Stream_Io.Stream (File); > Base.Input (Base.Item'Class'Input (S)); > Ada.Streams.Stream_Io.Close (File); > end Play_Back; > > Obj : Gizmo.Move; > Speed : constant Integer := 999; > begin > Obj.Speed := Speed; > Save (Obj); -- Save the command > Play_Back; -- Play back (and dispatch) the command > Text_Io.Put_Line ("Speed should be =" & Integer'Image (Speed)); > end Stream_Save; > > pragma Main (Posix_Compliant => False); -- needed for Text_IO.Create >