sync/functions.ysl2
author Krista 'DarthMama' Bennett <krista@pep.foundation>
Wed, 16 Oct 2019 16:35:08 +0200
branchENGINE-654
changeset 4118 b0995cc07d02
parent 2829 e444c3c960bb
child 4585 af441dfc1d2c
permissions -rw-r--r--
merged in sync
     1 // This file is under GNU General Public License 3.0
     2 // see LICENSE.txt
     3 
     4 // function library
     5 
     6 def "func:distinctName" {
     7     param "nodes", "/..";
     8     choose {
     9         when "not($nodes)"
    10             result "/..";
    11         otherwise
    12             result "$nodes[1] | func:distinctName($nodes[position() > 1])[@name != $nodes[1]/@name]";
    13     }
    14 }
    15 
    16 def "func:distinctType" {
    17     param "nodes", "/..";
    18     choose {
    19         when "not($nodes)"
    20             result "/..";
    21         otherwise
    22             result "$nodes[1] | func:distinctType($nodes[position() > 1])[@type != $nodes[1]/@type]";
    23     }
    24 }
    25 
    26 def "func:asn1name"
    27     result "translate(@name, '_', '-')";
    28 
    29 def "func:asn1type" {
    30     choose {
    31         when "@type='bool'"
    32             result "'BOOLEAN'";
    33         when "@type='int'"
    34             result "'INTEGER'";
    35         otherwise
    36             result "translate(@type, '_', '-')";
    37     }
    38 }
    39 
    40 def "func:basicType" {
    41     choose {
    42         when "substring(@type,1,1)=yml:lcase(substring(@type,1,1))"
    43             result "true()";
    44         otherwise
    45             result "false()";
    46     }
    47 }
    48 
    49 def "func:ctype" {
    50     choose {
    51         when "func:basicType()"
    52             result "@type";
    53         otherwise
    54             result "concat(@type,'_t')";
    55     }
    56 }