projects
/
haskell-directory.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[project @ 2005-07-22 16:25:16 by ross]
[haskell-directory.git]
/
Foreign
/
Storable.hs
diff --git
a/Foreign/Storable.hs
b/Foreign/Storable.hs
index
78e2d4f
..
cfe0524
100644
(file)
--- a/
Foreign/Storable.hs
+++ b/
Foreign/Storable.hs
@@
-1,4
+1,4
@@
-{-# OPTIONS -fno-implicit-prelude #-}
+{-# OPTIONS_GHC -fno-implicit-prelude #-}
-----------------------------------------------------------------------------
-- |
-- Module : Foreign.Storable
-----------------------------------------------------------------------------
-- |
-- Module : Foreign.Storable
@@
-37,7
+37,7
@@
import NHC.FFI (Storable(..),Ptr,FunPtr,StablePtr
import Control.Monad ( liftM )
#include "MachDeps.h"
import Control.Monad ( liftM )
#include "MachDeps.h"
-#include "config.h"
+#include "HsBaseConfig.h"
#ifdef __GLASGOW_HASKELL__
import GHC.Storable
#ifdef __GLASGOW_HASKELL__
import GHC.Storable
@@
-81,7
+81,7
@@
All marshalling between Haskell and a foreign language ultimately
boils down to translating Haskell data structures into the binary
representation of a corresponding data structure of the foreign
language and vice versa. To code this marshalling in Haskell, it is
boils down to translating Haskell data structures into the binary
representation of a corresponding data structure of the foreign
language and vice versa. To code this marshalling in Haskell, it is
-necessary to manipulate primtive data types stored in unstructured
+necessary to manipulate primitive data types stored in unstructured
memory blocks. The class 'Storable' facilitates this manipulation on
all types for which it is instantiated, which are the standard basic
types of Haskell, the fixed size @Int@ types ('Int8', 'Int16',
memory blocks. The class 'Storable' facilitates this manipulation on
all types for which it is instantiated, which are the standard basic
types of Haskell, the fixed size @Int@ types ('Int8', 'Int16',
@@
-113,7
+113,7
@@
class Storable a where
-- @0@). The following equality holds,
--
-- > peekElemOff addr idx = IOExts.fixIO $ \result ->
-- @0@). The following equality holds,
--
-- > peekElemOff addr idx = IOExts.fixIO $ \result ->
- -- > peek (addr \`plusPtr\` (idx * sizeOf result))
+ -- > peek (addr `plusPtr` (idx * sizeOf result))
--
-- Note that this is only a specification, not
-- necessarily the concrete implementation of the
--
-- Note that this is only a specification, not
-- necessarily the concrete implementation of the
@@
-124,19
+124,19
@@
class Storable a where
-- values of the same kind. The following equality holds:
--
-- > pokeElemOff addr idx x =
-- values of the same kind. The following equality holds:
--
-- > pokeElemOff addr idx x =
- -- > poke (addr \`plusPtr\` (idx * sizeOf x)) x
+ -- > poke (addr `plusPtr` (idx * sizeOf x)) x
peekByteOff :: Ptr b -> Int -> IO a
-- ^ Read a value from a memory location given by a base
-- address and offset. The following equality holds:
--
peekByteOff :: Ptr b -> Int -> IO a
-- ^ Read a value from a memory location given by a base
-- address and offset. The following equality holds:
--
- -- > peekByteOff addr off = peek (addr \`plusPtr\` off)
+ -- > peekByteOff addr off = peek (addr `plusPtr` off)
pokeByteOff :: Ptr b -> Int -> a -> IO ()
-- ^ Write a value to a memory location given by a base
-- address and offset. The following equality holds:
--
pokeByteOff :: Ptr b -> Int -> a -> IO ()
-- ^ Write a value to a memory location given by a base
-- address and offset. The following equality holds:
--
- -- > pokeByteOff addr off x = poke (addr \`plusPtr\` off) x
+ -- > pokeByteOff addr off x = poke (addr `plusPtr` off) x
peek :: Ptr a -> IO a
-- ^ Read a value from the given memory location.
peek :: Ptr a -> IO a
-- ^ Read a value from the given memory location.
@@
-192,14
+192,14
@@
instance Storable (T) where { \
STORABLE(Char,SIZEOF_INT32,ALIGNMENT_INT32,
readWideCharOffPtr,writeWideCharOffPtr)
#elif defined(__HUGS__)
STORABLE(Char,SIZEOF_INT32,ALIGNMENT_INT32,
readWideCharOffPtr,writeWideCharOffPtr)
#elif defined(__HUGS__)
-STORABLE(Char,SIZEOF_CHAR,ALIGNMENT_HSCHAR,
+STORABLE(Char,SIZEOF_HSCHAR,ALIGNMENT_HSCHAR,
readCharOffPtr,writeCharOffPtr)
#endif
STORABLE(Int,SIZEOF_HSINT,ALIGNMENT_HSINT,
readIntOffPtr,writeIntOffPtr)
readCharOffPtr,writeCharOffPtr)
#endif
STORABLE(Int,SIZEOF_HSINT,ALIGNMENT_HSINT,
readIntOffPtr,writeIntOffPtr)
-#ifdef __GLASGOW_HASKELL__
+#ifndef __NHC__
STORABLE(Word,SIZEOF_HSWORD,ALIGNMENT_HSWORD,
readWordOffPtr,writeWordOffPtr)
#endif
STORABLE(Word,SIZEOF_HSWORD,ALIGNMENT_HSWORD,
readWordOffPtr,writeWordOffPtr)
#endif