Skip to content

Commit

Permalink
add dependencies, add empty test file, fix eval scope, turn on i/o re…
Browse files Browse the repository at this point in the history
…direction
  • Loading branch information
taylormcd committed Jul 15, 2019
1 parent f3ed26f commit c64e5c9
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 19 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ pathdef.m
*jldict.mat
*DS_Store
Manifest.toml
deps/build.log
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ authors = ["Taylor McDonnell <[email protected]>"]
version = "0.1.0"

[deps]
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
MATLAB = "10e44e05-a98a-55b3-a45b-ba969058deb6"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
38 changes: 19 additions & 19 deletions src/Mex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -183,17 +183,17 @@ function jl_mex(plhs::Vector{Ptr{Cvoid}}, prhs::Vector{Ptr{Cvoid}})

# TODO: manually turn stdout and stderr redirection on/off?

# # get stdout and stderr before changing them
# stdout = Base.stdout
# stderr = Base.stderr
#
# # redirect stdout and stderr to matlab terminal
# mexstdout_rd, mexstdout_wr = redirect_stdout()
# mexerrout_rd, mexerrout_wr = redirect_stderr()
#
# # start printing stdout and stderr to matlab console
# t1 = @async readloop(mexstdout_rd, 1)
# t2 = @async readloop(mexstderr_rd, 2)
# get stdout and stderr before changing them
stdout = Base.stdout
stderr = Base.stderr

# redirect stdout and stderr to matlab terminal
mexstdout_rd, mexstdout_wr = redirect_stdout()
mexerrout_rd, mexerrout_wr = redirect_stderr()

# start printing stdout and stderr to matlab console
t1 = @async readloop(mexstdout_rd, 1)
t2 = @async readloop(mexstderr_rd, 2)

jl_mex_call_depth[] += 1
try
Expand All @@ -208,13 +208,13 @@ function jl_mex(plhs::Vector{Ptr{Cvoid}}, prhs::Vector{Ptr{Cvoid}})
jl_mex_call_depth[] -= 1
end

# # stop printing stdout and stderr to matlab console
# @async Base.throwto(t1, InterruptException())
# @async Base.throwto(t2, InterruptException())
#
# # restore stdout and stderr
# redirect_stdout(stdout)
# redirect_stderr(stderr)
# stop printing stdout and stderr to matlab console
@async Base.throwto(t1, InterruptException())
@async Base.throwto(t2, InterruptException())

# restore stdout and stderr
redirect_stdout(stdout)
redirect_stderr(stderr)

# TODO: when called from the MATLAB engine, Julia will overwrite the last line
# of terminal output. fix this.
Expand Down Expand Up @@ -255,7 +255,7 @@ function jl_mex_inner(plhs::Vector{Ptr{Cvoid}}, prhs::Vector{Ptr{Cvoid}})
try

# extract function and arguments (function in first slot, arguments in remaining slots)
fun = eval(Meta.parse(MATLAB.jvalue(MATLAB.MxArray(prhs[1], false))))
fun = Core.eval(Main, Meta.parse(MATLAB.jvalue(MATLAB.MxArray(prhs[1], false))))
args = MATLAB.MxArray.(prhs[2:end], false)

# call Julia function
Expand Down
Empty file added test/runtests.jl
Empty file.

0 comments on commit c64e5c9

Please sign in to comment.