sync/gen_messages.ysl2
author Volker Birk <vb@pep.foundation>
Wed, 29 Aug 2018 21:49:28 +0200
branchsync
changeset 2903 33549a7c7191
parent 2864 dcbed0d35466
child 3509 a9c0c6f31c56
permissions -rw-r--r--
safeguards
vb@2831
     1
// This file is under GNU General Public License 3.0
vb@2831
     2
// see LICENSE.txt
vb@2831
     3
// generated files of this template are under BSD License 2.0
vb@2831
     4
vb@2831
     5
// generate message functions
vb@2831
     6
vb@2831
     7
// Copyleft (c) 2017, p≡p foundation
vb@2831
     8
vb@2831
     9
// Written by Volker Birk
vb@2831
    10
vb@2831
    11
include yslt.yml2
vb@2831
    12
vb@2831
    13
tstylesheet {
vb@2831
    14
    include standardlib.ysl2
vb@2831
    15
    include ./functions.ysl2
vb@2831
    16
vb@2831
    17
    function "pEp_imports"
vb@2831
    18
        | IMPORTS Identity, IdentityList, TID, Hash FROM PEP;
vb@2831
    19
vb@2864
    20
    function "header"
vb@2864
    21
    ||
vb@2864
    22
    -- This file is under BSD License 2.0
vb@2864
    23
vb@2864
    24
    -- «@name» protocol for p≡p
vb@2864
    25
    -- Copyright (c) 2016-2018 p≡p foundation
vb@2864
    26
vb@2864
    27
    -- Written by Volker Birk
vb@2864
    28
vb@2864
    29
    ||
vb@2864
    30
vb@2831
    31
    template "/" {
vb@2831
    32
        apply "protocol", 0, mode=overview;
vb@2831
    33
        apply "protocol/fsm", 0, mode=individual;
vb@2831
    34
    }
vb@2831
    35
vb@2831
    36
    template "protocol", mode=overview
vb@2864
    37
        document "generated/{yml:lcase(@name)}.asn1", "text" {
vb@2831
    38
vb@2864
    39
        call "header";
vb@2864
    40
        ||
vb@2864
    41
        «yml:ucase(@name)»
vb@2864
    42
            { iso(1) org(3) dod(6) internet(1) private(4) enterprise(1) pEp(47878) «yml:lcase(@name)»(«@id») }
vb@2831
    43
vb@2864
    44
        DEFINITIONS AUTOMATIC TAGS EXTENSIBILITY IMPLIED ::=
vb@2831
    45
vb@2864
    46
        BEGIN
vb@2831
    47
vb@2864
    48
        `` for "fsm" | IMPORTS «@name» FROM «yml:ucase(@name)»;
vb@2831
    49
vb@2864
    50
        «@name» ::= CHOICE {
vb@2864
    51
            `` for "fsm" |> «yml:lcase(@name)» [APPLICATION «@id»] «@name»`if "position()!=last()" > , `
vb@2864
    52
        }
vb@2831
    53
vb@2864
    54
        END
vb@2831
    55
vb@2864
    56
        ||
vb@2831
    57
    }
vb@2831
    58
vb@2864
    59
    template "fsm", mode=individual
vb@2864
    60
        document "generated/{yml:lcase(@name)}.asn1", "text" {
vb@2831
    61
vb@2864
    62
        call "header";
vb@2864
    63
        ||
vb@2864
    64
        «yml:ucase(@name)»
vb@2864
    65
            { iso(1) org(3) dod(6) internet(1) private(4) enterprise(1) pEp(47878) «yml:lcase(../@name)»(«../@id») «yml:lcase(@name)»(«@id») }
vb@2831
    66
vb@2864
    67
        DEFINITIONS AUTOMATIC TAGS EXTENSIBILITY IMPLIED ::=
vb@2831
    68
vb@2864
    69
        BEGIN
vb@2831
    70
vb@2864
    71
        EXPORTS «@name»;
vb@2864
    72
        `` call "pEp_imports"
vb@2831
    73
vb@2864
    74
        Version ::= SEQUENCE {
vb@2864
    75
            major INTEGER (0..255) DEFAULT «version/@major»,
vb@2864
    76
            minor INTEGER (0..255) DEFAULT «version/@minor»
vb@2864
    77
        }
vb@2831
    78
vb@2864
    79
        `` apply "message", 0, mode=impl;
vb@2864
    80
        «@name» ::= SEQUENCE {
vb@2864
    81
            header SEQUENCE {
vb@2864
    82
                sequence INTEGER  -- always increases
vb@2864
    83
            },
vb@2831
    84
vb@2864
    85
            payload CHOICE {
vb@2864
    86
            `` for "message" |>> «yml:mixedCase(@name)» [APPLICATION «@id»] «@name»`if "position()!=last()" > ,`
vb@2864
    87
            }
vb@2864
    88
        }
vb@2831
    89
vb@2864
    90
        END
vb@2831
    91
vb@2864
    92
        ||
vb@2831
    93
    }
vb@2831
    94
vb@2831
    95
    template "message", mode=impl
vb@2831
    96
    ||
vb@2831
    97
    «@name» ::= SEQUENCE {
vb@2831
    98
    `` for "field|auto" |> «func:asn1name()» «func:asn1type()»`if "position()!=last()" > ,`
vb@2831
    99
    }
vb@2831
   100
vb@2831
   101
    ||
vb@2831
   102
}
vb@2831
   103