sync/gen_actions.ysl2
author Volker Birk <vb@pep.foundation>
Mon, 13 Aug 2018 16:45:23 +0200
branchsync
changeset 2844 6fce34991f7d
parent 2830 d6f044e43e1a
child 2902 5692b0768f9e
permissions -rw-r--r--
...
krista@2271
     1
// This file is under GNU General Public License 3.0
krista@2271
     2
// see LICENSE.txt
krista@2271
     3
vb@2829
     4
// generate conditions and actions
krista@2271
     5
vb@2829
     6
// Copyleft (c) 2017, p≡p foundation
krista@2271
     7
krista@2271
     8
// Written by Volker Birk
krista@2271
     9
krista@2271
    10
include yslt.yml2
krista@2271
    11
vb@2829
    12
decl _func *name (*type) alias - {
vb@2829
    13
    template %name=*name, %type=*type, "%type[@name='%name']"
vb@2829
    14
        call *type with "content" content;
vb@2829
    15
};
vb@2829
    16
vb@2829
    17
decl condition is _func (*type="condition");
vb@2829
    18
decl action is _func (*type="action");
vb@2829
    19
krista@2271
    20
tstylesheet {
krista@2271
    21
    include standardlib.ysl2
krista@2271
    22
    include ./functions.ysl2
krista@2271
    23
vb@2844
    24
    include ./cond_act_*.yml2
vb@2829
    25
krista@2271
    26
    template "/protocol" {
vb@2829
    27
        document "generated/{@name}_actions.c", "text" {
vb@2829
    28
            ||
vb@2829
    29
            // This file is under GNU General Public License 3.0
vb@2829
    30
            // see LICENSE.txt
krista@2271
    31
vb@2830
    32
            #include "pEp_internal.h"
vb@2830
    33
            #include "map_asn1.h"
vb@2830
    34
vb@2829
    35
            #include "«@name»_impl.h"
vb@2829
    36
            `` for "fsm" | #include "«@name»_fsm.h"
krista@2271
    37
krista@2271
    38
            ||
vb@2829
    39
            apply "func:distinctName(//condition)", 0;
vb@2829
    40
            apply "func:distinctName(//action[not(starts-with(@name, 'send'))])", 0;
krista@2271
    41
        }
krista@2271
    42
    }
krista@2271
    43
vb@2829
    44
    template "condition" | #error condition «@name» not implemented\n
vb@2829
    45
    template "action" | #error action «@name» not implemented\n
vb@2829
    46
vb@2829
    47
    function "condition" {
vb@2829
    48
        param "content";
vb@2829
    49
        ||
vb@2829
    50
        PEP_STATUS «@name»(PEP_SESSION session, bool *result)
vb@2829
    51
        {
vb@2829
    52
            assert(session && result);
vb@2829
    53
            if (!(session && result))
vb@2829
    54
                return PEP_ILLEGAL_VALUE;
krista@2271
    55
krista@2271
    56
        ||
vb@2829
    57
        copy "$content";
vb@2829
    58
        ||
krista@2271
    59
vb@2829
    60
            return PEP_STATUS_OK;
krista@2271
    61
        }
krista@2271
    62
krista@2271
    63
        ||
krista@2271
    64
    }
krista@2271
    65
vb@2829
    66
    function "action" {
vb@2829
    67
        param "content";
vb@2829
    68
        ||
vb@2829
    69
        PEP_STATUS «@name»(PEP_SESSION session)
vb@2829
    70
        {
vb@2829
    71
            assert(session);
vb@2829
    72
            if (!session)
vb@2829
    73
                return PEP_ILLEGAL_VALUE;
krista@2271
    74
krista@2271
    75
        ||
vb@2829
    76
        copy "$content";
krista@2271
    77
        ||
krista@2271
    78
krista@2271
    79
            return PEP_STATUS_OK;
krista@2271
    80
        }
krista@2271
    81
krista@2271
    82
        ||
krista@2271
    83
    }
krista@2271
    84
}
krista@2271
    85