]> matita.cs.unibo.it Git - helm.git/blob - helm/DEVEL/lablgtk_gtkmathview/lablgtk-20000829_gtkmathview-0.2.0/minidom/ml_minidom.c
Repository fixing
[helm.git] / helm / DEVEL / lablgtk_gtkmathview / lablgtk-20000829_gtkmathview-0.2.0 / minidom / ml_minidom.c
1
2 #include <assert.h>
3 #include <mlvalues.h>
4 #include <memory.h>
5
6 #include "minidom.h"
7 #include "ml_minidom.h"
8
9 static value
10 ml_some(value v)
11 {
12   CAMLparam1(v);
13   value ret = alloc_small(1,0);
14   Field(ret,0) = v;
15   CAMLreturn(ret);
16 }
17
18 value
19 ml_string_of_mDOMString(value s)
20 {
21   CAMLparam1(s);
22   CAMLreturn(s);
23 }
24
25 value
26 ml_mDOMString_of_string(value s)
27 {
28   CAMLparam1(s);
29   CAMLreturn(s);
30 }
31
32 value
33 ml_doc_load(value file_name)
34 {
35   mDOMDocRef doc_ref;
36
37   CAMLparam1(file_name);
38
39   doc_ref = mdom_load(String_val(file_name), FALSE, NULL);
40   if (doc_ref == NULL) failwith("minidom: could not load document");
41
42   CAMLreturn((value) doc_ref);
43 }
44
45 value
46 ml_doc_unload(value doc)
47 {
48   CAMLparam1(doc);
49
50   mdom_unload((mDOMDocRef) doc);
51
52   CAMLreturn(Val_unit);
53 }
54
55 value
56 ml_doc_new(value s)
57 {
58   mDOMDocRef doc_ref;
59
60   CAMLparam1(s);
61
62   doc_ref = mdom_doc_new(mDOMString_val(s));
63   if (doc_ref == NULL) failwith("minidom: could not create new document");
64
65   CAMLreturn((value) doc_ref);
66 }
67
68
69 value
70 ml_doc_get_root_node(value doc)
71 {
72   mDOMNodeRef root;
73
74   CAMLparam1(doc);
75   root = mdom_doc_get_root_node((mDOMDocRef) doc);
76   if (root == NULL) failwith("minidom: document has no root node!");
77
78   CAMLreturn((value) root);
79 }
80
81 value
82 ml_doc_add_entity(value doc, value name, value content)
83 {
84   mDOMEntityRef ent;
85
86   CAMLparam3(doc, name, content);
87   ent = mdom_doc_add_entity((mDOMDocRef) doc, mDOMString_val(name), mDOMString_val(content));
88   if (ent == NULL) failwith("minidom: could not add entity");
89
90   CAMLreturn((value) ent);
91 }
92
93 value
94 ml_doc_get_entity(value doc, value name)
95 {
96   mDOMEntityRef ent;
97
98   CAMLparam2(doc, name);
99   ent = mdom_doc_get_entity((mDOMDocRef) doc, mDOMString_val(name));
100
101   CAMLreturn(Val_option(ent, Val_ptr));
102 }
103
104 value
105 ml_doc_get_predefined_entity(value name)
106 {
107   mDOMEntityRef ent;
108
109   CAMLparam1(name);
110   ent = mdom_get_predefined_entity(mDOMString_val(name));
111
112   CAMLreturn(Val_option(ent, Val_ptr));
113 }
114
115 value
116 ml_entity_get_content(value ent)
117 {
118   CAMLparam1(ent);
119   CAMLreturn(Val_mDOMString(mdom_entity_get_content((mDOMEntityRef) ent)));
120 }
121
122 value
123 ml_node_is_text(value node)
124 {
125   CAMLparam1(node);
126   CAMLreturn(Val_bool(mdom_node_is_text((mDOMNodeRef) node)));
127 }
128
129 value
130 ml_node_is_element(value node)
131 {
132   CAMLparam1(node);
133   CAMLreturn(Val_bool(mdom_node_is_element((mDOMNodeRef) node)));
134 }
135
136 value
137 ml_node_is_blank(value node)
138 {
139   CAMLparam1(node);
140   CAMLreturn(Val_bool(mdom_node_is_blank((mDOMNodeRef) node)));
141 }
142
143 value
144 ml_node_is_entity_ref(value node)
145 {
146   CAMLparam1(node);
147   CAMLreturn(Val_bool(mdom_node_is_entity_ref((mDOMNodeRef) node)));
148 }
149
150 value
151 ml_node_get_type(value node)
152 {
153   CAMLparam1(node);
154   CAMLreturn(Val_int(mdom_node_get_type((mDOMNodeRef) node)));
155 }
156
157 value
158 ml_node_get_name(value node)
159 {
160   CAMLparam1(node);
161   CAMLreturn(Val_option(mdom_node_get_name((mDOMNodeRef) node), Val_mDOMString));
162 }
163
164 value
165 ml_node_get_ns_uri(value node)
166 {
167   CAMLparam1(node);
168   CAMLreturn(Val_option(mdom_node_get_ns_uri((mDOMNodeRef) node), Val_mDOMString));
169 }
170
171 value
172 ml_node_get_attribute(value node, value name)
173 {
174   CAMLparam2(node,name);
175   CAMLreturn(Val_option(mdom_node_get_attribute((mDOMNodeRef) node, String_val(name)), Val_mDOMString));
176 }
177
178 value
179 ml_node_get_attribute_ns(value node, value name, value ns_uri)
180 {
181   CAMLparam2(node,name);
182   CAMLreturn(Val_option(mdom_node_get_attribute_ns((mDOMNodeRef) node,
183                                                    String_val(name),
184                                                    String_val(ns_uri)), Val_mDOMString));
185 }
186
187 value
188 ml_node_get_parent(value node)
189 {
190   CAMLparam1(node);
191   CAMLreturn(Val_option(mdom_node_get_parent((mDOMNodeRef) node), Val_ptr));
192 }
193
194 value
195 ml_node_get_prev_sibling(value node)
196 {
197   CAMLparam1(node);
198   CAMLreturn(Val_option(mdom_node_get_prev_sibling((mDOMNodeRef) node), Val_ptr));
199 }
200
201 value
202 ml_node_get_next_sibling(value node)
203 {
204   CAMLparam1(node);
205   CAMLreturn(Val_option(mdom_node_get_next_sibling((mDOMNodeRef) node), Val_ptr));
206 }
207
208 value
209 ml_node_get_first_child(value node)
210 {
211   CAMLparam1(node);
212   CAMLreturn(Val_option(mdom_node_get_first_child((mDOMNodeRef) node), Val_ptr));
213 }
214
215 value
216 ml_node_get_first_attribute(value node)
217 {
218   CAMLparam1(node);
219   CAMLreturn(Val_option(mdom_node_get_first_attribute((mDOMNodeRef) node), Val_ptr));
220 }
221
222 value
223 ml_node_is_first(value node)
224 {
225   CAMLparam1(node);
226   CAMLreturn(Val_bool(mdom_node_is_first((mDOMNodeRef) node)));
227 }
228
229 value
230 ml_node_is_last(value node)
231 {
232   CAMLparam1(node);
233   CAMLreturn(Val_bool(mdom_node_is_last((mDOMNodeRef) node)));
234 }
235
236 value
237 ml_attr_get_name(value attr)
238 {
239   CAMLparam1(attr);
240   CAMLreturn(Val_option(mdom_attr_get_name((mDOMAttrRef) attr), Val_mDOMString));
241 }
242
243 value
244 ml_attr_get_ns_uri(value attr)
245 {
246   CAMLparam1(attr);
247   CAMLreturn(Val_option(mdom_attr_get_ns_uri((mDOMAttrRef) attr), Val_mDOMString));
248 }
249
250 value
251 ml_attr_get_value(value attr)
252 {
253   CAMLparam1(attr);
254   CAMLreturn(Val_option(mdom_attr_get_value((mDOMAttrRef) attr), Val_mDOMString));
255 }
256
257 value
258 ml_attr_get_prev_sibling(value attr)
259 {
260   CAMLparam1(attr);
261   CAMLreturn(Val_option(mdom_attr_get_prev_sibling((mDOMAttrRef) attr), Val_ptr));
262 }
263
264 value
265 ml_attr_get_next_sibling(value attr)
266 {
267   CAMLparam1(attr);
268   CAMLreturn(Val_option(mdom_attr_get_next_sibling((mDOMAttrRef) attr), Val_ptr));
269 }
270
271 value
272 ml_attr_get_parent(value attr)
273 {
274   CAMLparam1(attr);
275   CAMLreturn(Val_option(mdom_attr_get_parent((mDOMAttrRef) attr), Val_ptr));
276 }
277