Skip to content

Commit d19595e

Browse files
authored
Merge pull request #31 from PainterQubits/dep07
Clean up some deprecations, bump to 0.7
2 parents ce750f8 + ad5c89e commit d19595e

File tree

4 files changed

+29
-31
lines changed

4 files changed

+29
-31
lines changed

REQUIRE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
julia 0.6
1+
julia 0.7
22
BinaryProvider

src/Clipper.jl

+24-26
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ module Clipper
1313
check_deps()
1414
end
1515

16-
1716
export PolyType, PolyTypeSubject, PolyTypeClip,
1817
ClipType, ClipTypeIntersection, ClipTypeUnion, ClipTypeDifference, ClipTypeXor,
1918
PolyFillType, PolyFillTypeEvenOdd, PolyFillTypeNonZero, PolyFillTypePositive, PolyFillTypeNegative,
@@ -33,8 +32,7 @@ module Clipper
3332

3433
@enum EndType EndTypeClosedPolygon=0 EndTypeClosedLine=1 EndTypeOpenSquare=2 EndTypeOpenRound=3 EndTypeOpenButt=4
3534

36-
37-
immutable IntPoint
35+
struct IntPoint
3836
X::Int64
3937
Y::Int64
4038
end
@@ -97,7 +95,7 @@ module Clipper
9795
print(io, "[$(point.X),$(point.Y)]")
9896
end
9997

100-
function append!(outputArray::Ptr{Void}, polyIndex::Csize_t, point::IntPoint)
98+
function append!(outputArray::Ptr{Cvoid}, polyIndex::Csize_t, point::IntPoint)
10199
ourArray = unsafe_pointer_to_objref(outputArray)::Vector{Vector{IntPoint}}
102100

103101
while (polyIndex + 1) > length(ourArray)
@@ -108,13 +106,13 @@ module Clipper
108106
end
109107

110108
# private
111-
function appendpn!(jl_node::Ptr{Void}, point::IntPoint)
109+
function appendpn!(jl_node::Ptr{Cvoid}, point::IntPoint)
112110
node = unsafe_pointer_to_objref(jl_node)::PolyNode{IntPoint}
113111
push!(contour(node), point)
114112
end
115113

116114
# private
117-
function newnode(outputTree::Ptr{Void}, ishole::Bool, isopen::Bool)
115+
function newnode(outputTree::Ptr{Cvoid}, ishole::Bool, isopen::Bool)
118116
tree = unsafe_pointer_to_objref(outputTree)::PolyNode{IntPoint}
119117
node = PolyNode{IntPoint}(IntPoint[], ishole, isopen, PolyNode{IntPoint}[], tree)
120118
push!(children(tree), node)
@@ -147,17 +145,17 @@ module Clipper
147145
# Clipper object
148146
#==============================================================#
149147
mutable struct Clip
150-
clipper_ptr::Ptr{Void}
148+
clipper_ptr::Ptr{Cvoid}
151149

152150
function Clip()
153-
clipper = new(ccall((:get_clipper, cclipper), Ptr{Void}, ()))
154-
finalizer(clipper, c -> ccall((:delete_clipper, cclipper), Void, (Ptr{Void},), c.clipper_ptr))
151+
clipper = new(ccall((:get_clipper, cclipper), Ptr{Cvoid}, ()))
152+
finalizer(c -> ccall((:delete_clipper, cclipper), Cvoid, (Ptr{Cvoid},), c.clipper_ptr), clipper)
155153
clipper
156154
end
157155
end
158156

