DataMuseum.dk

Presents historical artifacts from the history of:

Rational R1000/400 Tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Rational R1000/400 Tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download
Index: ┃ T V

⟦186de3b41⟧ TextFile

    Length: 7020 (0x1b6c)
    Types: TextFile
    Names: »V«

Derivation

└─⟦afbc8121e⟧ Bits:30000532 8mm tape, Rational 1000, MC68020_OS2000 7_2_2
    └─ ⟦77aa8350c⟧ »DATA« 
        └─⟦f794ecd1d⟧ 
            └─⟦4c85d69e2⟧ 
                └─⟦this⟧ 

TextFile

--    The use of this system is subject to the software license terms and
--    conditions agreed upon between Rational and the Customer.
--
--                Copyright 1988 by Rational.
--
--                          RESTRICTED RIGHTS LEGEND
--
--    Use, duplication, or disclosure by the Government is subject to
--    restrictions as set forth in subdivision (b)(3)(ii) of the Rights in
--    Technical Data and Computer Software clause at 52.227-7013.
--
--
--                Rational
--                3320 Scott Boulevard
--                Santa Clara, California 95054-3197
--
--   PROPRIETARY AND CONFIDENTIAL INFORMATION OF RATIONAL;
--   USE OR COPYING WITHOUT EXPRESS WRITTEN AUTHORIZATION
--   IS STRICTLY PROHIBITED.  THIS MATERIAL IS PROTECTED AS
--   AN UNPUBLISHED WORK UNDER THE U.S. COPYRIGHT ACT OF
--   1976.  CREATED 1988.  ALL RIGHTS RESERVED.
--
--

with System_Types;

package Buffering is

    -- This implementation implements a non-circular buffer.  That is,
    -- it slides when necessary to fill the buffer.

    -- In this implementation Head points to the last character filled
    -- while tail points to the next character to read.

    subtype Byte        is System_Types.Byte;
    subtype Byte_String is System_Types.Byte_String;  -- <= 64K bytes

    type Buffer (Max_Length : Natural) is
        record
            Head   : Natural;
            Tail   : Natural;
            Buffer : Byte_String (1 .. Max_Length);
        end record;

    type Data_Buffer is access Buffer;

    No_Buffer : constant Data_Buffer := null;


    -- Some simple conversions
    function To_Character (B : Byte) return Character
        renames System_Types.To_Character;
    function To_Byte (C : Character) return Byte renames System_Types.To_Byte;


    function  Allocate     (Max_Length : in Natural) return Data_Buffer;
    procedure Free         (Buffer : in out Data_Buffer);
    function  Is_Allocated (Buffer : in Data_Buffer) return Boolean;


    Empty : exception;
    Full  : exception;


    procedure Clear    (Buffer : in Data_Buffer);
    function  Is_Empty (Buffer : in Data_Buffer) return Boolean;
    function  Is_Full  (Buffer : in Data_Buffer) return Boolean;

    -- Returns the number of characters currently in the buffer.
    function Left (Buffer : in Data_Buffer) return Natural;
    -- Returns the number of characters that could be put in the buffer
    -- at this time.
    function Room (Buffer : in Data_Buffer) return Natural;
    -- Returns the total number of characters that could be put in the
    -- buffer if it was empty.
    function Max_Length (Buffer : in Data_Buffer) return Natural;

    -- The following routines cheat (w.r.t. Ada) by modifying the
    -- buffer even though it is an "in" parameter.  The routines
    -- named "Next" may raise Empty.
    function  Next (Buffer : in Data_Buffer)                 return Byte;
    function  Next (Buffer : in Data_Buffer)                 return Character;
    procedure Next (Buffer : in Data_Buffer; S : out Byte_String);
    procedure Next (Buffer : in Data_Buffer; S : out String);
    function  Next (Buffer : in Data_Buffer; N : in Natural) return Byte_String;
    function  Next (Buffer : in Data_Buffer; N : in Natural) return String;
    procedure Rest (Buffer : in  Data_Buffer;
                    S      : out Byte_String;
                    N      : out Natural);
    procedure Rest (Buffer : in Data_Buffer; S : out String; N : out Natural);
    function  Rest (Buffer : in Data_Buffer)                 return Byte_String;
    function  Rest (Buffer : in Data_Buffer)                 return String;

    -- The following routines cheat (w.r.t. Ada) by modifying the
    -- buffer even though it is an "in" parameter.  These routines
    -- may raise Full.
    procedure Stuff (Buffer : in Data_Buffer; C : in Byte);
    procedure Stuff (Buffer : in Data_Buffer; C : in Character);
    procedure Stuff (Buffer : in Data_Buffer; S : in Byte_String);
    procedure Stuff (Buffer : in Data_Buffer; S : in String);


    function Peek (Buffer : in Data_Buffer) return Byte;
    -- ^ can raise Empty
    function Peek (Buffer : in Data_Buffer) return Character;
    -- ^ can raise Empty
    function Peek_At_Last (Buffer : in Data_Buffer) return Byte;
    -- ^ can raise Empty
    function Peek_At_Last (Buffer : in Data_Buffer) return Character;
    -- ^ can raise Empty
    procedure Consume (Buffer : in Data_Buffer; N : in Natural := 1);
    -- ^ can raise Empty
    procedure Throwback (Buffer : in Data_Buffer; N : in Natural := 1);
    -- ^ can raise Full


    -- If there is data in the buffer, it is in
    --    Buffer.Buffer (Buffer.T..Buffer.H)
    -- If there is room in the buffer, it is in
    --    Buffer.Buffer (Buffer.H+1..Buffer.Max_Length)


    procedure Ensure_Room_For (Buffer : in Data_Buffer; N : in Natural);
    -- ^ can raise full
    procedure Slide (Buffer : in Data_Buffer);
    procedure Bump  (Buffer : in Data_Buffer; N : in Natural);
    -- ^ can raise full
    procedure Unbump (Buffer : in Data_Buffer; N : in Natural := 1);
    -- ^ can raise empty

    -- For debugging purposes:
    procedure Display_Buffer (Buffer : in Data_Buffer);


