summaryrefslogtreecommitdiff
path: root/bos-meta-attribute.sh
blob: b5155ad42220a0b97d648334e734fab66ce5ea0e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!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/store-${attribute_type}-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_name; $self store-for-into bos_meta_attribute_store_name "$1"
    shift
    local -n bos_meta_attribute_store="$bos_meta_attribute_store_name"
 
    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_name; $self store-for-into bos_meta_attribute_store_name "$1"
    local -n bos_meta_attribute_store="$bos_meta_attribute_store_name"
 
    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
}