summaryrefslogtreecommitdiff
path: root/bos-dispatch.sh
blob: 47b5f33c4f95d22f9dd83c8eadefb2b1bfcb446c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!bash 
 
# the bare-bones / fallback dispatcher 
function bos-dispatch/invoke() {
    local class="$1";shift
    local self_id="$1";shift
    local method="$1";shift
 
    local self
    bos-object-id/pack-self-into "$class" "$self_id" self
 
    if declare -F "$class/$method" >/dev/null; then
        "$class/$method" "$@"
        return $?
    fi
 
    local metaclass_ref
    bos-namespaces/store-for-into meta "$class" metaclass_ref
    local -n metaclass_object="$metaclass_ref"
 
    $metaclass_object invoke "$class" "$self_id" "$method" "$@"
}