Safe Haskell | None |
---|---|
Language | Haskell2010 |
Extism.HostFunction
Synopsis
- data CurrentPlugin = CurrentPlugin (Ptr ExtismCurrentPlugin) [Val] (Ptr Val) Int
- data ValType
- data Val
- data MemoryHandle
- data Function
- memoryAlloc :: CurrentPlugin -> Word64 -> IO MemoryHandle
- memoryLength :: CurrentPlugin -> MemoryHandle -> IO Word64
- memoryFree :: CurrentPlugin -> MemoryHandle -> IO ()
- memory :: CurrentPlugin -> IO (Ptr Word8)
- memoryOffset :: CurrentPlugin -> MemoryHandle -> IO (Ptr Word8)
- memoryBytes :: CurrentPlugin -> MemoryHandle -> IO ByteString
- memoryString :: CurrentPlugin -> MemoryHandle -> IO String
- memoryGet :: FromBytes a => CurrentPlugin -> MemoryHandle -> IO (Result a)
- allocBytes :: CurrentPlugin -> ByteString -> IO MemoryHandle
- allocString :: CurrentPlugin -> String -> IO MemoryHandle
- alloc :: ToBytes a => CurrentPlugin -> a -> IO MemoryHandle
- toI32 :: Integral a => a -> Val
- toI64 :: Integral a => a -> Val
- toF32 :: Float -> Val
- toF64 :: Double -> Val
- fromI32 :: Integral a => Val -> Maybe a
- fromI64 :: Integral a => Val -> Maybe a
- fromF32 :: Val -> Maybe Float
- fromF64 :: Val -> Maybe Double
- hostFunction :: String -> [ValType] -> [ValType] -> (CurrentPlugin -> a -> IO ()) -> a -> IO Function
- hostFunction' :: String -> String -> [ValType] -> [ValType] -> (CurrentPlugin -> a -> IO ()) -> a -> IO Function
- newFunction :: String -> [ValType] -> [ValType] -> a -> (CurrentPlugin -> a -> IO ()) -> IO Function
- newFunction' :: String -> String -> [ValType] -> [ValType] -> a -> (CurrentPlugin -> a -> IO ()) -> IO Function
- input :: FromBytes a => CurrentPlugin -> Int -> IO (Result a)
- output :: ToBytes a => CurrentPlugin -> Int -> a -> IO ()
- getParams :: CurrentPlugin -> [Val]
- setResults :: CurrentPlugin -> [Val] -> IO ()
- hostContext :: CurrentPlugin -> IO (Maybe a)
- ptr :: ValType
Documentation
data CurrentPlugin Source #
Access the plugin that is currently executing from inside a host function
Low-level Wasm types
Instances
Storable ValType Source # | |
Show ValType Source # | |
Eq ValType Source # | |
Low-level Wasm values
data MemoryHandle Source #
A memory handle represents an allocated block of Extism memory
Instances
Host function, see hostFunction
memoryAlloc :: CurrentPlugin -> Word64 -> IO MemoryHandle Source #
Allocate a new handle of the given size
memoryLength :: CurrentPlugin -> MemoryHandle -> IO Word64 Source #
Get the length of a handle, returns 0 if the handle is invalid
memoryFree :: CurrentPlugin -> MemoryHandle -> IO () Source #
Free allocated memory
memoryOffset :: CurrentPlugin -> MemoryHandle -> IO (Ptr Word8) Source #
Access the pointer for the given MemoryHandle
memoryBytes :: CurrentPlugin -> MemoryHandle -> IO ByteString Source #
Access the data associated with a handle as a ByteString
memoryString :: CurrentPlugin -> MemoryHandle -> IO String Source #
Access the data associated with a handle as a String
memoryGet :: FromBytes a => CurrentPlugin -> MemoryHandle -> IO (Result a) Source #
Access the data associated with a handle and convert it into a Haskell type
allocBytes :: CurrentPlugin -> ByteString -> IO MemoryHandle Source #
Allocate memory and copy an existing ByteString
into it
allocString :: CurrentPlugin -> String -> IO MemoryHandle Source #
Allocate memory and copy an existing String
into it
alloc :: ToBytes a => CurrentPlugin -> a -> IO MemoryHandle Source #
hostFunction :: String -> [ValType] -> [ValType] -> (CurrentPlugin -> a -> IO ()) -> a -> IO Function Source #
hostFunction' :: String -> String -> [ValType] -> [ValType] -> (CurrentPlugin -> a -> IO ()) -> a -> IO Function Source #
newFunction :: String -> [ValType] -> [ValType] -> a -> (CurrentPlugin -> a -> IO ()) -> IO Function Source #
newFunction' :: String -> String -> [ValType] -> [ValType] -> a -> (CurrentPlugin -> a -> IO ()) -> IO Function Source #
getParams :: CurrentPlugin -> [Val] Source #
setResults :: CurrentPlugin -> [Val] -> IO () Source #
hostContext :: CurrentPlugin -> IO (Maybe a) Source #