Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve CompositeKind handling #174

Open
BambOoxX opened this issue Apr 25, 2022 · 1 comment
Open

Improve CompositeKind handling #174

BambOoxX opened this issue Apr 25, 2022 · 1 comment

Comments

@BambOoxX
Copy link

The current behavior for CompositeKind data is

MAT.jl/src/MAT_HDF5.jl

Lines 529 to 536 in 355bd1a

# Write generic CompositeKind as a struct
function m_write(mfile::MatlabHDF5File, parent::HDF5Parent, name::String, s)
if isbits(s)
error("This is the write function for CompositeKind, but the input doesn't fit")
end
T = typeof(s)
m_write(mfile, parent, name, check_struct_keys([string(x) for x in fieldnames(T)]), [getfield(s, x) for x in fieldnames(T)])
end

however, there are issues with the isbits(s) test, reported in #162,#143 or with simple user types such as

struct MyType
    field1::Int64
    field2::Int64
end

While these types are clearly isbitstypes, I do not see a reason to not allow their conversion the equivalent matlab struct.
Given

m_write(mfile, parent, name, check_struct_keys([string(x) for x in fieldnames(T)]), [getfield(s, x) for x in fieldnames(T)])

The requirement seems more to be that fieldcount(T) > 0, regardless of the actual bits type.

Can someone confirm this ?

@BambOoxX
Copy link
Author

Bump ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant