Skip to content

Commit

Permalink
Recognise but skip bitfields for now
Browse files Browse the repository at this point in the history
  • Loading branch information
phadej committed Jan 16, 2025
1 parent 695f231 commit ad0f3ca
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions hs-bindgen/src/HsBindgen/C/Fold/Type.hs
Original file line number Diff line number Diff line change
Expand Up @@ -413,13 +413,21 @@ mkStructField relPath unit path current = do
return (fieldName, fieldType, False)

fieldOffset <- fromIntegral <$> liftIO (clang_Cursor_getOffsetOfField current)
unless (fieldOffset `mod` 8 == 0) $ fail "bit-fields not supported yet"


if isIncompleteArray
then do
return $ Just $ Left StructField{fieldName, fieldOffset, fieldType, fieldSourceLoc}
else do
return $ Just $ Right StructField{fieldName, fieldOffset, fieldType, fieldSourceLoc}
isBitField <- liftIO $ clang_Cursor_isBitField current
if isBitField
then do
width <- liftIO $ clang_getFieldDeclBitWidth current
dtraceIO "bitfield" (fieldOffset, width)
return Nothing
else do
assertEff (fieldOffset `mod` 8 == 0) "offset should be divisible by 8"
return $ Just $ Right StructField{fieldName, fieldOffset, fieldType, fieldSourceLoc}

-- inner structs, there are two approaches:
-- * process eagerly
Expand Down

0 comments on commit ad0f3ca

Please sign in to comment.