packages feed

codec-libevent 0.1 → 0.1.1

raw patch · 3 files changed

+6/−20 lines, 3 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Codec.Libevent: prop_base128 :: Int -> Property
- Codec.Libevent: prop_lengthPrefixed :: Int -> Property

Files

LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) Lennart Kolmodin+Copyright (c) Adam Langley  All rights reserved. 
codec-libevent.cabal view
@@ -1,5 +1,5 @@ name:            codec-libevent-version:         0.1+version:         0.1.1 license:         BSD3 license-file:    LICENSE author:          Adam Langley <agl@imperialviolet.org>@@ -10,11 +10,10 @@ category:        Data, Parsing build-depends:   base, containers, array, bytestring>=0.9, QuickCheck>=1.1, binary-strict>=0.1, binary>=0.4.1, parsec>=2.1, regex-compat>=0.71 stability:       provisional-tested-with:     GHC == 6.8.1+tested-with:     GHC == 6.8.2 exposed-modules: Codec.Libevent, Codec.Libevent.Parse, Codec.Libevent.Generate, Codec.Libevent.Class extensions:      CPP, FlexibleContexts hs-source-dirs:  src-ghc-options:     -O2  executable:      codec-libevent-generate hs-source-dirs:  src
src/Codec/Libevent.hs view
@@ -63,8 +63,8 @@ getBase128 = f 0 0 where   f n x = do v <- getWord8              if v .&. 0x80 == 0-                then return $ x .|. (fromIntegral (v `shiftL` (7 * n)))-                else f (n + 1) $ x .|. (fromIntegral ((v .&. 0x7f) `shiftL` (7 * n)))+                then return $ x .|. ((fromIntegral v) `shiftL` (7 * n))+                else f (n + 1) $ x .|. ((fromIntegral (v .&. 0x7f)) `shiftL` (7 * n))  -- | Encode a integer in Base128 form putBase128 :: Word32 -> Put@@ -110,7 +110,7 @@        f :: Word32 -> Maybe (Word8, Word32)       f 0 = Nothing-      f n = Just ((fromIntegral $ n `shiftL` 4) .|. (fromIntegral $ n `shiftR` 4), n `shiftR` 8)+      f n = Just (((fromIntegral n) `shiftL` 4) .|. ((fromIntegral  n) `shiftR` 4), n `shiftR` 8)    putWord8 ((nibbles - 1) `shiftL` 4 .|. firstNibble)   putByteString rest@@ -136,16 +136,3 @@  decodeString :: BS.ByteString -> String decodeString = map (chr . fromIntegral) . BS.unpack---- | Properties that check that (encode . decode) is the identity function-prop_lengthPrefixed :: Int -> Property-prop_lengthPrefixed n =-  (n >= 0) ==>-  (fst $ runGet getLengthPrefixed $-    BS.concat $ BSL.toChunks $ runPut $ putLengthPrefixed $ fromIntegral n) == Right (fromIntegral n)--prop_base128 :: Int -> Property-prop_base128 n =-  (n >= 0) ==>-  (fst $ runGet getBase128 $-    BS.concat $ BSL.toChunks $ runPut $ putBase128 $ fromIntegral n) == Right (fromIntegral n)