-- GENERATED by C->Haskell Compiler, version 0.28.3 Switcheroo, 25 November 2017 (Haskell)
-- Edit the ORIGNAL .chs file instead!


{-# LINE 1 "src/Chiphunk/Low/Callback.chs" #-}
-- | Description: Collision handler definition
-- Module provides definitions for collision handlers.
module Chiphunk.Low.Callback
  ( CollisionCallback
  , CollisionHandler (..)
  , CollisionHandlerPtr
  , spaceAddCollisionHandler
  , spaceAddWildcardHandler
  , spaceAddDefaultCollisionHandler
  , modifyCollisionHandler
  , mkCallback
  , mkCallbackB
  , PostStepFunc
  , spaceAddPostStepCallback
  ) where
import qualified Foreign.C.Types as C2HSImp
import qualified Foreign.Marshal.Utils as C2HSImp
import qualified Foreign.Ptr as C2HSImp
import qualified Foreign.Storable as C2HSImp



import Control.Applicative (liftA)
import Control.Exception.Safe
import Data.Bool (bool)
import Foreign

import Chiphunk.Low.Types
{-# LINE 22 "src/Chiphunk/Low/Callback.chs" #-}




-- | Collision callback
type CollisionCallback ret = Arbiter -> Space -> DataPtr -> IO ret

-- | This collision handler processes collisions between objects of type @typeA@ and @typeB@.
-- Fill the desired collision callback functions- they are documented above. A user definable context pointer
-- @userData@ is included for your convenience. This pointer is provided as an argument in each callback function.
--
-- A collision handler is a set of 4 function callbacks for the different collision events that Chipmunk recognizes.
data CollisionHandler = CollisionHandler
  { CollisionHandler -> CollisionType
chTypeA         :: !CollisionType                   -- ^ typeA
  , CollisionHandler -> CollisionType
chTypeB         :: !CollisionType                   -- ^ typeB
  , CollisionHandler -> FunPtr (CollisionCallback CPBool)
chBeginFunc     :: !(FunPtr (CollisionCallback CPBool))
    -- ^ Two shapes just started touching for the first time this step. Return true from the callback
    -- to process the collision normally or false to cause Chipmunk to ignore the collision entirely.
    -- If you return false, the preSolve and postSolve callbacks will never be run, but you will still recieve
    -- a separate event when the shapes stop overlapping.
  , CollisionHandler -> FunPtr (CollisionCallback CPBool)
chPreSolveFunc  :: !(FunPtr (CollisionCallback CPBool))
    -- ^ Two shapes are touching during this step. Return false from the callback to make Chipmunk ignore the collision
    -- this step or true to process it normally. Additionally, you may override collision values using
    -- 'Chiphunk.Low.Arbiter.arbiterFriction', 'Chiphunk.Low.Arbiter.arbiterRestitution' or
    -- 'Chiphunk.Low.arbiterSurfaceVelocity' to provide custom friction, elasticity, or surface velocity values.
    -- See 'Arbiter' for more info.
  , CollisionHandler -> FunPtr (CollisionCallback ())
chPostSolveFunc :: !(FunPtr (CollisionCallback ()))
    -- ^ Two shapes are touching and their collision response has been processed. You can retrieve the collision
    -- impulse or kinetic energy at this time if you want to use it to calculate sound volumes or damage amounts.
    -- See 'Arbiter' for more info.
  , CollisionHandler -> FunPtr (CollisionCallback ())
chSeparateFunc  :: !(FunPtr (CollisionCallback ()))
    -- ^ Two shapes have just stopped touching for the first time this step. To ensure that begin/separate
    -- are always called in balanced pairs, it will also be called when removing a shape while its in contact
    -- with something or when deallocating the space.
  , CollisionHandler -> DataPtr
cpUserData      :: !DataPtr                         -- ^ userData
  } deriving Int -> CollisionHandler -> ShowS
[CollisionHandler] -> ShowS
CollisionHandler -> String
(Int -> CollisionHandler -> ShowS)
-> (CollisionHandler -> String)
-> ([CollisionHandler] -> ShowS)
-> Show CollisionHandler
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CollisionHandler] -> ShowS
$cshowList :: [CollisionHandler] -> ShowS
show :: CollisionHandler -> String
$cshow :: CollisionHandler -> String
showsPrec :: Int -> CollisionHandler -> ShowS
$cshowsPrec :: Int -> CollisionHandler -> ShowS
Show

instance Storable CollisionHandler where
  sizeOf :: CollisionHandler -> Int
sizeOf CollisionHandler
_ = Int
56
{-# LINE 60 "src/Chiphunk/Low/Callback.chs" #-}

  alignment _ = 8
{-# LINE 61 "src/Chiphunk/Low/Callback.chs" #-}

  poke p (CollisionHandler typA typB beginFunc preSolveFunc postSolveFunc separateFunc userData) = do
    (\ptr val -> do {C2HSImp.pokeByteOff ptr 0 (val :: C2HSImp.CULong)}) p $ fromIntegral typA
    (\ptr val -> do {C2HSImp.pokeByteOff ptr 8 (val :: C2HSImp.CULong)}) p $ fromIntegral typB
    (\ptr val -> do {C2HSImp.pokeByteOff ptr 16 (val :: (C2HSImp.FunPtr ((Arbiter) -> ((Space) -> ((DataPtr) -> (IO C2HSImp.CUChar))))))}) p beginFunc
    (\ptr val -> do {C2HSImp.pokeByteOff ptr 24 (val :: (C2HSImp.FunPtr ((Arbiter) -> ((Space) -> ((DataPtr) -> (IO C2HSImp.CUChar))))))}) p preSolveFunc
    (\ptr val -> do {C2HSImp.pokeByteOff ptr 32 (val :: (C2HSImp.FunPtr ((Arbiter) -> ((Space) -> ((DataPtr) -> (IO ()))))))}) p postSolveFunc
    (\ptr val -> do {C2HSImp.pokeByteOff ptr 40 (val :: (C2HSImp.FunPtr ((Arbiter) -> ((Space) -> ((DataPtr) -> (IO ()))))))}) p separateFunc
    (\ptr val -> do {C2HSImp.pokeByteOff ptr 48 (val :: (C2HSImp.Ptr ()))}) p userData
  peek :: Ptr CollisionHandler -> IO CollisionHandler
peek Ptr CollisionHandler
p = CollisionType
-> CollisionType
-> FunPtr (CollisionCallback CPBool)
-> FunPtr (CollisionCallback CPBool)
-> FunPtr (CollisionCallback ())
-> FunPtr (CollisionCallback ())
-> DataPtr
-> CollisionHandler
CollisionHandler (CollisionType
 -> CollisionType
 -> FunPtr (CollisionCallback CPBool)
 -> FunPtr (CollisionCallback CPBool)
 -> FunPtr (CollisionCallback ())
 -> FunPtr (CollisionCallback ())
 -> DataPtr
 -> CollisionHandler)
-> IO CollisionType
-> IO
     (CollisionType
      -> FunPtr (CollisionCallback CPBool)
      -> FunPtr (CollisionCallback CPBool)
      -> FunPtr (CollisionCallback ())
      -> FunPtr (CollisionCallback ())
      -> DataPtr
      -> CollisionHandler)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (CULong -> CollisionType
forall a b. (Integral a, Num b) => a -> b
fromIntegral (CULong -> CollisionType) -> IO CULong -> IO CollisionType
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (\Ptr CollisionHandler
ptr -> do {Ptr CollisionHandler -> Int -> IO CULong
forall a b. Storable a => Ptr b -> Int -> IO a
C2HSImp.peekByteOff Ptr CollisionHandler
ptr Int
0 :: IO C2HSImp.CULong}) Ptr CollisionHandler
p)
                            IO
  (CollisionType
   -> FunPtr (CollisionCallback CPBool)
   -> FunPtr (CollisionCallback CPBool)
   -> FunPtr (CollisionCallback ())
   -> FunPtr (CollisionCallback ())
   -> DataPtr
   -> CollisionHandler)
-> IO CollisionType
-> IO
     (FunPtr (CollisionCallback CPBool)
      -> FunPtr (CollisionCallback CPBool)
      -> FunPtr (CollisionCallback ())
      -> FunPtr (CollisionCallback ())
      -> DataPtr
      -> CollisionHandler)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (CULong -> CollisionType
forall a b. (Integral a, Num b) => a -> b
fromIntegral (CULong -> CollisionType) -> IO CULong -> IO CollisionType
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (\Ptr CollisionHandler
ptr -> do {Ptr CollisionHandler -> Int -> IO CULong
forall a b. Storable a => Ptr b -> Int -> IO a
C2HSImp.peekByteOff Ptr CollisionHandler
ptr Int
8 :: IO C2HSImp.CULong}) Ptr CollisionHandler
p)
                            IO
  (FunPtr (CollisionCallback CPBool)
   -> FunPtr (CollisionCallback CPBool)
   -> FunPtr (CollisionCallback ())
   -> FunPtr (CollisionCallback ())
   -> DataPtr
   -> CollisionHandler)
-> IO (FunPtr (CollisionCallback CPBool))
-> IO
     (FunPtr (CollisionCallback CPBool)
      -> FunPtr (CollisionCallback ())
      -> FunPtr (CollisionCallback ())
      -> DataPtr
      -> CollisionHandler)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (\Ptr CollisionHandler
ptr -> do {Ptr CollisionHandler
-> Int -> IO (FunPtr (CollisionCallback CPBool))
forall a b. Storable a => Ptr b -> Int -> IO a
C2HSImp.peekByteOff Ptr CollisionHandler
ptr Int
16 :: IO (C2HSImp.FunPtr ((Arbiter) -> ((Space) -> ((DataPtr) -> (IO C2HSImp.CUChar)))))}) Ptr CollisionHandler
p
                            IO
  (FunPtr (CollisionCallback CPBool)
   -> FunPtr (CollisionCallback ())
   -> FunPtr (CollisionCallback ())
   -> DataPtr
   -> CollisionHandler)
-> IO (FunPtr (CollisionCallback CPBool))
-> IO
     (FunPtr (CollisionCallback ())
      -> FunPtr (CollisionCallback ()) -> DataPtr -> CollisionHandler)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (\Ptr CollisionHandler
ptr -> do {Ptr CollisionHandler
-> Int -> IO (FunPtr (CollisionCallback CPBool))
forall a b. Storable a => Ptr b -> Int -> IO a
C2HSImp.peekByteOff Ptr CollisionHandler
ptr Int
24 :: IO (C2HSImp.FunPtr ((Arbiter) -> ((Space) -> ((DataPtr) -> (IO C2HSImp.CUChar)))))}) Ptr CollisionHandler
p
                            IO
  (FunPtr (CollisionCallback ())
   -> FunPtr (CollisionCallback ()) -> DataPtr -> CollisionHandler)
-> IO (FunPtr (CollisionCallback ()))
-> IO
     (FunPtr (CollisionCallback ()) -> DataPtr -> CollisionHandler)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (\Ptr CollisionHandler
ptr -> do {Ptr CollisionHandler -> Int -> IO (FunPtr (CollisionCallback ()))
forall a b. Storable a => Ptr b -> Int -> IO a
C2HSImp.peekByteOff Ptr CollisionHandler
ptr Int
32 :: IO (C2HSImp.FunPtr ((Arbiter) -> ((Space) -> ((DataPtr) -> (IO ())))))}) Ptr CollisionHandler
p
                            IO (FunPtr (CollisionCallback ()) -> DataPtr -> CollisionHandler)
-> IO (FunPtr (CollisionCallback ()))
-> IO (DataPtr -> CollisionHandler)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (\Ptr CollisionHandler
ptr -> do {Ptr CollisionHandler -> Int -> IO (FunPtr (CollisionCallback ()))
forall a b. Storable a => Ptr b -> Int -> IO a
C2HSImp.peekByteOff Ptr CollisionHandler
ptr Int
40 :: IO (C2HSImp.FunPtr ((Arbiter) -> ((Space) -> ((DataPtr) -> (IO ())))))}) Ptr CollisionHandler
p
                            IO (DataPtr -> CollisionHandler)
-> IO DataPtr -> IO CollisionHandler
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (\Ptr CollisionHandler
ptr -> do {Ptr CollisionHandler -> Int -> IO DataPtr
forall a b. Storable a => Ptr b -> Int -> IO a
C2HSImp.peekByteOff Ptr CollisionHandler
ptr Int
48 :: IO (C2HSImp.Ptr ())}) Ptr CollisionHandler
p

foreign import ccall unsafe "wrapper"
  mkCallback' :: CollisionCallback () -> IO (FunPtr (CollisionCallback ()))

-- | Make callback. Need to free afterwards.
mkCallback :: CollisionCallback () -> IO (FunPtr (CollisionCallback ()))
mkCallback :: CollisionCallback () -> IO (FunPtr (CollisionCallback ()))
mkCallback = CollisionCallback () -> IO (FunPtr (CollisionCallback ()))
mkCallback'

foreign import ccall unsafe "wrapper"
  mkCallbackB' :: CollisionCallback CPBool -> IO (FunPtr (CollisionCallback CPBool))

-- | Make callback. Need to free afterwards.
mkCallbackB :: CollisionCallback Bool -> IO (FunPtr (CollisionCallback CPBool))
mkCallbackB :: CollisionCallback Bool -> IO (FunPtr (CollisionCallback CPBool))
mkCallbackB = CollisionCallback CPBool -> IO (FunPtr (CollisionCallback CPBool))
mkCallbackB' (CollisionCallback CPBool
 -> IO (FunPtr (CollisionCallback CPBool)))
-> (CollisionCallback Bool -> CollisionCallback CPBool)
-> CollisionCallback Bool
-> IO (FunPtr (CollisionCallback CPBool))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Space -> DataPtr -> IO Bool) -> Space -> DataPtr -> IO CPBool)
-> CollisionCallback Bool -> CollisionCallback CPBool
forall (f :: * -> *) a b. Applicative f => (a -> b) -> f a -> f b
liftA (((DataPtr -> IO Bool) -> DataPtr -> IO CPBool)
-> (Space -> DataPtr -> IO Bool) -> Space -> DataPtr -> IO CPBool
forall (f :: * -> *) a b. Applicative f => (a -> b) -> f a -> f b
liftA (((DataPtr -> IO Bool) -> DataPtr -> IO CPBool)
 -> (Space -> DataPtr -> IO Bool) -> Space -> DataPtr -> IO CPBool)
-> ((DataPtr -> IO Bool) -> DataPtr -> IO CPBool)
-> (Space -> DataPtr -> IO Bool)
-> Space
-> DataPtr
-> IO CPBool
forall a b. (a -> b) -> a -> b
$ (IO Bool -> IO CPBool)
-> (DataPtr -> IO Bool) -> DataPtr -> IO CPBool
forall (f :: * -> *) a b. Applicative f => (a -> b) -> f a -> f b
liftA ((IO Bool -> IO CPBool)
 -> (DataPtr -> IO Bool) -> DataPtr -> IO CPBool)
-> (IO Bool -> IO CPBool)
-> (DataPtr -> IO Bool)
-> DataPtr
-> IO CPBool
forall a b. (a -> b) -> a -> b
$ (Bool -> CPBool) -> IO Bool -> IO CPBool
forall (f :: * -> *) a b. Applicative f => (a -> b) -> f a -> f b
liftA ((Bool -> CPBool) -> IO Bool -> IO CPBool)
-> (Bool -> CPBool) -> IO Bool -> IO CPBool
forall a b. (a -> b) -> a -> b
$ CPBool -> CPBool -> Bool -> CPBool
forall a. a -> a -> Bool -> a
bool CPBool
0 CPBool
1)

