Skip to content

Commit b4378f6

Browse files
authored
Fix deprecated warnings (#37)
1 parent d839406 commit b4378f6

File tree

9 files changed

+120
-100
lines changed

9 files changed

+120
-100
lines changed

example/julia2xml.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,8 @@ function expr2elem(expr)
3333
end
3434
end
3535

36-
prettyprint(expr2xml(parse(String(read(STDIN)))))
36+
if VERSION > v"0.7-"
37+
prettyprint(expr2xml(Meta.parse(String(read(STDIN)))))
38+
else
39+
prettyprint(expr2xml(parse(String(read(STDIN)))))
40+
end

src/EzXML.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,14 @@ else
101101
const libxml2 = "libxml2"
102102
end
103103

104+
if VERSION > v"0.7.0-DEV.3052"
105+
import Printf: @printf
106+
end
107+
108+
if !isdefined(Base, :Cvoid)
109+
const Cvoid = Void
110+
end
111+
104112
include("error.jl")
105113
include("node.jl")
106114
include("document.jl")

src/buffer.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ struct _Buffer
55
content::Cstring
66
use::Cuint
77
size::Cuint
8-
alloc::Ptr{Void}
8+
alloc::Ptr{Cvoid}
99
contentIO::Cstring
1010
end
1111

@@ -30,7 +30,7 @@ end
3030
function finalize_buffer(buf)
3131
ccall(
3232
(:xmlBufferFree, libxml2),
33-
Void,
34-
(Ptr{Void},),
33+
Cvoid,
34+
(Ptr{Cvoid},),
3535
buf.ptr)
3636
end

src/document.jl

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ function readxml(input::IO)
164164
doc_ptr = @check ccall(
165165
(:xmlReadIO, libxml2),
166166
Ptr{_Node},
167-
(Ptr{Void}, Ptr{Void}, Ptr{Void}, Cstring, Cstring, Cint),
167+
(Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Cstring, Cstring, Cint),
168168
readcb, closecb, context, uri, encoding, options) != C_NULL
169169
return Document(doc_ptr)
170170
end
@@ -201,7 +201,7 @@ function readhtml(input::IO)
201201
doc_ptr = @check ccall(
202202
(:htmlReadIO, libxml2),
203203
Ptr{_Node},
204-
(Ptr{Void}, Ptr{Void}, Ptr{Void}, Cstring, Cstring, Cint),
204+
(Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Cstring, Cstring, Cint),
205205
readcb, closecb, context, uri, encoding, options) != C_NULL
206206
show_warnings()
207207
return Document(doc_ptr)
@@ -213,15 +213,15 @@ function Base.write(filename::AbstractString, doc::Document)
213213
ret = @check ccall(
214214
(:xmlSaveFormatFileEnc, libxml2),
215215
Cint,
216-
(Cstring, Ptr{Void}, Cstring, Cint),
216+
(Cstring, Ptr{Cvoid}, Cstring, Cint),
217217
filename, doc.node.ptr, encoding, format) != -1
218218
return Int(ret)
219219
end
220220

221221
function make_read_callback()
222222
# Passing an input stream as an argument is impossible to create a callback
223223
# because Julia does not support C-callable closures yet.
224-
return cfunction(Cint, Tuple{Ptr{Void}, Ptr{UInt8}, Cint}) do context, buffer, len
224+
return cfunction(Cint, Tuple{Ptr{Cvoid}, Ptr{UInt8}, Cint}) do context, buffer, len
225225
input = unsafe_pointer_to_objref(context)
226226
avail = min(nb_available(input), len)
227227
if avail > 0
@@ -253,8 +253,8 @@ Return if `doc` has a root element.
253253
function hasroot(doc::Document)
254254
ptr = ccall(
255255
(:xmlDocGetRootElement, libxml2),
256-
Ptr{Void},
257-
(Ptr{Void},),
256+
Ptr{Cvoid},
257+
(Ptr{Cvoid},),
258258
doc.node.ptr)
259259
return ptr != C_NULL
260260
end
@@ -271,7 +271,7 @@ function root(doc::Document)
271271
root_ptr = @check ccall(
272272
(:xmlDocGetRootElement, libxml2),
273273
Ptr{_Node},
274-
(Ptr{Void},),
274+
(Ptr{Cvoid},),
275275
doc.node.ptr) != C_NULL
276276
return Node(root_ptr)
277277
end
@@ -288,7 +288,7 @@ function setroot!(doc::Document, root::Node)
288288
old_root_ptr = ccall(
289289
(:xmlDocSetRootElement, libxml2),
290290
Ptr{_Node},
291-
(Ptr{Void}, Ptr{Void}),
291+
(Ptr{Cvoid}, Ptr{Cvoid}),
292292
doc.node.ptr, root.ptr)
293293
update_owners!(root, doc.node)
294294
if old_root_ptr != C_NULL
@@ -311,7 +311,7 @@ function hasdtd(doc::Document)
311311
dtd_ptr = ccall(
312312
(:xmlGetIntSubset, libxml2),
313313
Ptr{_Node},
314-
(Ptr{Void},),
314+
(Ptr{Cvoid},),
315315
doc.node.ptr)
316316
return dtd_ptr != C_NULL
317317
end
@@ -328,7 +328,7 @@ function dtd(doc::Document)
328328
dtd_ptr = @check ccall(
329329
(:xmlGetIntSubset, libxml2),
330330
Ptr{_Node},
331-
(Ptr{Void},),
331+
(Ptr{Cvoid},),
332332
doc.node.ptr) != C_NULL
333333
return Node(dtd_ptr)
334334
end
@@ -385,7 +385,7 @@ function validate(doc::Document)
385385
valid = ccall(
386386
(:xmlValidateDocument, libxml2),
387387
Cint,
388-
(Ptr{Void}, Ptr{Void}),
388+
(Ptr{Cvoid}, Ptr{Cvoid}),
389389
ctxt_ptr, doc.node.ptr)
390390
free(ctxt_ptr)
391391
@assert (valid == 1) == isempty(XML_GLOBAL_ERROR_STACK)
@@ -400,7 +400,7 @@ function validate(doc::Document, dtd::Node)
400400
valid = ccall(
401401
(:xmlValidateDtd, libxml2),
402402
Cint,
403-
(Ptr{Void}, Ptr{Void}, Ptr{Void}),
403+
(Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}),
404404
ctxt_ptr, doc.node.ptr, dtd.ptr)
405405
free(ctxt_ptr)
406406
@assert (valid == 1) == isempty(XML_GLOBAL_ERROR_STACK)
@@ -420,7 +420,7 @@ end
420420
function free(ptr::Ptr{_ValidCtxt})
421421
ccall(
422422
(:xmlFreeValidCtxt, libxml2),
423-
Void,
424-
(Ptr{Void},),
423+
Cvoid,
424+
(Ptr{Cvoid},),
425425
ptr)
426426
end

