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