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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,fe62d63cd6fe976f,start X-Google-Attributes: gid103376,public From: Doug Rogers Subject: Sequential_Mixed_IO (DEC) for GNAT Date: 1996/03/25 Message-ID: <4j794u$ldn@ra.nrl.navy.mil>#1/1 X-Deja-AN: 144177772 content-type: text/plain; charset=us-ascii organization: Naval Research Laboratory x-url: news:comp.lang.ada mime-version: 1.0 newsgroups: comp.lang.ada x-mailer: Mozilla 1.1N (X11; I; Linux 1.3.69 i486) Date: 1996-03-25T00:00:00+00:00 List-Id: This is moved from another thread (Gripe about Ada...). I have a requirement to use Ada83 only, 'cause it's DEC Ada on OpenVMS AXP. I need access to a heterogeneous stream of data coming from a binary file. DEC provides a few packages for doing this "mixed" IO, one called Sequential_Mixed_IO. It includes a generic for getting and putting typed data to disk. Here are the basics of it: package Sequential_Mixed_IO is type File_Type is new System.Sequential_IO.File_Type; procedure Open (...); -- all the standard file IO routines generic type Item_Type is private; procedure Get_Item (File : in File_Type; Item : out Item_Type); -- plus Put_Item, etc. end Sequential_Mixed_IO; -- with's deleted package body Sequential_Mixed_IO is -- NOTE: lots of stuff deleted package FIO renames System.File_IO; package FCB renames System.File_Control_Block; SU : constant := System.Storage_Unit; subtype AP is FCB.AFCB_Ptr; -- generic -- type Item_Type is private; procedure Get_Item (File : in File_Type; Item : out Item_Type) is Siz : constant size_t := (Item'Size + SU - 1) / SU; begin -- Get_Item FIO.Check_Read_Status (AP (File)); FIO.Read_Buf (AP (File), Item'Address, Siz); end Get_Item; end Sequential_Mixed_IO; The Open/Create procedures are NOT generic. Now, I copied the spec pretty much verbatim from DEC (with (c) notice!), and then I began to implement the body. I found that I could only implement it by using .File_IO child package. I simply copied the code from System.Sequential_IO. This raised an uproar when I mentioned it on the aforementioned thread. "My GOD! Someone is using a GNAT-specific, totally unsupported, possibly changing package for user code!" I explained that it was prototype code. It works. It allows me to do development in an environment that's local (and not 28.8kb away). There were calls out to make "with"-ing such packages illegal. Well, first the language makes it practically impossible to get access to binary data (Sequential_IO on a byte type doesn't cut it!), now even the low-level hacks will be gone (yes, of course it's a hack -- conveniently localized to only one file). If you can know of an elegant way to get access to mixed types from a binary file, please let me know. I heard mention of streams (?) under Ada95. I'll look into that myself (I have to abandon Ada83 for my GNAT compilations, anyway, 'cause my solution invokes a child unit -- not allowed in Ada83 -- when the generic is instantiated during compilation, a strictly GNAT thing). Doug =------cxiuj-opinioj-estas-sole-miaj.-----any-opinions-are-mine-alone.------= = Doug Rogers vocxe/voice = 1.703.893.2007 fakse/fax = 1.703.893.5890 = = Innovative Concepts Inc; 8200 Greensboro Drive Suite 801; McLean VA 22102 = = PGP ID: pub 1024/016DE91D 1994/11/14 Doug Rogers = =senemankasalvimultodatempolernulaanglan-ifyouvegotalittletimelearnesperanto=