-- Produced by boxnd-gen; edit the generator, not this file.

module Box2D.Recording
  ( create
  , destroy
  , getData
  , getSize
  )

  where

import Foreign
import Foreign.C.Types (CInt(..))
import Box2D.Tags (Recording)

foreign import ccall unsafe "b2CreateRecording"
  c_b2CreateRecording :: CInt -> IO (Ptr Recording)

foreign import ccall unsafe "b2DestroyRecording"
  c_b2DestroyRecording :: Ptr Recording -> IO ()

foreign import ccall unsafe "b2Recording_GetData"
  c_b2Recording_GetData :: Ptr Recording -> IO (Ptr Word8)

foreign import ccall unsafe "b2Recording_GetSize"
  c_b2Recording_GetSize :: Ptr Recording -> IO CInt

{- | Create a recording buffer. The buffer grows on demand. \@p byteCapacity pre-sizes it to avoid
reallocations during a known-length session. Pass 0 for a small default.

Returns: A recording handle, freed with b2DestroyRecording

Binds @b2CreateRecording@.
-}
create
  :: Int
  -- ^ @byteCapacity@
  -> IO (Ptr Recording)
create :: Int -> IO (Ptr Recording)
create Int
a0 =
  CInt -> IO (Ptr Recording)
c_b2CreateRecording (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a0)

{- | Destroy a recording buffer and free its memory.

Binds @b2DestroyRecording@.
-}
destroy
  :: Ptr Recording
  -> IO ()
destroy :: Ptr Recording -> IO ()
destroy Ptr Recording
a0 =
  Ptr Recording -> IO ()
c_b2DestroyRecording Ptr Recording
a0

{- | Get a pointer to the recorded bytes, for saving to a file or transmitting. Valid until the
next recording call or b2DestroyRecording.

Binds @b2Recording_GetData@.
-}
getData
  :: Ptr Recording
  -> IO (Ptr Word8)
getData :: Ptr Recording -> IO (Ptr Word8)
getData Ptr Recording
a0 =
  Ptr Recording -> IO (Ptr Word8)
c_b2Recording_GetData Ptr Recording
a0

{- | Get the number of recorded bytes.

Binds @b2Recording_GetSize@.
-}
getSize
  :: Ptr Recording
  -> IO Int
getSize :: Ptr Recording -> IO Int
getSize Ptr Recording
a0 =
  CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (CInt -> Int) -> IO CInt -> IO Int
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Ptr Recording -> IO CInt
c_b2Recording_GetSize Ptr Recording
a0)