bos_namespaces__bos__mop__base__meta="bos-dipatch/invoke bos/mop/base 0"
declare -a bos_namespaces__bos__mop__base__mro=( "bos/mop/base" )
function bos/mop/base/mro-for-into() {
bos-namespaces/store-array-for-into mro "$1" "$2"
}
function bos/mop/base/find-method-into() {
local class="$1"
local start_from_class="$2"
local method="$3"
local -n result="$4"
local mro_store; $self mro-for-into "$class" mro_store
local -n mro="$mro_store"
local idx=0
if [[ -n "$start_from_class" ]]; then
for (( ; idx < "${#mro[@]}" ; ++idx )); do
if [[ "${mro[$idx]}" == "$start_from_class" ]]; then
(( ++idx ))
break
fi
done
fi
for (( ; idx < "${#mro[@]}" ; ++idx )); do
local full_name="${mro[$idx]}/${method}"
if declare -F "$full_name" >/dev/null; then
result="${full_name}"
return 0
fi
done
>&2 echo "method $method not found"
return 1
}
function bos/mop/base/invoke() {
local class="$1";shift
local object_id="$1";shift
local method="$1";shift
local start_from_class=''
if [[ "$method" == 'next/method' ]]; then
local caller; bos-dispatch/caller-into caller
method="${caller##*/}"
start_from_class="${caller%/*}"
fi
local to_invoke
$self find-method-into "$class" "$start_from_class" "$method" to_invoke
local self
bos-object-id/pack-self-into "$class" "$object_id" self
"$to_invoke" "$@"
}