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