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