From b70fdf9c7af2004361f820e01a472b20aaee0c47 Mon Sep 17 00:00:00 2001 From: Volker Birk Date: Wed, 1 Sep 2021 22:03:27 +0200 Subject: [PATCH] generate label function --- .gitignore | 1 + src/Makefile | 5 ++++- src/gen_strings.ysl2 | 42 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 src/gen_strings.ysl2 diff --git a/.gitignore b/.gitignore index 1573c11..1ef179e 100644 --- a/.gitignore +++ b/.gitignore @@ -163,4 +163,5 @@ ws # generated files src/PEPTransportStatusCode.h src/transport_status_code.h +src/transport_status_code.c diff --git a/src/Makefile b/src/Makefile index 59b540d..2e12cd3 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,6 +1,6 @@ YML2PROC?=yml2proc -TARGET=transport_status_code.h PEPTransportStatusCode.h +TARGET=transport_status_code.h transport_status_code.c PEPTransportStatusCode.h TSC=$(wildcard *.tsc) @@ -9,6 +9,9 @@ all: $(TARGET) transport_status_code.h: gen_c.ysl2 transport_status_code.yml2 $(TSC) yml2proc -y $< -o $@ transport_status_code.yml2 +transport_status_code.c: gen_strings.ysl2 transport_status_code.yml2 $(TSC) + yml2proc -y $< -o $@ transport_status_code.yml2 + PEPTransportStatusCode.h: gen_objc.ysl2 transport_status_code.yml2 $(TSC) yml2proc -y $< -o $@ transport_status_code.yml2 diff --git a/src/gen_strings.ysl2 b/src/gen_strings.ysl2 new file mode 100644 index 0000000..ced886b --- /dev/null +++ b/src/gen_strings.ysl2 @@ -0,0 +1,42 @@ +include yslt.yml2 + +tstylesheet { + include standardlib.ysl2 + + template "/enum" + || + #include + + #ifdef __cplusplus + extern "C" { + #endif + + const char *«@name»_label(PEP_«@name» value) + { + switch (value) { + `` apply "item|doc" + + default: + return "unknown"; + } + } PEP_«@name»; + + #ifdef __cplusplus + } + #endif + || + + template "item" + || + case PEP_«yml:abbr(../@name)»_«@name»: + return "«translate(@name,'_',' ')»"; + || + + template "doc" + || + + // «.» + + || +} +