@@ -11,12 +11,12 @@ const default_startcmd = matlab_startcmd() * " -nosplash"
1111const default_output_buffer_size = 64 * 1024
1212
1313mutable 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
4848end
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
5656function 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
6363end
6464
6565function 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
104104if 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
122122end
129129
130130function 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
148148function 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
153153end
@@ -158,7 +158,7 @@ put_variable(name::Symbol, v) = put_variable(get_default_msession(), name, v)
158158
159159
160160function 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)
164164end
@@ -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
0 commit comments