From ab3442596aa017e6923402d7d207306cf266bded Mon Sep 17 00:00:00 2001 From: Volker Birk Date: Fri, 10 Sep 2021 19:47:17 +0200 Subject: [PATCH] generate C# --- .gitignore | 1 + src/Makefile | 12 ++++++++++-- src/gen_cs.ysl2 | 37 +++++++++++++++++++++++++++++++++++++ src/rce.tsc | 4 ++++ src/sctp.tsc | 2 +- 5 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 src/gen_cs.ysl2 diff --git a/.gitignore b/.gitignore index ad2d148..5cf391c 100644 --- a/.gitignore +++ b/.gitignore @@ -165,4 +165,5 @@ src/PEPTransportStatusCode.h src/transport_status_code.h src/transport_status_code.c src/TransportStatusCode.kt +src/transport_status_code.cs diff --git a/src/Makefile b/src/Makefile index d599e25..31b1328 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,6 +1,7 @@ YML2PROC?=yml2proc +PREFIX?=$(HOME) -TARGET=transport_status_code.h transport_status_code.c PEPTransportStatusCode.h TransportStatusCode.kt +TARGET=transport_status_code.h transport_status_code.c PEPTransportStatusCode.h TransportStatusCode.kt transport_status_code.cs TSC=$(wildcard *.tsc) @@ -18,7 +19,14 @@ PEPTransportStatusCode.h: gen_objc.ysl2 transport_status_code.yml2 $(TSC) TransportStatusCode.kt: gen_kotlin.ysl2 transport_status_code.yml2 $(TSC) yml2proc -y $< -o $@ transport_status_code.yml2 -.PHONY: clean +transport_status_code.cs: gen_cs.ysl2 transport_status_code.yml2 $(TSC) + yml2proc -y $< -o $@ transport_status_code.yml2 + +.PHONY: clean install clean: rm -f $(TARGET) + +install: + mkdir -p $(PREFIX)/include/pEp + cp -f transport_status_code.h $(PREFIX)/include/pEp/ diff --git a/src/gen_cs.ysl2 b/src/gen_cs.ysl2 new file mode 100644 index 0000000..bafef49 --- /dev/null +++ b/src/gen_cs.ysl2 @@ -0,0 +1,37 @@ +include yslt.yml2 + +tstylesheet { + include standardlib.ysl2 + + template "/enum" + || + namespace pEp { + enum «yml:CamelCase(@name)» + { + `` apply "item|doc", 2 + } + } + || + + template "item" { + 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 "doc" + || + + // «.» + + || +} + diff --git a/src/rce.tsc b/src/rce.tsc index 738ad6f..7127e96 100644 --- a/src/rce.tsc +++ b/src/rce.tsc @@ -1,5 +1,9 @@ doc > transport status codes for RCE (0x02) +hex rce_cannot_create_user 0x02800001; +hex rce_cannot_login_user 0x02800002; +hex rce_cannot_find_user 0x02800003; + hex torrent_has_no_seeders 0x02ff0001; hex unknown_torrent_error 0x02ffffff; diff --git a/src/sctp.tsc b/src/sctp.tsc index 3ce9b0b..5a7f82b 100644 --- a/src/sctp.tsc +++ b/src/sctp.tsc @@ -1,3 +1,3 @@ -doc > transport status codes for p≡p over SCTP (0x04) +doc > transport status codes for pEp over SCTP (0x04) hex unkown_sctp_error 0x04ffffff;