flatdata icon indicating copy to clipboard operation
flatdata copied to clipboard

Add annotations for offset based references

Open VeaaC opened this issue 4 years ago • 0 comments

In flatdata archives users often use a pattern in which they reference other resources with relative references, e.g.:

struct Node
{
    @range(edge_refs)
    first_edge_ref : u32;
}

struct Edge
{
    target_ref : u32;
    value : u32;
}

struct GraphIndex
{
    @range(node_refs)
    first_node_ref : u32;
    @range(edge_refs)
    first_edge_ref : u32;
}

archive Ch
{
    // this actually  is a relative reference: first_edge_ref +  GraphIndex.first_edge_ref
    @explicit_reference( Node.first_edge_ref, edges )
    nodes : vector< Node >;
   // this actually  is a relative reference: target_ref +  GraphIndex.first_node_ref
    @explicit_reference( Edge.target_ref, nodes )
    edges : vector< Edge >;
    index: vector< GraphIndex >;
}

It would be nice to add a special reference annotation to make this more visible for the user (and maybe enable code generation later on)

VeaaC avatar Jan 05 '21 09:01 VeaaC