diff options
Diffstat (limited to 'bos-dispatch.sh')
-rw-r--r-- | bos-dispatch.sh | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/bos-dispatch.sh b/bos-dispatch.sh new file mode 100644 index 0000000..47b5f33 --- /dev/null +++ b/bos-dispatch.sh @@ -0,0 +1,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" "$@" +} |