forked from andreww/fox
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathm_dom_object.m4
141 lines (134 loc) · 2.89 KB
/
m_dom_object.m4
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
include(`foreach.m4')`'dnl
dnl
dnl
define(`TOHW_m_dom_get', `dnl
dnl
dnl Provide a getter for the object:
dnl object is presumed to be a node named np
dnl $1 is attribute type
dnl $2 is attribute name
dnl $3 is location of value within node
dnl $4 is list of applicable node types
dnl
ifelse(`$1', `DOMString', `
pure function get$2_len(np, p) result(n)
type(Node), intent(in) :: np
logical, intent(in) :: p
integer :: n
ifelse(`$4', `', `dnl
if (p) then
', `dnl
if (p .and. ( &
dnl
m4_foreach(`x', `$4', `dnl
np%nodeType==x .or. &
')`'dnl
.false.)) then
')`'dnl
n = size(`$3')
else
n = 0
endif
end function get$2_len
')dnl
dnl
dnl
TOHW_function(`get$2', (np), c)
type(Node), pointer :: np
ifelse(`$1', `DOMString', `dnl
#ifdef RESTRICTED_ASSOCIATED_BUG
character(len=get$2_len(np, .true.)) :: c
#else
character(len=get$2_len(np, associated(np))) :: c
#endif
', `$1', `Node',`dnl
type(Node), pointer :: c
', `$1', `NodeList',`dnl
type(NodeList), pointer :: c
', `$1', `NamedNodeMap',`dnl
type(NamedNodeMap), pointer :: c
', `$1', `DOMConfiguration',`dnl
type(DOMConfiguration), pointer :: c
',`dnl
$1 :: c
')
if (.not.associated(np)) then
TOHW_m_dom_throw_error(FoX_NODE_IS_NULL)
endif
ifelse($4, `', `', `dnl
if (dnl
m4_foreach(`x', `$4', `getNodeType(np)/=x .and. &
')dnl
.true.) then
TOHW_m_dom_throw_error(FoX_INVALID_NODE)
endif
')`'dnl
ifelse(`$1', `DOMString', `dnl
c = str_vs($3)
', `$1', `Node', `dnl
c => $3
', `$1', `NodeList', `dnl
c => $3
', `$1', `NamedNodeMap', `dnl
c => $3
', `$1', `DOMConfiguration', `dnl
c => $3
',`dnl
c = $3
')
end function get$2
')dnl
dnl
define(`TOHW_m_dom_set', `dnl
dnl
dnl Provide a setter for the object:
dnl object is presumed to be a node named np
dnl $1 is attribute type
dnl $2 is attribute name
dnl $3 is location of value within node
dnl $4 is list of applicable node types
dnl
dnl
dnl
TOHW_subroutine(`set$2', (np, c))
type(Node), pointer :: np
ifelse(`$1', `DOMString', `dnl
character(len=*) :: c
', `$1', `Node',`dnl
type(Node), pointer :: c
', `$1', `NodeList',`dnl
type(NodeList), pointer :: c
', `$1', `NamedNodeMap',`dnl
type(NamedNodeMap), pointer :: c
', `$1', `DOMConfiguration',`dnl
type(DOMConfiguration), pointer :: c
',`dnl
$1 :: c
')
if (.not.associated(np)) then
TOHW_m_dom_throw_error(FoX_NODE_IS_NULL)
endif
ifelse($4, `', `', `dnl
if (dnl
m4_foreach(`x', `$4', `getNodeType(np)/=x .and. &
')dnl
.true.) then
TOHW_m_dom_throw_error(FoX_INVALID_NODE)
endif
')`'dnl
ifelse(`$1', `DOMString', `dnl
if (associated($3)) deallocate($3)
$3 => vs_str_alloc(c)
', `$1', `Node', `dnl
$3 => c
', `$1', `NodeList', `dnl
$3 => c
', `$1', `NamedNodeMap', `dnl
$3 => c
', `$1', `DOMConfiguration', `dnl
$3 => c
',`dnl
$3 = c
')
end subroutine set$2
')`'dnl