Skip to content

Improve CompositeKind handling #174

Description

@BambOoxX

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 ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions