comp.lang.ada
 help / color / mirror / Atom feed
From: "Greg Bek" <gbek@bigpond.net.au>
Subject: Re: Reading from a saved stream
Date: Thu, 24 Jan 2002 06:03:45 GMT
Date: 2002-01-24T06:03:45+00:00	[thread overview]
Message-ID: <5tN38.5197$Ni2.34177@news-server.bigpond.net.au> (raw)
In-Reply-To: 3c4e2839.2139458@news.tc.umn.edu

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



<puk @ umn._edu_ (Paul Pukite)> 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
>





      parent reply	other threads:[~2002-01-24  6:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-01-23  4:10 Reading from a saved stream Paul Pukite
2002-01-23 17:49 ` Stephen Leake
2002-01-24  6:03 ` Greg Bek [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox