diff options
author | Gianni Ceccarelli <gianni.ceccarelli@broadbean.com> | 2023-07-14 15:22:38 +0100 |
---|---|---|
committer | Gianni Ceccarelli <gianni.ceccarelli@broadbean.com> | 2023-07-14 15:22:38 +0100 |
commit | 6297ec2ae4263c346a9f7cf036055ca8cdb72c78 (patch) | |
tree | 77263057ecc8c925315cd6cd10939a0cf0942413 /bos-mop.sh | |
parent | much better encoding (diff) | |
download | bash-object-system-6297ec2ae4263c346a9f7cf036055ca8cdb72c78.tar.gz bash-object-system-6297ec2ae4263c346a9f7cf036055ca8cdb72c78.tar.bz2 bash-object-system-6297ec2ae4263c346a9f7cf036055ca8cdb72c78.zip |
inheritance via MOP
*probably*, I'm still not completely certain I've found all the
weirdness
Diffstat (limited to 'bos-mop.sh')
-rw-r--r-- | bos-mop.sh | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -23,6 +23,12 @@ function bos/mop/base/find-method-into() { local mro_store; $self mro-for-into "$class" mro_store local -n mro="$mro_store" + + # minimal MRO: the class itself + if [[ "${#mro[@]}" -eq 0 ]]; then + mro=( "$class" ) + fi + local idx=0 # if we don't have a $start_from_class, it means we're doing the @@ -67,14 +73,18 @@ function bos/mop/base/invoke() { fi # get the first class that defines the method - local to_invoke - $self find-method-into "$class" "$start_from_class" "$method" to_invoke + + # there is some fuckery going on with namerefs, recursion, and + # local; this is a probably-bad-but-works workaround: use a + # different variable name in different recursive calls + local ffsname="to_invoke_${#FUNCNAME[*]}" + $self find-method-into "$class" "$start_from_class" "$method" "$ffsname" # TODO: make the fields accessible! - local self bos-object-id/pack-self-into "$class" "$object_id" self # call it - "$to_invoke" "$@" + eval "\"\$$ffsname\" \"\$@\"" + return $? } |