|
|
@ -3,17 +3,41 @@ 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" |
|
|
|
|| |
|
|
|
import System; |
|
|
|
|
|
|
|
namespace pEp { |
|
|
|
enum «yml:CamelCase(@name)» |
|
|
|
{ |
|
|
|
`` apply "item|doc", 2 |
|
|
|
`` apply "item|doc", 2, mode=enum |
|
|
|
} |
|
|
|
|
|
|
|
`` apply "item", mode=exception |
|
|
|
class UnknownErrorException : Exception { } |
|
|
|
|
|
|
|
class «yml:CamelCase(@name)»Converter { |
|
|
|
public static void throwTSCError(TransportStatusCode tsc) { |
|
|
|
switch (tsc) { |
|
|
|
``apply "item", 4, mode=case |
|
|
|
default: |
|
|
|
throw new UnknownErrorException(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|| |
|
|
|
|
|
|
|
template "item" { |
|
|
|
template "item", mode=enum { |
|
|
|
param "hexdigits", 8; |
|
|
|
indent 0; |
|
|
|
choose { |
|
|
@ -27,7 +51,25 @@ tstylesheet { |
|
|
|
> \n |
|
|
|
} |
|
|
|
|
|
|
|
template "doc" |
|
|
|
template "item", mode=exception { |
|
|
|
const "isError" call "isError" with "tsc", "."; |
|
|
|
if "$isError > 127" |
|
|
|
| class «yml:CamelCase(@name)»Exception : Exception { } |
|
|
|
} |
|
|
|
|
|
|
|
template "item", mode=case { |
|
|
|
| case «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 |
|
|
|
|| |
|
|
|
|
|
|
|
// «.» |
|
|
|