sync/gen_statemachine.ysl2
branchsync
changeset 2881 26b451252f73
parent 2880 fa5b054aa4b6
child 2884 2ed5aba15296
     1.1 --- a/sync/gen_statemachine.ysl2	Thu Aug 23 10:24:49 2018 +0200
     1.2 +++ b/sync/gen_statemachine.ysl2	Thu Aug 23 10:33:59 2018 +0200
     1.3 @@ -585,6 +585,7 @@
     1.4          // state machine
     1.5  
     1.6          const char *«@name»_state_name(int state);
     1.7 +        const char *«@name»_event_name(int event);
     1.8  
     1.9          // the state machine function is returning the next state in case of a
    1.10          // transition or None for staying
    1.11 @@ -630,6 +631,25 @@
    1.12              }
    1.13          }
    1.14  
    1.15 +        const char *«@name»_event_name(int event)
    1.16 +        {
    1.17 +            switch (event) {
    1.18 +                case None:
    1.19 +                    return "None";
    1.20 +                case Init:
    1.21 +                    return "Init";
    1.22 +        ||
    1.23 +        for "func:distinctName(state/event[not(@name='Init')])" {
    1.24 +            |>> case «@name»:
    1.25 +            |>>> return "«@name»";
    1.26 +        }
    1.27 +        ||
    1.28 +                default:
    1.29 +                    return "unknown event";
    1.30 +            }
    1.31 +        }
    1.32 +
    1.33 +
    1.34          static char *_str(int n, bool hex)
    1.35          {
    1.36              char *buf = calloc(1, 24);