159157
function add_path!(c::Clip, path::Vector{IntPoint}, polyType::PolyType, closed::Bool)
160-
ccall((:add_path, cclipper), Cuchar, (Ptr{Void}, Ptr{IntPoint}, Csize_t, Cint, Cuchar),
158+
ccall((:add_path, cclipper), Cuchar, (Ptr{Cvoid}, Ptr{IntPoint}, Csize_t, Cint, Cuchar),
161159
c.clipper_ptr,
162160
path,
163161
length(path),
@@ -171,7 +169,7 @@ module Clipper
171169
push!(lengths, length(path))
172170
end
173171

174-
ccall((:add_paths, cclipper), Cuchar, (Ptr{Void}, Ptr{Ptr{IntPoint}}, Ptr{Csize_t}, Csize_t, Cint, Cuchar),
172+
ccall((:add_paths, cclipper), Cuchar, (Ptr{Cvoid}, Ptr{Ptr{IntPoint}}, Ptr{Csize_t}, Csize_t, Cint, Cuchar),
175173
c.clipper_ptr,
176174
paths,
177175
lengths,
@@ -183,13 +181,13 @@ module Clipper
183181
function execute(c::Clip, clipType::ClipType, subjFillType::PolyFillType, clipFillType::PolyFillType)
184182
polys = Vector{Vector{IntPoint}}()
185183

186-
result = ccall((:execute, cclipper), Cuchar, (Ptr{Void}, Cint, Cint, Cint, Any, Ptr{Void}),
184+
result = ccall((:execute, cclipper), Cuchar, (Ptr{Cvoid}, Cint, Cint, Cint, Any, Ptr{Cvoid}),
187185
c.clipper_ptr,
188186
Int(clipType),
189187
Int(subjFillType),
190188
Int(clipFillType),
191189
polys,
192-
cfunction(append!, Any, (Ptr{Void}, Csize_t, IntPoint)))
190+
@cfunction(append!, Any, (Ptr{Cvoid}, Csize_t, IntPoint)))
193191

194192
return result == 1 ? true : false, polys
195193
end
@@ -198,20 +196,20 @@ module Clipper
198196
pt = PolyNode{IntPoint}(IntPoint[], false, false, PolyNode{IntPoint}[])
199197

200198
result = ccall((:execute_pt, cclipper), Cuchar,
201-
(Ptr{Void}, Cint, Cint, Cint, Any, Ptr{Void}, Ptr{Void}),
199+
(Ptr{Cvoid}, Cint, Cint, Cint, Any, Ptr{Cvoid}, Ptr{Cvoid}),
202200
c.clipper_ptr,
203201
Int(clipType),
204202
Int(subjFillType),
205203
Int(clipFillType),
206204
pt,
207-
cfunction(newnode, Ptr{Void}, (Ptr{Void}, Bool, Bool)),
208-
cfunction(appendpn!, Any, (Ptr{Void}, IntPoint)))
205+
@cfunction(newnode, Ptr{Cvoid}, (Ptr{Cvoid}, Bool, Bool)),
206+
@cfunction(appendpn!, Any, (Ptr{Cvoid}, IntPoint)))
209207

210208
return result == 1 ? true : false, pt
211209
end
212210

213211
function clear!(c::Clip)
214-
ccall((:clear, cclipper), Void, (Ptr{Void},), c.clipper_ptr)
212+
ccall((:clear, cclipper), Cvoid, (Ptr{Cvoid},), c.clipper_ptr)
215213
end
216214

217215
mutable struct IntRect
@@ -222,25 +220,25 @@ module Clipper
222220
end
223221

224222
function get_bounds(c::Clip)
225-
ccall((:get_bounds, cclipper), IntRect, (Ptr{Void}, ), c.clipper_ptr)
223+
ccall((:get_bounds, cclipper), IntRect, (Ptr{Cvoid}, ), c.clipper_ptr)
226224
end
227225

228226
#==============================================================#
229227
# ClipperOffset object
230228
#==============================================================#
231229
mutable struct ClipperOffset
232-
clipper_ptr::Ptr{Void}
230+
clipper_ptr::Ptr{Cvoid}
233231

234232
function ClipperOffset(miterLimit::Float64 = 2.0, roundPrecision::Float64 = 0.25)
235-
clipper = new(ccall((:get_clipper_offset, cclipper), Ptr{Void}, (Cdouble, Cdouble), miterLimit, roundPrecision))
236-
finalizer(clipper, c -> ccall((:delete_clipper_offset, cclipper), Void, (Ptr{Void},), c.clipper_ptr))
233+
clipper = new(ccall((:get_clipper_offset, cclipper), Ptr{Cvoid}, (Cdouble, Cdouble), miterLimit, roundPrecision))
234+
finalizer(c -> ccall((:delete_clipper_offset, cclipper), Cvoid, (Ptr{Cvoid},), c.clipper_ptr), clipper)
237235

238236
clipper
239237
end
240238
end
241239

242240
function add_path!(c::ClipperOffset, path::Vector{IntPoint}, joinType::JoinType, endType::EndType)
243-
ccall((:add_offset_path, cclipper), Void, (Ptr{Void}, Ptr{IntPoint}, Csize_t, Cint, Cint),
241+
ccall((:add_offset_path, cclipper), Cvoid, (Ptr{Cvoid}, Ptr{IntPoint}, Csize_t, Cint, Cint),
244242
c.clipper_ptr,
245243
path,
246244
length(path),
@@ -254,7 +252,7 @@ module Clipper
254252
push!(lengths, length(path))
255253
end
256254

257-
ccall((:add_offset_paths, cclipper), Void, (Ptr{Void}, Ptr{Ptr{IntPoint}}, Ptr{Csize_t}, Csize_t, Cint, Cint),
255+
ccall((:add_offset_paths, cclipper), Cvoid, (Ptr{Cvoid}, Ptr{Ptr{IntPoint}}, Ptr{Csize_t}, Csize_t, Cint, Cint),
258256
c.clipper_ptr,
259257
paths,
260258
lengths,
@@ -264,16 +262,16 @@ module Clipper
264262
end
265263

266264
function clear!(c::ClipperOffset)
267-
ccall((:clear_offset, cclipper), Void, (Ptr{Void},), c.clipper_ptr)
265+
ccall((:clear_offset, cclipper), Cvoid, (Ptr{Cvoid},), c.clipper_ptr)
268266
end
269267

270268
function execute(c::ClipperOffset, delta::Float64)
271269
polys = Vector{Vector{IntPoint}}()
272-
result = ccall((:execute_offset, cclipper), Void, (Ptr{Void}, Cdouble, Any, Ptr{Void}),
270+
result = ccall((:execute_offset, cclipper), Cvoid, (Ptr{Cvoid}, Cdouble, Any, Ptr{Cvoid}),
273271
c.clipper_ptr,
274272
delta,
275273
polys,
276-
cfunction(append!, Any, (Ptr{Void}, Csize_t, IntPoint)))
274+
@cfunction(append!, Any, (Ptr{Cvoid}, Csize_t, IntPoint)))
277275

278276
return polys
279277
end

test/clipper_test.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ test("Union") do
3737
@test polys[1][2] == Clipper.IntPoint(2, 0)
3838
@test polys[1][3] == Clipper.IntPoint(2, 1)
3939
@test polys[1][4] == Clipper.IntPoint(0, 1)
40-
40+
4141
result, pt = execute_pt(c, ClipTypeUnion, PolyFillTypeEvenOdd, PolyFillTypeEvenOdd)
4242
@test result == true
4343
@test string(pt) == "Top-level PolyNode with 1 immediate children."
@@ -81,13 +81,13 @@ test("Difference") do
8181
@test polys[2][2] == Clipper.IntPoint(0, 0)
8282
@test polys[2][3] == Clipper.IntPoint(4, 0)
8383
@test polys[2][4] == Clipper.IntPoint(4, 10)
84-
84+
8585
result, pt = execute_pt(c, ClipTypeDifference, PolyFillTypeEvenOdd, PolyFillTypeEvenOdd)
8686
@test result == true
8787
@test string(pt) == "Top-level PolyNode with 2 immediate children."
8888
@test length(children(pt)) === 2
8989

90-
pn1,pn2 = (children(pt)...)
90+
pn1,pn2 = (children(pt)...,)
9191
@test length(children(pn1)) == 0
9292
@test length(children(pn2)) == 0
9393

test/runtests.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ using Base.Test
44
function test(run::Function, name::AbstractString; verbose=true)
55
test_name = "Test $(name)"
66
if verbose
7-
println(STDERR, test_name)
7+
println(stderr, test_name)
88
end
99
try
1010
run()

0 commit comments

Comments
 (0)