comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: Sending Variable Length Messages with GNAT.Sockets
Date: Sat, 14 May 2005 12:12:43 +0100
Date: 2005-05-14T12:12:43+01:00	[thread overview]
Message-ID: <m2d5rujc2c.fsf@grendel.local> (raw)
In-Reply-To: m2hdh8214m.fsf@hugin.crs4.it

Jacob Sparre Andersen <sparre@nbi.dk> 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!



  reply	other threads:[~2005-05-14 11:12 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-09 10:11 Sending Variable Length Messages with GNAT.Sockets markp
2005-05-09 10:39 ` Adrien Plisson
2005-05-09 11:19   ` markp
2005-05-09 11:50     ` Adrien Plisson
2005-05-09 14:30     ` John B. Matthews
2005-05-09 14:51       ` markp
2005-05-09 18:49         ` Adrien Plisson
2005-05-09 19:16         ` Simon Wright
2005-05-10 15:08           ` markp
2005-05-10 20:34           ` Simon Wright
2005-05-11 13:19             ` Marc A. Criley
2005-05-11 17:14               ` tmoran
2005-05-11 21:05               ` Simon Wright
2005-05-12 10:24                 ` Jacob Sparre Andersen
2005-05-14 11:12                   ` Simon Wright [this message]
2005-05-09 11:19   ` Jeff C
2005-05-09 11:35     ` markp
2005-05-09 11:57     ` Adrien Plisson
replies disabled

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