From: Shark8 <onewingedshark@gmail.com>
Subject: General integer-types.
Date: Sat, 6 Apr 2013 18:45:43 -0700 (PDT)
Date: 2013-04-06T18:45:43-07:00 [thread overview]
Message-ID: <4a0e3b63-7139-4f03-bae2-35beca608bda@googlegroups.com> (raw)
I'm toying with the idea of making a SWF-player (I found the documentation for the format online) and was wondering about the integers. Sure I could write out all of them (8-bit, 16-bit, 32-bit)x(signed, unsigned) + 64-bit unsigned = 7-types -- not too bad, but this is a lot of repetition so could I make a generic to qualify?
Generic
Size : Positive;
Package SWF_Integer is
Exp : Constant Positive := Size-1;
-- For some reason adding the "New Long_Long_Integer" allows
-- this to compile... but it might ignore the Size aspect.
Type Signed is New Long_Long_Integer Range -2**Exp..2**Exp-1
with Size => Size;
-- This doesn't work at all; Size is not static.
Type Unsigned is Mod 0..2**Size
with Size => Size;
End SWF_Integer;
The specs are as follows:
> Integer types and byte order
> The SWF file format uses 8-bit, 16-bit, 32-bit, 64-bit, signed,
> and unsigned integer types. All integer values are stored in the
> SWF file by using little-endian byte order: the least
> significant byte is stored first, and the most significant byte
> is stored last, in the same way as the Intel x86 architecture.
> The bit order within bytes in the SWF file format is big-endian:
> the most significant bit is stored first, and the least
> significant bit is stored last.
>
> All integer types must be byte-aligned. That is, the first bit
> of an integer value must be stored in the first bit of a byte in
> the SWF file.
Would the bit_order definition work on ensuring the correct representation? The documentation seems to indicate it is for the bit-numbering in record-representations. Further, would the alignment definition (alignment => 1? 8?) be appropriate?
next reply other threads:[~2013-04-07 1:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-07 1:45 Shark8 [this message]
2013-04-07 8:45 ` General integer-types J-P. Rosen
2013-04-07 14:29 ` Shark8
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox