sync/gen_actions_skeleton.ysl2
author Volker Birk <vb@pep-project.org>
Sun, 15 May 2016 15:18:53 +0200
changeset 623 533a7fcc423b
child 624 4892dffa9e70
permissions -rw-r--r--
basic structure and skeleton
vb@623
     1
// generate actions skeleton
vb@623
     2
vb@623
     3
// Copyleft (c) 2016, p≡p foundation
vb@623
     4
vb@623
     5
// Written by Volker Birk
vb@623
     6
vb@623
     7
include yslt.yml2
vb@623
     8
vb@623
     9
tstylesheet {
vb@623
    10
    include ./functions.ysl2
vb@623
    11
vb@623
    12
    template "/protocol/fsm" {
vb@623
    13
    document "../src/fsm_driver.c", "text"
vb@623
    14
    ||
vb@623
    15
    // Driver for «@name» state machine
vb@623
    16
vb@623
    17
    #include <assert.h>
vb@623
    18
    #include "sync_fsm.h"
vb@623
    19
vb@623
    20
vb@623
    21
    PEP_STATUS fsm_«@name»_inject(PEP_SESSION session, «@name»_event event)
vb@623
    22
    {
vb@623
    23
        PEP_STATUS status = PEP_STATUS_OK;
vb@623
    24
vb@623
    25
        return status;
vb@623
    26
    }
vb@623
    27
    ||
vb@623
    28
    ||
vb@623
    29
    // Actions for «@name» state machine
vb@623
    30
vb@623
    31
    #include <assert.h>
vb@623
    32
    #include "sync_fsm.h"
vb@623
    33
vb@623
    34
vb@623
    35
    `` for "func:distinctName(//action)" call "action" with "action", ".";
vb@623
    36
vb@623
    37
    ||
vb@623
    38
    }
vb@623
    39
vb@623
    40
    function "action" {
vb@623
    41
        param "action";
vb@623
    42
vb@623
    43
        ||
vb@623
    44
        // «$action/@name»() - 
vb@623
    45
        //
vb@623
    46
        //  params:
vb@623
    47
        `` if "parm"        | //      partner (in)        partner in sync
vb@623
    48
        `` if "not(parm)"   | //      partner (in)        (must be NULL)
vb@623
    49
        //
vb@623
    50
        //  returns:
vb@623
    51
        //      PEP_STATUS_OK or any other value on error
vb@623
    52
vb@623
    53
        PEP_STATUS «$action/@name»(const Identity partner)
vb@623
    54
        {
vb@623
    55
            PEP_STATUS status = PEP_STATUS_OK;
vb@623
    56
vb@623
    57
        `` if "parm"        |> assert(partner);
vb@623
    58
        `` if "parm"        |> if (!partner)
vb@623
    59
        `` if "parm"        |>> return PEP_ILLEGAL_VALUE;
vb@623
    60
        `` if "not(parm)"   |> assert(partner == NULL);
vb@623
    61
        `` if "not(parm)"   |> if (partner)
vb@623
    62
        `` if "not(parm)"   |>> return PEP_ILLEGAL_VALUE;
vb@623
    63
vb@623
    64
            // working code
vb@623
    65
vb@623
    66
vb@623
    67
            return status;
vb@623
    68
        }
vb@623
    69
vb@623
    70
        ||
vb@623
    71
    }
vb@623
    72
}
vb@623
    73