[project @ 2002-04-24 16:31:37 by simonmar]
[ghc-base.git] / Foreign / C / String.hs
index 000bd2f..6f465e5 100644 (file)
@@ -1,6 +1,6 @@
 {-# OPTIONS -fno-implicit-prelude #-}
 -----------------------------------------------------------------------------
--- 
+-- |
 -- Module      :  Foreign.C.String
 -- Copyright   :  (c) The FFI task force 2001
 -- License     :  BSD-style (see the file libraries/core/LICENSE)
@@ -9,7 +9,7 @@
 -- Stability   :  provisional
 -- Portability :  portable
 --
--- $Id: String.hs,v 1.2 2001/07/03 11:37:50 simonmar Exp $
+-- $Id: String.hs,v 1.5 2002/04/24 16:31:44 simonmar Exp $
 --
 -- Utilities for primitive marshaling
 --
@@ -40,14 +40,6 @@ module Foreign.C.String (   -- representation of strings in C
   castCharToCChar,   -- :: Char -> CChar
   castCCharToChar,   -- :: CChar -> Char
 
-  -- UnsafeCString: these might be more efficient than CStrings when
-  -- passing the string to an "unsafe" foreign import.  NOTE: this
-  -- feature might be removed in favour of a more general approach in
-  -- the future.
-  --
-  UnsafeCString,     -- abstract
-  withUnsafeCString, -- :: String -> (UnsafeCString -> IO a) -> IO a
-
   ) where
 
 import Foreign.Marshal.Array
@@ -57,8 +49,6 @@ import Foreign.Ptr
 import Data.Word
 
 #ifdef __GLASGOW_HASKELL__
-import GHC.ByteArr
-import GHC.Pack
 import GHC.List
 import GHC.Real
 import GHC.Num
@@ -164,16 +154,3 @@ castCCharToChar ch = unsafeChr (fromIntegral (fromIntegral ch :: Word8))
 
 castCharToCChar :: Char -> CChar
 castCharToCChar ch = fromIntegral (ord ch)
-
-
--- unsafe CStrings
--- ---------------
-
-withUnsafeCString :: String -> (UnsafeCString -> IO a) -> IO a
-#if __GLASGOW_HASKELL__
-newtype UnsafeCString = UnsafeCString (ByteArray Int)
-withUnsafeCString s f = f (UnsafeCString (packString s))
-#else
-newtype UnsafeCString = UnsafeCString (Ptr CChar)
-withUnsafeCString s f = withCString s (\p -> f (UnsafeCString p))
-#endif