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,dcfafdc50abb8ce4 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-06-07 19:10:08 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!cyclone.bc.net!newsfeed.direct.ca!look.ca!newsfeed1.earthlink.net!newsfeed.earthlink.net!newsmaster1.prod.itd.earthlink.net!newsread1.prod.itd.earthlink.net.POSTED!not-for-mail Message-ID: <3B2033F5.366D250A@acm.org> From: Jeffrey Carter X-Mailer: Mozilla 4.7 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: records containing variable length arrays [long] References: <3B1E8BB9.42BF95D2@mida.se> <3B1EB781.11B6923D@boeing.com> <3B1F6939.88D49233@mida.se> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Fri, 08 Jun 2001 02:10:08 GMT NNTP-Posting-Host: 206.133.138.234 X-Complaints-To: abuse@earthlink.net X-Trace: newsread1.prod.itd.earthlink.net 991966208 206.133.138.234 (Thu, 07 Jun 2001 19:10:08 PDT) NNTP-Posting-Date: Thu, 07 Jun 2001 19:10:08 PDT Organization: EarthLink Inc. -- http://www.EarthLink.net X-Received-Date: Thu, 07 Jun 2001 19:08:10 PDT (newsmaster1.prod.itd.earthlink.net) Xref: archiver1.google.com comp.lang.ada:8376 Date: 2001-06-08T02:10:08+00:00 List-Id: Mats Karlssohn wrote: > > Jeffrey Carter wrote: > > > > Mats Karlssohn wrote: > > > > -- the other big problem is to get the correct representation > > > for Message use > > > record > %< > > > Status at 4 range 0..15; > > > Response_Length at 4 range 0.. 7; > > This is a typo... "Response_Length at 5 range 0..7;" is the correct > representation statement, this also means that all the following > components move up one byte. Good. That makes life easier for you. > > %< > > However, you have additional problems, such as overlaying your lengths, > > which would be your discriminants, with Status. I presume that you > > receive your message as a simple Buffer. In that case you might be able > > to work something along these lines > > Yes, I receive a C pointer (converted to System.Address) and an integer > Length from a buffer manager for the shared memory where thit beast > lives. I forgot to mention that I really only neet to read this data > structure, I will NOT need to assign to it. In that case you can access it simply. We'll call what you get from C Data_Address and Data_Length. Then you can say Raw_Data : constant Buffer (1 .. Data_Length); -- or (7 .. Data_Length + 6), if you prefer pragma Import (Ada, Raw_Data); -- Prevent any initialization of Raw_Data for Raw_Data'Address use Data_Address; You can then Translate this to an appropriately constrained record type. Since you do not need to modify it, you can make it constant, which should avoid copying the data. If you want to live dangerously, you can avoid the buffer representation and simply apply the address clause to the record object. -- Jeff Carter "Perfidious English mouse-dropping hoarders." Monty Python & the Holy Grail