private

    -- pragma Inline (Free);
    -- pragma Inline (Is_Allocated);
    -- pragma Inline (Clear);
    -- pragma Inline (Is_Empty);
    -- pragma Inline (Is_Full);
    -- pragma Inline (Left);
    -- pragma Inline (Room);
    -- pragma Inline (Max_Length);
    -- pragma Inline (Peek);
    -- pragma Inline (Peek_At_Last);
    -- pragma Inline (Consume);
    -- pragma Inline (Throwback);
    -- pragma Inline (Ensure_Room_For);
    -- pragma Inline (Bump);
    -- pragma Inline (Unbump);

    -- Unfortunately, there are some long procedures as well as short
    -- procedures that are named Next, Rest, and Stuff.

    pragma Suppress (Elaboration_Check, On => Allocate);
    pragma Suppress (Elaboration_Check, On => Free);
    pragma Suppress (Elaboration_Check, On => Is_Allocated);
    pragma Suppress (Elaboration_Check, On => Clear);
    pragma Suppress (Elaboration_Check, On => Is_Empty);
    pragma Suppress (Elaboration_Check, On => Is_Full);
    pragma Suppress (Elaboration_Check, On => Left);
    pragma Suppress (Elaboration_Check, On => Room);
    pragma Suppress (Elaboration_Check, On => Max_Length);
    pragma Suppress (Elaboration_Check, On => Next);
    pragma Suppress (Elaboration_Check, On => Rest);
    pragma Suppress (Elaboration_Check, On => Stuff);
    pragma Suppress (Elaboration_Check, On => Peek);
    pragma Suppress (Elaboration_Check, On => Peek_At_Last);
    pragma Suppress (Elaboration_Check, On => Consume);
    pragma Suppress (Elaboration_Check, On => Throwback);
    pragma Suppress (Elaboration_Check, On => Ensure_Room_For);
    pragma Suppress (Elaboration_Check, On => Slide);
    pragma Suppress (Elaboration_Check, On => Bump);
    pragma Suppress (Elaboration_Check, On => Unbump);
    pragma Suppress (Elaboration_Check, On => Display_Buffer);

end Buffering;