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-Thread: 103376,deffccd74319c23d X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!newsfeed2.dallas1.level3.net!news.level3.com!newsfeed-00.mathworks.com!peer-uk.news.demon.net!kibo.news.demon.net!news.demon.co.uk!demon!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Sending Variable Length Messages with GNAT.Sockets Date: Sat, 14 May 2005 12:12:43 +0100 Organization: Pushface Message-ID: References: <1115633512.107824.259680@g14g2000cwa.googlegroups.com> <427f3dfa$0$28058$ba620e4c@news.skynet.be> <1115637556.074009.113830@o13g2000cwo.googlegroups.com> <1115650283.330746.109740@f14g2000cwb.googlegroups.com> NNTP-Posting-Host: pogner.demon.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: news.demon.co.uk 1116069165 10947 62.49.19.209 (14 May 2005 11:12:45 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Sat, 14 May 2005 11:12:45 +0000 (UTC) Cancel-Lock: sha1:dWfoz8xVjfV2y7r5ZMFcQDyvMx4= User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (darwin) Xref: g2news1.google.com comp.lang.ada:11027 Date: 2005-05-14T12:12:43+01:00 List-Id: Jacob Sparre Andersen writes: > Simon Wright wrote: > >> On our side there's quite a lot of generated code to cope with >> mapping Booleans to packed arrays of bits, driven by UML tags in the >> models, but once the data is in the 32-bit form we do indeed use >> Streams. > > Why not use representation clauses for doing those mappings? (or is > the generated code actually mostly generated representation clauses?) Because rep clauses are endian-dependent. I know that there are techniques for writing bit offsets in an endian-independent way, but if humans are involved it's often easier (for both writing and reviewing) to have an Unsigned_32 and do shifts and masks in the good old C way (IME). I have used the in the spec declare un-represented record in the body read raw bytes if big-endian then declare big-endian represented derived record unchecked conversion from raw bytes to represented record begin convert raw bytes to represented record return conversion from represented record to un-represented record end else the same for the little-endian representation technique, but it's a lot of work!