Skip to content

Commit 767af06

Browse files
committed
Explicit about Array size
1 parent 8fc25ad commit 767af06

File tree

3 files changed

+16
-17
lines changed

3 files changed

+16
-17
lines changed

src/engine.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type MSession
2121
# hide the MATLAB command window on Windows
2222
is_windows() && ccall(eng_set_visible[], Cint, (Ptr{Void}, Cint), ep, 0)
2323

24-
buf = Array{UInt8}(bufsize)
24+
buf = Vector{UInt8}(bufsize)
2525
if bufsize > 0
2626
bufptr = pointer(buf)
2727
ccall(eng_output_buffer[], Cint, (Ptr{Void}, Ptr{UInt8}, Cint),
@@ -163,7 +163,7 @@ function _mput_multi(vs::Symbol...)
163163
v = vs[1]
164164
:( MATLAB.put_variable($(Meta.quot(v)), $(v)) )
165165
else
166-
stmts = Array{Expr}(nv)
166+
stmts = Vector{Expr}(nv)
167167
for i = 1 : nv
168168
v = vs[i]
169169
stmts[i] = :( MATLAB.put_variable($(Meta.quot(v)), $(v)) )
@@ -196,7 +196,7 @@ function _mget_multi(vs::Union{Symbol, Expr}...)
196196
if nv == 1
197197
make_getvar_statement(vs[1])
198198
else
199-
stmts = Array{Expr}(nv)
199+
stmts = Vector{Expr}(nv)
200200
for i = 1:nv
201201
stmts[i] = make_getvar_statement(vs[i])
202202
end
@@ -227,8 +227,8 @@ function mxcall(session::MSession, mfun::Symbol, nout::Integer, in_args...)
227227

228228
# generate temporary variable names
229229

230-
in_arg_names = Array{String}(nin)
231-
out_arg_names = Array{String}(nout)
230+
in_arg_names = Vector{String}(nin)
231+
out_arg_names = Vector{String}(nout)
232232

233233
for i = 1:nin
234234
in_arg_names[i] = _gen_marg_name(mfun, "in", i)
@@ -276,8 +276,8 @@ function mxcall(session::MSession, mfun::Symbol, nout::Integer, in_args...)
276276
ret = if nout == 1
277277
jvalue(get_mvariable(session, Symbol(out_arg_names[1])))
278278
elseif nout >= 2
279-
results = Array{Any}(nout)
280-
for i = 1 : nout
279+
results = Vector{Any}(nout)
280+
for i = 1:nout
281281
results[i] = jvalue(get_mvariable(session, Symbol(out_arg_names[i])))
282282
end
283283
tuple(results...)

src/mxarray.jl

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ function size(mx::MxArray)
183183
nd = ndims(mx)
184184
pdims::Ptr{mwSize} = @mxget_attr(mx_get_dims[], Ptr{mwSize}, mx)
185185
_dims = unsafe_wrap(Array, pdims, (nd,))
186-
dims = Array{Int}(nd)
186+
dims = Vector{Int}(nd)
187187
for i = 1:nd
188188
dims[i] = convert(Int, _dims[i])
189189
end
@@ -216,7 +216,7 @@ end
216216

217217
function _dims_to_mwSize(dims::Tuple{Vararg{Int}})
218218
ndim = length(dims)
219-
_dims = Array{mwSize}(ndim)
219+
_dims = Vector{mwSize}(ndim)
220220
for i = 1:ndim
221221
_dims[i] = convert(mwSize, dims[i])
222222
end
@@ -227,7 +227,6 @@ function mxarray{T<:MxNum}(ty::Type{T}, dims::Tuple{Vararg{Int}})
227227
pm = ccall(mx_create_numeric_array[], Ptr{Void},
228228
(mwSize, Ptr{mwSize}, mxClassID, mxComplexity),
229229
length(dims), _dims_to_mwSize(dims), mxclassid(ty), mxcomplexflag(ty))
230-
231230
MxArray(pm)
232231
end
233232
mxarray{T<:MxNum}(ty::Type{T}, dims::Int...) = mxarray(ty, dims)
@@ -382,7 +381,7 @@ mxarray(a::Array) = mxcellarray(a)
382381

383382
function _fieldname_array(fieldnames::String...)
384383
n = length(fieldnames)
385-
a = Array{Ptr{UInt8}}(n)
384+
a = Vector{Ptr{UInt8}}(n)
386385
for i = 1:n
387386
a[i] = unsafe_convert(Ptr{UInt8}, fieldnames[i])
388387
end
@@ -437,7 +436,7 @@ typealias Pairs Union{Pair,NTuple{2}}
437436

438437
function mxstruct(pairs::Pairs...)
439438
nf = length(pairs)
440-
fieldnames = Array{String}(nf)
439+
fieldnames = Vector{String}(nf)
441440
for i = 1:nf
442441
fn = pairs[i][1]
443442
fieldnames[i] = string(fn)
@@ -546,8 +545,8 @@ function _jsparse{T<:MxRealNum}(ty::Type{T}, mx::MxArray)
546545
jc_a::Vector{mwIndex} = unsafe_wrap(Array, jc_ptr, (n+1,))
547546
nnz = jc_a[n+1]
548547

549-
ir = Array{Int}(nnz)
550-
jc = Array{Int}(n+1)
548+
ir = Vector{Int}(nnz)
549+
jc = Vector{Int}(n+1)
551550

552551
ir_x = unsafe_wrap(Array, ir_ptr, (nnz,))
553552
for i = 1:nnz
@@ -582,8 +581,8 @@ function Dict(mx::MxArray)
582581
throw(ArgumentError("Dict(mx::MxArray) only applies to a single struct"))
583582
end
584583
nf = mxnfields(mx)
585-
fnames = Array{String}(nf)
586-
fvals = Array{Any}(nf)
584+
fnames = Vector{String}(nf)
585+
fvals = Vector{Any}(nf)
587586
for i = 1:nf
588587
fnames[i] = get_fieldname(mx, i)
589588
pv = ccall(mx_get_field_bynum[], Ptr{Void}, (Ptr{Void}, mwIndex, Cint), mx, 0, i-1)

test/mxarray.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ a = rand(3, 4, 5)
342342
x = mxarray(a)
343343
y = jvalue(x)
344344
delete(x)
345-
@test isa(y, Array{Float64, 3})
345+
@test isa(y, Array{Float64,3})
346346
@test isequal(y, a)
347347

348348
a = "MATLAB"

0 commit comments

Comments
 (0)