libxml-ruby 4.1.1-x64-mingw-ucrt → 4.1.2-x64-mingw-ucrt

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,251 +1,252 @@
1
- #include "ruby_libxml.h"
2
- #include "ruby_xml_schema_type.h"
3
- #include "ruby_xml_schema_element.h"
4
- #include "ruby_xml_schema_attribute.h"
5
- #include "ruby_xml_schema_facet.h"
6
-
7
- #define UNBOUNDED 1 << 30
8
- #define FREE_AND_NULL(str) if ((str) != NULL) { xmlFree((xmlChar *) (str)); str = NULL; }
9
-
10
- /**
11
- * xmlSchemaTreeItem:
12
- *
13
- * The abstract base type for tree-like structured schema components.
14
- * (Extends xmlSchemaAnnotItem)
15
- */
16
- typedef struct _xmlSchemaTreeItem xmlSchemaTreeItem;
17
- typedef xmlSchemaTreeItem *xmlSchemaTreeItemPtr;
18
- struct _xmlSchemaTreeItem {
19
- xmlSchemaTypeType type;
20
- xmlSchemaAnnotPtr annot;
21
- xmlSchemaTreeItemPtr next;
22
- xmlSchemaTreeItemPtr children;
23
- };
24
-
25
- /**
26
- * xmlSchemaParticle:
27
- *
28
- * A particle component.
29
- * (Extends xmlSchemaTreeItem)
30
- */
31
- typedef struct _xmlSchemaParticle xmlSchemaParticle;
32
- typedef xmlSchemaParticle *xmlSchemaParticlePtr;
33
- struct _xmlSchemaParticle {
34
- xmlSchemaTypeType type;
35
- xmlSchemaAnnotPtr annot;
36
- xmlSchemaTreeItemPtr next;
37
- /* next particle */
38
- xmlSchemaTreeItemPtr children;
39
- /* the "term" (e.g. a model group,
40
- a group definition, a XML_SCHEMA_EXTRA_QNAMEREF (if a reference),
41
- etc.) */
42
- int minOccurs;
43
- int maxOccurs;
44
- xmlNodePtr node;
45
- };
46
-
47
- VALUE cXMLSchemaType;
48
-
49
- static void rxml_schema_type_free(xmlSchemaTypePtr xschema_type)
50
- {
51
- xschema_type = NULL;
52
- xmlFree(xschema_type);
53
- }
54
-
55
- VALUE rxml_wrap_schema_type(xmlSchemaTypePtr xtype)
56
- {
57
- VALUE result;
58
-
59
- if (!xtype)
60
- rb_raise(rb_eArgError, "XML::Schema::Type required!");
61
-
62
- result = Data_Wrap_Struct(cXMLSchemaType, NULL, rxml_schema_type_free, xtype);
63
-
64
- rb_iv_set(result, "@name", QNIL_OR_STRING(xtype->name));
65
- rb_iv_set(result, "@namespace", QNIL_OR_STRING(xtype->targetNamespace));
66
- rb_iv_set(result, "@kind", INT2NUM(xtype->type));
67
-
68
- return result;
69
- }
70
-
71
- static VALUE rxml_schema_type_base(VALUE self)
72
- {
73
- xmlSchemaTypePtr xtype;
74
-
75
- Data_Get_Struct(self, xmlSchemaType, xtype);
76
-
77
- return (xtype->baseType != xtype) ? rxml_wrap_schema_type(xtype->baseType) : Qnil;
78
- }
79
-
80
- static VALUE rxml_schema_type_node(VALUE self)
81
- {
82
- xmlSchemaTypePtr xtype;
83
-
84
- Data_Get_Struct(self, xmlSchemaType, xtype);
85
-
86
- return (xtype->node != NULL) ? rxml_node_wrap(xtype->node) : Qnil;
87
- }
88
-
89
- static VALUE rxml_schema_type_facets(VALUE self)
90
- {
91
- xmlSchemaTypePtr xtype;
92
- xmlSchemaFacetPtr xfacet;
93
- VALUE result = rb_ary_new();
94
- VALUE facet;
95
-
96
- Data_Get_Struct(self, xmlSchemaType, xtype);
97
-
98
- xfacet = xtype->facets;
99
-
100
- while (xfacet != NULL)
101
- {
102
- facet = rxml_wrap_schema_facet((xmlSchemaFacetPtr)xfacet);
103
- rb_ary_push(result, facet);
104
- xfacet = xfacet->next;
105
- }
106
-
107
- return result;
108
- }
109
-
110
- static VALUE rxml_schema_type_annot(VALUE self)
111
- {
112
- VALUE result = Qnil;
113
- xmlSchemaTypePtr xtype;
114
-
115
- Data_Get_Struct(self, xmlSchemaType, xtype);
116
-
117
- if(xtype != NULL && xtype->annot != NULL && xtype->annot->content != NULL)
118
- {
119
- xmlChar *content = xmlNodeGetContent(xtype->annot->content);
120
- if (content)
121
- {
122
- result = rxml_new_cstr(content, NULL);
123
- xmlFree(content);
124
- }
125
- }
126
- return result;
127
- }
128
-
129
- static void rxmlSchemaCollectElements(xmlSchemaParticlePtr xparticle, VALUE hash)
130
- {
131
- VALUE element;
132
- xmlSchemaTreeItemPtr xterm;
133
-
134
- if (xparticle == NULL)
135
- return;
136
-
137
- xterm = xparticle->children;
138
-
139
- if (xterm != NULL)
140
- {
141
- switch (xterm->type)
142
- {
143
- case XML_SCHEMA_TYPE_ELEMENT:
144
- element = rxml_wrap_schema_element((xmlSchemaElementPtr)xterm);
145
- rb_iv_set(element, "@min", INT2NUM(xparticle->minOccurs));
146
-
147
- if (xparticle->maxOccurs >= UNBOUNDED)
148
- rb_iv_set(element, "@max", rb_const_get(rb_path2class("Float"), rb_intern("INFINITY")));
149
- else
150
- rb_iv_set(element, "@max", INT2NUM(xparticle->maxOccurs));
151
-
152
- if (xparticle->annot != NULL)
153
- {
154
- xmlChar *content = xmlNodeGetContent(xparticle->annot->content);
155
-
156
- if (content != NULL)
157
- {
158
- rb_iv_set(element, "@annotation", rb_str_new2((const char *) content));
159
- xmlFree(content);
160
- }
161
- }
162
-
163
- rb_hash_aset(hash, rb_str_new2((const char *) ((xmlSchemaElementPtr)xterm)->name), element);
164
- break;
165
-
166
- case XML_SCHEMA_TYPE_SEQUENCE:
167
- break;
168
-
169
- case XML_SCHEMA_TYPE_CHOICE:
170
- break;
171
-
172
- case XML_SCHEMA_TYPE_ALL:
173
- break;
174
-
175
- case XML_SCHEMA_TYPE_ANY:
176
- break;
177
-
178
- default:
179
- return;
180
- }
181
- }
182
-
183
- if (xterm &&
184
- ((xterm->type == XML_SCHEMA_TYPE_SEQUENCE) || (xterm->type == XML_SCHEMA_TYPE_CHOICE) || (xterm->type == XML_SCHEMA_TYPE_ALL)) &&
185
- (xterm->children != NULL))
186
- {
187
- rxmlSchemaCollectElements((xmlSchemaParticlePtr)xterm->children, hash);
188
- }
189
-
190
- if (xparticle->next != NULL)
191
- {
192
- rxmlSchemaCollectElements((xmlSchemaParticlePtr)xparticle->next, hash);
193
- }
194
- }
195
-
196
- static VALUE rxml_schema_type_elements(VALUE self)
197
- {
198
- VALUE result = rb_hash_new();
199
- xmlSchemaTypePtr xtype;
200
-
201
- Data_Get_Struct(self, xmlSchemaType, xtype);
202
- rxmlSchemaCollectElements((xmlSchemaParticlePtr) xtype->subtypes, result);
203
-
204
- return result;
205
- }
206
-
207
- static VALUE rxml_schema_type_attributes(VALUE self)
208
- {
209
- VALUE result = rb_ary_new();
210
- xmlSchemaTypePtr xtype;
211
- xmlSchemaAttributeUsePtr xuse;
212
- xmlSchemaItemListPtr xuses;
213
- int i;
214
-
215
- Data_Get_Struct(self, xmlSchemaType, xtype);
216
- xuses = xtype->attrUses;
217
-
218
- if (xuses != NULL)
219
- {
220
- for (i = 0; i < xuses->nbItems; i++)
221
- {
222
- xuse = (xmlSchemaAttributeUsePtr)xuses->items[i];
223
- rb_ary_push(result, rxml_wrap_schema_attribute(xuse));
224
- }
225
- }
226
-
227
- return result;
228
- }
229
-
230
- void rxml_init_schema_type(void)
231
- {
232
- /* Add in infinity support for ruby 1.8.7 */
233
- #if !defined(RUBY_VM) && defined(INFINITY)
234
- ID infinityId = rb_intern("INFINITY");
235
- if (rb_const_defined(rb_cFloat, infinityId) == Qfalse)
236
- rb_define_const(rb_cFloat, "INFINITY", rb_float_new(INFINITY));
237
- #endif
238
-
239
- cXMLSchemaType = rb_define_class_under(cXMLSchema, "Type", rb_cObject);
240
-
241
- rb_define_attr(cXMLSchemaType, "namespace", 1, 0);
242
- rb_define_attr(cXMLSchemaType, "name", 1, 0);
243
- rb_define_attr(cXMLSchemaType, "kind", 1, 0);
244
-
245
- rb_define_method(cXMLSchemaType, "base", rxml_schema_type_base, 0);
246
- rb_define_method(cXMLSchemaType, "node", rxml_schema_type_node, 0);
247
- rb_define_method(cXMLSchemaType, "elements", rxml_schema_type_elements, 0);
248
- rb_define_method(cXMLSchemaType, "attributes", rxml_schema_type_attributes, 0);
249
- rb_define_method(cXMLSchemaType, "facets", rxml_schema_type_facets, 0);
250
- rb_define_method(cXMLSchemaType, "annotation", rxml_schema_type_annot, 0);
251
- }
1
+ #include "ruby_libxml.h"
2
+ #include "ruby_xml_schema_type.h"
3
+ #include "ruby_xml_schema_element.h"
4
+ #include "ruby_xml_schema_attribute.h"
5
+ #include "ruby_xml_schema_facet.h"
6
+
7
+ #define UNBOUNDED 1 << 30
8
+ #define FREE_AND_NULL(str) if ((str) != NULL) { xmlFree((xmlChar *) (str)); str = NULL; }
9
+
10
+ /**
11
+ * xmlSchemaTreeItem:
12
+ *
13
+ * The abstract base type for tree-like structured schema components.
14
+ * (Extends xmlSchemaAnnotItem)
15
+ */
16
+ typedef struct _xmlSchemaTreeItem xmlSchemaTreeItem;
17
+ typedef xmlSchemaTreeItem *xmlSchemaTreeItemPtr;
18
+ struct _xmlSchemaTreeItem {
19
+ xmlSchemaTypeType type;
20
+ xmlSchemaAnnotPtr annot;
21
+ xmlSchemaTreeItemPtr next;
22
+ xmlSchemaTreeItemPtr children;
23
+ };
24
+
25
+ /**
26
+ * xmlSchemaParticle:
27
+ *
28
+ * A particle component.
29
+ * (Extends xmlSchemaTreeItem)
30
+ */
31
+ typedef struct _xmlSchemaParticle xmlSchemaParticle;
32
+ typedef xmlSchemaParticle *xmlSchemaParticlePtr;
33
+ struct _xmlSchemaParticle {
34
+ xmlSchemaTypeType type;
35
+ xmlSchemaAnnotPtr annot;
36
+ xmlSchemaTreeItemPtr next;
37
+ /* next particle */
38
+ xmlSchemaTreeItemPtr children;
39
+ /* the "term" (e.g. a model group,
40
+ a group definition, a XML_SCHEMA_EXTRA_QNAMEREF (if a reference),
41
+ etc.) */
42
+ int minOccurs;
43
+ int maxOccurs;
44
+ xmlNodePtr node;
45
+ };
46
+
47
+ VALUE cXMLSchemaType;
48
+
49
+ static void rxml_schema_type_free(xmlSchemaTypePtr xschema_type)
50
+ {
51
+ xschema_type = NULL;
52
+ xmlFree(xschema_type);
53
+ }
54
+
55
+ VALUE rxml_wrap_schema_type(xmlSchemaTypePtr xtype)
56
+ {
57
+ VALUE result;
58
+
59
+ if (!xtype)
60
+ rb_raise(rb_eArgError, "XML::Schema::Type required!");
61
+
62
+ result = Data_Wrap_Struct(cXMLSchemaType, NULL, rxml_schema_type_free, xtype);
63
+
64
+ rb_iv_set(result, "@name", QNIL_OR_STRING(xtype->name));
65
+ rb_iv_set(result, "@namespace", QNIL_OR_STRING(xtype->targetNamespace));
66
+ rb_iv_set(result, "@kind", INT2NUM(xtype->type));
67
+
68
+ return result;
69
+ }
70
+
71
+ static VALUE rxml_schema_type_base(VALUE self)
72
+ {
73
+ xmlSchemaTypePtr xtype;
74
+
75
+ Data_Get_Struct(self, xmlSchemaType, xtype);
76
+
77
+ return (xtype->baseType != xtype) ? rxml_wrap_schema_type(xtype->baseType) : Qnil;
78
+ }
79
+
80
+ static VALUE rxml_schema_type_node(VALUE self)
81
+ {
82
+ xmlSchemaTypePtr xtype;
83
+
84
+ Data_Get_Struct(self, xmlSchemaType, xtype);
85
+
86
+ return (xtype->node != NULL) ? rxml_node_wrap(xtype->node) : Qnil;
87
+ }
88
+
89
+ static VALUE rxml_schema_type_facets(VALUE self)
90
+ {
91
+ xmlSchemaTypePtr xtype;
92
+ xmlSchemaFacetPtr xfacet;
93
+ VALUE result = rb_ary_new();
94
+ VALUE facet;
95
+
96
+ Data_Get_Struct(self, xmlSchemaType, xtype);
97
+
98
+ xfacet = xtype->facets;
99
+
100
+ while (xfacet != NULL)
101
+ {
102
+ facet = rxml_wrap_schema_facet((xmlSchemaFacetPtr)xfacet);
103
+ rb_ary_push(result, facet);
104
+ xfacet = xfacet->next;
105
+ }
106
+
107
+ return result;
108
+ }
109
+
110
+ static VALUE rxml_schema_type_annot(VALUE self)
111
+ {
112
+ VALUE result = Qnil;
113
+ xmlSchemaTypePtr xtype;
114
+
115
+ Data_Get_Struct(self, xmlSchemaType, xtype);
116
+
117
+ if(xtype != NULL && xtype->annot != NULL && xtype->annot->content != NULL)
118
+ {
119
+ xmlChar *content = xmlNodeGetContent(xtype->annot->content);
120
+ if (content)
121
+ {
122
+ result = rxml_new_cstr(content, NULL);
123
+ xmlFree(content);
124
+ }
125
+ }
126
+ return result;
127
+ }
128
+
129
+ static void rxmlSchemaCollectElements(xmlSchemaParticlePtr xparticle, VALUE hash)
130
+ {
131
+ VALUE element;
132
+ xmlSchemaTreeItemPtr xterm;
133
+
134
+ if (xparticle == NULL)
135
+ return;
136
+
137
+ xterm = xparticle->children;
138
+
139
+ if (xterm != NULL)
140
+ {
141
+ switch (xterm->type)
142
+ {
143
+ case XML_SCHEMA_TYPE_ELEMENT:
144
+ element = rxml_wrap_schema_element((xmlSchemaElementPtr)xterm);
145
+ rb_iv_set(element, "@min", INT2NUM(xparticle->minOccurs));
146
+
147
+ if (xparticle->maxOccurs >= UNBOUNDED)
148
+ rb_iv_set(element, "@max", rb_const_get(rb_path2class("Float"), rb_intern("INFINITY")));
149
+ else
150
+ rb_iv_set(element, "@max", INT2NUM(xparticle->maxOccurs));
151
+
152
+ if (xparticle->annot != NULL)
153
+ {
154
+ xmlChar *content = xmlNodeGetContent(xparticle->annot->content);
155
+
156
+ if (content != NULL)
157
+ {
158
+ rb_iv_set(element, "@annotation", rb_str_new2((const char *) content));
159
+ xmlFree(content);
160
+ }
161
+ }
162
+
163
+ rb_hash_aset(hash, rb_str_new2((const char *) ((xmlSchemaElementPtr)xterm)->name), element);
164
+ break;
165
+
166
+ case XML_SCHEMA_TYPE_SEQUENCE:
167
+ break;
168
+
169
+ case XML_SCHEMA_TYPE_CHOICE:
170
+ break;
171
+
172
+ case XML_SCHEMA_TYPE_ALL:
173
+ break;
174
+
175
+ case XML_SCHEMA_TYPE_ANY:
176
+ break;
177
+
178
+ default:
179
+ return;
180
+ }
181
+ }
182
+
183
+ if (xterm &&
184
+ ((xterm->type == XML_SCHEMA_TYPE_SEQUENCE) || (xterm->type == XML_SCHEMA_TYPE_CHOICE) || (xterm->type == XML_SCHEMA_TYPE_ALL)) &&
185
+ (xterm->children != NULL))
186
+ {
187
+ rxmlSchemaCollectElements((xmlSchemaParticlePtr)xterm->children, hash);
188
+ }
189
+
190
+ if (xparticle->next != NULL)
191
+ {
192
+ rxmlSchemaCollectElements((xmlSchemaParticlePtr)xparticle->next, hash);
193
+ }
194
+ }
195
+
196
+ static VALUE rxml_schema_type_elements(VALUE self)
197
+ {
198
+ VALUE result = rb_hash_new();
199
+ xmlSchemaTypePtr xtype;
200
+
201
+ Data_Get_Struct(self, xmlSchemaType, xtype);
202
+ rxmlSchemaCollectElements((xmlSchemaParticlePtr) xtype->subtypes, result);
203
+
204
+ return result;
205
+ }
206
+
207
+ static VALUE rxml_schema_type_attributes(VALUE self)
208
+ {
209
+ VALUE result = rb_ary_new();
210
+ xmlSchemaTypePtr xtype;
211
+ xmlSchemaAttributeUsePtr xuse;
212
+ xmlSchemaItemListPtr xuses;
213
+ int i;
214
+
215
+ Data_Get_Struct(self, xmlSchemaType, xtype);
216
+ xuses = xtype->attrUses;
217
+
218
+ if (xuses != NULL)
219
+ {
220
+ for (i = 0; i < xuses->nbItems; i++)
221
+ {
222
+ xuse = (xmlSchemaAttributeUsePtr)xuses->items[i];
223
+ rb_ary_push(result, rxml_wrap_schema_attribute(xuse));
224
+ }
225
+ }
226
+
227
+ return result;
228
+ }
229
+
230
+ void rxml_init_schema_type(void)
231
+ {
232
+ /* Add in infinity support for ruby 1.8.7 */
233
+ #if !defined(RUBY_VM) && defined(INFINITY)
234
+ ID infinityId = rb_intern("INFINITY");
235
+ if (rb_const_defined(rb_cFloat, infinityId) == Qfalse)
236
+ rb_define_const(rb_cFloat, "INFINITY", rb_float_new(INFINITY));
237
+ #endif
238
+
239
+ cXMLSchemaType = rb_define_class_under(cXMLSchema, "Type", rb_cObject);
240
+ rb_undef_alloc_func(cXMLSchemaType);
241
+
242
+ rb_define_attr(cXMLSchemaType, "namespace", 1, 0);
243
+ rb_define_attr(cXMLSchemaType, "name", 1, 0);
244
+ rb_define_attr(cXMLSchemaType, "kind", 1, 0);
245
+
246
+ rb_define_method(cXMLSchemaType, "base", rxml_schema_type_base, 0);
247
+ rb_define_method(cXMLSchemaType, "node", rxml_schema_type_node, 0);
248
+ rb_define_method(cXMLSchemaType, "elements", rxml_schema_type_elements, 0);
249
+ rb_define_method(cXMLSchemaType, "attributes", rxml_schema_type_attributes, 0);
250
+ rb_define_method(cXMLSchemaType, "facets", rxml_schema_type_facets, 0);
251
+ rb_define_method(cXMLSchemaType, "annotation", rxml_schema_type_annot, 0);
252
+ }
@@ -1,9 +1,9 @@
1
1
  /* Don't nuke this block! It is used for automatically updating the
2
2
  * versions below. VERSION = string formatting, VERNUM = numbered
3
3
  * version for inline testing: increment both or none at all.*/
4
- #define RUBY_LIBXML_VERSION "4.1.1"
4
+ #define RUBY_LIBXML_VERSION "4.1.2"
5
5
  #define RUBY_LIBXML_VERNUM 400
6
6
  #define RUBY_LIBXML_VER_MAJ 4
7
7
  #define RUBY_LIBXML_VER_MIN 1
8
- #define RUBY_LIBXML_VER_MIC 1
8
+ #define RUBY_LIBXML_VER_MIC 2
9
9
  #define RUBY_LIBXML_VER_PATCH 0