summaryrefslogtreecommitdiff
path: root/bos-meta-attribute.sh
diff options
context:
space:
mode:
authorGianni Ceccarelli <gianni.ceccarelli@broadbean.com>2023-07-27 15:00:18 +0100
committerGianni Ceccarelli <gianni.ceccarelli@broadbean.com>2023-07-27 15:00:18 +0100
commit53017aeaaf162f4668155001900cc24571595a43 (patch)
treea67f643638768fadd7f5887e9af2e067e97a4549 /bos-meta-attribute.sh
parentsimpler syntax for assoc assginments (diff)
downloadbash-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.sh38
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
+}
+