Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- class ToCStruct a where
- withCStruct :: a -> (Ptr a -> IO b) -> IO b
- pokeCStruct :: Ptr a -> a -> IO b -> IO b
- withZeroCStruct :: (Ptr a -> IO b) -> IO b
- pokeZeroCStruct :: Ptr a -> IO b -> IO b
- cStructSize :: Int
- cStructAlignment :: Int
- class FromCStruct a where
- peekCStruct :: Ptr a -> IO a
Documentation
class ToCStruct a where Source #
A class for types which can be marshalled into a C style structure.
withCStruct :: a -> (Ptr a -> IO b) -> IO b Source #
Allocates a C type structure and all dependencies and passes it to a continuation. The space is deallocated when this continuation returns and the C type structure must not be returned out of it.
pokeCStruct :: Ptr a -> a -> IO b -> IO b Source #
Write a C type struct into some existing memory and run a continuation. The pointed to structure is not necessarily valid outside the continuation as additional allocations may have been made.
withZeroCStruct :: (Ptr a -> IO b) -> IO b Source #
Allocate space for an "empty" a
and populate any univalued
members with their value.
pokeZeroCStruct :: Ptr a -> IO b -> IO b Source #
And populate any univalued members with their value, run a function and then clean up any allocated resources.
cStructSize :: Int Source #
The size of this struct, note that this doesn't account for any extra pointed-to data
cStructAlignment :: Int Source #
The required memory alignment for this type
Instances
class FromCStruct a where Source #
A class for types which can be marshalled from a C style structure.
peekCStruct :: Ptr a -> IO a Source #
Read an a
and any other pointed to data from memory