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