bitfields

downs default_357-line at yahoo.de
Tue Jun 30 14:00:28 PDT 2009


novice2 wrote:
> downs Wrote:
>> Here's a way to do it.
>>
>> Enjoy! :)
>>
>> Usage example:
>>
>> struct Test {
>>  ... skipped...
> 
> Thank you, downs, for your job!
> 
> but, heh, i can't use something, that i can't understand :(
> i hate template and mixin (imho it lead to full unreadable code).
> so with my dumbness, i need deveral weeks to understand this :)

PackedAccessTools contains a few useful definitions given a bitfield variable name and a from..to bits-used range.

PackedAccess uses ctReplace (compile-time search&replace, from scrapple.tools.base), to generate accessors that cut out (or set) a bit of a variable. This is the meat of PackedAccess.

NaturalTypeSize is just the "default" size for a type.

And GroupPackedAccess is just a wrapper template for PackedAccess. All it does is split its parameter tuple into groups that are used to instantiate PackedAccess.

Feel free to ask if you have more specific questions.


More information about the Digitalmars-d-learn mailing list