|
28 | 28 | module MAT_v5 |
29 | 29 | using CodecZlib, HDF5, SparseArrays |
30 | 30 | import Base: read, write, close |
31 | | -import ..MAT_types: MatlabStructArray, MatlabClassObject, MatlabTable |
| 31 | +import ..MAT_types: MatlabStructArray, MatlabClassObject, MatlabTable, FunctionHandle |
32 | 32 |
|
33 | 33 | using ..MAT_subsys |
34 | 34 |
|
@@ -325,6 +325,11 @@ function read_string(f::IO, swap_bytes::Bool, dimensions::Vector{Int32}) |
325 | 325 | data |
326 | 326 | end |
327 | 327 |
|
| 328 | +function read_function_handle(f::IO, swap_bytes::Bool, subsys::Subsystem) |
| 329 | + data = read_matrix(f, swap_bytes, subsys)[2] # read_matrix returns (var_name, data) |
| 330 | + return FunctionHandle(data) |
| 331 | +end |
| 332 | + |
328 | 333 | function read_opaque(f::IO, swap_bytes::Bool, subsys::Subsystem) |
329 | 334 | type_name = String(read_element(f, swap_bytes, UInt8)) |
330 | 335 | classname = String(read_element(f, swap_bytes, UInt8)) |
@@ -375,7 +380,7 @@ function read_matrix(f::IO, swap_bytes::Bool, subsys::Subsystem) |
375 | 380 | elseif class == mxCHAR_CLASS && length(dimensions) <= 2 |
376 | 381 | data = read_string(f, swap_bytes, dimensions) |
377 | 382 | elseif class == mxFUNCTION_CLASS |
378 | | - data = read_matrix(f, swap_bytes, subsys) |
| 383 | + data = read_function_handle(f, swap_bytes, subsys) |
379 | 384 | elseif class == mxOPAQUE_CLASS |
380 | 385 | data = read_opaque(f, swap_bytes, subsys) |
381 | 386 | else |
|
0 commit comments