Skip to content

Commit

Permalink
Use class instead of struct for objects in XML module.
Browse files Browse the repository at this point in the history
This will allow a future change to let the XML module manage the libXML2 memory,
fixing crystal-lang#10435 without breaking the API.
  • Loading branch information
hugopl committed Feb 22, 2021
1 parent 5d031a4 commit a24c86b
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/xml/attributes.cr
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "./node"

struct XML::Attributes
class XML::Attributes
include Enumerable(Node)

def initialize(@node : Node)
Expand Down
2 changes: 1 addition & 1 deletion src/xml/builder.cr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# an invalid XML (for example, if invoking `end_element`
# without a matching `start_element`, or trying to use
# a non-string value as an object's field name)
struct XML::Builder
class XML::Builder
private CDATA_END = "]]>"
private CDATA_ESCAPE = "]]]]><![CDATA[>"

Expand Down
2 changes: 1 addition & 1 deletion src/xml/namespace.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
struct XML::Namespace
class XML::Namespace
getter document : Node

def initialize(@document : Node, @ns : LibXML::NS*)
Expand Down
2 changes: 1 addition & 1 deletion src/xml/node.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
struct XML::Node
class XML::Node
LOOKS_LIKE_XPATH = /^(\.\/|\/|\.\.|\.$)/

# Creates a new node.
Expand Down
2 changes: 1 addition & 1 deletion src/xml/node/type.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
struct XML::Node
class XML::Node
enum Type
NONE = 0
ELEMENT_NODE = 1
Expand Down
2 changes: 1 addition & 1 deletion src/xml/node_set.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
struct XML::NodeSet
class XML::NodeSet
include Enumerable(Node)

def initialize(@doc : Node, @set : LibXML::NodeSet*)
Expand Down
2 changes: 1 addition & 1 deletion src/xml/reader.cr
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "./libxml2"
require "./parser_options"

struct XML::Reader
class XML::Reader
# Creates a new reader from a string.
#
# See `XML::ParserOptions.default` for default options.
Expand Down
2 changes: 1 addition & 1 deletion src/xml/reader/type.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
struct XML::Reader
class XML::Reader
enum Type
NONE = 0
ELEMENT = 1
Expand Down
2 changes: 1 addition & 1 deletion src/xml/xpath_context.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
struct XML::XPathContext
class XML::XPathContext
def initialize(node : Node)
@ctx = LibXML.xmlXPathNewContext(node.to_unsafe.value.doc)
@ctx.value.node = node.to_unsafe
Expand Down

0 comments on commit a24c86b

Please sign in to comment.