packages feed

hsrs 0.1.0.0 → 0.1.2.0

raw patch · 2 files changed

+12/−9 lines, 2 filesdep +generics-sop

Dependencies added: generics-sop

Files

hsrs.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name:          hsrs-version:       0.1.0.0+version:       0.1.2.0 synopsis:      Runtime support for hsrs-generated Haskell FFI bindings description:   Provides the Haskell-side runtime needed by code generated@@ -27,11 +27,13 @@  library   exposed-modules: Hsrs.Runtime+  reexported-modules: Generics.SOP   build-depends:-      base        >= 4.16 && < 5-    , borsh       >= 0.3  && < 0.4-    , bytestring  >= 0.11 && < 0.13-    , text        >= 2.0  && < 2.3+      base         >= 4.16 && < 5+    , borsh        >= 0.3  && < 0.4+    , bytestring   >= 0.11 && < 0.13+    , generics-sop >= 0.5  && < 0.6+    , text         >= 2.0  && < 2.3   hs-source-dirs: src   default-language: Haskell2010   ghc-options: -Wall
src/Hsrs/Runtime.hs view
@@ -10,17 +10,18 @@   , BorshSize   , ToBorsh   , FromBorsh-  , AsStruct+  , AsStruct(..)   , serialiseBorsh   , deserialiseBorsh     -- * Re-exports for generated code   , Text   ) where -import Codec.Borsh (AsStruct, BorshSize, FromBorsh, ToBorsh, deserialiseBorsh, serialiseBorsh)+import Codec.Borsh (AsStruct(..), BorshSize, FromBorsh, ToBorsh, deserialiseBorsh, serialiseBorsh) import Control.Exception (Exception, throwIO) import Data.Text (Text) import Data.ByteString (packCStringLen, useAsCStringLen)+import qualified Data.ByteString.Lazy as LBS import Data.Word (Word8, Word64) import Foreign (FinalizerPtr, Ptr, castPtr, newForeignPtr, withForeignPtr) @@ -42,11 +43,11 @@     len <- c_hsrsBorshLen p     dataPtr <- c_hsrsBorshPtr p     bs <- packCStringLen (castPtr dataPtr, fromIntegral len)-    case deserialiseBorsh bs of+    case deserialiseBorsh (LBS.fromStrict bs) of       Left err -> throwIO (HsrsDeserialiseError (show err))       Right val -> pure val  withBorshArg :: ToBorsh a => a -> (Ptr Word8 -> Word64 -> IO b) -> IO b withBorshArg val f =-  useAsCStringLen (serialiseBorsh val) $ \(ptr, len) ->+  useAsCStringLen (LBS.toStrict (serialiseBorsh val)) $ \(ptr, len) ->     f (castPtr ptr) (fromIntegral len)