sdl3-bindgen-sys-0.0.0.1: runtime/HsBindgen/Runtime/Support/CAPI.hs
{-# OPTIONS_HADDOCK hide #-}
-- We capitalize module names, but use camelCase/PascalCase in code:
--
-- - in types names: CapiFoo, FooCapiBar
-- - in variable names: capiFoo, fooCapiBar
module HsBindgen.Runtime.Support.CAPI (
addCSource,
allocaAndPeek,
-- * Auxiliary
Data.List.unlines,
) where
import Data.List qualified
import Foreign (Ptr, Storable, alloca, peek)
import Language.Haskell.TH (DecsQ)
import Language.Haskell.TH.Syntax (ForeignSrcLang (LangC), addForeignSource)
addCSource :: String -> DecsQ
addCSource src = do
addForeignSource LangC src
return []
allocaAndPeek :: (Storable a) => (Ptr a -> IO ()) -> IO a
allocaAndPeek k = alloca $ \ptr -> k ptr >> peek ptr