From 53017aeaaf162f4668155001900cc24571595a43 Mon Sep 17 00:00:00 2001 From: Gianni Ceccarelli Date: Thu, 27 Jul 2023 15:00:18 +0100 Subject: untested start of attribute support --- bos-meta-attribute.sh | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 bos-meta-attribute.sh (limited to 'bos-meta-attribute.sh') diff --git a/bos-meta-attribute.sh b/bos-meta-attribute.sh new file mode 100644 index 0000000..78c573e --- /dev/null +++ b/bos-meta-attribute.sh @@ -0,0 +1,38 @@ +#!bash + +# this must be callable without a `self`, see +# bos/meta/class/get-attribute-by-name-into +function bos/meta/attribute/store-for-into() { + local bos_meta_attribute_class bos_meta_attribute_objid + bos-object/unpack-self-into bos_meta_attribute_class bos_meta_attribute_objid "$2" + + "bos-namespaces/${attribute_type}-store-for-into" "$1" attribute "$attribute_name" "$associated_class" "$bos_meta_attribute_class" "$bos_meta_attribute_objid" +} + +function bos/meta/attribute/set-value() { + local bos_meta_attribute_store; $self store-for-into bos_meta_attribute_store "$1" + shift + + case "$attribute_type" in + scalar) bos_meta_attribute_store="$1" ;; + array) bos_meta_attribute_store=( "$@" ) ;; + assoc) >&2 echo "NYI"; return 1 ;; + esac + + return 0 +} + +function bos/meta/attribute/get-value-into() { + local -n bos_meta_attribute_result="$1"; shift; + + local bos_meta_attribute_store; $self store-for-into bos_meta_attribute_store "$1" + + case "$attribute_type" in + scalar) bos_meta_attribute_result="$bos_meta_attribute_store" ;; + array) bos_meta_attribute_result=( "${bos_meta_attribute_store[@]}" ) ;; + assoc) >&2 echo "NYI"; return 1 ;; + esac + + return 0 +} + -- cgit v1.2.3