Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add iteratorsize #47

Merged
merged 3 commits into from
May 27, 2016
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/LightXML.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ module LightXML

using Compat

# iteratorsize is new in 0.5, declare it here for older versions. However,
# we do not actually support calling these, since the traits are not defined
if VERSION < v"0.5.0-dev+3305"
function iteratorsize(v)
error("Do not call this on older versions")
end
else
import Base: iteratorsize, SizeUnknown, IsInfinite, HasLength
end



const libxml2 = @windows? Pkg.dir("WinRPM","deps","usr","$(Sys.ARCH)-w64-mingw32","sys-root","mingw","bin","libxml2-2") : "libxml2"

export
Expand Down
4 changes: 3 additions & 1 deletion src/nodes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ end
Base.start(it::XMLAttrIter) = it.p
Base.done(it::XMLAttrIter, p::Xptr) = (p == C_NULL)
Base.next(it::XMLAttrIter, p::Xptr) = (a = XMLAttr(p); (a, a._struct.next))

iteratorsize(::Type{XMLAttrIter})=SizeUnknown()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spaces around the =

#######################################
#
Expand Down Expand Up @@ -163,6 +163,7 @@ end
Base.start(it::XMLNodeIter) = it.p
Base.done(it::XMLNodeIter, p::Xptr) = (p == C_NULL)
Base.next(it::XMLNodeIter, p::Xptr) = (nd = XMLNode(p); (nd, nd._struct.next))
iteratorsize(::Type{XMLNodeIter})=SizeUnknown()

child_nodes(nd::XMLNode) = XMLNodeIter(nd._struct.children)

Expand Down Expand Up @@ -263,6 +264,7 @@ end
Base.start(it::XMLElementIter) = ccall((:xmlFirstElementChild,libxml2), Xptr, (Xptr,), it.parent_ptr)
Base.done(it::XMLElementIter, p::Xptr) = (p == C_NULL)
Base.next(it::XMLElementIter, p::Xptr) = (XMLElement(p), ccall((:xmlNextElementSibling,libxml2), Xptr, (Xptr,), p))
iteratorsize(::Type{XMLElementIter})=SizeUnknown()

child_elements(x::XMLElement) = XMLElementIter(x.node.ptr)

Expand Down