-- | Pointer to collision handler
type CollisionHandlerPtr = C2HSImp.Ptr (CollisionHandler)
{-# LINE 93 "src/Chiphunk/Low/Callback.chs" #-}


-- | Add a 'CollisionHandler' for specific collision type pair or return the existing handler for the type pair.
-- Whenever shapes with collision types (cpShape.collision_type) a and b collide,
-- this handler will be used to process the collision events. When a new collision handler is created,
-- the callbacks will all be set to builtin callbacks that perform the default behavior
-- (call the wildcard handlers, and accept all collisions).
spaceAddCollisionHandler :: (Space) -> (CollisionType) -- ^ a
 -> (CollisionType) -- ^ b
 -> IO ((CollisionHandlerPtr))
spaceAddCollisionHandler :: Space
-> CollisionType -> CollisionType -> IO (Ptr CollisionHandler)
spaceAddCollisionHandler Space
a1 CollisionType
a2 CollisionType
a3 =
  let {a1' :: Space
a1' = Space -> Space
forall a. a -> a
id Space
a1} in 
  let {a2' :: CULong
a2' = CollisionType -> CULong
forall a b. (Integral a, Num b) => a -> b
fromIntegral CollisionType
a2} in 
  let {a3' :: CULong
a3' = CollisionType -> CULong
forall a b. (Integral a, Num b) => a -> b
fromIntegral CollisionType
a3} in 
  Space -> CULong -> CULong -> IO (Ptr CollisionHandler)
spaceAddCollisionHandler'_ Space
a1' CULong
a2' CULong
a3' IO (Ptr CollisionHandler)
-> (Ptr CollisionHandler -> IO (Ptr CollisionHandler))
-> IO (Ptr CollisionHandler)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CollisionHandler
res ->
  let {res' :: Ptr CollisionHandler
res' = Ptr CollisionHandler -> Ptr CollisionHandler
forall a. a -> a
id Ptr CollisionHandler
res} in
  Ptr CollisionHandler -> IO (Ptr CollisionHandler)
forall (m :: * -> *) a. Monad m => a -> m a
return (Ptr CollisionHandler
res')

{-# LINE 104 "src/Chiphunk/Low/Callback.chs" #-}


-- | Add a wildcard collision handler for given collision type. This handler will be used any time an object
-- with this type collides with another object, regardless of its type. A good example is a projectile
-- that should be destroyed the first time it hits anything. There may be a specific collision handler
-- and two wildcard handlers. It’s up to the specific handler to decide if and when to call the wildcard handlers
-- and what to do with their return values. (See arbiterCallWildcard* below)
-- When a new wildcard handler is created, the callbacks will all be set to builtin callbacks
-- that perform the default behavior. (accept all collisions in begin and preSolve, or do nothing for postSolve
-- and separate.
spaceAddWildcardHandler :: (Space) -> (CollisionType) -- ^ type
 -> IO ((CollisionHandlerPtr))
spaceAddWildcardHandler :: Space -> CollisionType -> IO (Ptr CollisionHandler)
spaceAddWildcardHandler Space
a1 CollisionType
a2 =
  let {a1' :: Space
a1' = Space -> Space
forall a. a -> a
id Space
a1} in 
  let {a2' :: CULong
a2' = CollisionType -> CULong
forall a b. (Integral a, Num b) => a -> b
fromIntegral CollisionType
a2} in 
  Space -> CULong -> IO (Ptr CollisionHandler)
spaceAddWildcardHandler'_ Space
a1' CULong
a2' IO (Ptr CollisionHandler)
-> (Ptr CollisionHandler -> IO (Ptr CollisionHandler))
-> IO (Ptr CollisionHandler)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CollisionHandler
res ->
  let {res' :: Ptr CollisionHandler
res' = Ptr CollisionHandler -> Ptr CollisionHandler
forall a. a -> a
id Ptr CollisionHandler
res} in
  Ptr CollisionHandler -> IO (Ptr CollisionHandler)
forall (m :: * -> *) a. Monad m => a -> m a
return (Ptr CollisionHandler
res')

{-# LINE 117 "src/Chiphunk/Low/Callback.chs" #-}


-- | Return a reference to the default collision handler or that is used to process all collisions
-- that don’t have a more specific handler. The default behavior for each of the callbacks
-- is to call the wildcard handlers, ANDing their return values together if applicable.
spaceAddDefaultCollisionHandler :: (Space) -> IO ((CollisionHandlerPtr))
spaceAddDefaultCollisionHandler a1 =
  let {a1' = id a1} in 
  spaceAddDefaultCollisionHandler'_ a1' >>= \res ->
  let {res' = id res} in
  return (res')

{-# LINE 124 "src/Chiphunk/Low/Callback.chs" #-}


-- | Use this helper function to modify collision handler.
--
-- @
-- spaceAddCollisionHandler s t1 t2 >>= flip modifyColliionHandler (\ch -> pure ch {chSeparateFunc = separateCollback})
-- @
modifyCollisionHandler :: CollisionHandlerPtr -> (CollisionHandler -> IO CollisionHandler) -> IO ()
modifyCollisionHandler :: Ptr CollisionHandler
-> (CollisionHandler -> IO CollisionHandler) -> IO ()
modifyCollisionHandler Ptr CollisionHandler
chPtr CollisionHandler -> IO CollisionHandler
inner = Ptr CollisionHandler -> IO CollisionHandler
forall a. Storable a => Ptr a -> IO a
peek Ptr CollisionHandler
chPtr IO CollisionHandler
-> (CollisionHandler -> IO CollisionHandler) -> IO CollisionHandler
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= CollisionHandler -> IO CollisionHandler
inner IO CollisionHandler -> (CollisionHandler -> IO ()) -> IO ()
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Ptr CollisionHandler -> CollisionHandler -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr CollisionHandler
chPtr

-- | Function type used for postStep callbacks. @space@ is the space the callback was registered on,
-- @obj@ is the pointer value you supplied as the key, and @data@ is a user definable pointer you can use
-- to pass in as a context value.
type PostStepFunc
  = Space   -- ^ space
  -> Ptr () -- ^ obj
  -> Ptr () -- ^ data
  -> IO ()

foreign import ccall "wrapper"
  mkPostStep :: PostStepFunc -> IO (FunPtr PostStepFunc)

-- | Add @func@ to be called before 'spaceStep' returns. @key@ and @data@ will be passed to your function.
-- Only the first callback registered for any unique value of @key@ will be recorded.
--
-- It returns 'True' if the callback is scheduled and 'False' when the key has already been used.
--
-- __The behavior of adding a postStep callback from outside of a collision handler or query callback is undefined.__
spaceAddPostStepCallback :: (Space) -- ^ space
 -> (PostStepFunc) -- ^ func
 -> (Ptr ()) -- ^ key
 -> (Ptr ()) -- ^ data
 -> IO ((Bool))
spaceAddPostStepCallback :: Space -> PostStepFunc -> DataPtr -> DataPtr -> IO Bool
spaceAddPostStepCallback Space
a1 PostStepFunc
a2 DataPtr
a3 DataPtr
a4 =
  let {a1' :: Space
a1' = Space -> Space
forall a. a -> a
id Space
a1} in 
  PostStepFunc -> (FunPtr PostStepFunc -> IO Bool) -> IO Bool
forall c. PostStepFunc -> (FunPtr PostStepFunc -> IO c) -> IO c
mk PostStepFunc
a2 ((FunPtr PostStepFunc -> IO Bool) -> IO Bool)
-> (FunPtr PostStepFunc -> IO Bool) -> IO Bool
forall a b. (a -> b) -> a -> b
$ \FunPtr PostStepFunc
a2' -> 
  let {a3' :: DataPtr
a3' = DataPtr -> DataPtr
forall a. a -> a
id DataPtr
a3} in 
  let {a4' :: DataPtr
a4' = DataPtr -> DataPtr
forall a. a -> a
id DataPtr
a4} in 
  Space -> FunPtr PostStepFunc -> DataPtr -> DataPtr -> IO CPBool
spaceAddPostStepCallback'_ Space
a1' FunPtr PostStepFunc
a2' DataPtr
a3' DataPtr
a4' IO CPBool -> (CPBool -> IO Bool) -> IO Bool
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CPBool
res ->
  let {res' :: Bool
res' = CPBool -> Bool
forall a. (Eq a, Num a) => a -> Bool
C2HSImp.toBool CPBool
res} in
  Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return (Bool
res')

{-# LINE 157 "src/Chiphunk/Low/Callback.chs" #-}

  where
    mk f = mkPostStep f `bracket` freeHaskellFunPtr

foreign import ccall unsafe "Chiphunk/Low/Callback.chs.h cpSpaceAddCollisionHandler"
  spaceAddCollisionHandler'_ :: ((Space) -> (C2HSImp.CULong -> (C2HSImp.CULong -> (IO (CollisionHandlerPtr)))))

foreign import ccall unsafe "Chiphunk/Low/Callback.chs.h cpSpaceAddWildcardHandler"
  spaceAddWildcardHandler'_ :: ((Space) -> (C2HSImp.CULong -> (IO (CollisionHandlerPtr))))

foreign import ccall unsafe "Chiphunk/Low/Callback.chs.h cpSpaceAddDefaultCollisionHandler"
  spaceAddDefaultCollisionHandler'_ :: ((Space) -> (IO (CollisionHandlerPtr)))

foreign import ccall unsafe "Chiphunk/Low/Callback.chs.h cpSpaceAddPostStepCallback"
  spaceAddPostStepCallback'_ :: ((Space) -> ((C2HSImp.FunPtr ((Space) -> ((C2HSImp.Ptr ()) -> ((C2HSImp.Ptr ()) -> (IO ()))))) -> ((C2HSImp.Ptr ()) -> ((C2HSImp.Ptr ()) -> (IO C2HSImp.CUChar)))))