| Copyright | (c) 2026 Tushar Adhatrao |
|---|---|
| License | MIT |
| Stability | internal |
| Safe Haskell | None |
| Language | GHC2021 |
WasmEdge.Internal.FFI.Basic
Description
Direct 'foreign import' declarations for all WasmEdge basic C API functions,
via the cbits/wasmedge_hs_shims.c shim layer. All struct-by-value returns
have been converted to out-pointer style.
Do not import this module in user code.
Synopsis
- c_VersionGet :: IO CString
- c_VersionGetMajor :: IO Word32
- c_VersionGetMinor :: IO Word32
- c_VersionGetPatch :: IO Word32
- c_LogSetErrorLevel :: IO ()
- c_LogSetDebugLevel :: IO ()
- c_LogOff :: IO ()
- c_LogSetLevel :: Word32 -> IO ()
- c_LogSetCallback :: FunPtr RawLogCallbackT -> IO ()
- c_StringCreateByCString :: Ptr CString_ -> CString -> IO ()
- c_StringCreateByBuffer :: Ptr CString_ -> CString -> Word32 -> IO ()
- c_StringWrap :: Ptr CString_ -> CString -> Word32 -> IO ()
- c_StringIsEqual :: Ptr CString_ -> Ptr CString_ -> IO CBool
- c_StringCopy :: Ptr CString_ -> CString -> Word32 -> IO Word32
- c_StringDelete :: Ptr CString_ -> IO ()
- c_StringGetLength :: Ptr CString_ -> IO Word32
- c_StringGetBuf :: Ptr CString_ -> IO CString
- c_BytesCreate :: Ptr CBytes_ -> Ptr Word8 -> Word32 -> IO ()
- c_BytesWrap :: Ptr CBytes_ -> Ptr Word8 -> Word32 -> IO ()
- c_BytesDelete :: Ptr CBytes_ -> IO ()
- c_BytesGetLength :: Ptr CBytes_ -> IO Word32
- c_BytesGetBuf :: Ptr CBytes_ -> IO (Ptr Word8)
- c_Result_Success :: Ptr CResult_ -> IO ()
- c_Result_Terminate :: Ptr CResult_ -> IO ()
- c_Result_Fail :: Ptr CResult_ -> IO ()
- c_ResultOK :: Ptr CResult_ -> IO CBool
- c_ResultGen :: Ptr CResult_ -> Word32 -> Word32 -> IO ()
- c_ResultGetCode :: Ptr CResult_ -> IO Word32
- c_ResultGetCategory :: Ptr CResult_ -> IO Word32
- c_ResultGetMessage :: Ptr CResult_ -> IO CString
- type RawLogCallbackT = Ptr () -> IO ()
- mkLogCallback :: RawLogCallbackT -> IO (FunPtr RawLogCallbackT)
Version
c_VersionGet :: IO CString #
Get the version string of the WasmEdge C API (e.g., "0.18.0").
The returned pointer points to a static string — do NOT free it.
c_VersionGetMajor :: IO Word32 #
Get the major version number.
c_VersionGetMinor :: IO Word32 #
Get the minor version number.
c_VersionGetPatch :: IO Word32 #
Get the patch version number.
Logging
c_LogSetErrorLevel :: IO () #
Set the logging system to filter to error level only.
c_LogSetDebugLevel :: IO () #
Set the logging system to filter to debug level (verbose).
c_LogSetLevel :: Word32 -> IO () #
c_LogSetCallback :: FunPtr RawLogCallbackT -> IO () #
Set a custom log callback (safe: callback may call back into Haskell).
String (via shims)
c_StringCreateByCString :: Ptr CString_ -> CString -> IO () #
Create a WasmEdge_String from a NULL-terminated C string.
Caller owns the result; call c_StringDelete to free.
c_StringCreateByBuffer :: Ptr CString_ -> CString -> Word32 -> IO () #
Create a WasmEdge_String from a buffer with explicit length.
Caller owns the result; call c_StringDelete to free.
c_StringWrap :: Ptr CString_ -> CString -> Word32 -> IO () #
Wrap a buffer as a WasmEdge_String (no copy; DO NOT call c_StringDelete).
c_StringIsEqual :: Ptr CString_ -> Ptr CString_ -> IO CBool #
Compare two WasmEdge_String objects for equality.
c_StringCopy :: Ptr CString_ -> CString -> Word32 -> IO Word32 #
Copy the content of a WasmEdge_String into a buffer.
c_StringDelete :: Ptr CString_ -> IO () #
Delete (free) a WasmEdge_String created by 'c_StringCreateBy*'.
Bytes (via shims)
c_BytesCreate :: Ptr CBytes_ -> Ptr Word8 -> Word32 -> IO () #
Create a WasmEdge_Bytes from a buffer (copies the data).
Caller owns the result; call c_BytesDelete to free.
c_BytesWrap :: Ptr CBytes_ -> Ptr Word8 -> Word32 -> IO () #
Wrap a buffer as WasmEdge_Bytes (no copy; DO NOT call c_BytesDelete).
c_BytesDelete :: Ptr CBytes_ -> IO () #
Delete a WasmEdge_Bytes created by c_BytesCreate.
Result (via shims)
c_Result_Success :: Ptr CResult_ -> IO () #
Fill a CResult_ with the Success code (0x00).
c_Result_Terminate :: Ptr CResult_ -> IO () #
Fill a CResult_ with the Terminate code (0x01).
c_Result_Fail :: Ptr CResult_ -> IO () #
Fill a CResult_ with the Fail code (0x02).
c_ResultOK :: Ptr CResult_ -> IO CBool #
Check whether a CResult_ represents success (Success or Terminate).
c_ResultGen :: Ptr CResult_ -> Word32 -> Word32 -> IO () #
Generate a result with a specific error category and code.
Category is a Word32 mapping to WasmEdge_ErrCategory.
c_ResultGetMessage :: Ptr CResult_ -> IO CString #
Get the error message as a static C string (do NOT free).
Raw callback type
type RawLogCallbackT = Ptr () -> IO () #
The raw C type of a log callback:
void callback(const WasmEdge_LogMessage *msg)
We represent the message pointer as 'Ptr ()' since hsc2hs will resolve
the exact struct layout separately. Users should use the public
setLogCallback API instead of this raw import.
mkLogCallback :: RawLogCallbackT -> IO (FunPtr RawLogCallbackT) #