2 # SPDX-License-Identifier: LGPL-3-or-later
3 # See Notices.txt for copyright information
5 # utility script for expanding input type annotations for SimdMap methods.
6 # not actually needed anymore, but I thought I'd commit it in case anyone
9 mapfile lines
< src
/ieee754
/part
/util.pyi
15 ((state
= LOOKING_FOR_DEF
))
17 # split into list of python method definitions
18 for line
in "${lines[@]}"; do
19 if ((state
== LOOKING_FOR_DEF
)); then
20 if [[ "$line" =~ ^
' '*'def ' ]]; then
21 ((state
= PARSING_BODY
))
24 elif [[ "$line" =~ ^
' '*'@' ]]; then
27 ((state
= LOOKING_FOR_DEF
))
28 elif [[ "$line" =~ ^
' '*'def ' ]]; then
35 if [[ "$def" != "" ]]; then
39 # expand all occurrences of _SimdMapInput[_T...]
43 old_defs
=("${defs[@]}")
45 for def
in "${old_defs[@]}"; do
46 if [[ "$def" =~ ^
(.
*)'Optional[_SimdMapInput['(_T
[0-9]*)']]'(.
*)$
]] ||
47 [[ "$a" =~ ^
(.
*)'_SimdMapInput['(_T
[0-9]*)']'(.
*)$
]]; then
49 defs
+=("${BASH_REMATCH[1]}SimdMap[${BASH_REMATCH[2]}]${BASH_REMATCH[3]}")
50 defs
+=("${BASH_REMATCH[1]}Mapping[_ElWid, Optional[${BASH_REMATCH[2]}]]${BASH_REMATCH[3]}")
51 defs
+=("${BASH_REMATCH[1]}Optional[${BASH_REMATCH[2]}]${BASH_REMATCH[3]}")
58 printf "%s" "${defs[@]}" > out.txt