X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=Foreign%2FMarshal%2FUtils.hs;h=72f7d9b11f6b92134a3922e6793c412f1448e3fe;hb=6cc0d200c099facf4bdedf92553a9eb98fd88f0f;hp=0012fedf2c6cd3c5366bf5961055ef9e5f4ab729;hpb=aaf764b3ad8b1816d68b5f27299eac125f08e1a5;p=ghc-base.git diff --git a/Foreign/Marshal/Utils.hs b/Foreign/Marshal/Utils.hs index 0012fed..72f7d9b 100644 --- a/Foreign/Marshal/Utils.hs +++ b/Foreign/Marshal/Utils.hs @@ -44,10 +44,6 @@ module Foreign.Marshal.Utils ( -- copyBytes, -- :: Ptr a -> Ptr a -> Int -> IO () moveBytes, -- :: Ptr a -> Ptr a -> Int -> IO () - - -- ** DEPRECATED FUNCTIONS (don\'t use; they may disappear at any time) - -- - withObject -- :: Storable a => a -> (Ptr a -> IO b) -> IO b ) where import Data.Maybe @@ -87,7 +83,7 @@ new val = -- |@'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 'alloca' and 'poke'). +-- @val@ has been marshalled (the combination of 'alloca' and 'poke'). -- -- 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. @@ -99,12 +95,6 @@ with val f = res <- f ptr return res --- old DEPRECATED name (don't use; may disappear at any time) --- -withObject :: Storable a => a -> (Ptr a -> IO b) -> IO b -{-# DEPRECATED withObject "use `with' instead" #-} -withObject = with - -- marshalling of Boolean values (non-zero corresponds to 'True') -- ----------------------------- @@ -169,13 +159,15 @@ withMany withFoo (x:xs) f = withFoo x $ \x' -> -- first (destination); the copied areas may /not/ overlap -- copyBytes :: Ptr a -> Ptr a -> Int -> IO () -copyBytes dest src size = memcpy dest src (fromIntegral size) +copyBytes dest src size = do memcpy dest src (fromIntegral size) + return () --- |Copies the given number of elements from the second area (source) into the +-- |Copies the given number of bytes from the second area (source) into the -- first (destination); the copied areas /may/ overlap -- moveBytes :: Ptr a -> Ptr a -> Int -> IO () -moveBytes dest src size = memmove dest src (fromIntegral size) +moveBytes dest src size = do memmove dest src (fromIntegral size) + return () -- auxilliary routines @@ -183,5 +175,5 @@ moveBytes dest src size = memmove dest src (fromIntegral size) -- |Basic C routines needed for memory copying -- -foreign import ccall unsafe "string.h" memcpy :: Ptr a -> Ptr a -> CSize -> IO () -foreign import ccall unsafe "string.h" memmove :: Ptr a -> Ptr a -> CSize -> IO () +foreign import ccall unsafe "string.h" memcpy :: Ptr a -> Ptr a -> CSize -> IO (Ptr a) +foreign import ccall unsafe "string.h" memmove :: Ptr a -> Ptr a -> CSize -> IO (Ptr a)