Skip to content

Commit 5dfde10

Browse files
David Bartonmusm
authored andcommitted
Fixes for compatibility with v0.7.0-alpha.0 (#133)
1 parent 27936dd commit 5dfde10

File tree

13 files changed

+194
-181
lines changed

13 files changed

+194
-181
lines changed

REQUIRE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
julia 0.6
2-
Compat 0.33.0
2+
Compat 0.62.0

src/MATLAB.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ module MATLAB
44

55
using Compat
66
using Compat.Sys: islinux, iswindows, isapple
7+
using Compat.Libdl
8+
using Compat.SparseArrays
79

810
import Base: eltype, close, size, copy, ndims, unsafe_convert
911

src/engine.jl

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ const default_startcmd = matlab_startcmd() * " -nosplash"
1111
const default_output_buffer_size = 64 * 1024
1212

1313
mutable struct MSession
14-
ptr::Ptr{Void}
14+
ptr::Ptr{Cvoid}
1515
buffer::Vector{UInt8}
1616
bufptr::Ptr{UInt8}
1717

1818
function MSession(bufsize::Integer = default_output_buffer_size)
19-
ep = ccall(eng_open[], Ptr{Void}, (Ptr{UInt8},), default_startcmd)
19+
ep = ccall(eng_open[], Ptr{Cvoid}, (Ptr{UInt8},), default_startcmd)
2020
if ep == C_NULL
2121
Base.warn_once("Confirm MATLAB is installed and discoverable.")
2222
if iswindows()
@@ -28,26 +28,26 @@ mutable struct MSession
2828
end
2929
if iswindows()
3030
# hide the MATLAB command window on Windows and change to current directory
31-
ccall(eng_set_visible[], Cint, (Ptr{Void}, Cint), ep, 0)
32-
ccall(eng_eval_string[], Cint, (Ptr{Void}, Ptr{UInt8}),
31+
ccall(eng_set_visible[], Cint, (Ptr{Cvoid}, Cint), ep, 0)
32+
ccall(eng_eval_string[], Cint, (Ptr{Cvoid}, Ptr{UInt8}),
3333
ep, "try cd('$(escape_string(pwd()))'); end")
3434
end
35-
buf = Vector{UInt8}(bufsize)
35+
buf = Vector{UInt8}(undef, bufsize)
3636
if bufsize > 0
3737
bufptr = pointer(buf)
38-
ccall(eng_output_buffer[], Cint, (Ptr{Void}, Ptr{UInt8}, Cint),
38+
ccall(eng_output_buffer[], Cint, (Ptr{Cvoid}, Ptr{UInt8}, Cint),
3939
ep, bufptr, bufsize)
4040
else
4141
bufptr = convert(Ptr{UInt8}, C_NULL)
4242
end
4343

4444
self = new(ep, buf, bufptr)
45-
finalizer(self, release)
45+
@compat finalizer(release, self)
4646
return self
4747
end
4848
end
4949

50-
function unsafe_convert(::Type{Ptr{Void}}, m::MSession)
50+
function unsafe_convert(::Type{Ptr{Cvoid}}, m::MSession)
5151
ptr = m.ptr
5252
ptr == C_NULL && throw(UndefRefError())
5353
return ptr
@@ -56,15 +56,15 @@ end
5656
function release(session::MSession)
5757
ptr = session.ptr
5858
if ptr != C_NULL
59-
ccall(eng_close[], Cint, (Ptr{Void},), ptr)
59+
ccall(eng_close[], Cint, (Ptr{Cvoid},), ptr)
6060
end
6161
session.ptr = C_NULL
6262
return nothing
6363
end
6464

6565
function close(session::MSession)
6666
# close a MATLAB Engine session
67-
ret = ccall(eng_close[], Cint, (Ptr{Void},), session)
67+
ret = ccall(eng_close[], Cint, (Ptr{Cvoid},), session)
6868
ret != 0 && throw(MEngineError("failed to close MATLAB engine session (err = $ret)"))
6969
session.ptr = C_NULL
7070
return nothing
@@ -103,20 +103,20 @@ end
103103

104104
if iswindows()
105105
function show_msession(m::MSession = get_default_msession())
106-
ret = ccall(eng_set_visible[], Cint, (Ptr{Void}, Cint), m, 1)
106+
ret = ccall(eng_set_visible[], Cint, (Ptr{Cvoid}, Cint), m, 1)
107107
ret != 0 && throw(MEngineError("failed to show MATLAB engine session (err = $ret)"))
108108
return nothing
109109
end
110110

111111
function hide_msession(m::MSession = get_default_msession())
112-
ret = ccall(eng_set_visible[], Cint, (Ptr{Void}, Cint), m, 0)
112+
ret = ccall(eng_set_visible[], Cint, (Ptr{Cvoid}, Cint), m, 0)
113113
ret != 0 && throw(MEngineError("failed to hide MATLAB engine session (err = $ret)"))
114114
return nothing
115115
end
116116

117117
function get_msession_visiblity(m::MSession = get_default_msession())
118118
vis = Ref{Cint}(true)
119-
ccall(eng_get_visible[], Int, (Ptr{Void}, Ptr{Cint}), m, vis)
119+
ccall(eng_get_visible[], Int, (Ptr{Cvoid}, Ptr{Cint}), m, vis)
120120
return vis[] == 1 ? true : false
121121
end
122122
end
@@ -129,7 +129,7 @@ end
129129

130130
function eval_string(session::MSession, stmt::String)
131131
# evaluate a MATLAB statement in a given MATLAB session
132-
ret = ccall(eng_eval_string[], Cint, (Ptr{Void}, Ptr{UInt8}), session, stmt)
132+
ret = ccall(eng_eval_string[], Cint, (Ptr{Cvoid}, Ptr{UInt8}), session, stmt)
133133
ret != 0 && throw(MEngineError("invalid engine session (err = $ret)"))
134134

135135
bufptr = session.bufptr
@@ -147,7 +147,7 @@ eval_string(stmt::String) = eval_string(get_default_msession(), stmt)
147147

148148
function put_variable(session::MSession, name::Symbol, v::MxArray)
149149
# put a variable into a MATLAB engine session
150-
ret = ccall(eng_put_variable[], Cint, (Ptr{Void}, Ptr{UInt8}, Ptr{Void}), session, string(name), v)
150+
ret = ccall(eng_put_variable[], Cint, (Ptr{Cvoid}, Ptr{UInt8}, Ptr{Cvoid}), session, string(name), v)
151151
ret != 0 && throw(MEngineError("failed to put variable $(name) into MATLAB session (err = $ret)"))
152152
return nothing
153153
end
@@ -158,7 +158,7 @@ put_variable(name::Symbol, v) = put_variable(get_default_msession(), name, v)
158158

159159

160160
function get_mvariable(session::MSession, name::Symbol)
161-
pv = ccall(eng_get_variable[], Ptr{Void}, (Ptr{Void}, Ptr{UInt8}), session, string(name))
161+
pv = ccall(eng_get_variable[], Ptr{Cvoid}, (Ptr{Cvoid}, Ptr{UInt8}), session, string(name))
162162
pv == C_NULL && throw(MEngineError("failed to get variable $(name) from MATLAB session"))
163163
return MxArray(pv)
164164
end
@@ -181,7 +181,7 @@ function _mput_multi(vs::Symbol...)
181181
v = vs[1]
182182
:( MATLAB.put_variable($(Meta.quot(v)), $(v)) )
183183
else
184-
stmts = Vector{Expr}(nv)
184+
stmts = Vector{Expr}(undef, nv)
185185
for i = 1 : nv
186186
v = vs[i]
187187
stmts[i] = :( MATLAB.put_variable($(Meta.quot(v)), $(v)) )
@@ -214,7 +214,7 @@ function _mget_multi(vs::Union{Symbol, Expr}...)
214214
if nv == 1
215215
make_getvar_statement(vs[1])
216216
else
217-
stmts = Vector{Expr}(nv)
217+
stmts = Vector{Expr}(undef, nv)
218218
for i = 1:nv
219219
stmts[i] = make_getvar_statement(vs[i])
220220
end
@@ -241,8 +241,8 @@ function mxcall(session::MSession, mfun::Symbol, nout::Integer, in_args...)
241241

242242
# generate temporary variable names
243243

244-
in_arg_names = Vector{String}(nin)
245-
out_arg_names = Vector{String}(nout)
244+
in_arg_names = Vector{String}(undef, nin)
245+
out_arg_names = Vector{String}(undef, nout)
246246

247247
for i = 1:nin
248248
in_arg_names[i] = _gen_marg_name(mfun, "in", i)
@@ -290,7 +290,7 @@ function mxcall(session::MSession, mfun::Symbol, nout::Integer, in_args...)
290290
ret = if nout == 1
291291
jvalue(get_mvariable(session, Symbol(out_arg_names[1])))
292292
elseif nout >= 2
293-
results = Vector{Any}(nout)
293+
results = Vector{Any}(undef, nout)
294294
for i = 1:nout
295295
results[i] = jvalue(get_mvariable(session, Symbol(out_arg_names[i])))
296296
end

src/init.jl

Lines changed: 71 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,96 @@
11
# libraries
22

3-
const libeng = Ref{Ptr{Void}}()
4-
const libmx = Ref{Ptr{Void}}()
5-
const libmat = Ref{Ptr{Void}}()
3+
const libeng = Ref{Ptr{Cvoid}}()
4+
const libmx = Ref{Ptr{Cvoid}}()
5+
const libmat = Ref{Ptr{Cvoid}}()
66

77
# matlab engine functions
88

9-
const eng_open = Ref{Ptr{Void}}()
10-
const eng_close = Ref{Ptr{Void}}()
11-
const eng_set_visible = Ref{Ptr{Void}}()
12-
const eng_get_visible = Ref{Ptr{Void}}()
13-
const eng_output_buffer = Ref{Ptr{Void}}()
14-
const eng_eval_string = Ref{Ptr{Void}}()
15-
const eng_put_variable = Ref{Ptr{Void}}()
16-
const eng_get_variable = Ref{Ptr{Void}}()
9+
const eng_open = Ref{Ptr{Cvoid}}()
10+
const eng_close = Ref{Ptr{Cvoid}}()
11+
const eng_set_visible = Ref{Ptr{Cvoid}}()
12+
const eng_get_visible = Ref{Ptr{Cvoid}}()
13+
const eng_output_buffer = Ref{Ptr{Cvoid}}()
14+
const eng_eval_string = Ref{Ptr{Cvoid}}()
15+
const eng_put_variable = Ref{Ptr{Cvoid}}()
16+
const eng_get_variable = Ref{Ptr{Cvoid}}()
1717

1818
# mxarray functions
1919

20-
const mx_destroy_array = Ref{Ptr{Void}}()
21-
const mx_duplicate_array = Ref{Ptr{Void}}()
20+
const mx_destroy_array = Ref{Ptr{Cvoid}}()
21+
const mx_duplicate_array = Ref{Ptr{Cvoid}}()
2222

2323
# functions to access mxarray
2424

25-
const mx_free = Ref{Ptr{Void}}()
26-
27-
const mx_get_classid = Ref{Ptr{Void}}()
28-
const mx_get_m = Ref{Ptr{Void}}()
29-
const mx_get_n = Ref{Ptr{Void}}()
30-
const mx_get_nelems = Ref{Ptr{Void}}()
31-
const mx_get_ndims = Ref{Ptr{Void}}()
32-
const mx_get_elemsize = Ref{Ptr{Void}}()
33-
const mx_get_data = Ref{Ptr{Void}}()
34-
const mx_get_dims = Ref{Ptr{Void}}()
35-
const mx_get_nfields = Ref{Ptr{Void}}()
36-
const mx_get_pr = Ref{Ptr{Void}}()
37-
const mx_get_pi = Ref{Ptr{Void}}()
38-
const mx_get_ir = Ref{Ptr{Void}}()
39-
const mx_get_jc = Ref{Ptr{Void}}()
40-
41-
const mx_is_double = Ref{Ptr{Void}}()
42-
const mx_is_single = Ref{Ptr{Void}}()
43-
const mx_is_int64 = Ref{Ptr{Void}}()
44-
const mx_is_uint64 = Ref{Ptr{Void}}()
45-
const mx_is_int32 = Ref{Ptr{Void}}()
46-
const mx_is_uint32 = Ref{Ptr{Void}}()
47-
const mx_is_int16 = Ref{Ptr{Void}}()
48-
const mx_is_uint16 = Ref{Ptr{Void}}()
49-
const mx_is_int8 = Ref{Ptr{Void}}()
50-
const mx_is_uint8 = Ref{Ptr{Void}}()
51-
const mx_is_char = Ref{Ptr{Void}}()
52-
53-
const mx_is_numeric = Ref{Ptr{Void}}()
54-
const mx_is_logical = Ref{Ptr{Void}}()
55-
const mx_is_complex = Ref{Ptr{Void}}()
56-
const mx_is_sparse = Ref{Ptr{Void}}()
57-
const mx_is_empty = Ref{Ptr{Void}}()
58-
const mx_is_struct = Ref{Ptr{Void}}()
59-
const mx_is_cell = Ref{Ptr{Void}}()
25+
const mx_free = Ref{Ptr{Cvoid}}()
26+
27+
const mx_get_classid = Ref{Ptr{Cvoid}}()
28+
const mx_get_m = Ref{Ptr{Cvoid}}()
29+
const mx_get_n = Ref{Ptr{Cvoid}}()
30+
const mx_get_nelems = Ref{Ptr{Cvoid}}()
31+
const mx_get_ndims = Ref{Ptr{Cvoid}}()
32+
const mx_get_elemsize = Ref{Ptr{Cvoid}}()
33+
const mx_get_data = Ref{Ptr{Cvoid}}()
34+
const mx_get_dims = Ref{Ptr{Cvoid}}()
35+
const mx_get_nfields = Ref{Ptr{Cvoid}}()
36+
const mx_get_pr = Ref{Ptr{Cvoid}}()
37+
const mx_get_pi = Ref{Ptr{Cvoid}}()
38+
const mx_get_ir = Ref{Ptr{Cvoid}}()
39+
const mx_get_jc = Ref{Ptr{Cvoid}}()
40+
41+
const mx_is_double = Ref{Ptr{Cvoid}}()
42+
const mx_is_single = Ref{Ptr{Cvoid}}()
43+
const mx_is_int64 = Ref{Ptr{Cvoid}}()
44+
const mx_is_uint64 = Ref{Ptr{Cvoid}}()
45+
const mx_is_int32 = Ref{Ptr{Cvoid}}()
46+
const mx_is_uint32 = Ref{Ptr{Cvoid}}()
47+
const mx_is_int16 = Ref{Ptr{Cvoid}}()
48+
const mx_is_uint16 = Ref{Ptr{Cvoid}}()
49+
const mx_is_int8 = Ref{Ptr{Cvoid}}()
50+
const mx_is_uint8 = Ref{Ptr{Cvoid}}()
51+
const mx_is_char = Ref{Ptr{Cvoid}}()
52+
53+
const mx_is_numeric = Ref{Ptr{Cvoid}}()
54+
const mx_is_logical = Ref{Ptr{Cvoid}}()
55+
const mx_is_complex = Ref{Ptr{Cvoid}}()
56+
const mx_is_sparse = Ref{Ptr{Cvoid}}()
57+
const mx_is_empty = Ref{Ptr{Cvoid}}()
58+
const mx_is_struct = Ref{Ptr{Cvoid}}()
59+
const mx_is_cell = Ref{Ptr{Cvoid}}()
6060

6161
# functions to create & delete MATLAB arrays
6262

63-
const mx_create_numeric_matrix = Ref{Ptr{Void}}()
64-
const mx_create_numeric_array = Ref{Ptr{Void}}()
63+
const mx_create_numeric_matrix = Ref{Ptr{Cvoid}}()
64+
const mx_create_numeric_array = Ref{Ptr{Cvoid}}()
6565

66-
const mx_create_double_scalar = Ref{Ptr{Void}}()
67-
const mx_create_logical_scalar = Ref{Ptr{Void}}()
66+
const mx_create_double_scalar = Ref{Ptr{Cvoid}}()
67+
const mx_create_logical_scalar = Ref{Ptr{Cvoid}}()
6868

69-
const mx_create_sparse = Ref{Ptr{Void}}()
70-
const mx_create_sparse_logical = Ref{Ptr{Void}}()
69+
const mx_create_sparse = Ref{Ptr{Cvoid}}()
70+
const mx_create_sparse_logical = Ref{Ptr{Cvoid}}()
7171

72-
const mx_create_string = Ref{Ptr{Void}}()
73-
const mx_create_char_array = Ref{Ptr{Void}}()
72+
const mx_create_string = Ref{Ptr{Cvoid}}()
73+
const mx_create_char_array = Ref{Ptr{Cvoid}}()
7474

75-
const mx_create_cell_array = Ref{Ptr{Void}}()
75+
const mx_create_cell_array = Ref{Ptr{Cvoid}}()
7676

77-
const mx_create_struct_matrix = Ref{Ptr{Void}}()
78-
const mx_create_struct_array = Ref{Ptr{Void}}()
77+
const mx_create_struct_matrix = Ref{Ptr{Cvoid}}()
78+
const mx_create_struct_array = Ref{Ptr{Cvoid}}()
7979

80-
const mx_get_cell = Ref{Ptr{Void}}()
81-
const mx_set_cell = Ref{Ptr{Void}}()
80+
const mx_get_cell = Ref{Ptr{Cvoid}}()
81+
const mx_set_cell = Ref{Ptr{Cvoid}}()
8282

83-
const mx_get_field = Ref{Ptr{Void}}()
84-
const mx_set_field = Ref{Ptr{Void}}()
85-
const mx_get_field_bynum = Ref{Ptr{Void}}()
86-
const mx_get_fieldname = Ref{Ptr{Void}}()
83+
const mx_get_field = Ref{Ptr{Cvoid}}()
84+
const mx_set_field = Ref{Ptr{Cvoid}}()
85+
const mx_get_field_bynum = Ref{Ptr{Cvoid}}()
86+
const mx_get_fieldname = Ref{Ptr{Cvoid}}()
8787

88-
const mx_get_string = Ref{Ptr{Void}}()
88+
const mx_get_string = Ref{Ptr{Cvoid}}()
8989

9090
# load I/O mat functions
9191

92-
const mat_open = Ref{Ptr{Void}}()
93-
const mat_close = Ref{Ptr{Void}}()
94-
const mat_get_variable = Ref{Ptr{Void}}()
95-
const mat_put_variable = Ref{Ptr{Void}}()
96-
const mat_get_dir = Ref{Ptr{Void}}()
92+
const mat_open = Ref{Ptr{Cvoid}}()
93+
const mat_close = Ref{Ptr{Cvoid}}()
94+
const mat_get_variable = Ref{Ptr{Cvoid}}()
95+
const mat_put_variable = Ref{Ptr{Cvoid}}()
96+
const mat_get_dir = Ref{Ptr{Cvoid}}()

0 commit comments

Comments
 (0)