diff --git a/.gitignore b/.gitignore index 1ef179e..ad2d148 100644 --- a/.gitignore +++ b/.gitignore @@ -164,4 +164,5 @@ ws src/PEPTransportStatusCode.h src/transport_status_code.h src/transport_status_code.c +src/TransportStatusCode.kt diff --git a/src/Makefile b/src/Makefile index 2e12cd3..d599e25 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,6 +1,6 @@ YML2PROC?=yml2proc -TARGET=transport_status_code.h transport_status_code.c PEPTransportStatusCode.h +TARGET=transport_status_code.h transport_status_code.c PEPTransportStatusCode.h TransportStatusCode.kt TSC=$(wildcard *.tsc) @@ -15,6 +15,9 @@ transport_status_code.c: gen_strings.ysl2 transport_status_code.yml2 $(TSC) PEPTransportStatusCode.h: gen_objc.ysl2 transport_status_code.yml2 $(TSC) yml2proc -y $< -o $@ transport_status_code.yml2 +TransportStatusCode.kt: gen_kotlin.ysl2 transport_status_code.yml2 $(TSC) + yml2proc -y $< -o $@ transport_status_code.yml2 + .PHONY: clean clean: diff --git a/src/gen_kotlin.ysl2 b/src/gen_kotlin.ysl2 new file mode 100644 index 0000000..9c19b65 --- /dev/null +++ b/src/gen_kotlin.ysl2 @@ -0,0 +1,36 @@ +include yslt.yml2 + +tstylesheet { + include standardlib.ysl2 + + template "/enum" + || + package foundation.pEp + + enum class «yml:CamelCase(@name)»(val «yml:abbr(@name)»: Int) { + `` apply "item|doc" + } + || + + template "item" { + param "hexdigits", 8; + indent 0; + choose { + when "@output='hex'" + > «yml:ucase(@name)»(0x«yml:ucase(yml:dec2hex(.,$hexdigits))») + otherwise + > «yml:ucase(@name)»(.) + } + if "position()!=last()" > , + if "@doc" > // «@doc» + > \n + } + + template "doc" + || + + // «.» + + || +} +