function bos-dispatch/caller-into() {
local -n bos_dispatch_caller_result="$1"
local idx
for caller in "${FUNCNAME[@]}"; do
if [[ ! $caller =~ ^bos[_/-] ]]; then
bos_dispatch_caller_result="$caller"
return 0
fi
done
return 1
}
function bos-dispatch/invoke() {
local class="$1";shift
local self_id="$1";shift
local method="$1";shift
local qualified_method="$class/$method"
if [[ "$method" =~ / ]]; then
qualified_method="$method"
fi
if declare -F "$qualified_method" >/dev/null; then
local self
bos-object-id/pack-self-into self "$class" "$self_id"
"$qualified_method" "$@"
return $?
fi
local metaclass_ref
bos-namespaces/store-scalar-for-into metaclass_ref meta "$class"
local -n metaclass_object="$metaclass_ref"
$metaclass_object invoke "$class" "$self_id" "$method" "$@"
return $?
}