From 9ae46690bd49431dcec13b2fe3ecd5331a8ad220 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Fri, 29 Apr 2016 01:02:13 +0000 Subject: [PATCH] xlat: extend syntax with #val_type directive When #val_type directive is encountered, gen.sh starts using XLAT_TYPE/XLAT_TYPE_PAIR macros instead of XLAT/XLAT_PAIR, with #val_type's argument as a type. For example, "#val_type uint64_t" means values of type uint64_t. * xlat/gen.sh (gen_header, print_xlat, print_xlat_pair): Add val_type support. --- xlat/gen.sh | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/xlat/gen.sh b/xlat/gen.sh index ac3d4663..7b074ef5 100755 --- a/xlat/gen.sh +++ b/xlat/gen.sh @@ -64,7 +64,11 @@ print_xlat() local val val="$1"; shift - echo " XLAT(${val})," + if [ -z "${val_type-}" ]; then + echo " XLAT(${val})," + else + echo " XLAT_TYPE(${val_type}, ${val})," + fi } print_xlat_pair() @@ -73,7 +77,11 @@ print_xlat_pair() val="$1"; shift str="$1"; shift - echo " XLAT_PAIR(${val}, \"${str}\")," + if [ -z "${val_type-}" ]; then + echo " XLAT_PAIR(${val}, \"${str}\")," + else + echo " XLAT_TYPE_PAIR(${val_type}, ${val}, \"${str}\")," + fi } cond_xlat() @@ -134,6 +142,9 @@ gen_header() '#unterminated') unterminated=1 ;; + '#val_type '*) + # to be processed during 2nd pass + ;; '#'*) echo "${line}" ;; @@ -175,7 +186,7 @@ gen_header() fi echo "const struct xlat ${name}[] = {" - unconditional= + unconditional= val_type= # 2nd pass: output everything. while read line; do LC_COLLATE=C @@ -186,6 +197,9 @@ gen_header() '#unterminated') # processed during 1st pass ;; + '#val_type '*) + val_type="${line#\#val_type }" + ;; [A-Z_]*) # symbolic constants if [ -n "${unconditional}" ]; then print_xlat "${line}"