[project @ 1999-10-10 18:38:52 by sof]
authorsof <unknown>
Sun, 10 Oct 1999 18:38:53 +0000 (18:38 +0000)
committersof <unknown>
Sun, 10 Oct 1999 18:38:53 +0000 (18:38 +0000)
Added the {index,read,write}{PrimTy}OffForeignObj ops to Foreign's
export list + upd. the docs on same a little.

ghc/docs/libraries/Foreign.sgml
ghc/lib/exts/Foreign.lhs

index 8ca16ee..05e56b3 100644 (file)
@@ -12,8 +12,10 @@ id="foreign-finalisers" name="Finalisation for foreign objects">).
 module Foreign where
 data ForeignObj  -- abstract, instance of: Eq
 
-makeForeignObj  :: Addr{-object-} -> IO ForeignObj
-writeForeignObj :: ForeignObj -> Addr{-new value-} -> IO ()
+makeForeignObj      :: Addr{-object-} -> Addr{-finaliser-} -> IO ForeignObj
+writeForeignObj     :: ForeignObj -> Addr{-new value-} -> IO ()
+mkForeignObj        :: Addr -> IO ForeignObj
+addForeignFinalizer :: ForeignObj -> IO () -> IO ()
 </verb> </tscreen>
 
 In addition to the above, the following operations for indexing via
@@ -23,6 +25,7 @@ over <tt/Addr/s:
 <tscreen><verb>
 indexCharOffForeignObj   :: ForeignObj -> Int -> Char
 indexIntOffForeignObj    :: ForeignObj -> Int -> Int
+indexWordOffForeignObj   :: ForeignObj -> Int -> Word
 indexAddrOffForeignObj   :: ForeignObj -> Int -> Addr
 indexFloatOffForeignObj  :: ForeignObj -> Int -> Float
 indexDoubleOffForeignObj :: ForeignObj -> Int -> Double
@@ -39,6 +42,7 @@ indexInt64OffForeignObj :: ForeignObj -> Int -> Int64
 -- read value out of mutable memory
 readCharOffForeignObj    :: ForeignObj -> Int -> IO Char
 readIntOffForeignObj     :: ForeignObj -> Int -> IO Int
+readWordOffForeignObj    :: ForeignObj -> Int -> IO Word
 readAddrOffForeignObj    :: ForeignObj -> Int -> IO Addr
 readFloatOffForeignObj   :: ForeignObj -> Int -> IO Float
 readDoubleOffForeignObj  :: ForeignObj -> Int -> IO Double
@@ -53,6 +57,7 @@ readInt64OffForeignObj   :: ForeignObj -> Int -> IO Int64
 
 writeCharOffForeignObj   :: ForeignObj -> Int -> Char   -> IO ()
 writeIntOffForeignObj    :: ForeignObj -> Int -> Int    -> IO ()
+writeWordOffForeignObj   :: ForeignObj -> Int -> Word   -> IO ()
 writeAddrOffForeignObj   :: ForeignObj -> Int -> Addr   -> IO ()
 writeFloatOffForeignObj  :: ForeignObj -> Int -> Float  -> IO ()
 writeDoubleOffForeignObj :: ForeignObj -> Int -> Double -> IO ()
index b15c0df..661bd8c 100644 (file)
@@ -21,6 +21,59 @@ module Foreign
        , makeStablePtr       -- :: a -> IO (StablePtr a)
        , deRefStablePtr      -- :: StablePtr a -> IO a
        , freeStablePtr       -- :: StablePtr a -> IO ()
