packages feed

extism-pdk 1.0.0.0 → 1.0.0.1

raw patch · 5 files changed

+30/−44 lines, 5 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

examples/CountVowels.hs view
@@ -5,11 +5,7 @@ import Extism.PDK import Extism.PDK.JSON -data Output = Output-  { count :: Int-  }-  deriving-    (Data, Typeable)+data Output = Output {count :: Int} deriving (Data)  isVowel c =   c == 'a'
examples/Hello.hs view
@@ -1,5 +1,3 @@-{-# LANGUAGE DeriveDataTypeable #-}- module Hello where  import Data.Maybe
extism-pdk.cabal view
@@ -1,6 +1,6 @@ cabal-version:      3.0 name:               extism-pdk-version:            1.0.0.0+version:            1.0.0.1  -- A short (one-line) description of the package. synopsis: Extism Plugin Development Kit
src/Extism/PDK/Bindings.hs view
@@ -78,35 +78,28 @@   if len /= 8     then error "invalid bytestring"     else-      withForeignPtr-        fp-        ( peek . castPtr @Word8 @Word64-        )+      withForeignPtr fp $ peek . castPtr @Word8 @Word64  word64ToBS :: Word64 -> ByteString word64ToBS word =-  unsafeCreate-    8-    ( \p ->-        poke (castPtr @Word8 @Word64 p) word-    )+  unsafeCreate 8 $ \p ->+    poke (castPtr @Word8 @Word64 p) word  readLoop :: (Word64 -> IO Word8) -> (Word64 -> IO Word64) -> Word64 -> Word64 -> [ByteString] -> IO ByteString readLoop f1 f8 total index acc =   if index >= total     then return $ B.concat . Prelude.reverse $ acc-    else+    else do       let diff = total - index-       in do-            (n, x) <--              if diff >= 8-                then do-                  u <- f8 index-                  return (8, word64ToBS u)-                else do-                  b <- f1 index-                  return (1, B.singleton b)-            readLoop f1 f8 total (index + n) (x : acc)+      (n, x) <-+        if diff >= 8+          then do+            u <- f8 index+            return (8, word64ToBS u)+          else do+            b <- f1 index+            return (1, B.singleton b)+      readLoop f1 f8 total (index + n) (x : acc)  readInputBytes :: InputLength -> IO ByteString readInputBytes len =@@ -119,22 +112,21 @@ writeBytesLoop :: MemoryOffset -> MemoryOffset -> ByteString -> IO () writeBytesLoop index total src =   if index >= total-    then return ()-    else+    then pure ()+    else do       let diff = total - index-       in do-            (n, sub) <--              if diff >= 8-                then do-                  let (curr, next) = B.splitAt 8 src-                  u <- bsToWord64 curr-                  extismStoreU64 index u-                  return (8, next)-                else do-                  let u = B.head src-                  extismStoreU8 index u-                  return (1, B.tail src)-            writeBytesLoop (index + n) total sub+      (n, sub) <-+        if diff >= 8+          then do+            let (curr, next) = B.splitAt 8 src+            u <- bsToWord64 curr+            extismStoreU64 index u+            return (8, next)+          else do+            let u = B.head src+            extismStoreU8 index u+            return (1, B.tail src)+      writeBytesLoop (index + n) total sub  writeBytes :: MemoryOffset -> MemoryLength -> ByteString -> IO () writeBytes offs len =
src/extism-pdk.c view
@@ -70,6 +70,6 @@ DEFINE(log_debug, void, ExtismPointer) void extism_log_debug(ExtismPointer p) { return _log_debug(p); } DEFINE(log_warn, void, ExtismPointer)-void extism_warn_info(ExtismPointer p) { return _log_warn(p); }+void extism_log_warn(ExtismPointer p) { return _log_warn(p); } DEFINE(log_error, void, ExtismPointer) void extism_log_error(ExtismPointer p) { return _log_error(p); }