The OpenD Programming Language

serdeDynamicAlgebraic

User defined attribute used to attach a function that returns a deserialization delegate.

The attribute is usefull for scripting languages and dynamic algebraic types.

template serdeDynamicAlgebraic (
alias getAlgebraicDeserializerByAnnotation
) {}

Examples

static struct _global
{
    alias Deserializer = S delegate(string s, ubyte[] data) @safe pure;
    Deserializer getDeserializer(string name) { return map[name]; }
    Deserializer[string] map;

    @serdeDynamicAlgebraic!getDeserializer
    struct S {}

    static assert(serdeIsDynamicAlgebraic!S);
    static assert(__traits(isSame, serdeGetAlgebraicDeserializer!S, getDeserializer));
}

Meta