bos_5fbos_2fmop_2fbase_5fmeta="bos-dipatch/invoke bos/mop/base 0"
declare -a bos_5fbos_2fmop_2fbase_5fmro=( "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 bos_mop_base_find_method_result="$4"
local mro_store; $self mro-for-into "$class" mro_store
local -n mro="$mro_store"
if [[ "${#mro[@]}" -eq 0 ]]; then
mro=( "$class" )
fi
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
bos_mop_base_find_method_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 ffsname="to_invoke_${#FUNCNAME[*]}"
$self find-method-into "$class" "$start_from_class" "$method" "$ffsname"
bos-object-id/pack-self-into "$class" "$object_id" self
eval "\"\$$ffsname\" \"\$@\""
return $?
}
function bos/mop/base/create-object-into() {
local -n bos_mop_base_create_object_result="$1";shift
local class="$1";shift
local object_id_store; bos-namespaces/store-scalar-for-into object_id "$class" object_id_store
local -n object_id="$object_id_store"
(( ++object_id ))
bos-object-id/pack-self-into "$class" "$object_id" bos_mop_base_create_object_result
return 0
}