libxml-ruby 0.9.2-x86-mswin32-60 → 0.9.3-x86-mswin32-60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES +13 -0
- data/ext/libxml/libxml.c +885 -886
- data/ext/libxml/ruby_libxml.h +70 -72
- data/ext/libxml/ruby_xml_attr.c +76 -76
- data/ext/libxml/ruby_xml_attr.h +8 -8
- data/ext/libxml/ruby_xml_attributes.c +36 -36
- data/ext/libxml/ruby_xml_attributes.h +6 -6
- data/ext/libxml/ruby_xml_document.c +133 -220
- data/ext/libxml/ruby_xml_document.h +4 -7
- data/ext/libxml/ruby_xml_dtd.c +30 -109
- data/ext/libxml/ruby_xml_dtd.h +2 -11
- data/ext/libxml/ruby_xml_error.c +10 -10
- data/ext/libxml/ruby_xml_error.h +4 -4
- data/ext/libxml/ruby_xml_html_parser.c +28 -40
- data/ext/libxml/ruby_xml_html_parser.h +4 -4
- data/ext/libxml/ruby_xml_input.c +208 -32
- data/ext/libxml/ruby_xml_input.h +7 -5
- data/ext/libxml/ruby_xml_input_cbg.c +3 -3
- data/ext/libxml/ruby_xml_node.c +217 -217
- data/ext/libxml/ruby_xml_node.h +5 -5
- data/ext/libxml/ruby_xml_ns.c +26 -26
- data/ext/libxml/ruby_xml_ns.h +4 -4
- data/ext/libxml/ruby_xml_parser.c +151 -164
- data/ext/libxml/ruby_xml_parser.h +3 -8
- data/ext/libxml/ruby_xml_parser_context.c +105 -105
- data/ext/libxml/ruby_xml_parser_context.h +4 -4
- data/ext/libxml/ruby_xml_reader.c +145 -162
- data/ext/libxml/ruby_xml_reader.h +4 -4
- data/ext/libxml/ruby_xml_relaxng.c +30 -43
- data/ext/libxml/ruby_xml_relaxng.h +2 -7
- data/ext/libxml/ruby_xml_sax_parser.c +174 -228
- data/ext/libxml/ruby_xml_sax_parser.h +12 -20
- data/ext/libxml/ruby_xml_schema.c +31 -44
- data/ext/libxml/ruby_xml_schema.h +2 -7
- data/ext/libxml/ruby_xml_state.c +6 -6
- data/ext/libxml/ruby_xml_state.h +2 -2
- data/ext/libxml/ruby_xml_xinclude.c +1 -1
- data/ext/libxml/ruby_xml_xinclude.h +3 -3
- data/ext/libxml/ruby_xml_xpath.c +1 -1
- data/ext/libxml/ruby_xml_xpath.h +3 -12
- data/ext/libxml/ruby_xml_xpath_context.c +293 -294
- data/ext/libxml/ruby_xml_xpath_context.h +3 -7
- data/ext/libxml/ruby_xml_xpath_expression.c +11 -11
- data/ext/libxml/ruby_xml_xpath_expression.h +2 -2
- data/ext/libxml/ruby_xml_xpath_object.c +52 -66
- data/ext/libxml/ruby_xml_xpath_object.h +3 -14
- data/ext/libxml/ruby_xml_xpointer.c +11 -12
- data/ext/libxml/ruby_xml_xpointer.h +5 -7
- data/ext/libxml/sax_parser_callbacks.inc +53 -36
- data/ext/libxml/version.h +2 -2
- data/ext/mingw/libxml_ruby.dll.a +0 -0
- data/ext/mingw/libxml_ruby.so +0 -0
- data/ext/vc/libxml_ruby.vcproj +1 -9
- data/lib/libxml/html_parser.rb +5 -5
- data/lib/libxml/parser.rb +4 -4
- data/lib/libxml/sax_parser.rb +24 -0
- data/test/tc_document_write.rb +2 -16
- data/test/tc_html_parser.rb +57 -5
- data/test/tc_input.rb +13 -0
- data/test/tc_parser.rb +11 -3
- data/test/tc_reader.rb +53 -34
- data/test/tc_sax_parser.rb +30 -8
- data/test/test.rb +8 -0
- data/test/test_suite.rb +1 -1
- metadata +5 -6
- data/ext/libxml/ruby_xml_encoding.c +0 -164
- data/ext/libxml/ruby_xml_encoding.h +0 -13
- data/test/tc_encoding.rb +0 -13
    
        data/ext/libxml/ruby_xml_attr.h
    CHANGED
    
    | @@ -1,16 +1,16 @@ | |
| 1 | 
            -
            /* $Id: ruby_xml_attr.h  | 
| 1 | 
            +
            /* $Id: ruby_xml_attr.h 612 2008-11-21 08:01:29Z cfis $ */
         | 
| 2 2 |  | 
| 3 3 | 
             
            /* Please see the LICENSE file for copyright and distribution information */
         | 
| 4 4 |  | 
| 5 | 
            -
            #ifndef  | 
| 6 | 
            -
            #define  | 
| 5 | 
            +
            #ifndef __rxml_ATTR__
         | 
| 6 | 
            +
            #define __rxml_ATTR__
         | 
| 7 7 |  | 
| 8 8 | 
             
            extern VALUE cXMLAttr;
         | 
| 9 9 |  | 
| 10 10 | 
             
            void ruby_init_xml_attr(void);
         | 
| 11 | 
            -
            VALUE  | 
| 12 | 
            -
            VALUE  | 
| 13 | 
            -
            VALUE  | 
| 14 | 
            -
            void  | 
| 15 | 
            -
            VALUE  | 
| 11 | 
            +
            VALUE rxml_attr_new(xmlAttrPtr xattr);
         | 
| 12 | 
            +
            VALUE rxml_attr_value_get(VALUE self);
         | 
| 13 | 
            +
            VALUE rxml_attr_value_set(VALUE self, VALUE val);
         | 
| 14 | 
            +
            void rxml_attr_free(xmlAttrPtr xattr);
         | 
| 15 | 
            +
            VALUE rxml_attr_wrap(xmlAttrPtr xattr);
         | 
| 16 16 | 
             
            #endif
         | 
| @@ -1,4 +1,4 @@ | |
| 1 | 
            -
            /* $Id:  | 
| 1 | 
            +
            /* $Id: rxml_attributes.c 300 2008-07-01 19:14:15Z cfis $ */
         | 
| 2 2 |  | 
| 3 3 | 
             
            /* Please see the LICENSE file for copyright and distribution information */
         | 
| 4 4 |  | 
| @@ -35,18 +35,18 @@ | |
| 35 35 | 
             
            VALUE cXMLAttributes;
         | 
| 36 36 |  | 
| 37 37 | 
             
            void
         | 
| 38 | 
            -
             | 
| 39 | 
            -
               | 
| 38 | 
            +
            rxml_attributes_mark(xmlNodePtr xnode) {
         | 
| 39 | 
            +
              rxml_node_mark_common(xnode);
         | 
| 40 40 | 
             
            }
         | 
| 41 41 |  | 
| 42 42 | 
             
            /*
         | 
| 43 43 | 
             
             * Creates a  new attributes instance.  Not exposed to ruby.
         | 
| 44 44 | 
             
             */
         | 
| 45 45 | 
             
            VALUE
         | 
| 46 | 
            -
             | 
| 46 | 
            +
            rxml_attributes_new(xmlNodePtr xnode)
         | 
| 47 47 | 
             
            {
         | 
| 48 48 | 
             
              return Data_Wrap_Struct(cXMLAttributes,
         | 
| 49 | 
            -
                                       | 
| 49 | 
            +
                                      rxml_attributes_mark, NULL,
         | 
| 50 50 | 
             
                                      xnode);
         | 
| 51 51 | 
             
            }
         | 
| 52 52 |  | 
| @@ -59,10 +59,10 @@ ruby_xml_attributes_new(xmlNodePtr xnode) | |
| 59 59 | 
             
             *  doc.root.attributes.node == doc.root
         | 
| 60 60 | 
             
             */
         | 
| 61 61 | 
             
            VALUE
         | 
| 62 | 
            -
             | 
