Maintainer | Bas van Dijk <v.dijk.bas@gmail.com> |
---|
- with :: (Storable α, MonadCatchIO pr) => α -> (forall s. RegionalPtr α (RegionT s pr) -> RegionT s pr β) -> pr β
- new :: (Storable α, MonadCatchIO pr) => α -> RegionT s pr (RegionalPtr α (RegionT s pr))
- fromBool :: Num a => Bool -> a
- toBool :: Num a => a -> Bool
- copyBytes :: (ParentOf pr1 cr, ParentOf pr2 cr, MonadIO cr) => RegionalPtr α pr1 -> RegionalPtr α pr2 -> Int -> cr ()
- moveBytes :: (ParentOf pr1 cr, ParentOf pr2 cr, MonadIO cr) => RegionalPtr α pr1 -> RegionalPtr α pr2 -> Int -> cr ()
General marshalling utilities
Combined allocation and marshalling
with :: (Storable α, MonadCatchIO pr) => α -> (forall s. RegionalPtr α (RegionT s pr) -> RegionT s pr β) -> pr βSource
executes the computation with
val ff
, passing as argument a regional
pointer to a temporarily allocated block of memory into which val
has been
marshalled (the combination of alloca
and poke
).
The memory is freed when f
terminates (either normally or via an
exception).
This provides a safer replacement for Foreign.Marshal.Utils.
.
with
new :: (Storable α, MonadCatchIO pr) => α -> RegionT s pr (RegionalPtr α (RegionT s pr))Source
Marshalling of Boolean values (non-zero corresponds to True
)
Marshalling of Maybe values
TODO: Define and export: maybeNew
, maybeWith
and maybePeek
.
Marshalling lists of storable objects
TODO: Define and export: withMany
.
Haskellish interface to memcpy and memmove
(argument order: destination, source)
:: (ParentOf pr1 cr, ParentOf pr2 cr, MonadIO cr) | |
=> RegionalPtr α pr1 | Destination |
-> RegionalPtr α pr2 | Source |
-> Int | Number of bytes to copy |
-> cr () |
Copies the given number of bytes from the second area (source) into the first (destination); the copied areas may not overlap
Wraps: Foreign.Marshal.Utils.
.
copyBytes
:: (ParentOf pr1 cr, ParentOf pr2 cr, MonadIO cr) | |
=> RegionalPtr α pr1 | Destination |
-> RegionalPtr α pr2 | Source |
-> Int | Number of bytes to move |
-> cr () |
Copies the given number of bytes from the second area (source) into the first (destination); the copied areas may overlap
Wraps: Foreign.Marshal.Utils.
.
moveBytes