Module: Nokogiri::LibXML::XmlDocumentMixin

Included in:
XmlDocument, XmlDocumentCast
Defined in:
lib/nokogiri/ffi/structs/xml_document.rb

Overview

:nodoc:

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



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
# File 'lib/nokogiri/ffi/structs/xml_document.rb', line 5

def self.included(base)
  base.class_eval do

    layout(
      :_private,  :pointer,
      :type,      :int,
      :name,      :string,
      :children,  :pointer,
      :last,      :pointer,
      :parent,    :pointer,
      :next,      :pointer,
      :prev,      :pointer,
      :doc,       :pointer,

      :compression,       :int,
      :standalone,        :int,
      :intSubset,         :pointer,
      :extSubset,         :pointer,
      :oldNs,             :pointer,
      :version,           :string,
      :encoding,          :pointer,
      :ids,               :pointer,
      :refs,              :pointer,
      :URL,               :string
      )

  end
end

Instance Method Details

#alloc_tupleObject



53
54
55
56
# File 'lib/nokogiri/ffi/structs/xml_document.rb', line 53

def alloc_tuple
  self[:_private] = LibXML.calloc(LibXML::POINTER_SIZE, 2)
  self[:_private].put_pointer(LibXML.pointer_offset(1), LibXML.xmlXPathNodeSetCreate(nil))
end

#documentObject



34
35
36
37
# File 'lib/nokogiri/ffi/structs/xml_document.rb', line 34

def document
  p = self[:doc]
  p.null? ? nil : LibXML::XmlDocumentCast.new(p)
end

#ruby_docObject



39
40
41
42
43
# File 'lib/nokogiri/ffi/structs/xml_document.rb', line 39

def ruby_doc
  ptr = self[:_private]
  return nil if ptr.null?
  ObjectSpace._id2ref(ptr.get_long(0))
end

#ruby_doc=(object) ⇒ Object



45
46
47
# File 'lib/nokogiri/ffi/structs/xml_document.rb', line 45

def ruby_doc=(object)
  self[:_private].put_long(0, object.object_id)
end

#unlinked_nodesObject



49
50
51
# File 'lib/nokogiri/ffi/structs/xml_document.rb', line 49

def unlinked_nodes
  LibXML::XmlNodeSetCast.new(self[:_private].get_pointer(LibXML.pointer_offset(1)))
end