diff options
author | Sam T <pxqr.sta@gmail.com> | 2013-05-20 16:09:03 +0400 |
---|---|---|
committer | Sam T <pxqr.sta@gmail.com> | 2013-05-20 16:09:03 +0400 |
commit | 014c66a0d4c163aa8014fce1f91abfda10f050e7 (patch) | |
tree | 1a24134002ebbf2c7aafcaff0fd736b8f3f213e7 | |
parent | c31623599ee6f7fbcfc7b3a991c9a608c8c10c53 (diff) |
~ Rename field names.
-rw-r--r-- | src/Data/Bitfield/Mutable.hs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/Data/Bitfield/Mutable.hs b/src/Data/Bitfield/Mutable.hs index 80954a2f..a2f736e9 100644 --- a/src/Data/Bitfield/Mutable.hs +++ b/src/Data/Bitfield/Mutable.hs | |||
@@ -52,15 +52,15 @@ import Foreign | |||
52 | 52 | ||
53 | -- | Basically 'BitSet' is a wrapper on the 'ForeignPtr'. | 53 | -- | Basically 'BitSet' is a wrapper on the 'ForeignPtr'. |
54 | data Bitfield = Bitfield { | 54 | data Bitfield = Bitfield { |
55 | sBasePtr :: {-# UNPACK #-} !(ForeignPtr Word8) | 55 | bfBasePtr :: {-# UNPACK #-} !(ForeignPtr Word8) |
56 | , sOffset :: {-# UNPACK #-} !Int | 56 | , bfOffset :: {-# UNPACK #-} !Int |
57 | , sByteSize :: {-# UNPACK #-} !Int | 57 | , bfByteSize :: {-# UNPACK #-} !Int |
58 | , sMaxSize :: {-# UNPACK #-} !Int | 58 | , bfMaxSize :: {-# UNPACK #-} !Int |
59 | } deriving Show | 59 | } deriving Show |
60 | 60 | ||
61 | 61 | ||
62 | maxSize :: Bitfield -> Int | 62 | maxSize :: Bitfield -> Int |
63 | maxSize = sMaxSize | 63 | maxSize = bfMaxSize |
64 | 64 | ||
65 | 65 | ||
66 | create :: Int -> (Int -> Ptr Word8 -> IO a) -> IO Bitfield | 66 | create :: Int -> (Int -> Ptr Word8 -> IO a) -> IO Bitfield |
@@ -86,7 +86,7 @@ full n = create n $ \bn ptr -> | |||
86 | -- can avoid using it at all if resource is not too scarce. | 86 | -- can avoid using it at all if resource is not too scarce. |
87 | -- | 87 | -- |
88 | releaseIntSet :: Bitfield -> IO () | 88 | releaseIntSet :: Bitfield -> IO () |
89 | releaseIntSet = finalizeForeignPtr . sBasePtr | 89 | releaseIntSet = finalizeForeignPtr . bfBasePtr |
90 | 90 | ||
91 | -- | Set nth bit in the given BifField to 1. | 91 | -- | Set nth bit in the given BifField to 1. |
92 | -- | 92 | -- |
@@ -134,7 +134,7 @@ toByteString = B.copy . toByteStringUnsafe | |||
134 | -- instead. | 134 | -- instead. |
135 | -- | 135 | -- |
136 | toByteStringUnsafe :: Bitfield -> ByteString | 136 | toByteStringUnsafe :: Bitfield -> ByteString |
137 | toByteStringUnsafe = B.fromForeignPtr <$> sBasePtr <*> pure 0 <*> sByteSize | 137 | toByteStringUnsafe = B.fromForeignPtr <$> bfBasePtr <*> pure 0 <*> bfByteSize |
138 | 138 | ||
139 | 139 | ||
140 | -- | Convert a 'ByteString' to 'BitField' /without/ copying, so we can | 140 | -- | Convert a 'ByteString' to 'BitField' /without/ copying, so we can |
@@ -171,7 +171,7 @@ bitLoc i = i `mod` 8 * sizeOf (error "bitLoc" :: Word8) | |||
171 | 171 | ||
172 | withByte :: Bitfield -> Int -> (Ptr Word8 -> IO a) -> IO a | 172 | withByte :: Bitfield -> Int -> (Ptr Word8 -> IO a) -> IO a |
173 | withByte s n action = do | 173 | withByte s n action = do |
174 | let offset = sOffset s + byteLoc n | 174 | let offset = bfOffset s + byteLoc n |
175 | withForeignPtr (sBasePtr s) $ \ptr -> | 175 | withForeignPtr (bfBasePtr s) $ \ptr -> |
176 | action (ptr `advancePtr` offset) | 176 | action (ptr `advancePtr` offset) |
177 | {-# INLINE withByte #-} \ No newline at end of file | 177 | {-# INLINE withByte #-} \ No newline at end of file |