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.
This commit is contained in:
parent
6b040fc505
commit
9ae46690bd
20
xlat/gen.sh
20
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}"
|
||||
|
Loading…
x
Reference in New Issue
Block a user