Maintainer | Bas van Dijk <v.dijk.bas@gmail.com> |
---|
Unsafe functions for constructing regional pointers, retrieving the native
Ptr
from a regional pointer and for lifting operations on Ptrs
to
RegionalPtrs
.
- unsafeRegionalPtr :: MonadIO pr => Ptr α -> Finalizer -> RegionT s pr (RegionalPtr α (RegionT s pr))
- wrapAlloca :: MonadControlIO pr => ((Ptr α -> IO (RegionT s pr β)) -> IO (RegionT s pr β)) -> (forall sl. LocalPtr α (LocalRegion sl s) -> RegionT (Local s) pr β) -> RegionT s pr β
- wrapAlloca2 :: MonadControlIO pr => ((γ -> Ptr α -> IO (RegionT s pr β)) -> IO (RegionT s pr β)) -> (forall sl. γ -> LocalPtr α (LocalRegion sl s) -> RegionT (Local s) pr β) -> RegionT s pr β
- wrapMalloc :: MonadControlIO pr => IO (Ptr α) -> RegionT s pr (RegionalPtr α (RegionT s pr))
- wrapPeekStringLen :: (Pointer pointer, AncestorRegion pr cr, MonadIO cr) => ((Ptr α, Int) -> IO String) -> (pointer α pr, Int) -> cr String
- wrapNewStringLen :: MonadControlIO pr => IO (Ptr α, Int) -> RegionT s pr (RegionalPtr α (RegionT s pr), Int)
- wrapWithStringLen :: MonadControlIO pr => (((Ptr α, Int) -> IO (RegionT s pr β)) -> IO (RegionT s pr β)) -> (forall sl. (LocalPtr α (LocalRegion sl s), Int) -> RegionT (Local s) pr β) -> RegionT s pr β
- unsafePtr :: Pointer pointer => pointer α r -> Ptr α
- unsafeWrap :: (MonadIO m, Pointer pointer) => (Ptr α -> IO β) -> pointer α r -> m β
- unsafeWrap2 :: (MonadIO m, Pointer pointer) => (Ptr α -> γ -> IO β) -> pointer α r -> γ -> m β
- unsafeWrap3 :: (MonadIO m, Pointer pointer) => (Ptr α -> γ -> δ -> IO β) -> pointer α r -> γ -> δ -> m β
- unsafeWrap2flp :: (MonadIO m, Pointer pointer) => (γ -> Ptr α -> IO β) -> γ -> pointer α r -> m β
Unsafely constructing regional pointers
unsafeRegionalPtr :: MonadIO pr => Ptr α -> Finalizer -> RegionT s pr (RegionalPtr α (RegionT s pr))Source
Construct a regional pointer from a native pointer and an IO
computation that
finalizes the pointer (like free ptr
) which is performed when the region
terminates.
This function is unsafe because this library can't guarantee that the
finalizer will actually finalize the pointer (suppose having return ()
as
the finalizer). You have to verify the correct finalisation yourself.
Wrapping alloca
- and malloc
-like functions
wrapAlloca :: MonadControlIO pr => ((Ptr α -> IO (RegionT s pr β)) -> IO (RegionT s pr β)) -> (forall sl. LocalPtr α (LocalRegion sl s) -> RegionT (Local s) pr β) -> RegionT s pr βSource
wrapAlloca2 :: MonadControlIO pr => ((γ -> Ptr α -> IO (RegionT s pr β)) -> IO (RegionT s pr β)) -> (forall sl. γ -> LocalPtr α (LocalRegion sl s) -> RegionT (Local s) pr β) -> RegionT s pr βSource
wrapMalloc :: MonadControlIO pr => IO (Ptr α) -> RegionT s pr (RegionalPtr α (RegionT s pr))Source
Wrapping CStringLen
operations
wrapPeekStringLen :: (Pointer pointer, AncestorRegion pr cr, MonadIO cr) => ((Ptr α, Int) -> IO String) -> (pointer α pr, Int) -> cr StringSource
wrapNewStringLen :: MonadControlIO pr => IO (Ptr α, Int) -> RegionT s pr (RegionalPtr α (RegionT s pr), Int)Source
wrapWithStringLen :: MonadControlIO pr => (((Ptr α, Int) -> IO (RegionT s pr β)) -> IO (RegionT s pr β)) -> (forall sl. (LocalPtr α (LocalRegion sl s), Int) -> RegionT (Local s) pr β) -> RegionT s pr βSource
Unsafe utility functions for lifting operations on Ptrs
to RegionalPtrs
unsafePtr :: Pointer pointer => pointer α r -> Ptr αSource
Retrieve the native pointer from a regional pointer.
This function is unsafe because it allows you to both free
the pointer
before the region terminates and use the pointer outside the region when it
is already freed.
unsafeWrap2 :: (MonadIO m, Pointer pointer) => (Ptr α -> γ -> IO β) -> pointer α r -> γ -> m βSource