src/error.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ struct _Error
1515
str3::Cstring
1616
int1::Cint
1717
int2::Cint
18-
ctxt::Ptr{Void}
19-
node::Ptr{Void}
18+
ctxt::Ptr{Cvoid}
19+
node::Ptr{Cvoid}
2020
end
2121

2222
"""
@@ -57,7 +57,7 @@ end
5757

5858
# Initialize an error handler.
5959
function init_error_handler()
60-
error_handler = cfunction(Void, Tuple{Ptr{Void}, Ptr{Void}}) do ctx, err_ptr
60+
error_handler = cfunction(Cvoid, Tuple{Ptr{Cvoid}, Ptr{Cvoid}}) do ctx, err_ptr
6161
if ctx == pointer_from_objref(_Error)
6262
err = unsafe_load(convert(Ptr{_Error}, err_ptr))
6363
push!(XML_GLOBAL_ERROR_STACK, XMLError(err.domain, err.code, chomp(unsafe_string(err.message)), err.level, err.line))
@@ -66,8 +66,8 @@ function init_error_handler()
6666
end
6767
ccall(
6868
(:xmlSetStructuredErrorFunc, libxml2),
69-
Void,
70-
(Ptr{Void}, Ptr{Void}),
69+
Cvoid,
70+
(Ptr{Cvoid}, Ptr{Cvoid}),
7171
pointer_from_objref(_Error), error_handler)
7272
end
7373

0 commit comments

Comments
 (0)