diff options
author | dakkar <dakkar@thenautilus.net> | 2023-07-22 16:05:29 +0100 |
---|---|---|
committer | dakkar <dakkar@thenautilus.net> | 2023-07-22 16:05:29 +0100 |
commit | 4b1b923e1426904b556349c8fe4b1b0453a7223f (patch) | |
tree | 85f1f7b70ad66b5199501d148a9fc7d27b6c099e | |
parent | single meta class (diff) | |
download | bash-object-system-4b1b923e1426904b556349c8fe4b1b0453a7223f.tar.gz bash-object-system-4b1b923e1426904b556349c8fe4b1b0453a7223f.tar.bz2 bash-object-system-4b1b923e1426904b556349c8fe4b1b0453a7223f.zip |
move constructor to global base class
-rw-r--r-- | bos-base.sh | 13 | ||||
-rw-r--r-- | bos-meta-class.sh | 2 | ||||
-rw-r--r-- | bos-sugar.sh | 13 | ||||
-rw-r--r-- | t/testlib.sh | 1 |
4 files changed, 16 insertions, 13 deletions
diff --git a/bos-base.sh b/bos-base.sh new file mode 100644 index 0000000..d964177 --- /dev/null +++ b/bos-base.sh @@ -0,0 +1,13 @@ +#!bash + +function bos/base/new-into() { + local class _; bos-object/unpack-self-into class _ "$self" + local -n new_into_result="$1"; shift + local metaclass_ref; bos-namespaces/store-scalar-for-into metaclass_ref meta "$class" + local -n metaclass_object="$metaclass_ref" + + local new_object + $metaclass_object create-object-into new_object "$class" "$@" + + new_into_result="$new_object" +} diff --git a/bos-meta-class.sh b/bos-meta-class.sh index 4d701b5..9bfdd0a 100644 --- a/bos-meta-class.sh +++ b/bos-meta-class.sh @@ -53,6 +53,8 @@ function bos/meta/class/make-mro-for() { $self get-superclasses-for-into nextclasses "$class" done + mro+=( "bos/base" ) + return 0 } diff --git a/bos-sugar.sh b/bos-sugar.sh index f7e790a..8f3a810 100644 --- a/bos-sugar.sh +++ b/bos-sugar.sh @@ -57,19 +57,6 @@ function bos-sugar/class-open() { local fq_class; bos-namespaces/current-namespace-into fq_class bos-sugar/set-metaclass-for "$fq_class" - # this will get renamed into the class - function new-into() { - local class _; bos-object/unpack-self-into class _ "$self" - local -n new_into_result="$1"; shift - local metaclass_ref; bos-namespaces/store-scalar-for-into metaclass_ref meta "$class" - local -n metaclass_object="$metaclass_ref" - - local new_object - $metaclass_object create-object-into new_object "$class" "$@" - - new_into_result="$new_object" - } - return 0 } diff --git a/t/testlib.sh b/t/testlib.sh index 00b82af..af5eed2 100644 --- a/t/testlib.sh +++ b/t/testlib.sh @@ -4,6 +4,7 @@ PS4='[${#FUNCNAME[*]}] ${BASH_SOURCE[0]}:${LINENO} (${FUNCNAME[0]}) +' . bos-namespaces.sh . bos-object-id.sh +. bos-base.sh . bos-meta-class.sh . bos-dispatch.sh . bos-sugar.sh |