|Copyright||(c) The FFI task force 2001|
|License||BSD-style (see the file libraries/base/LICENSE)|
Utilities for primitive marshaling
with :: Storable a => a -> (Ptr a -> IO b) -> IO b Source
with val f executes the computation
f, passing as argument a pointer to a temporarily allocated block of memory into which
val has been marshalled (the combination of
The memory is freed when
f terminates (either normally or via an exception), so the pointer passed to
f must not be used after this.
new :: Storable a => a -> IO (Ptr a) Source
Allocate a block of memory and marshal a value into it (the combination of
poke). The size of the area allocated is determined by the
sizeOf method from the instance of
Storable for the appropriate type.
The memory may be deallocated using
finalizerFree when no longer required.
fromBool :: Num a => Bool -> a Source
Convert a Haskell
Bool to its numeric representation
toBool :: (Eq a, Num a) => a -> Bool Source
Convert a Boolean in numeric representation to a Haskell value
maybeNew :: (a -> IO (Ptr b)) -> Maybe a -> IO (Ptr b) Source
Allocate storage and marshal a storable value wrapped into a
maybeWith :: (a -> (Ptr b -> IO c) -> IO c) -> Maybe a -> (Ptr b -> IO c) -> IO c Source
withXXX combinator into one marshalling a value wrapped into a
nullPtr to represent
maybePeek :: (Ptr a -> IO b) -> Ptr a -> IO (Maybe b) Source
Convert a peek combinator into a one returning
Nothing if applied to a
withMany :: (a -> (b -> res) -> res) -> [a] -> ([b] -> res) -> res Source
withXXX combinator over a list of objects, yielding a list of marshalled objects
(argument order: destination, source)
copyBytes :: Ptr a -> Ptr a -> Int -> IO () Source
Copies the given number of bytes from the second area (source) into the first (destination); the copied areas may not overlap
moveBytes :: Ptr a -> Ptr a -> Int -> IO () Source
Copies the given number of bytes from the second area (source) into the first (destination); the copied areas may overlap
fillBytes :: Ptr a -> Word8 -> Int -> IO () Source
Fill a given number of bytes in memory area with a byte value.
© The University of Glasgow and others
Licensed under a BSD-style license (see top of the page).