forked from zerothi/fdict
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dict_funcs_inc.inc
46 lines (43 loc) · 1.33 KB
/
dict_funcs_inc.inc
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
40
41
42
43
44
45
46
#ifdef COMMENTS
! For LICENSE, see README.md
#endif
function ROUTINE(dict_kv,VAR)(key,val) result(this)
character(len=*), intent(in) :: key
VAR_TYPE, intent(in)DIMS :: val
type(dict) :: this
this = new_d_key(key)
call assign(this%first%value,val)
end function ROUTINE(dict_kv,VAR)
function ROUTINE(dict_kvp,VAR)(key, val) result(this)
character(len=*), intent(in) :: key
#ifdef COMMENTS
! Setting the intent(inout) ensures that no constants
! will be able to be passed.
! However, the dictionary type does not allow
! this due to OPERATORS, hence we keep it as this
! and proclaim that any user creating a pointer
! to a constant is insane...
#endif
VAR_TYPE, intent(in)DIMS, target :: val
type(dict) :: this
this = new_d_key(key)
call associate(this%first%value,val)
end function ROUTINE(dict_kvp,VAR)
subroutine ROUTINE(dict_get_val,VAR)(val,this,key)
VAR_TYPE, intent(out)DIMS :: val
type(dict), intent(inout) :: this
character(len=*), intent(in) :: key
type(var) :: v
call associate(v,this,key=key)
call assign(val,v)
call nullify(v)
end subroutine ROUTINE(dict_get_val,VAR)
subroutine ROUTINE(dict_get_p,VAR)(val,this,key)
VAR_TYPE, pointer DIMS :: val
type(dict), intent(inout) :: this
character(len=*), intent(in) :: key
type(var) :: v
call associate(v,this,key=key)
call associate(val,v)
call nullify(v)
end subroutine ROUTINE(dict_get_p,VAR)