Sep.26.2018 -- CAlive to introduce adhocstruct extensions

7 views
Skip to first unread message

Rick C. Hodgin

unread,
Sep 26, 2018, 8:46:49 AM9/26/18
to caliveprogra...@googlegroups.com
CAlive will introduce the ability to create a definition for accessing dynamically created structures at runtime.  This will simplify the coding required to access complex and coordinated flexible data where the details of a struct implementation are known only at runtime, being derived by observed real-word values in real data.  This syntax will hide the mechanics of that ad hoc data access / traversal.

    // Create the same structure with the flexible portion
    flexstruct SCdxNode
    {
        u16     type;
        u16     keyCount;
        u32     nodeLeft;
        u32     nodeRight;

        u32     mask_RN;
        u8      mask_TC;
        u8      mask_DC;

        u8      bits_RN;
        u8      bits_TC;
        u8      bits_DC;
        // Total:  21 bytes

        // Add the flex space which extends up to 512 bytes
        flex    keyspace#512;
    };

    function example
    | params SCdxNode* node
    | returns u32 count
    {
        // Create an ad hoc struct to access the bits within this header portion
        adhocstruct SKeyMeta
        {
            u32     RN : node->bits_RN;
            u32     TC : node->bits_TC;
            u32     DC : node->bits_DC;
        };

        // Iterate through each key reference
        SKeyMeta* km = &node.keyspace;
        iterate (to node->keyCount; ++km)
        {
            // Code here can use km->RN, km->TC, km->DC as needed
        }
    }

-- 
Rick C. Hodgin

Reply all
Reply to author
Forward
0 new messages