| 62 | 
            +
            rxml_attributes_node_get(VALUE self) {
         | 
| 63 63 | 
             
              xmlNodePtr xnode;
         | 
| 64 64 | 
             
              Data_Get_Struct(self, xmlNode, xnode);
         | 
| 65 | 
            -
              return( | 
| 65 | 
            +
              return(rxml_node2_wrap(cXMLNode, xnode));
         | 
| 66 66 | 
             
            }
         | 
| 67 67 |  | 
| 68 68 |  | 
| @@ -76,8 +76,8 @@ ruby_xml_attributes_node_get(VALUE self) { | |
| 76 76 | 
             
             *
         | 
| 77 77 | 
             
             *  doc.root.attributes.get_attribute("foo")
         | 
| 78 78 | 
             
             */
         | 
| 79 | 
            -
            VALUE
         | 
| 80 | 
            -
             | 
| 79 | 
            +
            static VALUE
         | 
| 80 | 
            +
            rxml_attributes_get_attribute(VALUE self, VALUE name) {
         | 
| 81 81 | 
             
              xmlNodePtr xnode;
         | 
| 82 82 | 
             
              xmlAttrPtr xattr;
         | 
| 83 83 |  | 
| @@ -88,7 +88,7 @@ ruby_xml_attributes_get_attribute(VALUE self, VALUE name) { | |
| 88 88 | 
             
              xattr = xmlHasProp(xnode, (xmlChar*)StringValuePtr(name));
         | 
| 89 89 |  | 
| 90 90 | 
             
              if (xattr)
         | 
| 91 | 
            -
                return( | 
| 91 | 
            +
                return(rxml_attr_wrap(xattr));
         | 
| 92 92 | 
             
              else
         | 
| 93 93 | 
             
                return(Qnil);
         | 
| 94 94 | 
             
            }
         | 
| @@ -104,8 +104,8 @@ ruby_xml_attributes_get_attribute(VALUE self, VALUE name) { | |
| 104 104 | 
             
             *
         | 
| 105 105 | 
             
             *  doc.root.attributes.get_attribute_ns('http://www.w3.org/1999/xlink', 'href')
         | 
| 106 106 | 
             
             */
         | 
| 107 | 
            -
            VALUE
         | 
| 108 | 
            -
             | 
| 107 | 
            +
            static VALUE
         | 
| 108 | 
            +
            rxml_attributes_get_attribute_ns(VALUE self, VALUE namespace, VALUE name) {
         | 
| 109 109 | 
             
              xmlNodePtr xnode;
         | 
| 110 110 | 
             
              xmlAttrPtr xattr;
         | 
| 111 111 |  | 
| @@ -116,7 +116,7 @@ ruby_xml_attributes_get_attribute_ns(VALUE self, VALUE namespace, VALUE name) { | |
| 116 116 | 
             
              xattr = xmlHasNsProp(xnode, (xmlChar*)StringValuePtr(name), (xmlChar*)StringValuePtr(namespace));
         | 
| 117 117 |  | 
| 118 118 | 
             
              if (xattr)
         | 
| 119 | 
            -
                return( | 
| 119 | 
            +
                return(rxml_attr_wrap(xattr));
         | 
| 120 120 | 
             
              else
         | 
| 121 121 | 
             
                return(Qnil);
         | 
| 122 122 | 
             
            }
         | 
| @@ -133,12 +133,12 @@ ruby_xml_attributes_get_attribute_ns(VALUE self, VALUE namespace, VALUE name) { | |
| 133 133 | 
             
             *  doc.root.attributes['att'] -> 'some value'
         | 
| 134 134 | 
             
             */
         | 
| 135 135 | 
             
            VALUE
         | 
| 136 | 
            -
             | 
| 137 | 
            -
              VALUE xattr =  | 
| 136 | 
            +
            rxml_attributes_attribute_get(VALUE self, VALUE name) {
         | 
| 137 | 
            +
              VALUE xattr = rxml_attributes_get_attribute(self, name);
         | 
| 138 138 | 
             
              if NIL_P(xattr)
         | 
| 139 139 | 
             
                return(Qnil);
         | 
| 140 140 | 
             
              else
         | 
| 141 | 
            -
                return  | 
| 141 | 
            +
                return rxml_attr_value_get(xattr);
         | 
| 142 142 | 
             
            }  
         | 
| 143 143 |  | 
| 144 144 | 
             
            /*
         | 
| @@ -154,13 +154,13 @@ ruby_xml_attributes_attribute_get(VALUE self, VALUE name) { | |
| 154 154 | 
             
             *  doc.root.attributes['att'] = 'some value'
         | 
| 155 155 | 
             
             */
         | 
| 156 156 | 
             
            VALUE
         | 
| 157 | 
            -
             | 
| 158 | 
            -
              VALUE xattr =  | 
| 157 | 
            +
            rxml_attributes_attribute_set(VALUE self, VALUE name, VALUE value) {
         | 
| 158 | 
            +
              VALUE xattr = rxml_attributes_get_attribute(self, name);
         | 
| 159 159 | 
             
              if NIL_P(xattr)
         | 
| 160 160 | 
             
              {
         | 
| 161 161 | 
             
                VALUE args[3];
         | 
| 162 162 |  | 
| 163 | 
            -
                args[0] =  | 
| 163 | 
            +
                args[0] = rxml_attributes_node_get(self);
         | 
| 164 164 | 
             
                args[1] = name;
         | 
| 165 165 | 
             
                args[2] = value;
         | 
| 166 166 |  | 
| @@ -168,7 +168,7 @@ ruby_xml_attributes_attribute_set(VALUE self, VALUE name, VALUE value) { | |
| 168 168 | 
             
              }
         | 
| 169 169 | 
             
              else
         | 
| 170 170 | 
             
              {
         | 
| 171 | 
            -
                return  | 
| 171 | 
            +
                return rxml_attr_value_set(xattr, value);
         | 
| 172 172 | 
             
              }
         | 
| 173 173 | 
             
            }  
         | 
| 174 174 |  | 
| @@ -181,8 +181,8 @@ ruby_xml_attributes_attribute_set(VALUE self, VALUE name, VALUE value) { | |
| 181 181 | 
             
             *  
         | 
| 182 182 | 
             
             *  doc.root.attributes.each {|attribute| puts attribute.name}
         | 
| 183 183 | 
             
             */
         | 
| 184 | 
            -
            VALUE
         | 
| 185 | 
            -
             | 
| 184 | 
            +
            static VALUE
         | 
| 185 | 
            +
            rxml_attributes_each(VALUE self) {
         | 
| 186 186 | 
             
              xmlNodePtr xnode;
         | 
| 187 187 | 
             
              xmlAttrPtr xattr;
         | 
| 188 188 | 
             
              Data_Get_Struct(self, xmlNode, xnode);
         | 
| @@ -191,7 +191,7 @@ ruby_xml_attributes_each(VALUE self) { | |
| 191 191 |  | 
| 192 192 | 
             
              while (xattr)
         | 
| 193 193 | 
             
              {
         | 
| 194 | 
            -
                 VALUE attr =  | 
| 194 | 
            +
                 VALUE attr = rxml_attr_wrap(xattr);
         | 
| 195 195 | 
             
                 rb_yield(attr);
         | 
| 196 196 | 
             
                 xattr = xattr->next;
         | 
| 197 197 | 
             
              }
         | 
| @@ -207,8 +207,8 @@ ruby_xml_attributes_each(VALUE self) { | |
| 207 207 | 
             
             *
         | 
| 208 208 | 
             
             *  doc.root.attributes.length
         | 
| 209 209 | 
             
             */
         | 
| 210 | 
            -
            VALUE
         | 
| 211 | 
            -
             | 
| 210 | 
            +
            static VALUE
         | 
| 211 | 
            +
            rxml_attributes_length(VALUE self) {
         | 
| 212 212 | 
             
              int length = 0;
         | 
| 213 213 | 
             
              xmlNodePtr xnode;
         | 
| 214 214 | 
             
              xmlAttrPtr xattr;
         | 
| @@ -233,8 +233,8 @@ ruby_xml_attributes_length(VALUE self) { | |
| 233 233 | 
             
             *
         | 
| 234 234 | 
             
             *  doc.root.attributes.first
         | 
| 235 235 | 
             
             */
         | 
| 236 | 
            -
            VALUE
         | 
| 237 | 
            -
             | 
| 236 | 
            +
            static VALUE
         | 
| 237 | 
            +
            rxml_attributes_first(VALUE self) {
         | 
| 238 238 | 
             
              xmlNodePtr xnode;
         | 
| 239 239 | 
             
              Data_Get_Struct(self, xmlNode, xnode);
         | 
| 240 240 |  | 
| @@ -242,7 +242,7 @@ ruby_xml_attributes_first(VALUE self) { | |
| 242 242 | 
             
                xmlAttrPtr xattr = xnode->properties;
         | 
| 243 243 |  | 
| 244 244 | 
             
                if (xattr) {
         | 
| 245 | 
            -
                  return( | 
| 245 | 
            +
                  return(rxml_attr_wrap(xattr));
         | 
| 246 246 | 
             
                }
         | 
| 247 247 | 
             
              } 
         | 
| 248 248 | 
             
              return(Qnil);
         | 
| @@ -258,12 +258,12 @@ void | |
| 258 258 | 
             
            ruby_init_xml_attributes(void) {
         | 
| 259 259 | 
             
              cXMLAttributes = rb_define_class_under(mXML, "Attributes", rb_cObject);
         | 
| 260 260 | 
             
              rb_include_module(cXMLAttributes, rb_mEnumerable);
         | 
| 261 | 
            -
              rb_define_method(cXMLAttributes, "node",  | 
| 262 | 
            -
              rb_define_method(cXMLAttributes, "get_attribute",  | 
| 263 | 
            -
              rb_define_method(cXMLAttributes, "get_attribute_ns",  | 
| 264 | 
            -
              rb_define_method(cXMLAttributes, "[]",  | 
| 265 | 
            -
              rb_define_method(cXMLAttributes, "[]=",  | 
| 266 | 
            -
              rb_define_method(cXMLAttributes, "each",  | 
| 267 | 
            -
              rb_define_method(cXMLAttributes, "length",  | 
| 268 | 
            -
              rb_define_method(cXMLAttributes, "first",  | 
| 261 | 
            +
              rb_define_method(cXMLAttributes, "node", rxml_attributes_node_get, 0);
         | 
| 262 | 
            +
              rb_define_method(cXMLAttributes, "get_attribute", rxml_attributes_get_attribute, 1);
         | 
| 263 | 
            +
              rb_define_method(cXMLAttributes, "get_attribute_ns", rxml_attributes_get_attribute_ns, 2);
         | 
| 264 | 
            +
              rb_define_method(cXMLAttributes, "[]", rxml_attributes_attribute_get, 1);
         | 
| 265 | 
            +
              rb_define_method(cXMLAttributes, "[]=", rxml_attributes_attribute_set, 2);
         | 
| 266 | 
            +
              rb_define_method(cXMLAttributes, "each", rxml_attributes_each, 0);
         | 
| 267 | 
            +
              rb_define_method(cXMLAttributes, "length", rxml_attributes_length, 0);
         | 
| 268 | 
            +
              rb_define_method(cXMLAttributes, "first", rxml_attributes_first, 0);
         | 
| 269 269 | 
             
            }
         | 
| @@ -1,17 +1,17 @@ | |
| 1 | 
            -
            /* $Id:  | 
| 1 | 
            +
            /* $Id: rxml_attributes.h 282 2008-07-01 06:44:30Z cfis $ */
         | 
| 2 2 |  | 
| 3 3 | 
             
            /* Please see the LICENSE file for copyright and distribution information */
         | 
| 4 4 |  | 
| 5 | 
            -
            #ifndef  | 
| 6 | 
            -
            #define  | 
| 5 | 
            +
            #ifndef __rxml_ATTRIBUTES__
         | 
| 6 | 
            +
            #define __rxml_ATTRIBUTES__
         | 
| 7 7 |  | 
| 8 8 | 
             
            extern VALUE cXMLAttributesibutes;
         | 
| 9 9 |  | 
| 10 10 | 
             
            void ruby_init_xml_attributes(void);
         | 
| 11 | 
            -
            VALUE  | 
| 11 | 
            +
            VALUE rxml_attributes_new(xmlNodePtr xnode);
         | 
| 12 12 |  | 
| 13 | 
            -
            VALUE  | 
| 14 | 
            -
            VALUE  | 
| 13 | 
            +
            VALUE rxml_attributes_attribute_get(VALUE self, VALUE name);
         | 
| 14 | 
            +
            VALUE rxml_attributes_attribute_set(VALUE self, VALUE name, VALUE value);
         | 
| 15 15 |  | 
| 16 16 |  | 
| 17 17 | 
             
            #endif
         | 
| @@ -1,4 +1,4 @@ | |
| 1 | 
            -
            /* $Id: ruby_xml_document.c  | 
| 1 | 
            +
            /* $Id: ruby_xml_document.c 614 2008-11-22 08:04:39Z cfis $ */
         | 
| 2 2 |  | 
| 3 3 | 
             
            /*
         | 
| 4 4 | 
             
            * Document-class: LibXML::XML::Document
         | 
| @@ -34,105 +34,19 @@ | |
| 34 34 |  | 
| 35 35 | 
             
            VALUE cXMLDocument;
         | 
| 36 36 |  | 
| 37 | 
            -
             | 
| 38 | 
            -
            /* We have to make sure that documents are freed after
         | 
| 39 | 
            -
               XPathObjects.  The Ruby gc does not guarantee this
         | 
| 40 | 
            -
               at shutdown or in normal operation when a document,
         | 
| 41 | 
            -
               xpath context and xpath object form a cycle.  So
         | 
| 42 | 
            -
               we implement this simple reference counting scheme.
         | 
| 43 | 
            -
               It works as you'd expect, except with a simple twist.
         | 
| 44 | 
            -
               If a document is freed, but still has outstanding
         | 
| 45 | 
            -
               references, its reference count is made negative.  Thus
         | 
| 46 | 
            -
               if it has ref_count of 1, then its becomes -1.  At that
         | 
| 47 | 
            -
               point, decrement will increase the account to 0, and 
         | 
| 48 | 
            -
               once it reaches 0, the document is freed. */
         | 
| 49 | 
            -
             | 
| 50 | 
            -
            static st_table *ref_count_table = 0;
         | 
| 51 | 
            -
             | 
| 52 37 | 
             
            void
         | 
| 53 | 
            -
             | 
| 54 | 
            -
              st_delete(ref_count_table, (st_data_t*)&xdoc, 0);
         | 
| 38 | 
            +
            rxml_document_free(xmlDocPtr xdoc) {
         | 
| 55 39 | 
             
              xdoc->_private = NULL;
         | 
| 56 40 | 
             
              xmlFreeDoc(xdoc);
         | 
| 57 | 
            -
            }
         | 
| 58 | 
            -
             | 
| 59 | 
            -
            int
         | 
| 60 | 
            -
            ruby_xml_document_incr(xmlDocPtr xdoc) {
         | 
| 61 | 
            -
              int ref_count;
         | 
| 62 | 
            -
             | 
| 63 | 
            -
              if (st_lookup(ref_count_table, (st_data_t)xdoc, (st_data_t*)&ref_count))
         | 
| 64 | 
            -
              {
         | 
| 65 | 
            -
                ref_count++;
         | 
| 66 | 
            -
                st_insert(ref_count_table, (st_data_t)xdoc, (st_data_t)ref_count);
         | 
| 67 | 
            -
              }
         | 
| 68 | 
            -
              else
         | 
| 69 | 
            -
              {
         | 
| 70 | 
            -
                ref_count = 1;
         | 
| 71 | 
            -
                st_add_direct(ref_count_table, (st_data_t)xdoc, (st_data_t)ref_count);
         | 
| 72 | 
            -
              }
         | 
| 73 | 
            -
              
         | 
| 74 | 
            -
              return ref_count;
         | 
| 75 | 
            -
            }
         | 
| 76 | 
            -
             | 
| 77 | 
            -
            int
         | 
| 78 | 
            -
            ruby_xml_document_decr(xmlDocPtr xdoc) {
         | 
| 79 | 
            -
              int ref_count = 0;
         | 
| 80 | 
            -
             | 
| 81 | 
            -
              if (!st_lookup(ref_count_table, (st_data_t)xdoc, (st_data_t*)&ref_count)) 
         | 
| 82 | 
            -
                rb_raise(rb_eRuntimeError, "Document does not have a reference count.");
         | 
| 83 | 
            -
             | 
| 84 | 
            -
              if (ref_count == 0)
         | 
| 85 | 
            -
              {
         | 
| 86 | 
            -
                rb_raise(rb_eRuntimeError, "Document already has no references.");
         | 
| 87 | 
            -
              }
         | 
| 88 | 
            -
              else if (ref_count > 0)
         | 
| 89 | 
            -
              {
         | 
| 90 | 
            -
                ref_count--;
         | 
| 91 | 
            -
              }
         | 
| 92 | 
            -
              else
         | 
| 93 | 
            -
              {
         | 
| 94 | 
            -
                ref_count++;
         | 
| 95 | 
            -
                if (ref_count == 0)
         | 
| 96 | 
            -
                {
         | 
| 97 | 
            -
                  ruby_xml_document_internal_free(xdoc);
         | 
| 98 | 
            -
                  return ref_count;
         | 
| 99 | 
            -
                }
         | 
| 100 | 
            -
              }
         | 
| 101 | 
            -
             | 
| 102 | 
            -
              st_insert(ref_count_table, (st_data_t)xdoc, ref_count);
         | 
| 103 | 
            -
              return ref_count;
         | 
| 104 | 
            -
            }
         | 
| 105 | 
            -
             | 
| 106 | 
            -
            void
         | 
| 107 | 
            -
            ruby_xml_document_free(xmlDocPtr xdoc) {
         | 
| 108 | 
            -
              int ref_count;
         | 
| 109 | 
            -
             | 
| 110 | 
            -
              if (!st_lookup(ref_count_table, (st_data_t)xdoc, (st_data_t*)&ref_count))
         | 
| 111 | 
            -
              {
         | 
| 112 | 
            -
                ruby_xml_document_internal_free(xdoc);
         | 
| 113 | 
            -
              }
         | 
| 114 | 
            -
              else if (ref_count == 0)
         | 
| 115 | 
            -
              {
         | 
| 116 | 
            -
                ruby_xml_document_internal_free(xdoc);
         | 
| 117 | 
            -
              }
         | 
| 118 | 
            -
              else if (ref_count > 0)
         | 
| 119 | 
            -
              {
         | 
| 120 | 
            -
                ref_count *= -1;
         | 
| 121 | 
            -
                st_insert(ref_count_table, (st_data_t)xdoc, ref_count);
         | 
| 122 | 
            -
              }
         | 
| 123 | 
            -
              else 
         | 
| 124 | 
            -
              {
         | 
| 125 | 
            -
                rb_raise(rb_eRuntimeError, "Ruby is attempting to free document twice.");
         | 
| 126 | 
            -
              }
         | 
| 127 41 | 
             
            }   
         | 
| 128 42 |  | 
| 129 43 | 
             
            void
         | 
| 130 | 
            -
             | 
| 44 | 
            +
            rxml_document_mark(xmlDocPtr xdoc) {
         | 
| 131 45 | 
             
              rb_gc_mark(LIBXML_STATE);
         | 
| 132 46 | 
             
            }
         | 
| 133 47 |  | 
| 134 48 | 
             
            VALUE
         | 
| 135 | 
            -
             | 
| 49 | 
            +
            rxml_document_wrap(xmlDocPtr xdoc) {
         | 
| 136 50 | 
             
              VALUE result;
         | 
| 137 51 |  | 
| 138 52 | 
             
              // This node is already wrapped
         | 
| @@ -142,7 +56,7 @@ ruby_xml_document_wrap(xmlDocPtr xdoc) { | |
| 142 56 | 
             
              }
         | 
| 143 57 | 
             
              else  
         | 
| 144 58 | 
             
              {
         | 
| 145 | 
            -
                result = Data_Wrap_Struct(cXMLDocument,  | 
| 59 | 
            +
                result = Data_Wrap_Struct(cXMLDocument, rxml_document_mark, rxml_document_free, xdoc);
         | 
| 146 60 | 
             
                xdoc->_private = (void*)result;
         | 
| 147 61 | 
             
              }
         | 
| 148 62 |  | 
| @@ -157,9 +71,9 @@ ruby_xml_document_wrap(xmlDocPtr xdoc) { | |
| 157 71 | 
             
             * Alocates a new XML::Document, optionally specifying the
         | 
| 158 72 | 
             
             * XML version.
         | 
| 159 73 | 
             
             */
         | 
| 160 | 
            -
            VALUE
         | 
| 161 | 
            -
             | 
| 162 | 
            -
              return Data_Wrap_Struct(klass,  | 
| 74 | 
            +
            static VALUE
         | 
| 75 | 
            +
            rxml_document_alloc(VALUE klass) {
         | 
| 76 | 
            +
              return Data_Wrap_Struct(klass, rxml_document_mark, rxml_document_free, NULL);
         | 
| 163 77 | 
             
            }
         | 
| 164 78 |  | 
| 165 79 | 
             
            /*
         | 
| @@ -169,8 +83,8 @@ ruby_xml_document_alloc(VALUE klass) { | |
| 169 83 | 
             
             * Initializes a new XML::Document, optionally specifying the
         | 
| 170 84 | 
             
             * XML version.
         | 
| 171 85 | 
             
             */
         | 
| 172 | 
            -
            VALUE
         | 
| 173 | 
            -
             | 
| 86 | 
            +
            static VALUE
         | 
| 87 | 
            +
            rxml_document_initialize(int argc, VALUE *argv, VALUE self) {
         | 
| 174 88 | 
             
              xmlDocPtr xdoc;
         | 
| 175 89 | 
             
              VALUE xmlver;
         | 
| 176 90 |  | 
| @@ -200,8 +114,8 @@ ruby_xml_document_initialize(int argc, VALUE *argv, VALUE self) { | |
| 200 114 | 
             
             * 
         | 
| 201 115 | 
             
             * Obtain this document's compression mode identifier.
         | 
| 202 116 | 
             
             */
         | 
| 203 | 
            -
            VALUE
         | 
| 204 | 
            -
             | 
| 117 | 
            +
            static VALUE
         | 
| 118 | 
            +
            rxml_document_compression_get(VALUE self) {
         | 
| 205 119 | 
             
            #ifdef HAVE_ZLIB_H
         | 
| 206 120 | 
             
              xmlDocPtr xdoc;
         | 
| 207 121 |  | 
| @@ -226,8 +140,8 @@ ruby_xml_document_compression_get(VALUE self) { | |
| 226 140 | 
             
             * 
         | 
| 227 141 | 
             
             * Set this document's compression mode.
         | 
| 228 142 | 
             
             */
         | 
| 229 | 
            -
            VALUE
         | 
| 230 | 
            -
             | 
| 143 | 
            +
            static VALUE
         | 
| 144 | 
            +
            rxml_document_compression_set(VALUE self, VALUE num) {
         | 
| 231 145 | 
             
            #ifdef HAVE_ZLIB_H
         | 
| 232 146 | 
             
              xmlDocPtr xdoc;
         | 
| 233 147 |  | 
| @@ -259,8 +173,8 @@ ruby_xml_document_compression_set(VALUE self, VALUE num) { | |
| 259 173 | 
             
             * 
         | 
| 260 174 | 
             
             * Determine whether this document is compressed.
         | 
| 261 175 | 
             
             */
         | 
| 262 | 
            -
            VALUE
         | 
| 263 | 
            -
             | 
| 176 | 
            +
            static VALUE
         | 
| 177 | 
            +
            rxml_document_compression_q(VALUE self) {
         | 
| 264 178 | 
             
            #ifdef HAVE_ZLIB_H
         | 
| 265 179 | 
             
              xmlDocPtr xdoc;
         | 
| 266 180 |  | 
| @@ -283,15 +197,15 @@ ruby_xml_document_compression_q(VALUE self) { | |
| 283 197 | 
             
             * 
         | 
| 284 198 | 
             
             * Get this document's child node.
         | 
| 285 199 | 
             
             */
         | 
| 286 | 
            -
            VALUE
         | 
| 287 | 
            -
             | 
| 200 | 
            +
            static VALUE
         | 
| 201 | 
            +
            rxml_document_child_get(VALUE self) {
         | 
| 288 202 | 
             
              xmlDocPtr xdoc;
         | 
| 289 203 | 
             
              Data_Get_Struct(self, xmlDoc, xdoc);
         | 
| 290 204 |  | 
| 291 205 | 
             
              if (xdoc->children == NULL)
         | 
| 292 206 | 
             
                return(Qnil);
         | 
| 293 207 |  | 
| 294 | 
            -
              return  | 
| 208 | 
            +
              return rxml_node2_wrap(cXMLNode, xdoc->children);
         | 
| 295 209 | 
             
            }
         | 
| 296 210 |  | 
| 297 211 |  | 
| @@ -301,8 +215,8 @@ ruby_xml_document_child_get(VALUE self) { | |
| 301 215 | 
             
             * 
         | 
| 302 216 | 
             
             * Determine whether this document has a child node.
         | 
| 303 217 | 
             
             */
         | 
| 304 | 
            -
            VALUE
         | 
| 305 | 
            -
             | 
| 218 | 
            +
            static VALUE
         | 
| 219 | 
            +
            rxml_document_child_q(VALUE self) {
         | 
| 306 220 | 
             
              xmlDocPtr xdoc;
         | 
| 307 221 | 
             
              Data_Get_Struct(self, xmlDoc, xdoc);
         | 
| 308 222 |  | 
| @@ -320,8 +234,8 @@ ruby_xml_document_child_q(VALUE self) { | |
| 320 234 | 
             
             * Dump this document's XML to the specified IO stream.
         | 
| 321 235 | 
             
             * If no stream is specified, stdout is used.
         | 
| 322 236 | 
             
             */
         | 
| 323 | 
            -
            VALUE
         | 
| 324 | 
            -
             | 
| 237 | 
            +
            static VALUE
         | 
| 238 | 
            +
            rxml_document_dump(int argc, VALUE *argv, VALUE self) {
         | 
| 325 239 | 
             
              OpenFile *fptr;
         | 
| 326 240 | 
             
              VALUE io;
         | 
| 327 241 | 
             
              FILE *out;
         | 
| @@ -358,8 +272,8 @@ ruby_xml_document_dump(int argc, VALUE *argv, VALUE self) { | |
| 358 272 | 
             
             * 
         | 
| 359 273 | 
             
             * Debug version of dump.
         | 
| 360 274 | 
             
             */
         | 
| 361 | 
            -
            VALUE
         | 
| 362 | 
            -
             | 
| 275 | 
            +
            static VALUE
         | 
| 276 | 
            +
            rxml_document_debug_dump(int argc, VALUE *argv, VALUE self) {
         | 
| 363 277 | 
             
            #ifdef LIBXML_DEBUG_ENABLED
         | 
| 364 278 | 
             
              OpenFile *fptr;
         | 
| 365 279 | 
             
              VALUE io;
         | 
| @@ -402,8 +316,8 @@ ruby_xml_document_debug_dump(int argc, VALUE *argv, VALUE self) { | |
| 402 316 | 
             
             * Debug-dump this document's header to the specified IO stream.
         | 
| 403 317 | 
             
             * If no stream is specified, stdout is used.
         | 
| 404 318 | 
             
             */
         | 
| 405 | 
            -
            VALUE
         | 
| 406 | 
            -
             | 
| 319 | 
            +
            static VALUE
         | 
| 320 | 
            +
            rxml_document_debug_dump_head(int argc, VALUE *argv, VALUE self) {
         | 
| 407 321 | 
             
            #ifdef LIBXML_DEBUG_ENABLED
         | 
| 408 322 | 
             
              OpenFile *fptr;
         | 
| 409 323 | 
             
              VALUE io;
         | 
| @@ -449,8 +363,8 @@ ruby_xml_document_debug_dump_head(int argc, VALUE *argv, VALUE self) { | |
| 449 363 | 
             
             * specified, it must be a boolean that determines whether 
         | 
| 450 364 | 
             
             * spacing is used.
         | 
| 451 365 | 
             
             */
         | 
| 452 | 
            -
            VALUE
         | 
| 453 | 
            -
             | 
| 366 | 
            +
            static VALUE
         | 
| 367 | 
            +
            rxml_document_format_dump(int argc, VALUE *argv, VALUE self) {
         | 
| 454 368 | 
             
              OpenFile *fptr;
         | 
| 455 369 | 
             
              VALUE bool, io;
         | 
| 456 370 | 
             
              FILE *out;
         | 
| @@ -504,10 +418,10 @@ ruby_xml_document_format_dump(int argc, VALUE *argv, VALUE self) { | |
| 504 418 | 
             
             * 
         | 
| 505 419 | 
             
             * *Deprecated* in favour of format_dump.
         | 
| 506 420 | 
             
             */
         | 
| 507 | 
            -
            VALUE
         | 
| 508 | 
            -
             | 
| 421 | 
            +
            static VALUE
         | 
| 422 | 
            +
            rxml_document_debug_format_dump(int argc, VALUE *argv, VALUE self) {
         | 
| 509 423 | 
             
              rb_warn("debug_format_dump has been deprecaited, use format_dump instead");
         | 
| 510 | 
            -
              return( | 
| 424 | 
            +
              return(rxml_document_format_dump(argc, argv, self));
         | 
| 511 425 | 
             
            }
         | 
| 512 426 |  | 
| 513 427 |  | 
| @@ -517,8 +431,8 @@ ruby_xml_document_debug_format_dump(int argc, VALUE *argv, VALUE self) { | |
| 517 431 | 
             
             * 
         | 
| 518 432 | 
             
             * Obtain the encoding specified by this document.
         | 
| 519 433 | 
             
             */
         | 
| 520 | 
            -
            VALUE
         | 
| 521 | 
            -
             | 
| 434 | 
            +
            static VALUE
         | 
| 435 | 
            +
            rxml_document_encoding_get(VALUE self) {
         | 
| 522 436 | 
             
              xmlDocPtr xdoc;
         | 
| 523 437 |  | 
| 524 438 | 
             
              Data_Get_Struct(self, xmlDoc, xdoc);
         | 
| @@ -535,15 +449,15 @@ ruby_xml_document_encoding_get(VALUE self) { | |
| 535 449 | 
             
             * 
         | 
| 536 450 | 
             
             * Set the encoding for this document.
         | 
| 537 451 | 
             
             */
         | 
| 538 | 
            -
            VALUE
         | 
| 539 | 
            -
             | 
| 452 | 
            +
            static VALUE
         | 
| 453 | 
            +
            rxml_document_encoding_set(VALUE self, VALUE encoding) {
         | 
| 540 454 | 
             
              xmlDocPtr xdoc;
         | 
| 541 455 |  | 
| 542 456 |  | 
| 543 457 | 
             
              Check_Type(encoding, T_STRING);
         | 
| 544 458 | 
             
              Data_Get_Struct(self, xmlDoc, xdoc);
         | 
| 545 459 | 
             
              xdoc->encoding = xmlStrdup(StringValuePtr(encoding));
         | 
| 546 | 
            -
              return( | 
| 460 | 
            +
              return(rxml_document_encoding_get(self));
         | 
| 547 461 | 
             
            }
         | 
| 548 462 |  | 
| 549 463 | 
             
            /*
         | 
| @@ -552,8 +466,8 @@ ruby_xml_document_encoding_set(VALUE self, VALUE encoding) { | |
| 552 466 | 
             
             * 
         | 
| 553 467 | 
             
             * Obtain the last node.
         | 
| 554 468 | 
             
             */
         | 
| 555 | 
            -
            VALUE
         | 
| 556 | 
            -
             | 
| 469 | 
            +
            static VALUE
         | 
| 470 | 
            +
            rxml_document_last_get(VALUE self) {
         | 
| 557 471 | 
             
              xmlDocPtr xdoc;
         | 
| 558 472 |  | 
| 559 473 |  | 
| @@ -562,7 +476,7 @@ ruby_xml_document_last_get(VALUE self) { | |
| 562 476 | 
             
              if (xdoc->last == NULL)
         | 
| 563 477 | 
             
                return(Qnil);
         | 
| 564 478 |  | 
| 565 | 
            -
              return  | 
| 479 | 
            +
              return rxml_node2_wrap(cXMLNode, xdoc->last);
         | 
| 566 480 | 
             
            }
         | 
| 567 481 |  | 
| 568 482 |  | 
| @@ -572,8 +486,8 @@ ruby_xml_document_last_get(VALUE self) { | |
| 572 486 | 
             
             * 
         | 
| 573 487 | 
             
             * Determine whether there is a last node.
         | 
| 574 488 | 
             
             */
         | 
| 575 | 
            -
            VALUE
         | 
| 576 | 
            -
             | 
| 489 | 
            +
            static VALUE
         | 
| 490 | 
            +
            rxml_document_last_q(VALUE self) {
         | 
| 577 491 | 
             
              xmlDocPtr xdoc;
         | 
| 578 492 |  | 
| 579 493 | 
             
              Data_Get_Struct(self, xmlDoc, xdoc);
         | 
| @@ -591,8 +505,8 @@ ruby_xml_document_last_q(VALUE self) { | |
| 591 505 | 
             
             * 
         | 
| 592 506 | 
             
             * Obtain the next node.
         | 
| 593 507 | 
             
             */
         | 
| 594 | 
            -
            VALUE
         | 
| 595 | 
            -
             | 
| 508 | 
            +
            static VALUE
         | 
| 509 | 
            +
            rxml_document_next_get(VALUE self) {
         | 
| 596 510 | 
             
              xmlDocPtr xdoc;
         | 
| 597 511 |  | 
| 598 512 |  | 
| @@ -601,7 +515,7 @@ ruby_xml_document_next_get(VALUE self) { | |
| 601 515 | 
             
              if (xdoc->next == NULL)
         | 
| 602 516 | 
             
                return(Qnil);
         | 
| 603 517 |  | 
| 604 | 
            -
              return  | 
| 518 | 
            +
              return rxml_node2_wrap(cXMLNode, xdoc->next);
         | 
| 605 519 | 
             
            }
         | 
| 606 520 |  | 
| 607 521 |  | 
| @@ -611,8 +525,8 @@ ruby_xml_document_next_get(VALUE self) { | |
| 611 525 | 
             
             * 
         | 
| 612 526 | 
             
             * Determine whether there is a next node.
         | 
| 613 527 | 
             
             */
         | 
| 614 | 
            -
            VALUE
         | 
| 615 | 
            -
             | 
| 528 | 
            +
            static VALUE
         | 
| 529 | 
            +
            rxml_document_next_q(VALUE self) {
         | 
| 616 530 | 
             
              xmlDocPtr xdoc;
         | 
| 617 531 |  | 
| 618 532 | 
             
              Data_Get_Struct(self, xmlDoc, xdoc);
         | 
| @@ -630,8 +544,8 @@ ruby_xml_document_next_q(VALUE self) { | |
| 630 544 | 
             
             * 
         | 
| 631 545 | 
             
             * Obtain the parent node.
         | 
| 632 546 | 
             
             */
         | 
| 633 | 
            -
            VALUE
         | 
| 634 | 
            -
             | 
| 547 | 
            +
            static VALUE
         | 
| 548 | 
            +
            rxml_document_parent_get(VALUE self) {
         | 
| 635 549 | 
             
              xmlDocPtr xdoc;
         | 
| 636 550 |  | 
| 637 551 |  | 
| @@ -640,7 +554,7 @@ ruby_xml_document_parent_get(VALUE self) { | |
| 640 554 | 
             
              if (xdoc->parent == NULL)
         | 
| 641 555 | 
             
                return(Qnil);
         | 
| 642 556 |  | 
| 643 | 
            -
              return  | 
| 557 | 
            +
              return rxml_node2_wrap(cXMLNode, xdoc->parent);
         | 
| 644 558 | 
             
            }
         | 
| 645 559 |  | 
| 646 560 |  | 
| @@ -650,8 +564,8 @@ ruby_xml_document_parent_get(VALUE self) { | |
| 650 564 | 
             
             * 
         | 
| 651 565 | 
             
             * Determine whether there is a parent node.
         | 
| 652 566 | 
             
             */
         | 
| 653 | 
            -
            VALUE
         | 
| 654 | 
            -
             | 
| 567 | 
            +
            static VALUE
         | 
| 568 | 
            +
            rxml_document_parent_q(VALUE self) {
         | 
| 655 569 | 
             
              xmlDocPtr xdoc;
         | 
| 656 570 |  | 
| 657 571 | 
             
              Data_Get_Struct(self, xmlDoc, xdoc);
         | 
| @@ -669,8 +583,8 @@ ruby_xml_document_parent_q(VALUE self) { | |
| 669 583 | 
             
             * 
         | 
| 670 584 | 
             
             * Obtain the previous node.
         | 
| 671 585 | 
             
             */
         | 
| 672 | 
            -
            VALUE
         | 
| 673 | 
            -
             | 
| 586 | 
            +
            static VALUE
         | 
| 587 | 
            +
            rxml_document_prev_get(VALUE self) {
         | 
| 674 588 | 
             
              xmlDocPtr xdoc;
         | 
| 675 589 |  | 
| 676 590 |  | 
| @@ -679,7 +593,7 @@ ruby_xml_document_prev_get(VALUE self) { | |
| 679 593 | 
             
              if (xdoc->prev == NULL)
         | 
| 680 594 | 
             
                return(Qnil);
         | 
| 681 595 |  | 
| 682 | 
            -
              return  | 
| 596 | 
            +
              return rxml_node2_wrap(cXMLNode, xdoc->prev);
         | 
| 683 597 | 
             
            }
         | 
| 684 598 |  | 
| 685 599 |  | 
| @@ -689,8 +603,8 @@ ruby_xml_document_prev_get(VALUE self) { | |
| 689 603 | 
             
             * 
         | 
| 690 604 | 
             
             * Determine whether there is a previous node.
         | 
| 691 605 | 
             
             */
         | 
| 692 | 
            -
            VALUE
         | 
| 693 | 
            -
             | 
| 606 | 
            +
            static VALUE
         | 
| 607 | 
            +
            rxml_document_prev_q(VALUE self) {
         | 
| 694 608 | 
             
              xmlDocPtr xdoc;
         | 
| 695 609 |  | 
| 696 610 | 
             
              Data_Get_Struct(self, xmlDoc, xdoc);
         | 
| @@ -708,8 +622,8 @@ ruby_xml_document_prev_q(VALUE self) { | |
| 708 622 | 
             
             * 
         | 
| 709 623 | 
             
             * Obtain the root node.
         | 
| 710 624 | 
             
             */
         | 
| 711 | 
            -
            VALUE
         | 
| 712 | 
            -
             | 
| 625 | 
            +
            static VALUE
         | 
| 626 | 
            +
            rxml_document_root_get(VALUE self) {
         | 
| 713 627 | 
             
              xmlDocPtr xdoc;
         | 
| 714 628 |  | 
| 715 629 | 
             
              xmlNodePtr root;
         | 
| @@ -720,7 +634,7 @@ ruby_xml_document_root_get(VALUE self) { | |
| 720 634 | 
             
              if (root == NULL)
         | 
| 721 635 | 
             
                return(Qnil);
         | 
| 722 636 |  | 
| 723 | 
            -
              return  | 
| 637 | 
            +
              return rxml_node2_wrap(cXMLNode, root);
         | 
| 724 638 | 
             
            }
         | 
| 725 639 |  | 
| 726 640 |  | 
| @@ -730,8 +644,8 @@ ruby_xml_document_root_get(VALUE self) { | |
| 730 644 | 
             
             * 
         | 
| 731 645 | 
             
             * Set the root node.
         | 
| 732 646 | 
             
             */
         | 
| 733 | 
            -
            VALUE
         | 
| 734 | 
            -
             | 
| 647 | 
            +
            static VALUE
         | 
| 648 | 
            +
            rxml_document_root_set(VALUE self, VALUE node) {
         | 
| 735 649 | 
             
              xmlDocPtr xdoc;
         | 
| 736 650 | 
             
              xmlNodePtr xroot, xnode;
         | 
| 737 651 |  | 
| @@ -744,7 +658,7 @@ ruby_xml_document_root_set(VALUE self, VALUE node) { | |
| 744 658 | 
             
              if (xroot == NULL)
         | 
| 745 659 | 
             
                return(Qnil);
         | 
| 746 660 |  | 
| 747 | 
            -
              return  | 
| 661 | 
            +
              return rxml_node2_wrap(cXMLNode, xroot);
         | 
| 748 662 | 
             
            }
         | 
| 749 663 |  | 
| 750 664 |  | 
| @@ -760,8 +674,8 @@ ruby_xml_document_root_set(VALUE self, VALUE node) { | |
| 760 674 | 
             
             *  format: Specifies whether formatting spaces should be added.
         | 
| 761 675 | 
             
             *  returns: The number of bytes written or -1 in case of error. 
         | 
| 762 676 | 
             
             */
         | 
| 763 | 
            -
            VALUE
         | 
| 764 | 
            -
             | 
| 677 | 
            +
            static VALUE
         | 
| 678 | 
            +
            rxml_document_save(int argc, VALUE *argv, VALUE self) {
         | 
| 765 679 | 
             
              xmlDocPtr xdoc;
         | 
| 766 680 |  | 
| 767 681 | 
             
              const char *filename;
         | 
| @@ -804,8 +718,8 @@ ruby_xml_document_save(int argc, VALUE *argv, VALUE self) { | |
| 804 718 | 
             
             * 
         | 
| 805 719 | 
             
             * Determine whether this is a standalone document.
         | 
| 806 720 | 
             
             */
         | 
| 807 | 
            -
            VALUE
         | 
| 808 | 
            -
             | 
| 721 | 
            +
            static VALUE
         | 
| 722 | 
            +
            rxml_document_standalone_q(VALUE self) {
         | 
| 809 723 | 
             
              xmlDocPtr xdoc;
         | 
| 810 724 |  | 
| 811 725 | 
             
              Data_Get_Struct(self, xmlDoc, xdoc);
         | 
| @@ -828,8 +742,8 @@ ruby_xml_document_standalone_q(VALUE self) { | |
| 828 742 | 
             
             * The encoding is not applied to the document, but is
         | 
| 829 743 | 
             
             * encoding target of the resulting string.
         | 
| 830 744 | 
             
             */
         | 
| 831 | 
            -
            VALUE
         | 
| 832 | 
            -
             | 
| 745 | 
            +
            static VALUE
         | 
| 746 | 
            +
            rxml_document_to_s(int argc, VALUE *argv, VALUE self) {
         | 
| 833 747 | 
             
              xmlDocPtr xdoc;
         | 
| 834 748 |  | 
| 835 749 | 
             
              xmlChar *result, *encoding=NULL;
         | 
| @@ -884,8 +798,8 @@ ruby_xml_document_to_s(int argc, VALUE *argv, VALUE self) { | |
| 884 798 | 
             
             * 
         | 
| 885 799 | 
             
             * Obtain this document's source URL, if any.
         | 
| 886 800 | 
             
             */
         | 
| 887 | 
            -
            VALUE
         | 
| 888 | 
            -
             | 
| 801 | 
            +
            static VALUE
         | 
| 802 | 
            +
            rxml_document_url_get(VALUE self) {
         | 
| 889 803 | 
             
              xmlDocPtr xdoc;
         | 
| 890 804 |  | 
| 891 805 | 
             
              Data_Get_Struct(self, xmlDoc, xdoc);
         | 
| @@ -902,8 +816,8 @@ ruby_xml_document_url_get(VALUE self) { | |
| 902 816 | 
             
             * 
         | 
| 903 817 | 
             
             * Obtain the XML version specified by this document.
         | 
| 904 818 | 
             
             */
         | 
| 905 | 
            -
            VALUE
         | 
| 906 | 
            -
             | 
| 819 | 
            +
            static VALUE
         | 
| 820 | 
            +
            rxml_document_version_get(VALUE self) {
         | 
| 907 821 | 
             
              xmlDocPtr xdoc;
         | 
| 908 822 |  | 
| 909 823 | 
             
              Data_Get_Struct(self, xmlDoc, xdoc);
         | 
| @@ -920,8 +834,8 @@ ruby_xml_document_version_get(VALUE self) { | |
| 920 834 | 
             
             * 
         | 
| 921 835 | 
             
             * Process xinclude directives in this document. 
         | 
| 922 836 | 
             
             */
         | 
| 923 | 
            -
            VALUE
         | 
| 924 | 
            -
             | 
| 837 | 
            +
            static VALUE
         | 
| 838 | 
            +
            rxml_document_xinclude(VALUE self) {
         | 
| 925 839 | 
             
            #ifdef LIBXML_XINCLUDE_ENABLED
         | 
| 926 840 | 
             
              xmlDocPtr xdoc;
         | 
| 927 841 |  | 
| @@ -935,7 +849,7 @@ ruby_xml_document_xinclude(VALUE self) { | |
| 935 849 | 
             
              }
         | 
| 936 850 | 
             
              else
         | 
| 937 851 | 
             
              {
         | 
| 938 | 
            -
                 | 
| 852 | 
            +
                rxml_raise(&xmlLastError);
         | 
| 939 853 | 
             
                return Qnil;
         | 
| 940 854 | 
             
              }
         | 
| 941 855 | 
             
            #else
         | 
| @@ -980,17 +894,17 @@ LibXML_validity_warning(void * ctxt, const char * msg, va_list ap) | |
| 980 894 | 
             
             * The block is called with two argument, the message and a flag indication
         | 
| 981 895 | 
             
             * if the message is an error (true) or a warning (false).
         | 
| 982 896 | 
             
             */
         | 
| 983 | 
            -
            VALUE
         | 
| 984 | 
            -
             | 
| 897 | 
            +
            static VALUE
         | 
| 898 | 
            +
            rxml_document_validate_schema(VALUE self, VALUE schema) {
         | 
| 985 899 | 
             
              xmlSchemaValidCtxtPtr vptr;
         | 
| 986 900 | 
             
              xmlDocPtr xdoc;
         | 
| 987 | 
            -
               | 
| 901 | 
            +
              xmlSchemaPtr xschema;
         | 
| 988 902 | 
             
              int is_invalid;
         | 
| 989 903 |  | 
| 990 904 | 
             
              Data_Get_Struct(self, xmlDoc, xdoc);
         | 
| 991 | 
            -
              Data_Get_Struct(schema,  | 
| 905 | 
            +
              Data_Get_Struct(schema, xmlSchema, xschema);
         | 
| 992 906 |  | 
| 993 | 
            -
              vptr = xmlSchemaNewValidCtxt( | 
| 907 | 
            +
              vptr = xmlSchemaNewValidCtxt(xschema);
         | 
| 994 908 |  | 
| 995 909 | 
             
              xmlSchemaSetValidErrors(vptr, (xmlSchemaValidityErrorFunc)LibXML_validity_error,
         | 
| 996 910 | 
             
                                            (xmlSchemaValidityWarningFunc)LibXML_validity_warning, NULL);
         | 
| @@ -999,9 +913,10 @@ ruby_xml_document_validate_schema(VALUE self, VALUE schema) { | |
| 999 913 | 
             
              xmlSchemaFreeValidCtxt(vptr);
         | 
| 1000 914 | 
             
              if (is_invalid) 
         | 
| 1001 915 | 
             
              {
         | 
| 1002 | 
            -
                 | 
| 916 | 
            +
                rxml_raise(&xmlLastError);
         | 
| 1003 917 | 
             
                return Qfalse;
         | 
| 1004 | 
            -
              }  | 
| 918 | 
            +
              } 
         | 
| 919 | 
            +
              else
         | 
| 1005 920 | 
             
              {
         | 
| 1006 921 | 
             
            	  return Qtrue;
         | 
| 1007 922 | 
             
              }
         | 
| @@ -1017,17 +932,17 @@ ruby_xml_document_validate_schema(VALUE self, VALUE schema) { | |
| 1017 932 | 
             
             * The block is called with two argument, the message and a flag indication
         | 
| 1018 933 | 
             
             * if the message is an error (true) or a warning (false).
         | 
| 1019 934 | 
             
             */
         | 
| 1020 | 
            -
            VALUE
         | 
| 1021 | 
            -
             | 
| 935 | 
            +
            static VALUE
         | 
| 936 | 
            +
            rxml_document_validate_relaxng(VALUE self, VALUE relaxng) {
         | 
| 1022 937 | 
             
              xmlRelaxNGValidCtxtPtr vptr;
         | 
| 1023 938 | 
             
              xmlDocPtr xdoc;
         | 
| 1024 | 
            -
               | 
| 939 | 
            +
              xmlRelaxNGPtr xrelaxng;
         | 
| 1025 940 | 
             
              int is_invalid;
         | 
| 1026 941 |  | 
| 1027 942 | 
             
              Data_Get_Struct(self, xmlDoc, xdoc);
         | 
| 1028 | 
            -
              Data_Get_Struct(relaxng,  | 
| 943 | 
            +
              Data_Get_Struct(relaxng, xmlRelaxNG, xrelaxng);
         | 
| 1029 944 |  | 
| 1030 | 
            -
              vptr = xmlRelaxNGNewValidCtxt( | 
| 945 | 
            +
              vptr = xmlRelaxNGNewValidCtxt(xrelaxng);
         | 
| 1031 946 |  | 
| 1032 947 | 
             
              xmlRelaxNGSetValidErrors(vptr, (xmlRelaxNGValidityErrorFunc)LibXML_validity_error,
         | 
| 1033 948 | 
             
                                            (xmlRelaxNGValidityWarningFunc)LibXML_validity_warning, NULL);
         | 
| @@ -1036,7 +951,7 @@ ruby_xml_document_validate_relaxng(VALUE self, VALUE relaxng) { | |
| 1036 951 | 
             
              xmlRelaxNGFreeValidCtxt(vptr);
         | 
| 1037 952 | 
             
              if (is_invalid) 
         | 
| 1038 953 | 
             
              {
         | 
| 1039 | 
            -
                 | 
| 954 | 
            +
                rxml_raise(&xmlLastError);
         | 
| 1040 955 | 
             
                return Qfalse;
         | 
| 1041 956 | 
             
              } else 
         | 
| 1042 957 | 
             
              {
         | 
| @@ -1051,15 +966,15 @@ ruby_xml_document_validate_relaxng(VALUE self, VALUE relaxng) { | |
| 1051 966 | 
             
             * 
         | 
| 1052 967 | 
             
             * Validate this document against the specified XML::DTD.
         | 
| 1053 968 | 
             
             */
         | 
| 1054 | 
            -
            VALUE
         | 
| 1055 | 
            -
             | 
| 969 | 
            +
            static VALUE
         | 
| 970 | 
            +
            rxml_document_validate_dtd(VALUE self, VALUE dtd) {
         | 
| 1056 971 | 
             
              VALUE error = Qnil;
         | 
| 1057 972 | 
             
              xmlValidCtxt ctxt;
         | 
| 1058 973 | 
             
              xmlDocPtr xdoc;
         | 
| 1059 | 
            -
               | 
| 974 | 
            +
              xmlDtdPtr xdtd;
         | 
| 1060 975 |  | 
| 1061 976 | 
             
              Data_Get_Struct(self, xmlDoc, xdoc);
         | 
| 1062 | 
            -
              Data_Get_Struct(dtd,  | 
| 977 | 
            +
              Data_Get_Struct(dtd, xmlDtd, xdtd);
         | 
| 1063 978 |  | 
| 1064 979 | 
             
              ctxt.userData = &error;
         | 
| 1065 980 | 
             
              ctxt.error = (xmlValidityErrorFunc)LibXML_validity_error;
         | 
| @@ -1070,13 +985,13 @@ ruby_xml_document_validate_dtd(VALUE self, VALUE dtd) { | |
| 1070 985 | 
             
              ctxt.vstateNr = 0;
         | 
| 1071 986 | 
             
              ctxt.vstateTab = NULL;
         | 
| 1072 987 |  | 
| 1073 | 
            -
              if (xmlValidateDtd(&ctxt, xdoc,  | 
| 988 | 
            +
              if (xmlValidateDtd(&ctxt, xdoc, xdtd))
         | 
| 1074 989 | 
             
              {
         | 
| 1075 990 | 
             
                return(Qtrue);
         | 
| 1076 991 | 
             
              }
         | 
| 1077 992 | 
             
              else
         | 
| 1078 993 | 
             
              {
         | 
| 1079 | 
            -
                 | 
| 994 | 
            +
                rxml_raise(&xmlLastError);
         | 
| 1080 995 | 
             
                return Qfalse;
         | 
| 1081 996 | 
             
              }
         | 
| 1082 997 | 
             
            }
         | 
| @@ -1090,9 +1005,9 @@ ruby_xml_document_validate_dtd(VALUE self, VALUE dtd) { | |
| 1090 1005 | 
             
             * XML::Reader.walker().
         | 
| 1091 1006 | 
             
             */
         | 
| 1092 1007 | 
             
            static VALUE
         | 
| 1093 | 
            -
             | 
| 1008 | 
            +
            rxml_document_reader(VALUE self)
         | 
| 1094 1009 | 
             
            {
         | 
| 1095 | 
            -
              return  | 
| 1010 | 
            +
              return rxml_reader_new_walker(cXMLReader, self);
         | 
| 1096 1011 | 
             
            }
         | 
| 1097 1012 |  | 
| 1098 1013 | 
             
            // Rdoc needs to know 
         | 
| @@ -1103,42 +1018,40 @@ ruby_xml_document_reader(VALUE self) | |
| 1103 1018 |  | 
| 1104 1019 | 
             
            void
         | 
| 1105 1020 | 
             
            ruby_init_xml_document(void) {
         | 
| 1106 | 
            -
              ref_count_table = st_init_numtable();
         | 
| 1107 | 
            -
             | 
| 1108 1021 | 
             
              cXMLDocument = rb_define_class_under(mXML, "Document", rb_cObject);
         | 
| 1109 | 
            -
              rb_define_alloc_func(cXMLDocument,  | 
| 1110 | 
            -
             | 
| 1111 | 
            -
              rb_define_method(cXMLDocument, "initialize",  | 
| 1112 | 
            -
              rb_define_method(cXMLDocument, "child",  | 
| 1113 | 
            -
              rb_define_method(cXMLDocument, "child?",  | 
| 1114 | 
            -
              rb_define_method(cXMLDocument, "compression",  | 
| 1115 | 
            -
              rb_define_method(cXMLDocument, "compression=",  | 
| 1116 | 
            -
              rb_define_method(cXMLDocument, "compression?",  | 
| 1117 | 
            -
              rb_define_method(cXMLDocument, "dump",  | 
| 1118 | 
            -
              rb_define_method(cXMLDocument, "debug_dump",  | 
| 1119 | 
            -
              rb_define_method(cXMLDocument, "debug_dump_head",  | 
| 1120 | 
            -
              rb_define_method(cXMLDocument, "debug_format_dump",  | 
| 1121 | 
            -
              rb_define_method(cXMLDocument, "encoding",  | 
| 1122 | 
            -
              rb_define_method(cXMLDocument, "encoding=",  | 
| 1123 | 
            -
              rb_define_method(cXMLDocument, "format_dump",  | 
| 1124 | 
            -
              rb_define_method(cXMLDocument, "last",  | 
| 1125 | 
            -
              rb_define_method(cXMLDocument, "last?",  | 
| 1126 | 
            -
              rb_define_method(cXMLDocument, "next",  | 
| 1127 | 
            -
              rb_define_method(cXMLDocument, "next?",  | 
| 1128 | 
            -
              rb_define_method(cXMLDocument, "parent",  | 
| 1129 | 
            -
              rb_define_method(cXMLDocument, "parent?",  | 
| 1130 | 
            -
              rb_define_method(cXMLDocument, "prev",  | 
| 1131 | 
            -
              rb_define_method(cXMLDocument, "prev?",  | 
| 1132 | 
            -
              rb_define_method(cXMLDocument, "root",  | 
| 1133 | 
            -
              rb_define_method(cXMLDocument, "root=",  | 
| 1134 | 
            -
              rb_define_method(cXMLDocument, "save",  | 
| 1135 | 
            -
              rb_define_method(cXMLDocument, "standalone?",  | 
| 1136 | 
            -
              rb_define_method(cXMLDocument, "to_s",  | 
| 1137 | 
            -
              rb_define_method(cXMLDocument, "url",  | 
| 1138 | 
            -
              rb_define_method(cXMLDocument, "version",  | 
| 1139 | 
            -
              rb_define_method(cXMLDocument, "xinclude",  | 
| 1140 | 
            -
              rb_define_method(cXMLDocument, "validate",  | 
| 1141 | 
            -
              rb_define_method(cXMLDocument, "validate_schema",  | 
| 1142 | 
            -
              rb_define_method(cXMLDocument, "validate_relaxng",  | 
| 1143 | 
            -
              rb_define_method(cXMLDocument, "reader",  | 
| 1022 | 
            +
              rb_define_alloc_func(cXMLDocument, rxml_document_alloc);
         | 
| 1023 | 
            +
             | 
| 1024 | 
            +
              rb_define_method(cXMLDocument, "initialize", rxml_document_initialize, -1);
         | 
| 1025 | 
            +
              rb_define_method(cXMLDocument, "child", rxml_document_child_get, 0);
         | 
| 1026 | 
            +
              rb_define_method(cXMLDocument, "child?", rxml_document_child_q, 0);
         | 
| 1027 | 
            +
              rb_define_method(cXMLDocument, "compression", rxml_document_compression_get, 0);
         | 
| 1028 | 
            +
              rb_define_method(cXMLDocument, "compression=", rxml_document_compression_set, 1);
         | 
| 1029 | 
            +
              rb_define_method(cXMLDocument, "compression?", rxml_document_compression_q, 0);
         | 
| 1030 | 
            +
              rb_define_method(cXMLDocument, "dump", rxml_document_dump, -1);
         | 
| 1031 | 
            +
              rb_define_method(cXMLDocument, "debug_dump", rxml_document_debug_dump, -1);
         | 
| 1032 | 
            +
              rb_define_method(cXMLDocument, "debug_dump_head", rxml_document_debug_dump_head, -1);
         | 
| 1033 | 
            +
              rb_define_method(cXMLDocument, "debug_format_dump", rxml_document_debug_format_dump, -1);
         | 
| 1034 | 
            +
              rb_define_method(cXMLDocument, "encoding", rxml_document_encoding_get, 0);
         | 
| 1035 | 
            +
              rb_define_method(cXMLDocument, "encoding=", rxml_document_encoding_set, 1);
         | 
| 1036 | 
            +
              rb_define_method(cXMLDocument, "format_dump", rxml_document_format_dump, -1);
         | 
| 1037 | 
            +
              rb_define_method(cXMLDocument, "last", rxml_document_last_get, 0);
         | 
| 1038 | 
            +
              rb_define_method(cXMLDocument, "last?", rxml_document_last_q, 0);
         | 
| 1039 | 
            +
              rb_define_method(cXMLDocument, "next", rxml_document_next_get, 0);
         | 
| 1040 | 
            +
              rb_define_method(cXMLDocument, "next?", rxml_document_next_q, 0);
         | 
| 1041 | 
            +
              rb_define_method(cXMLDocument, "parent", rxml_document_parent_get, 0);
         | 
| 1042 | 
            +
              rb_define_method(cXMLDocument, "parent?", rxml_document_parent_q, 0);
         | 
| 1043 | 
            +
              rb_define_method(cXMLDocument, "prev", rxml_document_prev_get, 0);
         | 
| 1044 | 
            +
              rb_define_method(cXMLDocument, "prev?", rxml_document_prev_q, 0);
         | 
| 1045 | 
            +
              rb_define_method(cXMLDocument, "root", rxml_document_root_get, 0);
         | 
| 1046 | 
            +
              rb_define_method(cXMLDocument, "root=", rxml_document_root_set, 1);
         | 
| 1047 | 
            +
              rb_define_method(cXMLDocument, "save", rxml_document_save, -1);
         | 
| 1048 | 
            +
              rb_define_method(cXMLDocument, "standalone?", rxml_document_standalone_q, 0);
         | 
| 1049 | 
            +
              rb_define_method(cXMLDocument, "to_s", rxml_document_to_s, -1);
         | 
| 1050 | 
            +
              rb_define_method(cXMLDocument, "url", rxml_document_url_get, 0);
         | 
| 1051 | 
            +
              rb_define_method(cXMLDocument, "version", rxml_document_version_get, 0);
         | 
| 1052 | 
            +
              rb_define_method(cXMLDocument, "xinclude", rxml_document_xinclude, 0);
         | 
| 1053 | 
            +
              rb_define_method(cXMLDocument, "validate", rxml_document_validate_dtd, 1);
         | 
| 1054 | 
            +
              rb_define_method(cXMLDocument, "validate_schema", rxml_document_validate_schema, 1);
         | 
| 1055 | 
            +
              rb_define_method(cXMLDocument, "validate_relaxng", rxml_document_validate_relaxng, 1);
         | 
| 1056 | 
            +
              rb_define_method(cXMLDocument, "reader", rxml_document_reader, 0);
         | 
| 1144 1057 | 
             
            }
         |