From c3141fc3b3c8d6fb7270a3a1cd15be4895ea052d Mon Sep 17 00:00:00 2001 From: Gianni Ceccarelli Date: Thu, 13 Jul 2023 17:29:26 +0100 Subject: flailing about with MOPs --- bos-dispatch.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 bos-dispatch.sh (limited to 'bos-dispatch.sh') 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" "$@" +} -- cgit v1.2.3