Relax sizeof conditions in structinfo

This commit is contained in:
Sasha Demin 2024-03-15 02:41:22 +01:00 committed by TEC
parent 6ac75ded73
commit df6f20fbf6
Signed by: tec
SSH Key Fingerprint: SHA256:eobz41Mnm0/iYWBvWThftS0ElEs1ftBr6jamutnXc/A
1 changed files with 6 additions and 2 deletions

View File

@ -13,14 +13,18 @@ end
function structinfo(T::Type)
map(1:fieldcount(T)) do i
if hassizeof(T) && hassizeof(fieldtype(T, i))
if hassizeof(T)
offset = fieldoffset(T, i) |> Int
size = Int(if i < fieldcount(T)
fieldoffset(T, i+1)
else
sizeof(T)
end - fieldoffset(T, i))
contentsize = sizeof(fieldtype(T, i))
contentsize = if hassizeof(fieldtype(T, i))
sizeof(fieldtype(T, i))
else
0
end
if contentsize > size # Pointer?
contentsize = 0
end