You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
libpEpTransport/src/gen_cs.ysl2

80 lines
1.8 KiB
Plaintext

2 years ago
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))";
}
2 years ago
template "/enum"
||
using System;
2 years ago
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();
}
}
2 years ago
}
}
||
template "item", mode=enum {
2 years ago
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
2 years ago
||
// «.»
||
}