Nov.06.2018 -- CAlive to introduce bounce structure

12 views
Skip to first unread message

Rick C. Hodgin

unread,
Nov 6, 2018, 9:44:36 AM11/6/18
to caliveprogra...@googlegroups.com
CAlive will introduce a bounce structure, which is an expanded reflection of a bitfield struct, one where the bitfield values are extracted and expanded to a full version of the struct, allowing for an expression of the compacted bitfields into native types.  The ability will exist to populate a bounce struct from a bitfield struct, and to populate a bitfield struct from a bounce struct using simple assignment.

    struct SBitStruct
    {
        s32   hour       : 5;
        s32   minute     : 6;
        s32   dbl_second : 5;
        // Total 16-bits, or two bytes
    }

    // To use in code:
    SBitStruct bTypes [|bounce|];
    SBitStruct bBits;

    // The [|bounce|] definition casks creates a typed structure
    // representing the types in the bitfield structure.
    // Like this:
    struct
    {
        s32   hour;
        s32   minute;
        s32   dbl_second;
        // Total 96-bits, or 12 bytes
    }

    // Populate either one as normal
    bTypes.hour       = 12;
    bTypes.minute     = 38;
    bTypes.dbl_second = 14;
    bBits.hour        = 12;
    bBits.minute      = 38;
    bBits.dbl_second  = 14;

    // To transfer one to the other:
    bTypes = bBits;
    bBits  = bTypes;

    // Likewise for pointers:
    SBitStruct* bTypesPtr [|bounce|];
    SBitStruct* bBitsPtr;

    *bTypesPtr = *bBitsPtr;    // Simple assignment bits into bounced structure
    *bBitsPtr  = *bTypesPtr;   // Simple assignment bounced structure back into bits

In this way, a simple expansion and collapse of the bitfield structs and expanded type structs will occur through the bounce.

-- 
Rick C. Hodgin

Reply all
Reply to author
Forward
0 new messages