From 86278c154c0e8f88f3df91298b4fcd40f8c7571b Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch Date: Thu, 29 Sep 2022 16:39:26 +0200 Subject: Clean up protocol code generators --- xC-gen-proto.awk | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'xC-gen-proto.awk') diff --git a/xC-gen-proto.awk b/xC-gen-proto.awk index 9b65a74..1a9ab1f 100644 --- a/xC-gen-proto.awk +++ b/xC-gen-proto.awk @@ -22,7 +22,7 @@ # unless this role is already filled by, e.g., WebSocket. # # Usage: env LC_ALL=C awk -f xC-gen-proto.awk -f xC-gen-proto-{c,go,js}.awk \ -# xC-proto > xC-proto.{c,go,js} | {clang-format,gofmt,...} +# -v PrefixCamel=Relay xC-proto > xC-proto.{c,go,js} | {clang-format,gofmt,...} # --- Utilities ---------------------------------------------------------------- @@ -289,12 +289,14 @@ function deftype() { return 0 } -BEGIN { - PrefixLower = "relay_" - PrefixUpper = "RELAY_" - PrefixCamel = "Relay" +{ + if (PrefixCamel) { + PrefixLower = tolower(cameltosnake(PrefixCamel)) "_" + PrefixUpper = toupper(cameltosnake(PrefixCamel)) "_" + } - print "// Generated by xC-gen-proto.awk. DO NOT MODIFY." + # This is not in a BEGIN clause (even though it consumes all input), + # so that the code generator can insert the first FILENAME. codegen_begin() nexttoken() -- cgit v1.2.3-54-g00ecf