summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--eshtrans/eshrt/eshrtbegin.esh43
1 files changed, 43 insertions, 0 deletions
diff --git a/eshtrans/eshrt/eshrtbegin.esh b/eshtrans/eshrt/eshrtbegin.esh
index fcc2df1..1848c45 100644
--- a/eshtrans/eshrt/eshrtbegin.esh
+++ b/eshtrans/eshrt/eshrtbegin.esh
@@ -33,6 +33,11 @@ __prev_vars=''
__var=''
__val=''
__fn_frame=0
+__paramc=''
+__paramv=''
+__param=''
+__i=0
+__err=false
__fn_begin_hooks=''
__fn_end_hooks=''
__init_funcs=''
@@ -230,6 +235,44 @@ __static()
done
}
+__check_args()
+{
+ __fn="${1}"
+ __paramc="${2}"
+ __paramv="${3}"
+ shift 3
+
+ if [ ${#} -ne ${__paramc} ]; then
+ printf 'Error: Incorrect number of arguments to function %s\n' \
+ "${__fn}()" >&2
+ exit 1
+ fi
+ unset IFS
+ __i=0
+ for __param in ${__paramv}; do
+ __i=$((${__i} + 1))
+ __err=false
+ case "${__param%:*}" in
+ 'bool')
+ case "${1}" in 'true'|'false');; *) __err=true;;
+ esac
+ ;;
+ 'int')
+ case "${1}" in *[!0-9]*) __err=true;; esac
+ ;;
+ esac
+ if ${__err}; then
+ printf 'Error: Argument %d of %s() %s (%s %s)\n' \
+ ${__i} "${__fn}" 'has incorrect type' \
+ 'expecting' "${__param%:*}" >&2
+ exit 1
+ else
+ __local "${__param#*:}=${1}"
+ fi
+ shift 1
+ done
+}
+
__fn_begin_hook()
{
__fn_begin_hooks="${__fn_begin_hooks} ${1}"