@@ -13,7 +13,6 @@ module Clipper
13
13
check_deps ()
14
14
end
15
15
16
-
17
16
export PolyType, PolyTypeSubject, PolyTypeClip,
18
17
ClipType, ClipTypeIntersection, ClipTypeUnion, ClipTypeDifference, ClipTypeXor,
19
18
PolyFillType, PolyFillTypeEvenOdd, PolyFillTypeNonZero, PolyFillTypePositive, PolyFillTypeNegative,
@@ -33,8 +32,7 @@ module Clipper
33
32
34
33
@enum EndType EndTypeClosedPolygon= 0 EndTypeClosedLine= 1 EndTypeOpenSquare= 2 EndTypeOpenRound= 3 EndTypeOpenButt= 4
35
34
36
-
37
- immutable IntPoint
35
+ struct IntPoint
38
36
X:: Int64
39
37
Y:: Int64
40
38
end
@@ -97,7 +95,7 @@ module Clipper
97
95
print (io, " [$(point. X) ,$(point. Y) ]" )
98
96
end
99
97
100
- function append! (outputArray:: Ptr{Void } , polyIndex:: Csize_t , point:: IntPoint )
98
+ function append! (outputArray:: Ptr{Cvoid } , polyIndex:: Csize_t , point:: IntPoint )
101
99
ourArray = unsafe_pointer_to_objref (outputArray):: Vector{Vector{IntPoint}}
102
100
103
101
while (polyIndex + 1 ) > length (ourArray)
@@ -108,13 +106,13 @@ module Clipper
108
106
end
109
107
110
108
# private
111
- function appendpn! (jl_node:: Ptr{Void } , point:: IntPoint )
109
+ function appendpn! (jl_node:: Ptr{Cvoid } , point:: IntPoint )
112
110
node = unsafe_pointer_to_objref (jl_node):: PolyNode{IntPoint}
113
111
push! (contour (node), point)
114
112
end
115
113
116
114
# private
117
- function newnode (outputTree:: Ptr{Void } , ishole:: Bool , isopen:: Bool )
115
+ function newnode (outputTree:: Ptr{Cvoid } , ishole:: Bool , isopen:: Bool )
118
116
tree = unsafe_pointer_to_objref (outputTree):: PolyNode{IntPoint}
119
117
node = PolyNode {IntPoint} (IntPoint[], ishole, isopen, PolyNode{IntPoint}[], tree)
120
118
push! (children (tree), node)
@@ -147,17 +145,17 @@ module Clipper
147
145
# Clipper object
148
146
#= =============================================================#
149
147
mutable struct Clip
150
- clipper_ptr:: Ptr{Void }
148
+ clipper_ptr:: Ptr{Cvoid }
151
149
152
150
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 )
155
153
clipper
156
154
end
157
155
end
158
156
159
157
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),
161
159
c. clipper_ptr,
162
160
path,
163
161
length (path),
@@ -171,7 +169,7 @@ module Clipper
171
169
push! (lengths, length (path))
172
170
end
173
171
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),
175
173
c. clipper_ptr,
176
174
paths,
177
175
lengths,
@@ -183,13 +181,13 @@ module Clipper
183
181
function execute (c:: Clip , clipType:: ClipType , subjFillType:: PolyFillType , clipFillType:: PolyFillType )
184
182
polys = Vector {Vector{IntPoint}} ()
185
183
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 }),
187
185
c. clipper_ptr,
188
186
Int (clipType),
189
187
Int (subjFillType),
190
188
Int (clipFillType),
191
189
polys,
192
- cfunction (append!, Any, (Ptr{Void }, Csize_t, IntPoint)))
190
+ @ cfunction (append!, Any, (Ptr{Cvoid }, Csize_t, IntPoint)))
193
191
194
192
return result == 1 ? true : false , polys
195
193
end
@@ -198,20 +196,20 @@ module Clipper
198
196
pt = PolyNode {IntPoint} (IntPoint[], false , false , PolyNode{IntPoint}[])
199
197
200
198
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 }),
202
200
c. clipper_ptr,
203
201
Int (clipType),
204
202
Int (subjFillType),
205
203
Int (clipFillType),
206
204
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)))
209
207
210
208
return result == 1 ? true : false , pt
211
209
end
212
210
213
211
function clear! (c:: Clip )
214
- ccall ((:clear , cclipper), Void , (Ptr{Void },), c. clipper_ptr)
212
+ ccall ((:clear , cclipper), Cvoid , (Ptr{Cvoid },), c. clipper_ptr)
215
213
end
216
214
217
215
mutable struct IntRect
@@ -222,25 +220,25 @@ module Clipper
222
220
end
223
221
224
222
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)
226
224
end
227
225
228
226
#= =============================================================#
229
227
# ClipperOffset object
230
228
#= =============================================================#
231
229
mutable struct ClipperOffset
232
- clipper_ptr:: Ptr{Void }
230
+ clipper_ptr:: Ptr{Cvoid }
233
231
234
232
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 )
237
235
238
236
clipper
239
237
end
240
238
end
241
239
242
240
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),
244
242
c. clipper_ptr,
245
243
path,
246
244
length (path),
@@ -254,7 +252,7 @@ module Clipper
254
252
push! (lengths, length (path))
255
253
end
256
254
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),
258
256
c. clipper_ptr,
259
257
paths,
260
258
lengths,
@@ -264,16 +262,16 @@ module Clipper
264
262
end
265
263
266
264
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)
268
266
end
269
267
270
268
function execute (c:: ClipperOffset , delta:: Float64 )
271
269
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 }),
273
271
c. clipper_ptr,
274
272
delta,
275
273
polys,
276
- cfunction (append!, Any, (Ptr{Void }, Csize_t, IntPoint)))
274
+ @ cfunction (append!, Any, (Ptr{Cvoid }, Csize_t, IntPoint)))
277
275
278
276
return polys
279
277
end
0 commit comments