summaryrefslogtreecommitdiff
path: root/bos-meta-attribute.sh
diff options
context:
space:
mode:
Diffstat (limited to 'bos-meta-attribute.sh')
-rw-r--r--bos-meta-attribute.sh81
1 files changed, 79 insertions, 2 deletions
diff --git a/bos-meta-attribute.sh b/bos-meta-attribute.sh
index b5155ad..0d65dce 100644
--- a/bos-meta-attribute.sh
+++ b/bos-meta-attribute.sh
@@ -9,7 +9,61 @@ function bos/meta/attribute/store-for-into() {
"bos-namespaces/store-${attribute_type}-for-into" "$1" attribute "$attribute_name" "$associated_class" "$bos_meta_attribute_class" "$bos_meta_attribute_objid"
}
+function bos/meta/attribute/get-attribute-name-into() {
+ local attribute_type='scalar'
+ local associated_class='bos/meta/attribute'
+
+ local bos_meta_attribute_name_store
+ local attribute_name='attribute_name'
+ bos/meta/attribute/store-for-into bos_meta_attribute_name_store "$self"
+
+ local -n bos_meta_attribute_name="$bos_meta_attribute_name_store"
+
+ >&2 echo "get-attribute-name-into($1)<-$bos_meta_attribute_name_store"
+ local -n bos_meta_attribute_name_dest="$1"
+ bos_meta_attribute_name_dest="$bos_meta_attribute_name"
+}
+
+function bos/meta/attribute/get-attribute-type-into() {
+ local attribute_type='scalar'
+ local associated_class='bos/meta/attribute'
+
+ local bos_meta_attribute_type_store
+ local attribute_name='attribute_type'
+ bos/meta/attribute/store-for-into bos_meta_attribute_type_store "$self"
+
+ local -n bos_meta_attribute_type="$bos_meta_attribute_type_store"
+
+ local -n bos_meta_attribute_type_dest="$1"
+ bos_meta_attribute_type_dest="$bos_meta_attribute_type"
+}
+
+function bos/meta/attribute/get-associated-class-into() {
+ local attribute_type='scalar'
+ local associated_class='bos/meta/attribute'
+
+ local bos_meta_attribute_class_store
+ local attribute_name='associated_class'
+ bos/meta/attribute/store-for-into bos_meta_attribute_class_store "$self"
+
+ local -n bos_meta_attribute_class="$bos_meta_attribute_class_store"
+
+ local -n bos_meta_attribute_class_dest="$1"
+ bos_meta_attribute_class_dest="$bos_meta_attribute_class"
+}
+
function bos/meta/attribute/set-value() {
+ # the `if` is there because bos-meta-bootstrap.sh sets these manually
+ if [[ -z "$attribute_name" ]]; then
+ local bos_meta_attribute_set_name; $self get-attribute-name-into bos_meta_attribute_set_name
+ local bos_meta_attribute_set_type; $self get-attribute-type-into bos_meta_attribute_set_type
+ local bos_meta_attribute_set_class; $self get-associated-class-into bos_meta_attribute_set_class
+
+ local attribute_name="$bos_meta_attribute_set_name"
+ local attribute_type="$bos_meta_attribute_set_type"
+ local associated_class="$bos_meta_attribute_set_class"
+ fi
+
local bos_meta_attribute_store_name; $self store-for-into bos_meta_attribute_store_name "$1"
shift
local -n bos_meta_attribute_store="$bos_meta_attribute_store_name"
@@ -17,23 +71,46 @@ function bos/meta/attribute/set-value() {
case "$attribute_type" in
scalar) bos_meta_attribute_store="$1" ;;
array) bos_meta_attribute_store=( "$@" ) ;;
- assoc) >&2 echo "NYI"; return 1 ;;
+ assoc) eval "bos_meta_attribute_store=( ${@@Q} )" ;;
esac
+ >&2 declare -p "$bos_meta_attribute_store_name"
+
return 0
}
function bos/meta/attribute/get-value-into() {
+ local bos_meta_attribute_result_name="$1"
local -n bos_meta_attribute_result="$1"; shift;
+ # meta-look! we can't depend on bos-dispatch/invoke or
+ # bos/meta/class/invoke to set these up
+
+ local bos_meta_attribute_get_name; $self get-attribute-name-into bos_meta_attribute_get_name
+ local bos_meta_attribute_get_type; $self get-attribute-type-into bos_meta_attribute_get_type
+ local bos_meta_attribute_get_class; $self get-associated-class-into bos_meta_attribute_get_class
+
+ local attribute_name="$bos_meta_attribute_get_name"
+ local attribute_type="$bos_meta_attribute_get_type"
+ local associated_class="$bos_meta_attribute_get_class"
+
+ >&2 echo "getting ($self) ($attribute_name) ($attribute_type) ($associated_class)"
+
local bos_meta_attribute_store_name; $self store-for-into bos_meta_attribute_store_name "$1"
local -n bos_meta_attribute_store="$bos_meta_attribute_store_name"
+ local bos_meta_attribute_value_expr
+
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 ;;
+ assoc)
+ bos_meta_attribute_value_expr="$(declare -p "$bos_meta_attribute_store_name")"
+ eval "bos_meta_attribute_result=${bos_meta_attribute_value_expr#*=}"
+ ;;
esac
+ >&2 declare -p "$bos_meta_attribute_result_name"
+
return 0
}