diff options
author | Gianni Ceccarelli <gianni.ceccarelli@broadbean.com> | 2023-07-27 15:00:18 +0100 |
---|---|---|
committer | Gianni Ceccarelli <gianni.ceccarelli@broadbean.com> | 2023-07-27 15:00:18 +0100 |
commit | 53017aeaaf162f4668155001900cc24571595a43 (patch) | |
tree | a67f643638768fadd7f5887e9af2e067e97a4549 /bos-meta-attribute.sh | |
parent | simpler syntax for assoc assginments (diff) | |
download | bash-object-system-53017aeaaf162f4668155001900cc24571595a43.tar.gz bash-object-system-53017aeaaf162f4668155001900cc24571595a43.tar.bz2 bash-object-system-53017aeaaf162f4668155001900cc24571595a43.zip |
untested start of attribute support
Diffstat (limited to 'bos-meta-attribute.sh')
-rw-r--r-- | bos-meta-attribute.sh | 38 |
1 files changed, 38 insertions, 0 deletions
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 +} + |