diff options
author | Gianni Ceccarelli <gianni.ceccarelli@broadbean.com> | 2023-07-13 17:29:26 +0100 |
---|---|---|
committer | Gianni Ceccarelli <gianni.ceccarelli@broadbean.com> | 2023-07-13 17:29:26 +0100 |
commit | c3141fc3b3c8d6fb7270a3a1cd15be4895ea052d (patch) | |
tree | 51e0ab1cca45f5d9491ab04b2a9ea80425a40474 /bos-dispatch.sh | |
parent | some docs (diff) | |
download | bash-object-system-c3141fc3b3c8d6fb7270a3a1cd15be4895ea052d.tar.gz bash-object-system-c3141fc3b3c8d6fb7270a3a1cd15be4895ea052d.tar.bz2 bash-object-system-c3141fc3b3c8d6fb7270a3a1cd15be4895ea052d.zip |
flailing about with MOPs
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" "$@" +} |