|
|
|
include yslt.yml2
|
|
|
|
|
|
|
|
tstylesheet {
|
|
|
|
include standardlib.ysl2
|
|
|
|
|
|
|
|
function "isError"
|
|
|
|
{
|
|
|
|
param "tsc";
|
|
|
|
param "hexdigits", 8;
|
|
|
|
|
|
|
|
const "hex", "yml:dec2hex($tsc,$hexdigits)";
|
|
|
|
value "yml:hex2dec(substring($hex,3,2))";
|
|
|
|
}
|
|
|
|
|
|
|
|
template "/enum"
|
|
|
|
||
|
|
|
|
using System;
|
|
|
|
|
|
|
|
namespace pEp {
|
|
|
|
enum «yml:CamelCase(@name)»
|
|
|
|
{
|
|
|
|
`` apply "item|doc", 2, mode=enum
|
|
|
|
}
|
|
|
|
|
|
|
|
`` apply "item", mode=exception
|
|
|
|
class UnknownTSCErrorException : Exception { }
|
|
|
|
|
|
|
|
class «yml:CamelCase(@name)»Converter {
|
|
|
|
public static void throwTSCError(TransportStatusCode tsc) {
|
|
|
|
switch (tsc) {
|
|
|
|
``apply "item", 4, mode=case
|
|
|
|
default:
|
|
|
|
throw new UnknownTSCErrorException();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
||
|
|
|
|
|
|
|
|
template "item", mode=enum {
|
|
|
|
param "hexdigits", 8;
|
|
|
|
indent 0;
|
|
|
|
choose {
|
|
|
|
when "@output='hex'"
|
|
|
|
> «yml:CamelCase(@name)» = 0x«yml:dec2hex(.,$hexdigits)»
|
|
|
|
otherwise
|
|
|
|
> «yml:CamelCase(@name)» = «.»
|
|
|
|
}
|
|
|
|
if "position()!=last()" > ,
|
|
|
|
if "@doc" > // «@doc»
|
|
|
|
> \n
|
|
|
|
}
|
|
|
|
|
|
|
|
template "item", mode=exception {
|
|
|
|
const "isError" call "isError" with "tsc", ".";
|
|
|
|
if "$isError > 127"
|
|
|
|
| class «yml:CamelCase(@name)»Exception : Exception { }
|
|
|
|
}
|
|
|
|
|
|
|
|
template "item", mode=case {
|
|
|
|
| case TransportStatusCode.«yml:CamelCase(@name)»:
|
|
|
|
const "isError" call "isError" with "tsc", ".";
|
|
|
|
choose {
|
|
|
|
when "$isError > 127"
|
|
|
|
|> throw new «yml:CamelCase(@name)»Exception();
|
|
|
|
otherwise
|
|
|
|
|> break;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
template "doc", mode=enum
|
|
|
|
||
|
|
|
|
|
|
|
|
// «.»
|
|
|
|
|
|
|
|
||
|
|
|
|
}
|
|
|
|
|