+       
+       , indexCharOffForeignObj   -- :: ForeignObj -> Int -> Char
+
+       , indexIntOffForeignObj    -- :: ForeignObj -> Int -> Int
+       , indexInt8OffForeignObj   -- :: ForeignObj -> Int -> Int8
+       , indexInt16OffForeignObj  -- :: ForeignObj -> Int -> Int16
+       , indexInt32OffForeignObj  -- :: ForeignObj -> Int -> Int32
+       , indexInt64OffForeignObj  -- :: ForeignObj -> Int -> Int64
+
+       , indexWord8OffForeignObj   -- :: ForeignObj -> Int -> Word
+       , indexWord8OffForeignObj   -- :: ForeignObj -> Int -> Word8
+       , indexWord16OffForeignObj  -- :: ForeignObj -> Int -> Word16
+       , indexWord32OffForeignObj  -- :: ForeignObj -> Int -> Word32
+       , indexWord64OffForeignObj  -- :: ForeignObj -> Int -> Word64
+
+       , indexAddrOffForeignObj   -- :: ForeignObj -> Int -> Addr
+       , indexFloatOffForeignObj  -- :: ForeignObj -> Int -> Float
+       , indexDoubleOffForeignObj -- :: ForeignObj -> Int -> Double
+       
+       , readCharOffForeignObj    -- :: ForeignObj -> Int -> IO Char
+       , readIntOffForeignObj     -- :: ForeignObj -> Int -> IO Int
+       , readInt8OffForeignObj    -- :: ForeignObj -> Int -> IO Int8
+       , readInt16OffForeignObj   -- :: ForeignObj -> Int -> IO Int16
+       , readInt32OffForeignObj   -- :: ForeignObj -> Int -> IO Int32
+       , readInt64OffForeignObj   -- :: ForeignObj -> Int -> IO Int64
+
+       , readWordOffForeignObj    -- :: ForeignObj -> Int -> IO Word
+       , readWord8OffForeignObj   -- :: ForeignObj -> Int -> IO Word8
+       , readWord16OffForeignObj  -- :: ForeignObj -> Int -> IO Word16
+       , readWord32OffForeignObj  -- :: ForeignObj -> Int -> IO Word32
+       , readWord64OffForeignObj  -- :: ForeignObj -> Int -> IO Word64
+
+       , readAddrOffForeignObj    -- :: ForeignObj -> Int -> IO Addr
+       , readFloatOffForeignObj   -- :: ForeignObj -> Int -> IO Float
+       , readDoubleOffForeignObj  -- :: ForeignObj -> Int -> IO Double
+       
+       , writeCharOffForeignObj   -- :: ForeignObj -> Int -> Char   -> IO ()
+       , writeIntOffForeignObj    -- :: ForeignObj -> Int -> Int    -> IO ()
+       , writeInt8OffForeignObj   -- :: ForeignObj -> Int -> Int8   -> IO ()
+       , writeInt16OffForeignObj  -- :: ForeignObj -> Int -> Int16  -> IO ()
+       , writeInt32OffForeignObj  -- :: ForeignObj -> Int -> Int32  -> IO ()
+       , writeInt64OffForeignObj  -- :: ForeignObj -> Int -> Int64  -> IO ()
+
+       , writeWordOffForeignObj   -- :: ForeignObj -> Int -> Word   -> IO ()
+       , writeWord8OffForeignObj  -- :: ForeignObj -> Int -> Word8  -> IO ()
+       , writeWord16OffForeignObj -- :: ForeignObj -> Int -> Word16 -> IO ()
+       , writeWord32OffForeignObj -- :: ForeignObj -> Int -> Word32 -> IO ()
+       , writeWord64OffForeignObj -- :: ForeignObj -> Int -> Word64 -> IO ()
+
+       , writeAddrOffForeignObj   -- :: ForeignObj -> Int -> Addr   -> IO ()
+       , writeFloatOffForeignObj  -- :: ForeignObj -> Int -> Float  -> IO ()
+       , writeDoubleOffForeignObj -- :: ForeignObj -> Int -> Double -> IO ()
+
        ) where
 
 import PrelForeign hiding ( makeForeignObj )
@@ -29,7 +82,7 @@ import qualified PrelForeign as PF ( makeForeignObj )
 import PrelBase    ( Int(..), Double(..), Float(..), Char(..) )
 import PrelGHC     ( indexCharOffForeignObj#, indexIntOffForeignObj#, 
                     indexAddrOffForeignObj#, indexFloatOffForeignObj#, 
-                    indexDoubleOffForeignObj#
+                    indexDoubleOffForeignObj#, indexWordOffForeignObj#
                   )
 import PrelAddr    ( Addr(..), Word(..) )
 import PrelWeak    ( addForeignFinalizer )
@@ -94,6 +147,9 @@ indexCharOffForeignObj (ForeignObj fo#) (I# i#) = C# (indexCharOffForeignObj# fo
 indexIntOffForeignObj    :: ForeignObj -> Int -> Int
 indexIntOffForeignObj (ForeignObj fo#) (I# i#) = I# (indexIntOffForeignObj# fo# i#)
 
+indexWordOffForeignObj    :: ForeignObj -> Int -> Word
+indexWordOffForeignObj (ForeignObj fo#) (I# i#) = W# (indexWordOffForeignObj# fo# i#)
+
 indexAddrOffForeignObj   :: ForeignObj -> Int -> Addr
 indexAddrOffForeignObj (ForeignObj fo#) (I# i#) = A# (indexAddrOffForeignObj# fo# i#)