{-# language CPP #-}
module OpenXR.Core10.Space ( destroySpace
, enumerateReferenceSpaces
, createReferenceSpace
, withReferenceSpace
, createActionSpace
, withActionSpace
, locateSpace
, getReferenceSpaceBoundsRect
, Vector3f(..)
, Quaternionf(..)
, Posef(..)
, ReferenceSpaceCreateInfo(..)
, ActionSpaceCreateInfo(..)
, SpaceLocation(..)
, SpaceVelocity(..)
) where
import OpenXR.Internal.Utils (traceAroundEvent)
import Control.Exception.Base (bracket)
import Control.Monad (unless)
import Control.Monad.IO.Class (liftIO)
import Data.Typeable (eqT)
import Foreign.Marshal.Alloc (allocaBytesAligned)
import Foreign.Marshal.Alloc (callocBytes)
import Foreign.Marshal.Alloc (free)
import GHC.Base (when)
import GHC.IO (throwIO)
import GHC.Ptr (castPtr)
import GHC.Ptr (nullFunPtr)
import Foreign.Ptr (nullPtr)
import Foreign.Ptr (plusPtr)
import Data.Coerce (coerce)
import Control.Monad.Trans.Class (lift)
import Control.Monad.Trans.Cont (evalContT)
import Data.Vector (generateM)
import OpenXR.CStruct (FromCStruct)
import OpenXR.CStruct (FromCStruct(..))
import OpenXR.CStruct (ToCStruct)
import OpenXR.CStruct (ToCStruct(..))
import OpenXR.Zero (Zero(..))
import Control.Monad.IO.Class (MonadIO)
import Data.Type.Equality ((:~:)(Refl))
import Data.Typeable (Typeable)
import Foreign.C.Types (CFloat)
import Foreign.C.Types (CFloat(..))
import Foreign.C.Types (CFloat(CFloat))
import Foreign.Storable (Storable)
import Foreign.Storable (Storable(peek))
import Foreign.Storable (Storable(poke))
import qualified Foreign.Storable (Storable(..))
import GHC.Generics (Generic)
import GHC.IO.Exception (IOErrorType(..))
import GHC.IO.Exception (IOException(..))
import Foreign.Ptr (FunPtr)
import Foreign.Ptr (Ptr)
import Data.Word (Word32)
import Data.Kind (Type)
import Control.Monad.Trans.Cont (ContT(..))
import Data.Vector (Vector)
import OpenXR.CStruct.Utils (advancePtrBytes)
import OpenXR.CStruct.Extends (forgetExtensions)
import OpenXR.NamedType ((:::))
import OpenXR.Core10.Handles (Action_T)
import OpenXR.CStruct.Extends (Chain)
import OpenXR.CStruct.Extends (Extends)
import OpenXR.CStruct.Extends (Extendss)
import OpenXR.CStruct.Extends (Extensible(..))
import OpenXR.Core10.FundamentalTypes (Extent2Df)
import {-# SOURCE #-} OpenXR.Extensions.XR_EXT_eye_gaze_interaction (EyeGazeSampleTimeEXT)
import OpenXR.Dynamic (InstanceCmds(pXrCreateActionSpace))
import OpenXR.Dynamic (InstanceCmds(pXrCreateReferenceSpace))
import OpenXR.Dynamic (InstanceCmds(pXrDestroySpace))
import OpenXR.Dynamic (InstanceCmds(pXrEnumerateReferenceSpaces))
import OpenXR.Dynamic (InstanceCmds(pXrGetReferenceSpaceBoundsRect))
import OpenXR.Dynamic (InstanceCmds(pXrLocateSpace))
import OpenXR.Exception (OpenXrException(..))
import OpenXR.Core10.SemanticPaths (Path)
import OpenXR.CStruct.Extends (PeekChain)
import OpenXR.CStruct.Extends (PeekChain(..))
import OpenXR.CStruct.Extends (PokeChain)
import OpenXR.CStruct.Extends (PokeChain(..))
import OpenXR.Core10.Enums.ReferenceSpaceType (ReferenceSpaceType)
import OpenXR.Core10.Enums.ReferenceSpaceType (ReferenceSpaceType(..))
import OpenXR.Core10.Enums.Result (Result)
import OpenXR.Core10.Enums.Result (Result(..))
import OpenXR.Core10.Handles (Session)
import OpenXR.Core10.Handles (Session(..))
import OpenXR.Core10.Handles (Session_T)
import OpenXR.CStruct.Extends (SomeStruct)
import OpenXR.Core10.Handles (Space)
import OpenXR.Core10.Handles (Space(..))
import OpenXR.Core10.Handles (Space(Space))
import OpenXR.Core10.Enums.SpaceLocationFlags (SpaceLocationFlags)
import OpenXR.Core10.Enums.SpaceVelocityFlags (SpaceVelocityFlags)
import OpenXR.Core10.Handles (Space_T)
import OpenXR.Core10.Enums.StructureType (StructureType)
import OpenXR.Core10.FundamentalTypes (Time)
import OpenXR.Core10.Enums.Result (Result(SUCCESS))
import OpenXR.Core10.Enums.StructureType (StructureType(TYPE_ACTION_SPACE_CREATE_INFO))
import OpenXR.Core10.Enums.StructureType (StructureType(TYPE_REFERENCE_SPACE_CREATE_INFO))
import OpenXR.Core10.Enums.StructureType (StructureType(TYPE_SPACE_LOCATION))
import OpenXR.Core10.Enums.StructureType (StructureType(TYPE_SPACE_VELOCITY))
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkXrDestroySpace
:: FunPtr (Ptr Space_T -> IO Result) -> Ptr Space_T -> IO Result
destroySpace :: forall io
. (MonadIO io)
=>
Space
-> io ()
destroySpace :: Space -> io ()
destroySpace space :: Space
space = IO () -> io ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> io ()) -> IO () -> io ()
forall a b. (a -> b) -> a -> b
$ do
let xrDestroySpacePtr :: FunPtr (Ptr Space_T -> IO Result)
xrDestroySpacePtr = InstanceCmds -> FunPtr (Ptr Space_T -> IO Result)
pXrDestroySpace (Space -> InstanceCmds
instanceCmds (Space
space :: Space))
Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr (Ptr Space_T -> IO Result)
xrDestroySpacePtr FunPtr (Ptr Space_T -> IO Result)
-> FunPtr (Ptr Space_T -> IO Result) -> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr (Ptr Space_T -> IO Result)
forall a. FunPtr a
nullFunPtr) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
IOException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (IOException -> IO ()) -> IOException -> IO ()
forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError Maybe Handle
forall a. Maybe a
Nothing IOErrorType
InvalidArgument "" "The function pointer for xrDestroySpace is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
let xrDestroySpace' :: Ptr Space_T -> IO Result
xrDestroySpace' = FunPtr (Ptr Space_T -> IO Result) -> Ptr Space_T -> IO Result
mkXrDestroySpace FunPtr (Ptr Space_T -> IO Result)
xrDestroySpacePtr
Result
r <- String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent "xrDestroySpace" (Ptr Space_T -> IO Result
xrDestroySpace' (Space -> Ptr Space_T
spaceHandle (Space
space)))
Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (OpenXrException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> OpenXrException
OpenXrException Result
r))
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkXrEnumerateReferenceSpaces
:: FunPtr (Ptr Session_T -> Word32 -> Ptr Word32 -> Ptr ReferenceSpaceType -> IO Result) -> Ptr Session_T -> Word32 -> Ptr Word32 -> Ptr ReferenceSpaceType -> IO Result
enumerateReferenceSpaces :: forall io
. (MonadIO io)
=>
Session
-> io (Result, ("spaces" ::: Vector ReferenceSpaceType))
enumerateReferenceSpaces :: Session -> io (Result, "spaces" ::: Vector ReferenceSpaceType)
enumerateReferenceSpaces session :: Session
session = IO (Result, "spaces" ::: Vector ReferenceSpaceType)
-> io (Result, "spaces" ::: Vector ReferenceSpaceType)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Result, "spaces" ::: Vector ReferenceSpaceType)
-> io (Result, "spaces" ::: Vector ReferenceSpaceType))
-> (ContT
(Result, "spaces" ::: Vector ReferenceSpaceType)
IO
(Result, "spaces" ::: Vector ReferenceSpaceType)
-> IO (Result, "spaces" ::: Vector ReferenceSpaceType))
-> ContT
(Result, "spaces" ::: Vector ReferenceSpaceType)
IO
(Result, "spaces" ::: Vector ReferenceSpaceType)
-> io (Result, "spaces" ::: Vector ReferenceSpaceType)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT
(Result, "spaces" ::: Vector ReferenceSpaceType)
IO
(Result, "spaces" ::: Vector ReferenceSpaceType)
-> IO (Result, "spaces" ::: Vector ReferenceSpaceType)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT
(Result, "spaces" ::: Vector ReferenceSpaceType)
IO
(Result, "spaces" ::: Vector ReferenceSpaceType)
-> io (Result, "spaces" ::: Vector ReferenceSpaceType))
-> ContT
(Result, "spaces" ::: Vector ReferenceSpaceType)
IO
(Result, "spaces" ::: Vector ReferenceSpaceType)
-> io (Result, "spaces" ::: Vector ReferenceSpaceType)
forall a b. (a -> b) -> a -> b
$ do
let xrEnumerateReferenceSpacesPtr :: FunPtr
(Ptr Session_T
-> ("spaceCapacityInput" ::: Word32)
-> ("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32))
-> ("spaces" ::: Ptr ReferenceSpaceType)
-> IO Result)
xrEnumerateReferenceSpacesPtr = InstanceCmds
-> FunPtr
(Ptr Session_T
-> ("spaceCapacityInput" ::: Word32)
-> ("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32))
-> ("spaces" ::: Ptr ReferenceSpaceType)
-> IO Result)
pXrEnumerateReferenceSpaces (Session -> InstanceCmds
instanceCmds (Session
session :: Session))
IO ()
-> ContT (Result, "spaces" ::: Vector ReferenceSpaceType) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ()
-> ContT (Result, "spaces" ::: Vector ReferenceSpaceType) IO ())
-> IO ()
-> ContT (Result, "spaces" ::: Vector ReferenceSpaceType) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
(Ptr Session_T
-> ("spaceCapacityInput" ::: Word32)
-> ("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32))
-> ("spaces" ::: Ptr ReferenceSpaceType)
-> IO Result)
xrEnumerateReferenceSpacesPtr FunPtr
(Ptr Session_T
-> ("spaceCapacityInput" ::: Word32)
-> ("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32))
-> ("spaces" ::: Ptr ReferenceSpaceType)
-> IO Result)
-> FunPtr
(Ptr Session_T
-> ("spaceCapacityInput" ::: Word32)
-> ("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32))
-> ("spaces" ::: Ptr ReferenceSpaceType)
-> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
(Ptr Session_T
-> ("spaceCapacityInput" ::: Word32)
-> ("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32))
-> ("spaces" ::: Ptr ReferenceSpaceType)
-> IO Result)
forall a. FunPtr a
nullFunPtr) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
IOException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (IOException -> IO ()) -> IOException -> IO ()
forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError Maybe Handle
forall a. Maybe a
Nothing IOErrorType
InvalidArgument "" "The function pointer for xrEnumerateReferenceSpaces is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
let xrEnumerateReferenceSpaces' :: Ptr Session_T
-> ("spaceCapacityInput" ::: Word32)
-> ("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32))
-> ("spaces" ::: Ptr ReferenceSpaceType)
-> IO Result
xrEnumerateReferenceSpaces' = FunPtr
(Ptr Session_T
-> ("spaceCapacityInput" ::: Word32)
-> ("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32))
-> ("spaces" ::: Ptr ReferenceSpaceType)
-> IO Result)
-> Ptr Session_T
-> ("spaceCapacityInput" ::: Word32)
-> ("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32))
-> ("spaces" ::: Ptr ReferenceSpaceType)
-> IO Result
mkXrEnumerateReferenceSpaces FunPtr
(Ptr Session_T
-> ("spaceCapacityInput" ::: Word32)
-> ("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32))
-> ("spaces" ::: Ptr ReferenceSpaceType)
-> IO Result)
xrEnumerateReferenceSpacesPtr
let session' :: Ptr Session_T
session' = Session -> Ptr Session_T
sessionHandle (Session
session)
"spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32)
pSpaceCountOutput <- ((("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32))
-> IO (Result, "spaces" ::: Vector ReferenceSpaceType))
-> IO (Result, "spaces" ::: Vector ReferenceSpaceType))
-> ContT
(Result, "spaces" ::: Vector ReferenceSpaceType)
IO
("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32))
-> IO (Result, "spaces" ::: Vector ReferenceSpaceType))
-> IO (Result, "spaces" ::: Vector ReferenceSpaceType))
-> ContT
(Result, "spaces" ::: Vector ReferenceSpaceType)
IO
("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32)))
-> ((("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32))
-> IO (Result, "spaces" ::: Vector ReferenceSpaceType))
-> IO (Result, "spaces" ::: Vector ReferenceSpaceType))
-> ContT
(Result, "spaces" ::: Vector ReferenceSpaceType)
IO
("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32))
forall a b. (a -> b) -> a -> b
$ IO ("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32))
-> (("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32))
-> IO ())
-> (("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32))
-> IO (Result, "spaces" ::: Vector ReferenceSpaceType))
-> IO (Result, "spaces" ::: Vector ReferenceSpaceType)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int
-> IO
("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32))
forall a. Int -> IO (Ptr a)
callocBytes @Word32 4) ("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32))
-> IO ()
forall a. Ptr a -> IO ()
free
Result
r <- IO Result
-> ContT (Result, "spaces" ::: Vector ReferenceSpaceType) IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result
-> ContT
(Result, "spaces" ::: Vector ReferenceSpaceType) IO Result)
-> IO Result
-> ContT (Result, "spaces" ::: Vector ReferenceSpaceType) IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent "xrEnumerateReferenceSpaces" (Ptr Session_T
-> ("spaceCapacityInput" ::: Word32)
-> ("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32))
-> ("spaces" ::: Ptr ReferenceSpaceType)
-> IO Result
xrEnumerateReferenceSpaces' Ptr Session_T
session' (0) ("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32)
pSpaceCountOutput) ("spaces" ::: Ptr ReferenceSpaceType
forall a. Ptr a
nullPtr))
IO ()
-> ContT (Result, "spaces" ::: Vector ReferenceSpaceType) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ()
-> ContT (Result, "spaces" ::: Vector ReferenceSpaceType) IO ())
-> IO ()
-> ContT (Result, "spaces" ::: Vector ReferenceSpaceType) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (OpenXrException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> OpenXrException
OpenXrException Result
r))
"spaceCapacityInput" ::: Word32
spaceCountOutput <- IO ("spaceCapacityInput" ::: Word32)
-> ContT
(Result, "spaces" ::: Vector ReferenceSpaceType)
IO
("spaceCapacityInput" ::: Word32)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ("spaceCapacityInput" ::: Word32)
-> ContT
(Result, "spaces" ::: Vector ReferenceSpaceType)
IO
("spaceCapacityInput" ::: Word32))
-> IO ("spaceCapacityInput" ::: Word32)
-> ContT
(Result, "spaces" ::: Vector ReferenceSpaceType)
IO
("spaceCapacityInput" ::: Word32)
forall a b. (a -> b) -> a -> b
$ ("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32))
-> IO ("spaceCapacityInput" ::: Word32)
forall a. Storable a => Ptr a -> IO a
peek @Word32 "spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32)
pSpaceCountOutput
"spaces" ::: Ptr ReferenceSpaceType
pSpaces <- ((("spaces" ::: Ptr ReferenceSpaceType)
-> IO (Result, "spaces" ::: Vector ReferenceSpaceType))
-> IO (Result, "spaces" ::: Vector ReferenceSpaceType))
-> ContT
(Result, "spaces" ::: Vector ReferenceSpaceType)
IO
("spaces" ::: Ptr ReferenceSpaceType)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("spaces" ::: Ptr ReferenceSpaceType)
-> IO (Result, "spaces" ::: Vector ReferenceSpaceType))
-> IO (Result, "spaces" ::: Vector ReferenceSpaceType))
-> ContT
(Result, "spaces" ::: Vector ReferenceSpaceType)
IO
("spaces" ::: Ptr ReferenceSpaceType))
-> ((("spaces" ::: Ptr ReferenceSpaceType)
-> IO (Result, "spaces" ::: Vector ReferenceSpaceType))
-> IO (Result, "spaces" ::: Vector ReferenceSpaceType))
-> ContT
(Result, "spaces" ::: Vector ReferenceSpaceType)
IO
("spaces" ::: Ptr ReferenceSpaceType)
forall a b. (a -> b) -> a -> b
$ IO ("spaces" ::: Ptr ReferenceSpaceType)
-> (("spaces" ::: Ptr ReferenceSpaceType) -> IO ())
-> (("spaces" ::: Ptr ReferenceSpaceType)
-> IO (Result, "spaces" ::: Vector ReferenceSpaceType))
-> IO (Result, "spaces" ::: Vector ReferenceSpaceType)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO ("spaces" ::: Ptr ReferenceSpaceType)
forall a. Int -> IO (Ptr a)
callocBytes @ReferenceSpaceType ((("spaceCapacityInput" ::: Word32) -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral ("spaceCapacityInput" ::: Word32
spaceCountOutput)) Int -> Int -> Int
forall a. Num a => a -> a -> a
* 4)) ("spaces" ::: Ptr ReferenceSpaceType) -> IO ()
forall a. Ptr a -> IO ()
free
Result
r' <- IO Result
-> ContT (Result, "spaces" ::: Vector ReferenceSpaceType) IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result
-> ContT
(Result, "spaces" ::: Vector ReferenceSpaceType) IO Result)
-> IO Result
-> ContT (Result, "spaces" ::: Vector ReferenceSpaceType) IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent "xrEnumerateReferenceSpaces" (Ptr Session_T
-> ("spaceCapacityInput" ::: Word32)
-> ("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32))
-> ("spaces" ::: Ptr ReferenceSpaceType)
-> IO Result
xrEnumerateReferenceSpaces' Ptr Session_T
session' (("spaceCapacityInput" ::: Word32
spaceCountOutput)) ("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32)
pSpaceCountOutput) ("spaces" ::: Ptr ReferenceSpaceType
pSpaces))
IO ()
-> ContT (Result, "spaces" ::: Vector ReferenceSpaceType) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ()
-> ContT (Result, "spaces" ::: Vector ReferenceSpaceType) IO ())
-> IO ()
-> ContT (Result, "spaces" ::: Vector ReferenceSpaceType) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r' Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (OpenXrException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> OpenXrException
OpenXrException Result
r'))
"spaceCapacityInput" ::: Word32
spaceCountOutput' <- IO ("spaceCapacityInput" ::: Word32)
-> ContT
(Result, "spaces" ::: Vector ReferenceSpaceType)
IO
("spaceCapacityInput" ::: Word32)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ("spaceCapacityInput" ::: Word32)
-> ContT
(Result, "spaces" ::: Vector ReferenceSpaceType)
IO
("spaceCapacityInput" ::: Word32))
-> IO ("spaceCapacityInput" ::: Word32)
-> ContT
(Result, "spaces" ::: Vector ReferenceSpaceType)
IO
("spaceCapacityInput" ::: Word32)
forall a b. (a -> b) -> a -> b
$ ("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32))
-> IO ("spaceCapacityInput" ::: Word32)
forall a. Storable a => Ptr a -> IO a
peek @Word32 "spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32)
pSpaceCountOutput
"spaces" ::: Vector ReferenceSpaceType
spaces' <- IO ("spaces" ::: Vector ReferenceSpaceType)
-> ContT
(Result, "spaces" ::: Vector ReferenceSpaceType)
IO
("spaces" ::: Vector ReferenceSpaceType)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ("spaces" ::: Vector ReferenceSpaceType)
-> ContT
(Result, "spaces" ::: Vector ReferenceSpaceType)
IO
("spaces" ::: Vector ReferenceSpaceType))
-> IO ("spaces" ::: Vector ReferenceSpaceType)
-> ContT
(Result, "spaces" ::: Vector ReferenceSpaceType)
IO
("spaces" ::: Vector ReferenceSpaceType)
forall a b. (a -> b) -> a -> b
$ Int
-> (Int -> IO ReferenceSpaceType)
-> IO ("spaces" ::: Vector ReferenceSpaceType)
forall (m :: * -> *) a.
Monad m =>
Int -> (Int -> m a) -> m (Vector a)
generateM (("spaceCapacityInput" ::: Word32) -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral ("spaceCapacityInput" ::: Word32
spaceCountOutput')) (\i :: Int
i -> ("spaces" ::: Ptr ReferenceSpaceType) -> IO ReferenceSpaceType
forall a. Storable a => Ptr a -> IO a
peek @ReferenceSpaceType (("spaces" ::: Ptr ReferenceSpaceType
pSpaces ("spaces" ::: Ptr ReferenceSpaceType)
-> Int -> "spaces" ::: Ptr ReferenceSpaceType
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (4 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr ReferenceSpaceType)))
(Result, "spaces" ::: Vector ReferenceSpaceType)
-> ContT
(Result, "spaces" ::: Vector ReferenceSpaceType)
IO
(Result, "spaces" ::: Vector ReferenceSpaceType)
forall (f :: * -> *) a. Applicative f => a -> f a
pure ((Result, "spaces" ::: Vector ReferenceSpaceType)
-> ContT
(Result, "spaces" ::: Vector ReferenceSpaceType)
IO
(Result, "spaces" ::: Vector ReferenceSpaceType))
-> (Result, "spaces" ::: Vector ReferenceSpaceType)
-> ContT
(Result, "spaces" ::: Vector ReferenceSpaceType)
IO
(Result, "spaces" ::: Vector ReferenceSpaceType)
forall a b. (a -> b) -> a -> b
$ ((Result
r'), "spaces" ::: Vector ReferenceSpaceType
spaces')
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkXrCreateReferenceSpace
:: FunPtr (Ptr Session_T -> Ptr ReferenceSpaceCreateInfo -> Ptr (Ptr Space_T) -> IO Result) -> Ptr Session_T -> Ptr ReferenceSpaceCreateInfo -> Ptr (Ptr Space_T) -> IO Result
createReferenceSpace :: forall io
. (MonadIO io)
=>
Session
->
ReferenceSpaceCreateInfo
-> io (Result, Space)
createReferenceSpace :: Session -> ReferenceSpaceCreateInfo -> io (Result, Space)
createReferenceSpace session :: Session
session createInfo :: ReferenceSpaceCreateInfo
createInfo = IO (Result, Space) -> io (Result, Space)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Result, Space) -> io (Result, Space))
-> (ContT (Result, Space) IO (Result, Space) -> IO (Result, Space))
-> ContT (Result, Space) IO (Result, Space)
-> io (Result, Space)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT (Result, Space) IO (Result, Space) -> IO (Result, Space)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT (Result, Space) IO (Result, Space) -> io (Result, Space))
-> ContT (Result, Space) IO (Result, Space) -> io (Result, Space)
forall a b. (a -> b) -> a -> b
$ do
let cmds :: InstanceCmds
cmds = Session -> InstanceCmds
instanceCmds (Session
session :: Session)
let xrCreateReferenceSpacePtr :: FunPtr
(Ptr Session_T
-> Ptr ReferenceSpaceCreateInfo
-> ("space" ::: Ptr (Ptr Space_T))
-> IO Result)
xrCreateReferenceSpacePtr = InstanceCmds
-> FunPtr
(Ptr Session_T
-> Ptr ReferenceSpaceCreateInfo
-> ("space" ::: Ptr (Ptr Space_T))
-> IO Result)
pXrCreateReferenceSpace InstanceCmds
cmds
IO () -> ContT (Result, Space) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT (Result, Space) IO ())
-> IO () -> ContT (Result, Space) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
(Ptr Session_T
-> Ptr ReferenceSpaceCreateInfo
-> ("space" ::: Ptr (Ptr Space_T))
-> IO Result)
xrCreateReferenceSpacePtr FunPtr
(Ptr Session_T
-> Ptr ReferenceSpaceCreateInfo
-> ("space" ::: Ptr (Ptr Space_T))
-> IO Result)
-> FunPtr
(Ptr Session_T
-> Ptr ReferenceSpaceCreateInfo
-> ("space" ::: Ptr (Ptr Space_T))
-> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
(Ptr Session_T
-> Ptr ReferenceSpaceCreateInfo
-> ("space" ::: Ptr (Ptr Space_T))
-> IO Result)
forall a. FunPtr a
nullFunPtr) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
IOException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (IOException -> IO ()) -> IOException -> IO ()
forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError Maybe Handle
forall a. Maybe a
Nothing IOErrorType
InvalidArgument "" "The function pointer for xrCreateReferenceSpace is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
let xrCreateReferenceSpace' :: Ptr Session_T
-> Ptr ReferenceSpaceCreateInfo
-> ("space" ::: Ptr (Ptr Space_T))
-> IO Result
xrCreateReferenceSpace' = FunPtr
(Ptr Session_T
-> Ptr ReferenceSpaceCreateInfo
-> ("space" ::: Ptr (Ptr Space_T))
-> IO Result)
-> Ptr Session_T
-> Ptr ReferenceSpaceCreateInfo
-> ("space" ::: Ptr (Ptr Space_T))
-> IO Result
mkXrCreateReferenceSpace FunPtr
(Ptr Session_T
-> Ptr ReferenceSpaceCreateInfo
-> ("space" ::: Ptr (Ptr Space_T))
-> IO Result)
xrCreateReferenceSpacePtr
Ptr ReferenceSpaceCreateInfo
createInfo' <- ((Ptr ReferenceSpaceCreateInfo -> IO (Result, Space))
-> IO (Result, Space))
-> ContT (Result, Space) IO (Ptr ReferenceSpaceCreateInfo)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr ReferenceSpaceCreateInfo -> IO (Result, Space))
-> IO (Result, Space))
-> ContT (Result, Space) IO (Ptr ReferenceSpaceCreateInfo))
-> ((Ptr ReferenceSpaceCreateInfo -> IO (Result, Space))
-> IO (Result, Space))
-> ContT (Result, Space) IO (Ptr ReferenceSpaceCreateInfo)
forall a b. (a -> b) -> a -> b
$ ReferenceSpaceCreateInfo
-> (Ptr ReferenceSpaceCreateInfo -> IO (Result, Space))
-> IO (Result, Space)
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (ReferenceSpaceCreateInfo
createInfo)
"space" ::: Ptr (Ptr Space_T)
pSpace <- ((("space" ::: Ptr (Ptr Space_T)) -> IO (Result, Space))
-> IO (Result, Space))
-> ContT (Result, Space) IO ("space" ::: Ptr (Ptr Space_T))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("space" ::: Ptr (Ptr Space_T)) -> IO (Result, Space))
-> IO (Result, Space))
-> ContT (Result, Space) IO ("space" ::: Ptr (Ptr Space_T)))
-> ((("space" ::: Ptr (Ptr Space_T)) -> IO (Result, Space))
-> IO (Result, Space))
-> ContT (Result, Space) IO ("space" ::: Ptr (Ptr Space_T))
forall a b. (a -> b) -> a -> b
$ IO ("space" ::: Ptr (Ptr Space_T))
-> (("space" ::: Ptr (Ptr Space_T)) -> IO ())
-> (("space" ::: Ptr (Ptr Space_T)) -> IO (Result, Space))
-> IO (Result, Space)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO ("space" ::: Ptr (Ptr Space_T))
forall a. Int -> IO (Ptr a)
callocBytes @(Ptr Space_T) 8) ("space" ::: Ptr (Ptr Space_T)) -> IO ()
forall a. Ptr a -> IO ()
free
Result
r <- IO Result -> ContT (Result, Space) IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT (Result, Space) IO Result)
-> IO Result -> ContT (Result, Space) IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent "xrCreateReferenceSpace" (Ptr Session_T
-> Ptr ReferenceSpaceCreateInfo
-> ("space" ::: Ptr (Ptr Space_T))
-> IO Result
xrCreateReferenceSpace' (Session -> Ptr Session_T
sessionHandle (Session
session)) Ptr ReferenceSpaceCreateInfo
createInfo' ("space" ::: Ptr (Ptr Space_T)
pSpace))
IO () -> ContT (Result, Space) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT (Result, Space) IO ())
-> IO () -> ContT (Result, Space) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (OpenXrException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> OpenXrException
OpenXrException Result
r))
Ptr Space_T
space <- IO (Ptr Space_T) -> ContT (Result, Space) IO (Ptr Space_T)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO (Ptr Space_T) -> ContT (Result, Space) IO (Ptr Space_T))
-> IO (Ptr Space_T) -> ContT (Result, Space) IO (Ptr Space_T)
forall a b. (a -> b) -> a -> b
$ ("space" ::: Ptr (Ptr Space_T)) -> IO (Ptr Space_T)
forall a. Storable a => Ptr a -> IO a
peek @(Ptr Space_T) "space" ::: Ptr (Ptr Space_T)
pSpace
(Result, Space) -> ContT (Result, Space) IO (Result, Space)
forall (f :: * -> *) a. Applicative f => a -> f a
pure ((Result, Space) -> ContT (Result, Space) IO (Result, Space))
-> (Result, Space) -> ContT (Result, Space) IO (Result, Space)
forall a b. (a -> b) -> a -> b
$ (Result
r, ((\h :: Ptr Space_T
h -> Ptr Space_T -> InstanceCmds -> Space
Space Ptr Space_T
h InstanceCmds
cmds ) Ptr Space_T
space))
withReferenceSpace :: forall io r . MonadIO io => Session -> ReferenceSpaceCreateInfo -> (io (Result, Space) -> ((Result, Space) -> io ()) -> r) -> r
withReferenceSpace :: Session
-> ReferenceSpaceCreateInfo
-> (io (Result, Space) -> ((Result, Space) -> io ()) -> r)
-> r
withReferenceSpace session :: Session
session createInfo :: ReferenceSpaceCreateInfo
createInfo b :: io (Result, Space) -> ((Result, Space) -> io ()) -> r
b =
io (Result, Space) -> ((Result, Space) -> io ()) -> r
b (Session -> ReferenceSpaceCreateInfo -> io (Result, Space)
forall (io :: * -> *).
MonadIO io =>
Session -> ReferenceSpaceCreateInfo -> io (Result, Space)
createReferenceSpace Session
session ReferenceSpaceCreateInfo
createInfo)
(\(_, o1 :: Space
o1) -> Space -> io ()
forall (io :: * -> *). MonadIO io => Space -> io ()
destroySpace Space
o1)
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkXrCreateActionSpace
:: FunPtr (Ptr Session_T -> Ptr ActionSpaceCreateInfo -> Ptr (Ptr Space_T) -> IO Result) -> Ptr Session_T -> Ptr ActionSpaceCreateInfo -> Ptr (Ptr Space_T) -> IO Result
createActionSpace :: forall io
. (MonadIO io)
=>
Session
->
ActionSpaceCreateInfo
-> io (Result, Space)
createActionSpace :: Session -> ActionSpaceCreateInfo -> io (Result, Space)
createActionSpace session :: Session
session createInfo :: ActionSpaceCreateInfo
createInfo = IO (Result, Space) -> io (Result, Space)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Result, Space) -> io (Result, Space))
-> (ContT (Result, Space) IO (Result, Space) -> IO (Result, Space))
-> ContT (Result, Space) IO (Result, Space)
-> io (Result, Space)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT (Result, Space) IO (Result, Space) -> IO (Result, Space)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT (Result, Space) IO (Result, Space) -> io (Result, Space))
-> ContT (Result, Space) IO (Result, Space) -> io (Result, Space)
forall a b. (a -> b) -> a -> b
$ do
let cmds :: InstanceCmds
cmds = Session -> InstanceCmds
instanceCmds (Session
session :: Session)
let xrCreateActionSpacePtr :: FunPtr
(Ptr Session_T
-> Ptr ActionSpaceCreateInfo
-> ("space" ::: Ptr (Ptr Space_T))
-> IO Result)
xrCreateActionSpacePtr = InstanceCmds
-> FunPtr
(Ptr Session_T
-> Ptr ActionSpaceCreateInfo
-> ("space" ::: Ptr (Ptr Space_T))
-> IO Result)
pXrCreateActionSpace InstanceCmds
cmds
IO () -> ContT (Result, Space) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT (Result, Space) IO ())
-> IO () -> ContT (Result, Space) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
(Ptr Session_T
-> Ptr ActionSpaceCreateInfo
-> ("space" ::: Ptr (Ptr Space_T))
-> IO Result)
xrCreateActionSpacePtr FunPtr
(Ptr Session_T
-> Ptr ActionSpaceCreateInfo
-> ("space" ::: Ptr (Ptr Space_T))
-> IO Result)
-> FunPtr
(Ptr Session_T
-> Ptr ActionSpaceCreateInfo
-> ("space" ::: Ptr (Ptr Space_T))
-> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
(Ptr Session_T
-> Ptr ActionSpaceCreateInfo
-> ("space" ::: Ptr (Ptr Space_T))
-> IO Result)
forall a. FunPtr a
nullFunPtr) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
IOException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (IOException -> IO ()) -> IOException -> IO ()
forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError Maybe Handle
forall a. Maybe a
Nothing IOErrorType
InvalidArgument "" "The function pointer for xrCreateActionSpace is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
let xrCreateActionSpace' :: Ptr Session_T
-> Ptr ActionSpaceCreateInfo
-> ("space" ::: Ptr (Ptr Space_T))
-> IO Result
xrCreateActionSpace' = FunPtr
(Ptr Session_T
-> Ptr ActionSpaceCreateInfo
-> ("space" ::: Ptr (Ptr Space_T))
-> IO Result)
-> Ptr Session_T
-> Ptr ActionSpaceCreateInfo
-> ("space" ::: Ptr (Ptr Space_T))
-> IO Result
mkXrCreateActionSpace FunPtr
(Ptr Session_T
-> Ptr ActionSpaceCreateInfo
-> ("space" ::: Ptr (Ptr Space_T))
-> IO Result)
xrCreateActionSpacePtr
Ptr ActionSpaceCreateInfo
createInfo' <- ((Ptr ActionSpaceCreateInfo -> IO (Result, Space))
-> IO (Result, Space))
-> ContT (Result, Space) IO (Ptr ActionSpaceCreateInfo)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr ActionSpaceCreateInfo -> IO (Result, Space))
-> IO (Result, Space))
-> ContT (Result, Space) IO (Ptr ActionSpaceCreateInfo))
-> ((Ptr ActionSpaceCreateInfo -> IO (Result, Space))
-> IO (Result, Space))
-> ContT (Result, Space) IO (Ptr ActionSpaceCreateInfo)
forall a b. (a -> b) -> a -> b
$ ActionSpaceCreateInfo
-> (Ptr ActionSpaceCreateInfo -> IO (Result, Space))
-> IO (Result, Space)
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (ActionSpaceCreateInfo
createInfo)
"space" ::: Ptr (Ptr Space_T)
pSpace <- ((("space" ::: Ptr (Ptr Space_T)) -> IO (Result, Space))
-> IO (Result, Space))
-> ContT (Result, Space) IO ("space" ::: Ptr (Ptr Space_T))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("space" ::: Ptr (Ptr Space_T)) -> IO (Result, Space))
-> IO (Result, Space))
-> ContT (Result, Space) IO ("space" ::: Ptr (Ptr Space_T)))
-> ((("space" ::: Ptr (Ptr Space_T)) -> IO (Result, Space))
-> IO (Result, Space))
-> ContT (Result, Space) IO ("space" ::: Ptr (Ptr Space_T))
forall a b. (a -> b) -> a -> b
$ IO ("space" ::: Ptr (Ptr Space_T))
-> (("space" ::: Ptr (Ptr Space_T)) -> IO ())
-> (("space" ::: Ptr (Ptr Space_T)) -> IO (Result, Space))
-> IO (Result, Space)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO ("space" ::: Ptr (Ptr Space_T))
forall a. Int -> IO (Ptr a)
callocBytes @(Ptr Space_T) 8) ("space" ::: Ptr (Ptr Space_T)) -> IO ()
forall a. Ptr a -> IO ()
free
Result
r <- IO Result -> ContT (Result, Space) IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT (Result, Space) IO Result)
-> IO Result -> ContT (Result, Space) IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent "xrCreateActionSpace" (Ptr Session_T
-> Ptr ActionSpaceCreateInfo
-> ("space" ::: Ptr (Ptr Space_T))
-> IO Result
xrCreateActionSpace' (Session -> Ptr Session_T
sessionHandle (Session
session)) Ptr ActionSpaceCreateInfo
createInfo' ("space" ::: Ptr (Ptr Space_T)
pSpace))
IO () -> ContT (Result, Space) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT (Result, Space) IO ())
-> IO () -> ContT (Result, Space) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (OpenXrException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> OpenXrException
OpenXrException Result
r))
Ptr Space_T
space <- IO (Ptr Space_T) -> ContT (Result, Space) IO (Ptr Space_T)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO (Ptr Space_T) -> ContT (Result, Space) IO (Ptr Space_T))
-> IO (Ptr Space_T) -> ContT (Result, Space) IO (Ptr Space_T)
forall a b. (a -> b) -> a -> b
$ ("space" ::: Ptr (Ptr Space_T)) -> IO (Ptr Space_T)
forall a. Storable a => Ptr a -> IO a
peek @(Ptr Space_T) "space" ::: Ptr (Ptr Space_T)
pSpace
(Result, Space) -> ContT (Result, Space) IO (Result, Space)
forall (f :: * -> *) a. Applicative f => a -> f a
pure ((Result, Space) -> ContT (Result, Space) IO (Result, Space))
-> (Result, Space) -> ContT (Result, Space) IO (Result, Space)
forall a b. (a -> b) -> a -> b
$ (Result
r, ((\h :: Ptr Space_T
h -> Ptr Space_T -> InstanceCmds -> Space
Space Ptr Space_T
h InstanceCmds
cmds ) Ptr Space_T
space))
withActionSpace :: forall io r . MonadIO io => Session -> ActionSpaceCreateInfo -> (io (Result, Space) -> ((Result, Space) -> io ()) -> r) -> r
withActionSpace :: Session
-> ActionSpaceCreateInfo
-> (io (Result, Space) -> ((Result, Space) -> io ()) -> r)
-> r
withActionSpace session :: Session
session createInfo :: ActionSpaceCreateInfo
createInfo b :: io (Result, Space) -> ((Result, Space) -> io ()) -> r
b =
io (Result, Space) -> ((Result, Space) -> io ()) -> r
b (Session -> ActionSpaceCreateInfo -> io (Result, Space)
forall (io :: * -> *).
MonadIO io =>
Session -> ActionSpaceCreateInfo -> io (Result, Space)
createActionSpace Session
session ActionSpaceCreateInfo
createInfo)
(\(_, o1 :: Space
o1) -> Space -> io ()
forall (io :: * -> *). MonadIO io => Space -> io ()
destroySpace Space
o1)
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkXrLocateSpace
:: FunPtr (Ptr Space_T -> Ptr Space_T -> Time -> Ptr (SomeStruct SpaceLocation) -> IO Result) -> Ptr Space_T -> Ptr Space_T -> Time -> Ptr (SomeStruct SpaceLocation) -> IO Result
locateSpace :: forall a io
. (Extendss SpaceLocation a, PokeChain a, PeekChain a, MonadIO io)
=>
Space
->
("baseSpace" ::: Space)
->
Time
-> io (Result, SpaceLocation a)
locateSpace :: Space -> Space -> Time -> io (Result, SpaceLocation a)
locateSpace space :: Space
space baseSpace :: Space
baseSpace time :: Time
time = IO (Result, SpaceLocation a) -> io (Result, SpaceLocation a)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Result, SpaceLocation a) -> io (Result, SpaceLocation a))
-> (ContT (Result, SpaceLocation a) IO (Result, SpaceLocation a)
-> IO (Result, SpaceLocation a))
-> ContT (Result, SpaceLocation a) IO (Result, SpaceLocation a)
-> io (Result, SpaceLocation a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT (Result, SpaceLocation a) IO (Result, SpaceLocation a)
-> IO (Result, SpaceLocation a)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT (Result, SpaceLocation a) IO (Result, SpaceLocation a)
-> io (Result, SpaceLocation a))
-> ContT (Result, SpaceLocation a) IO (Result, SpaceLocation a)
-> io (Result, SpaceLocation a)
forall a b. (a -> b) -> a -> b
$ do
let xrLocateSpacePtr :: FunPtr
(Ptr Space_T
-> Ptr Space_T
-> Time
-> ("location" ::: Ptr (SomeStruct SpaceLocation))
-> IO Result)
xrLocateSpacePtr = InstanceCmds
-> FunPtr
(Ptr Space_T
-> Ptr Space_T
-> Time
-> ("location" ::: Ptr (SomeStruct SpaceLocation))
-> IO Result)
pXrLocateSpace (Space -> InstanceCmds
instanceCmds (Space
space :: Space))
IO () -> ContT (Result, SpaceLocation a) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT (Result, SpaceLocation a) IO ())
-> IO () -> ContT (Result, SpaceLocation a) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
(Ptr Space_T
-> Ptr Space_T
-> Time
-> ("location" ::: Ptr (SomeStruct SpaceLocation))
-> IO Result)
xrLocateSpacePtr FunPtr
(Ptr Space_T
-> Ptr Space_T
-> Time
-> ("location" ::: Ptr (SomeStruct SpaceLocation))
-> IO Result)
-> FunPtr
(Ptr Space_T
-> Ptr Space_T
-> Time
-> ("location" ::: Ptr (SomeStruct SpaceLocation))
-> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
(Ptr Space_T
-> Ptr Space_T
-> Time
-> ("location" ::: Ptr (SomeStruct SpaceLocation))
-> IO Result)
forall a. FunPtr a
nullFunPtr) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
IOException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (IOException -> IO ()) -> IOException -> IO ()
forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError Maybe Handle
forall a. Maybe a
Nothing IOErrorType
InvalidArgument "" "The function pointer for xrLocateSpace is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
let xrLocateSpace' :: Ptr Space_T
-> Ptr Space_T
-> Time
-> ("location" ::: Ptr (SomeStruct SpaceLocation))
-> IO Result
xrLocateSpace' = FunPtr
(Ptr Space_T
-> Ptr Space_T
-> Time
-> ("location" ::: Ptr (SomeStruct SpaceLocation))
-> IO Result)
-> Ptr Space_T
-> Ptr Space_T
-> Time
-> ("location" ::: Ptr (SomeStruct SpaceLocation))
-> IO Result
mkXrLocateSpace FunPtr
(Ptr Space_T
-> Ptr Space_T
-> Time
-> ("location" ::: Ptr (SomeStruct SpaceLocation))
-> IO Result)
xrLocateSpacePtr
Ptr (SpaceLocation a)
pLocation <- ((Ptr (SpaceLocation a) -> IO (Result, SpaceLocation a))
-> IO (Result, SpaceLocation a))
-> ContT (Result, SpaceLocation a) IO (Ptr (SpaceLocation a))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (forall b.
ToCStruct (SpaceLocation a) =>
(Ptr (SpaceLocation a) -> IO b) -> IO b
forall a b. ToCStruct a => (Ptr a -> IO b) -> IO b
withZeroCStruct @(SpaceLocation _))
Result
r <- IO Result -> ContT (Result, SpaceLocation a) IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT (Result, SpaceLocation a) IO Result)
-> IO Result -> ContT (Result, SpaceLocation a) IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent "xrLocateSpace" (Ptr Space_T
-> Ptr Space_T
-> Time
-> ("location" ::: Ptr (SomeStruct SpaceLocation))
-> IO Result
xrLocateSpace' (Space -> Ptr Space_T
spaceHandle (Space
space)) (Space -> Ptr Space_T
spaceHandle (Space
baseSpace)) (Time
time) (Ptr (SpaceLocation a)
-> "location" ::: Ptr (SomeStruct SpaceLocation)
forall (a :: [*] -> *) (es :: [*]).
Ptr (a es) -> Ptr (SomeStruct a)
forgetExtensions (Ptr (SpaceLocation a)
pLocation)))
IO () -> ContT (Result, SpaceLocation a) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT (Result, SpaceLocation a) IO ())
-> IO () -> ContT (Result, SpaceLocation a) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (OpenXrException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> OpenXrException
OpenXrException Result
r))
SpaceLocation a
location <- IO (SpaceLocation a)
-> ContT (Result, SpaceLocation a) IO (SpaceLocation a)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO (SpaceLocation a)
-> ContT (Result, SpaceLocation a) IO (SpaceLocation a))
-> IO (SpaceLocation a)
-> ContT (Result, SpaceLocation a) IO (SpaceLocation a)
forall a b. (a -> b) -> a -> b
$ Ptr (SpaceLocation a) -> IO (SpaceLocation a)
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @(SpaceLocation _) Ptr (SpaceLocation a)
pLocation
(Result, SpaceLocation a)
-> ContT (Result, SpaceLocation a) IO (Result, SpaceLocation a)
forall (f :: * -> *) a. Applicative f => a -> f a
pure ((Result, SpaceLocation a)
-> ContT (Result, SpaceLocation a) IO (Result, SpaceLocation a))
-> (Result, SpaceLocation a)
-> ContT (Result, SpaceLocation a) IO (Result, SpaceLocation a)
forall a b. (a -> b) -> a -> b
$ (Result
r, SpaceLocation a
location)
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkXrGetReferenceSpaceBoundsRect
:: FunPtr (Ptr Session_T -> ReferenceSpaceType -> Ptr Extent2Df -> IO Result) -> Ptr Session_T -> ReferenceSpaceType -> Ptr Extent2Df -> IO Result
getReferenceSpaceBoundsRect :: forall io
. (MonadIO io)
=>
Session
->
ReferenceSpaceType
-> io (Result, ("bounds" ::: Extent2Df))
getReferenceSpaceBoundsRect :: Session
-> ReferenceSpaceType -> io (Result, "bounds" ::: Extent2Df)
getReferenceSpaceBoundsRect session :: Session
session referenceSpaceType :: ReferenceSpaceType
referenceSpaceType = IO (Result, "bounds" ::: Extent2Df)
-> io (Result, "bounds" ::: Extent2Df)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Result, "bounds" ::: Extent2Df)
-> io (Result, "bounds" ::: Extent2Df))
-> (ContT
(Result, "bounds" ::: Extent2Df)
IO
(Result, "bounds" ::: Extent2Df)
-> IO (Result, "bounds" ::: Extent2Df))
-> ContT
(Result, "bounds" ::: Extent2Df)
IO
(Result, "bounds" ::: Extent2Df)
-> io (Result, "bounds" ::: Extent2Df)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT
(Result, "bounds" ::: Extent2Df)
IO
(Result, "bounds" ::: Extent2Df)
-> IO (Result, "bounds" ::: Extent2Df)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT
(Result, "bounds" ::: Extent2Df)
IO
(Result, "bounds" ::: Extent2Df)
-> io (Result, "bounds" ::: Extent2Df))
-> ContT
(Result, "bounds" ::: Extent2Df)
IO
(Result, "bounds" ::: Extent2Df)
-> io (Result, "bounds" ::: Extent2Df)
forall a b. (a -> b) -> a -> b
$ do
let xrGetReferenceSpaceBoundsRectPtr :: FunPtr
(Ptr Session_T
-> ReferenceSpaceType
-> ("bounds" ::: Ptr ("bounds" ::: Extent2Df))
-> IO Result)
xrGetReferenceSpaceBoundsRectPtr = InstanceCmds
-> FunPtr
(Ptr Session_T
-> ReferenceSpaceType
-> ("bounds" ::: Ptr ("bounds" ::: Extent2Df))
-> IO Result)
pXrGetReferenceSpaceBoundsRect (Session -> InstanceCmds
instanceCmds (Session
session :: Session))
IO () -> ContT (Result, "bounds" ::: Extent2Df) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT (Result, "bounds" ::: Extent2Df) IO ())
-> IO () -> ContT (Result, "bounds" ::: Extent2Df) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
(Ptr Session_T
-> ReferenceSpaceType
-> ("bounds" ::: Ptr ("bounds" ::: Extent2Df))
-> IO Result)
xrGetReferenceSpaceBoundsRectPtr FunPtr
(Ptr Session_T
-> ReferenceSpaceType
-> ("bounds" ::: Ptr ("bounds" ::: Extent2Df))
-> IO Result)
-> FunPtr
(Ptr Session_T
-> ReferenceSpaceType
-> ("bounds" ::: Ptr ("bounds" ::: Extent2Df))
-> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
(Ptr Session_T
-> ReferenceSpaceType
-> ("bounds" ::: Ptr ("bounds" ::: Extent2Df))
-> IO Result)
forall a. FunPtr a
nullFunPtr) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
IOException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (IOException -> IO ()) -> IOException -> IO ()
forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError Maybe Handle
forall a. Maybe a
Nothing IOErrorType
InvalidArgument "" "The function pointer for xrGetReferenceSpaceBoundsRect is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
let xrGetReferenceSpaceBoundsRect' :: Ptr Session_T
-> ReferenceSpaceType
-> ("bounds" ::: Ptr ("bounds" ::: Extent2Df))
-> IO Result
xrGetReferenceSpaceBoundsRect' = FunPtr
(Ptr Session_T
-> ReferenceSpaceType
-> ("bounds" ::: Ptr ("bounds" ::: Extent2Df))
-> IO Result)
-> Ptr Session_T
-> ReferenceSpaceType
-> ("bounds" ::: Ptr ("bounds" ::: Extent2Df))
-> IO Result
mkXrGetReferenceSpaceBoundsRect FunPtr
(Ptr Session_T
-> ReferenceSpaceType
-> ("bounds" ::: Ptr ("bounds" ::: Extent2Df))
-> IO Result)
xrGetReferenceSpaceBoundsRectPtr
"bounds" ::: Ptr ("bounds" ::: Extent2Df)
pBounds <- ((("bounds" ::: Ptr ("bounds" ::: Extent2Df))
-> IO (Result, "bounds" ::: Extent2Df))
-> IO (Result, "bounds" ::: Extent2Df))
-> ContT
(Result, "bounds" ::: Extent2Df)
IO
("bounds" ::: Ptr ("bounds" ::: Extent2Df))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (forall b.
ToCStruct ("bounds" ::: Extent2Df) =>
(("bounds" ::: Ptr ("bounds" ::: Extent2Df)) -> IO b) -> IO b
forall a b. ToCStruct a => (Ptr a -> IO b) -> IO b
withZeroCStruct @Extent2Df)
Result
r <- IO Result -> ContT (Result, "bounds" ::: Extent2Df) IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT (Result, "bounds" ::: Extent2Df) IO Result)
-> IO Result -> ContT (Result, "bounds" ::: Extent2Df) IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent "xrGetReferenceSpaceBoundsRect" (Ptr Session_T
-> ReferenceSpaceType
-> ("bounds" ::: Ptr ("bounds" ::: Extent2Df))
-> IO Result
xrGetReferenceSpaceBoundsRect' (Session -> Ptr Session_T
sessionHandle (Session
session)) (ReferenceSpaceType
referenceSpaceType) ("bounds" ::: Ptr ("bounds" ::: Extent2Df)
pBounds))
IO () -> ContT (Result, "bounds" ::: Extent2Df) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT (Result, "bounds" ::: Extent2Df) IO ())
-> IO () -> ContT (Result, "bounds" ::: Extent2Df) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (OpenXrException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> OpenXrException
OpenXrException Result
r))
"bounds" ::: Extent2Df
bounds <- IO ("bounds" ::: Extent2Df)
-> ContT
(Result, "bounds" ::: Extent2Df) IO ("bounds" ::: Extent2Df)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ("bounds" ::: Extent2Df)
-> ContT
(Result, "bounds" ::: Extent2Df) IO ("bounds" ::: Extent2Df))
-> IO ("bounds" ::: Extent2Df)
-> ContT
(Result, "bounds" ::: Extent2Df) IO ("bounds" ::: Extent2Df)
forall a b. (a -> b) -> a -> b
$ ("bounds" ::: Ptr ("bounds" ::: Extent2Df))
-> IO ("bounds" ::: Extent2Df)
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @Extent2Df "bounds" ::: Ptr ("bounds" ::: Extent2Df)
pBounds
(Result, "bounds" ::: Extent2Df)
-> ContT
(Result, "bounds" ::: Extent2Df)
IO
(Result, "bounds" ::: Extent2Df)
forall (f :: * -> *) a. Applicative f => a -> f a
pure ((Result, "bounds" ::: Extent2Df)
-> ContT
(Result, "bounds" ::: Extent2Df)
IO
(Result, "bounds" ::: Extent2Df))
-> (Result, "bounds" ::: Extent2Df)
-> ContT
(Result, "bounds" ::: Extent2Df)
IO
(Result, "bounds" ::: Extent2Df)
forall a b. (a -> b) -> a -> b
$ (Result
r, "bounds" ::: Extent2Df
bounds)
data Vector3f = Vector3f
{
Vector3f -> Float
x :: Float
,
Vector3f -> Float
y :: Float
,
Vector3f -> Float
z :: Float
}
deriving (Typeable, Vector3f -> Vector3f -> Bool
(Vector3f -> Vector3f -> Bool)
-> (Vector3f -> Vector3f -> Bool) -> Eq Vector3f
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Vector3f -> Vector3f -> Bool
$c/= :: Vector3f -> Vector3f -> Bool
== :: Vector3f -> Vector3f -> Bool
$c== :: Vector3f -> Vector3f -> Bool
Eq)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (Vector3f)
#endif
deriving instance Show Vector3f
instance ToCStruct Vector3f where
withCStruct :: Vector3f -> (Ptr Vector3f -> IO b) -> IO b
withCStruct x :: Vector3f
x f :: Ptr Vector3f -> IO b
f = Int -> Int -> (Ptr Vector3f -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 12 4 ((Ptr Vector3f -> IO b) -> IO b) -> (Ptr Vector3f -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: Ptr Vector3f
p -> Ptr Vector3f -> Vector3f -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr Vector3f
p Vector3f
x (Ptr Vector3f -> IO b
f Ptr Vector3f
p)
pokeCStruct :: Ptr Vector3f -> Vector3f -> IO b -> IO b
pokeCStruct p :: Ptr Vector3f
p Vector3f{..} f :: IO b
f = do
Ptr CFloat -> CFloat -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr Vector3f
p Ptr Vector3f -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr CFloat)) (Float -> CFloat
CFloat (Float
x))
Ptr CFloat -> CFloat -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr Vector3f
p Ptr Vector3f -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 4 :: Ptr CFloat)) (Float -> CFloat
CFloat (Float
y))
Ptr CFloat -> CFloat -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr Vector3f
p Ptr Vector3f -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr CFloat)) (Float -> CFloat
CFloat (Float
z))
IO b
f
cStructSize :: Int
cStructSize = 12
cStructAlignment :: Int
cStructAlignment = 4
pokeZeroCStruct :: Ptr Vector3f -> IO b -> IO b
pokeZeroCStruct p :: Ptr Vector3f
p f :: IO b
f = do
Ptr CFloat -> CFloat -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr Vector3f
p Ptr Vector3f -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr CFloat)) (Float -> CFloat
CFloat (Float
forall a. Zero a => a
zero))
Ptr CFloat -> CFloat -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr Vector3f
p Ptr Vector3f -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 4 :: Ptr CFloat)) (Float -> CFloat
CFloat (Float
forall a. Zero a => a
zero))
Ptr CFloat -> CFloat -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr Vector3f
p Ptr Vector3f -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr CFloat)) (Float -> CFloat
CFloat (Float
forall a. Zero a => a
zero))
IO b
f
instance FromCStruct Vector3f where
peekCStruct :: Ptr Vector3f -> IO Vector3f
peekCStruct p :: Ptr Vector3f
p = do
CFloat
x <- Ptr CFloat -> IO CFloat
forall a. Storable a => Ptr a -> IO a
peek @CFloat ((Ptr Vector3f
p Ptr Vector3f -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr CFloat))
CFloat
y <- Ptr CFloat -> IO CFloat
forall a. Storable a => Ptr a -> IO a
peek @CFloat ((Ptr Vector3f
p Ptr Vector3f -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 4 :: Ptr CFloat))
CFloat
z <- Ptr CFloat -> IO CFloat
forall a. Storable a => Ptr a -> IO a
peek @CFloat ((Ptr Vector3f
p Ptr Vector3f -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr CFloat))
Vector3f -> IO Vector3f
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Vector3f -> IO Vector3f) -> Vector3f -> IO Vector3f
forall a b. (a -> b) -> a -> b
$ Float -> Float -> Float -> Vector3f
Vector3f
(CFloat -> Float
forall a b. Coercible a b => a -> b
coerce @CFloat @Float CFloat
x) (CFloat -> Float
forall a b. Coercible a b => a -> b
coerce @CFloat @Float CFloat
y) (CFloat -> Float
forall a b. Coercible a b => a -> b
coerce @CFloat @Float CFloat
z)
instance Storable Vector3f where
sizeOf :: Vector3f -> Int
sizeOf ~Vector3f
_ = 12
alignment :: Vector3f -> Int
alignment ~Vector3f
_ = 4
peek :: Ptr Vector3f -> IO Vector3f
peek = Ptr Vector3f -> IO Vector3f
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
poke :: Ptr Vector3f -> Vector3f -> IO ()
poke ptr :: Ptr Vector3f
ptr poked :: Vector3f
poked = Ptr Vector3f -> Vector3f -> IO () -> IO ()
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr Vector3f
ptr Vector3f
poked (() -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())
instance Zero Vector3f where
zero :: Vector3f
zero = Float -> Float -> Float -> Vector3f
Vector3f
Float
forall a. Zero a => a
zero
Float
forall a. Zero a => a
zero
Float
forall a. Zero a => a
zero
data Quaternionf = Quaternionf
{
Quaternionf -> Float
x :: Float
,
Quaternionf -> Float
y :: Float
,
Quaternionf -> Float
z :: Float
,
Quaternionf -> Float
w :: Float
}
deriving (Typeable, Quaternionf -> Quaternionf -> Bool
(Quaternionf -> Quaternionf -> Bool)
-> (Quaternionf -> Quaternionf -> Bool) -> Eq Quaternionf
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Quaternionf -> Quaternionf -> Bool
$c/= :: Quaternionf -> Quaternionf -> Bool
== :: Quaternionf -> Quaternionf -> Bool
$c== :: Quaternionf -> Quaternionf -> Bool
Eq)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (Quaternionf)
#endif
deriving instance Show Quaternionf
instance ToCStruct Quaternionf where
withCStruct :: Quaternionf -> (Ptr Quaternionf -> IO b) -> IO b
withCStruct x :: Quaternionf
x f :: Ptr Quaternionf -> IO b
f = Int -> Int -> (Ptr Quaternionf -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 16 4 ((Ptr Quaternionf -> IO b) -> IO b)
-> (Ptr Quaternionf -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: Ptr Quaternionf
p -> Ptr Quaternionf -> Quaternionf -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr Quaternionf
p Quaternionf
x (Ptr Quaternionf -> IO b
f Ptr Quaternionf
p)
pokeCStruct :: Ptr Quaternionf -> Quaternionf -> IO b -> IO b
pokeCStruct p :: Ptr Quaternionf
p Quaternionf{..} f :: IO b
f = do
Ptr CFloat -> CFloat -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr Quaternionf
p Ptr Quaternionf -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr CFloat)) (Float -> CFloat
CFloat (Float
x))
Ptr CFloat -> CFloat -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr Quaternionf
p Ptr Quaternionf -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 4 :: Ptr CFloat)) (Float -> CFloat
CFloat (Float
y))
Ptr CFloat -> CFloat -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr Quaternionf
p Ptr Quaternionf -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr CFloat)) (Float -> CFloat
CFloat (Float
z))
Ptr CFloat -> CFloat -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr Quaternionf
p Ptr Quaternionf -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 12 :: Ptr CFloat)) (Float -> CFloat
CFloat (Float
w))
IO b
f
cStructSize :: Int
cStructSize = 16
cStructAlignment :: Int
cStructAlignment = 4
pokeZeroCStruct :: Ptr Quaternionf -> IO b -> IO b
pokeZeroCStruct p :: Ptr Quaternionf
p f :: IO b
f = do
Ptr CFloat -> CFloat -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr Quaternionf
p Ptr Quaternionf -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr CFloat)) (Float -> CFloat
CFloat (Float
forall a. Zero a => a
zero))
Ptr CFloat -> CFloat -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr Quaternionf
p Ptr Quaternionf -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 4 :: Ptr CFloat)) (Float -> CFloat
CFloat (Float
forall a. Zero a => a
zero))
Ptr CFloat -> CFloat -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr Quaternionf
p Ptr Quaternionf -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr CFloat)) (Float -> CFloat
CFloat (Float
forall a. Zero a => a
zero))
Ptr CFloat -> CFloat -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr Quaternionf
p Ptr Quaternionf -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 12 :: Ptr CFloat)) (Float -> CFloat
CFloat (Float
forall a. Zero a => a
zero))
IO b
f
instance FromCStruct Quaternionf where
peekCStruct :: Ptr Quaternionf -> IO Quaternionf
peekCStruct p :: Ptr Quaternionf
p = do
CFloat
x <- Ptr CFloat -> IO CFloat
forall a. Storable a => Ptr a -> IO a
peek @CFloat ((Ptr Quaternionf
p Ptr Quaternionf -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr CFloat))
CFloat
y <- Ptr CFloat -> IO CFloat
forall a. Storable a => Ptr a -> IO a
peek @CFloat ((Ptr Quaternionf
p Ptr Quaternionf -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 4 :: Ptr CFloat))
CFloat
z <- Ptr CFloat -> IO CFloat
forall a. Storable a => Ptr a -> IO a
peek @CFloat ((Ptr Quaternionf
p Ptr Quaternionf -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr CFloat))
CFloat
w <- Ptr CFloat -> IO CFloat
forall a. Storable a => Ptr a -> IO a
peek @CFloat ((Ptr Quaternionf
p Ptr Quaternionf -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 12 :: Ptr CFloat))
Quaternionf -> IO Quaternionf
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Quaternionf -> IO Quaternionf) -> Quaternionf -> IO Quaternionf
forall a b. (a -> b) -> a -> b
$ Float -> Float -> Float -> Float -> Quaternionf
Quaternionf
(CFloat -> Float
forall a b. Coercible a b => a -> b
coerce @CFloat @Float CFloat
x) (CFloat -> Float
forall a b. Coercible a b => a -> b
coerce @CFloat @Float CFloat
y) (CFloat -> Float
forall a b. Coercible a b => a -> b
coerce @CFloat @Float CFloat
z) (CFloat -> Float
forall a b. Coercible a b => a -> b
coerce @CFloat @Float CFloat
w)
instance Storable Quaternionf where
sizeOf :: Quaternionf -> Int
sizeOf ~Quaternionf
_ = 16
alignment :: Quaternionf -> Int
alignment ~Quaternionf
_ = 4
peek :: Ptr Quaternionf -> IO Quaternionf
peek = Ptr Quaternionf -> IO Quaternionf
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
poke :: Ptr Quaternionf -> Quaternionf -> IO ()
poke ptr :: Ptr Quaternionf
ptr poked :: Quaternionf
poked = Ptr Quaternionf -> Quaternionf -> IO () -> IO ()
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr Quaternionf
ptr Quaternionf
poked (() -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())
instance Zero Quaternionf where
zero :: Quaternionf
zero = Float -> Float -> Float -> Float -> Quaternionf
Quaternionf
Float
forall a. Zero a => a
zero
Float
forall a. Zero a => a
zero
Float
forall a. Zero a => a
zero
Float
forall a. Zero a => a
zero
data Posef = Posef
{
Posef -> Quaternionf
orientation :: Quaternionf
,
Posef -> Vector3f
position :: Vector3f
}
deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (Posef)
#endif
deriving instance Show Posef
instance ToCStruct Posef where
withCStruct :: Posef -> (Ptr Posef -> IO b) -> IO b
withCStruct x :: Posef
x f :: Ptr Posef -> IO b
f = Int -> Int -> (Ptr Posef -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 28 4 ((Ptr Posef -> IO b) -> IO b) -> (Ptr Posef -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: Ptr Posef
p -> Ptr Posef -> Posef -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr Posef
p Posef
x (Ptr Posef -> IO b
f Ptr Posef
p)
pokeCStruct :: Ptr Posef -> Posef -> IO b -> IO b
pokeCStruct p :: Ptr Posef
p Posef{..} f :: IO b
f = do
Ptr Quaternionf -> Quaternionf -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr Posef
p Ptr Posef -> Int -> Ptr Quaternionf
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr Quaternionf)) (Quaternionf
orientation)
Ptr Vector3f -> Vector3f -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr Posef
p Ptr Posef -> Int -> Ptr Vector3f
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr Vector3f)) (Vector3f
position)
IO b
f
cStructSize :: Int
cStructSize = 28
cStructAlignment :: Int
cStructAlignment = 4
pokeZeroCStruct :: Ptr Posef -> IO b -> IO b
pokeZeroCStruct p :: Ptr Posef
p f :: IO b
f = do
Ptr Quaternionf -> Quaternionf -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr Posef
p Ptr Posef -> Int -> Ptr Quaternionf
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr Quaternionf)) (Quaternionf
forall a. Zero a => a
zero)
Ptr Vector3f -> Vector3f -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr Posef
p Ptr Posef -> Int -> Ptr Vector3f
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr Vector3f)) (Vector3f
forall a. Zero a => a
zero)
IO b
f
instance FromCStruct Posef where
peekCStruct :: Ptr Posef -> IO Posef
peekCStruct p :: Ptr Posef
p = do
Quaternionf
orientation <- Ptr Quaternionf -> IO Quaternionf
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @Quaternionf ((Ptr Posef
p Ptr Posef -> Int -> Ptr Quaternionf
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr Quaternionf))
Vector3f
position <- Ptr Vector3f -> IO Vector3f
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @Vector3f ((Ptr Posef
p Ptr Posef -> Int -> Ptr Vector3f
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr Vector3f))
Posef -> IO Posef
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Posef -> IO Posef) -> Posef -> IO Posef
forall a b. (a -> b) -> a -> b
$ Quaternionf -> Vector3f -> Posef
Posef
Quaternionf
orientation Vector3f
position
instance Storable Posef where
sizeOf :: Posef -> Int
sizeOf ~Posef
_ = 28
alignment :: Posef -> Int
alignment ~Posef
_ = 4
peek :: Ptr Posef -> IO Posef
peek = Ptr Posef -> IO Posef
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
poke :: Ptr Posef -> Posef -> IO ()
poke ptr :: Ptr Posef
ptr poked :: Posef
poked = Ptr Posef -> Posef -> IO () -> IO ()
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr Posef
ptr Posef
poked (() -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())
instance Zero Posef where
zero :: Posef
zero = Quaternionf -> Vector3f -> Posef
Posef
Quaternionf
forall a. Zero a => a
zero
Vector3f
forall a. Zero a => a
zero
data ReferenceSpaceCreateInfo = ReferenceSpaceCreateInfo
{
ReferenceSpaceCreateInfo -> ReferenceSpaceType
referenceSpaceType :: ReferenceSpaceType
,
ReferenceSpaceCreateInfo -> Posef
poseInReferenceSpace :: Posef
}
deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (ReferenceSpaceCreateInfo)
#endif
deriving instance Show ReferenceSpaceCreateInfo
instance ToCStruct ReferenceSpaceCreateInfo where
withCStruct :: ReferenceSpaceCreateInfo
-> (Ptr ReferenceSpaceCreateInfo -> IO b) -> IO b
withCStruct x :: ReferenceSpaceCreateInfo
x f :: Ptr ReferenceSpaceCreateInfo -> IO b
f = Int -> Int -> (Ptr ReferenceSpaceCreateInfo -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 48 8 ((Ptr ReferenceSpaceCreateInfo -> IO b) -> IO b)
-> (Ptr ReferenceSpaceCreateInfo -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: Ptr ReferenceSpaceCreateInfo
p -> Ptr ReferenceSpaceCreateInfo
-> ReferenceSpaceCreateInfo -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr ReferenceSpaceCreateInfo
p ReferenceSpaceCreateInfo
x (Ptr ReferenceSpaceCreateInfo -> IO b
f Ptr ReferenceSpaceCreateInfo
p)
pokeCStruct :: Ptr ReferenceSpaceCreateInfo
-> ReferenceSpaceCreateInfo -> IO b -> IO b
pokeCStruct p :: Ptr ReferenceSpaceCreateInfo
p ReferenceSpaceCreateInfo{..} f :: IO b
f = do
Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ReferenceSpaceCreateInfo
p Ptr ReferenceSpaceCreateInfo -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
TYPE_REFERENCE_SPACE_CREATE_INFO)
Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ReferenceSpaceCreateInfo
p Ptr ReferenceSpaceCreateInfo -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
("spaces" ::: Ptr ReferenceSpaceType)
-> ReferenceSpaceType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ReferenceSpaceCreateInfo
p Ptr ReferenceSpaceCreateInfo
-> Int -> "spaces" ::: Ptr ReferenceSpaceType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr ReferenceSpaceType)) (ReferenceSpaceType
referenceSpaceType)
Ptr Posef -> Posef -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ReferenceSpaceCreateInfo
p Ptr ReferenceSpaceCreateInfo -> Int -> Ptr Posef
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 20 :: Ptr Posef)) (Posef
poseInReferenceSpace)
IO b
f
cStructSize :: Int
cStructSize = 48
cStructAlignment :: Int
cStructAlignment = 8
pokeZeroCStruct :: Ptr ReferenceSpaceCreateInfo -> IO b -> IO b
pokeZeroCStruct p :: Ptr ReferenceSpaceCreateInfo
p f :: IO b
f = do
Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ReferenceSpaceCreateInfo
p Ptr ReferenceSpaceCreateInfo -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
TYPE_REFERENCE_SPACE_CREATE_INFO)
Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ReferenceSpaceCreateInfo
p Ptr ReferenceSpaceCreateInfo -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
("spaces" ::: Ptr ReferenceSpaceType)
-> ReferenceSpaceType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ReferenceSpaceCreateInfo
p Ptr ReferenceSpaceCreateInfo
-> Int -> "spaces" ::: Ptr ReferenceSpaceType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr ReferenceSpaceType)) (ReferenceSpaceType
forall a. Zero a => a
zero)
Ptr Posef -> Posef -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ReferenceSpaceCreateInfo
p Ptr ReferenceSpaceCreateInfo -> Int -> Ptr Posef
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 20 :: Ptr Posef)) (Posef
forall a. Zero a => a
zero)
IO b
f
instance FromCStruct ReferenceSpaceCreateInfo where
peekCStruct :: Ptr ReferenceSpaceCreateInfo -> IO ReferenceSpaceCreateInfo
peekCStruct p :: Ptr ReferenceSpaceCreateInfo
p = do
ReferenceSpaceType
referenceSpaceType <- ("spaces" ::: Ptr ReferenceSpaceType) -> IO ReferenceSpaceType
forall a. Storable a => Ptr a -> IO a
peek @ReferenceSpaceType ((Ptr ReferenceSpaceCreateInfo
p Ptr ReferenceSpaceCreateInfo
-> Int -> "spaces" ::: Ptr ReferenceSpaceType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr ReferenceSpaceType))
Posef
poseInReferenceSpace <- Ptr Posef -> IO Posef
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @Posef ((Ptr ReferenceSpaceCreateInfo
p Ptr ReferenceSpaceCreateInfo -> Int -> Ptr Posef
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 20 :: Ptr Posef))
ReferenceSpaceCreateInfo -> IO ReferenceSpaceCreateInfo
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ReferenceSpaceCreateInfo -> IO ReferenceSpaceCreateInfo)
-> ReferenceSpaceCreateInfo -> IO ReferenceSpaceCreateInfo
forall a b. (a -> b) -> a -> b
$ ReferenceSpaceType -> Posef -> ReferenceSpaceCreateInfo
ReferenceSpaceCreateInfo
ReferenceSpaceType
referenceSpaceType Posef
poseInReferenceSpace
instance Storable ReferenceSpaceCreateInfo where
sizeOf :: ReferenceSpaceCreateInfo -> Int
sizeOf ~ReferenceSpaceCreateInfo
_ = 48
alignment :: ReferenceSpaceCreateInfo -> Int
alignment ~ReferenceSpaceCreateInfo
_ = 8
peek :: Ptr ReferenceSpaceCreateInfo -> IO ReferenceSpaceCreateInfo
peek = Ptr ReferenceSpaceCreateInfo -> IO ReferenceSpaceCreateInfo
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
poke :: Ptr ReferenceSpaceCreateInfo -> ReferenceSpaceCreateInfo -> IO ()
poke ptr :: Ptr ReferenceSpaceCreateInfo
ptr poked :: ReferenceSpaceCreateInfo
poked = Ptr ReferenceSpaceCreateInfo
-> ReferenceSpaceCreateInfo -> IO () -> IO ()
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr ReferenceSpaceCreateInfo
ptr ReferenceSpaceCreateInfo
poked (() -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())
instance Zero ReferenceSpaceCreateInfo where
zero :: ReferenceSpaceCreateInfo
zero = ReferenceSpaceType -> Posef -> ReferenceSpaceCreateInfo
ReferenceSpaceCreateInfo
ReferenceSpaceType
forall a. Zero a => a
zero
Posef
forall a. Zero a => a
zero
data ActionSpaceCreateInfo = ActionSpaceCreateInfo
{
ActionSpaceCreateInfo -> Ptr Action_T
action :: Ptr Action_T
,
ActionSpaceCreateInfo -> Path
subactionPath :: Path
,
ActionSpaceCreateInfo -> Posef
poseInActionSpace :: Posef
}
deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (ActionSpaceCreateInfo)
#endif
deriving instance Show ActionSpaceCreateInfo
instance ToCStruct ActionSpaceCreateInfo where
withCStruct :: ActionSpaceCreateInfo
-> (Ptr ActionSpaceCreateInfo -> IO b) -> IO b
withCStruct x :: ActionSpaceCreateInfo
x f :: Ptr ActionSpaceCreateInfo -> IO b
f = Int -> Int -> (Ptr ActionSpaceCreateInfo -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 64 8 ((Ptr ActionSpaceCreateInfo -> IO b) -> IO b)
-> (Ptr ActionSpaceCreateInfo -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: Ptr ActionSpaceCreateInfo
p -> Ptr ActionSpaceCreateInfo -> ActionSpaceCreateInfo -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr ActionSpaceCreateInfo
p ActionSpaceCreateInfo
x (Ptr ActionSpaceCreateInfo -> IO b
f Ptr ActionSpaceCreateInfo
p)
pokeCStruct :: Ptr ActionSpaceCreateInfo -> ActionSpaceCreateInfo -> IO b -> IO b
pokeCStruct p :: Ptr ActionSpaceCreateInfo
p ActionSpaceCreateInfo{..} f :: IO b
f = do
Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ActionSpaceCreateInfo
p Ptr ActionSpaceCreateInfo -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
TYPE_ACTION_SPACE_CREATE_INFO)
Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ActionSpaceCreateInfo
p Ptr ActionSpaceCreateInfo -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
Ptr (Ptr Action_T) -> Ptr Action_T -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ActionSpaceCreateInfo
p Ptr ActionSpaceCreateInfo -> Int -> Ptr (Ptr Action_T)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr (Ptr Action_T))) (Ptr Action_T
action)
Ptr Path -> Path -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ActionSpaceCreateInfo
p Ptr ActionSpaceCreateInfo -> Int -> Ptr Path
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr Path)) (Path
subactionPath)
Ptr Posef -> Posef -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ActionSpaceCreateInfo
p Ptr ActionSpaceCreateInfo -> Int -> Ptr Posef
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 32 :: Ptr Posef)) (Posef
poseInActionSpace)
IO b
f
cStructSize :: Int
cStructSize = 64
cStructAlignment :: Int
cStructAlignment = 8
pokeZeroCStruct :: Ptr ActionSpaceCreateInfo -> IO b -> IO b
pokeZeroCStruct p :: Ptr ActionSpaceCreateInfo
p f :: IO b
f = do
Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ActionSpaceCreateInfo
p Ptr ActionSpaceCreateInfo -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
TYPE_ACTION_SPACE_CREATE_INFO)
Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ActionSpaceCreateInfo
p Ptr ActionSpaceCreateInfo -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
Ptr (Ptr Action_T) -> Ptr Action_T -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ActionSpaceCreateInfo
p Ptr ActionSpaceCreateInfo -> Int -> Ptr (Ptr Action_T)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr (Ptr Action_T))) (Ptr Action_T
forall a. Zero a => a
zero)
Ptr Posef -> Posef -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ActionSpaceCreateInfo
p Ptr ActionSpaceCreateInfo -> Int -> Ptr Posef
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 32 :: Ptr Posef)) (Posef
forall a. Zero a => a
zero)
IO b
f
instance FromCStruct ActionSpaceCreateInfo where
peekCStruct :: Ptr ActionSpaceCreateInfo -> IO ActionSpaceCreateInfo
peekCStruct p :: Ptr ActionSpaceCreateInfo
p = do
Ptr Action_T
action <- Ptr (Ptr Action_T) -> IO (Ptr Action_T)
forall a. Storable a => Ptr a -> IO a
peek @(Ptr Action_T) ((Ptr ActionSpaceCreateInfo
p Ptr ActionSpaceCreateInfo -> Int -> Ptr (Ptr Action_T)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr (Ptr Action_T)))
Path
subactionPath <- Ptr Path -> IO Path
forall a. Storable a => Ptr a -> IO a
peek @Path ((Ptr ActionSpaceCreateInfo
p Ptr ActionSpaceCreateInfo -> Int -> Ptr Path
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr Path))
Posef
poseInActionSpace <- Ptr Posef -> IO Posef
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @Posef ((Ptr ActionSpaceCreateInfo
p Ptr ActionSpaceCreateInfo -> Int -> Ptr Posef
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 32 :: Ptr Posef))
ActionSpaceCreateInfo -> IO ActionSpaceCreateInfo
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ActionSpaceCreateInfo -> IO ActionSpaceCreateInfo)
-> ActionSpaceCreateInfo -> IO ActionSpaceCreateInfo
forall a b. (a -> b) -> a -> b
$ Ptr Action_T -> Path -> Posef -> ActionSpaceCreateInfo
ActionSpaceCreateInfo
Ptr Action_T
action Path
subactionPath Posef
poseInActionSpace
instance Storable ActionSpaceCreateInfo where
sizeOf :: ActionSpaceCreateInfo -> Int
sizeOf ~ActionSpaceCreateInfo
_ = 64
alignment :: ActionSpaceCreateInfo -> Int
alignment ~ActionSpaceCreateInfo
_ = 8
peek :: Ptr ActionSpaceCreateInfo -> IO ActionSpaceCreateInfo
peek = Ptr ActionSpaceCreateInfo -> IO ActionSpaceCreateInfo
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
poke :: Ptr ActionSpaceCreateInfo -> ActionSpaceCreateInfo -> IO ()
poke ptr :: Ptr ActionSpaceCreateInfo
ptr poked :: ActionSpaceCreateInfo
poked = Ptr ActionSpaceCreateInfo
-> ActionSpaceCreateInfo -> IO () -> IO ()
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr ActionSpaceCreateInfo
ptr ActionSpaceCreateInfo
poked (() -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())
instance Zero ActionSpaceCreateInfo where
zero :: ActionSpaceCreateInfo
zero = Ptr Action_T -> Path -> Posef -> ActionSpaceCreateInfo
ActionSpaceCreateInfo
Ptr Action_T
forall a. Zero a => a
zero
Path
forall a. Zero a => a
zero
Posef
forall a. Zero a => a
zero
data SpaceLocation (es :: [Type]) = SpaceLocation
{
SpaceLocation es -> Chain es
next :: Chain es
,
SpaceLocation es -> SpaceLocationFlags
locationFlags :: SpaceLocationFlags
,
SpaceLocation es -> Posef
pose :: Posef
}
deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (SpaceLocation (es :: [Type]))
#endif
deriving instance Show (Chain es) => Show (SpaceLocation es)
instance Extensible SpaceLocation where
extensibleTypeName :: String
extensibleTypeName = "SpaceLocation"
setNext :: SpaceLocation ds -> Chain es -> SpaceLocation es
setNext x :: SpaceLocation ds
x next :: Chain es
next = SpaceLocation ds
x{$sel:next:SpaceLocation :: Chain es
next = Chain es
next}
getNext :: SpaceLocation es -> Chain es
getNext SpaceLocation{..} = Chain es
next
extends :: forall e b proxy. Typeable e => proxy e -> (Extends SpaceLocation e => b) -> Maybe b
extends :: proxy e -> (Extends SpaceLocation e => b) -> Maybe b
extends _ f :: Extends SpaceLocation e => b
f
| Just Refl <- (Typeable e, Typeable EyeGazeSampleTimeEXT) =>
Maybe (e :~: EyeGazeSampleTimeEXT)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @EyeGazeSampleTimeEXT = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends SpaceLocation e => b
f
| Just Refl <- (Typeable e, Typeable SpaceVelocity) => Maybe (e :~: SpaceVelocity)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @SpaceVelocity = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends SpaceLocation e => b
f
| Bool
otherwise = Maybe b
forall a. Maybe a
Nothing
instance (Extendss SpaceLocation es, PokeChain es) => ToCStruct (SpaceLocation es) where
withCStruct :: SpaceLocation es -> (Ptr (SpaceLocation es) -> IO b) -> IO b
withCStruct x :: SpaceLocation es
x f :: Ptr (SpaceLocation es) -> IO b
f = Int -> Int -> (Ptr (SpaceLocation es) -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 48 8 ((Ptr (SpaceLocation es) -> IO b) -> IO b)
-> (Ptr (SpaceLocation es) -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: Ptr (SpaceLocation es)
p -> Ptr (SpaceLocation es) -> SpaceLocation es -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr (SpaceLocation es)
p SpaceLocation es
x (Ptr (SpaceLocation es) -> IO b
f Ptr (SpaceLocation es)
p)
pokeCStruct :: Ptr (SpaceLocation es) -> SpaceLocation es -> IO b -> IO b
pokeCStruct p :: Ptr (SpaceLocation es)
p SpaceLocation{..} f :: IO b
f = ContT b IO b -> IO b
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT b IO b -> IO b) -> ContT b IO b -> IO b
forall a b. (a -> b) -> a -> b
$ do
IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (SpaceLocation es)
p Ptr (SpaceLocation es) -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
TYPE_SPACE_LOCATION)
Ptr ()
next'' <- (Ptr (Chain es) -> Ptr ())
-> ContT b IO (Ptr (Chain es)) -> ContT b IO (Ptr ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Ptr (Chain es) -> Ptr ()
forall a b. Ptr a -> Ptr b
castPtr (ContT b IO (Ptr (Chain es)) -> ContT b IO (Ptr ()))
-> (((Ptr (Chain es) -> IO b) -> IO b)
-> ContT b IO (Ptr (Chain es)))
-> ((Ptr (Chain es) -> IO b) -> IO b)
-> ContT b IO (Ptr ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Ptr (Chain es) -> IO b) -> IO b) -> ContT b IO (Ptr (Chain es))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr (Chain es) -> IO b) -> IO b) -> ContT b IO (Ptr ()))
-> ((Ptr (Chain es) -> IO b) -> IO b) -> ContT b IO (Ptr ())
forall a b. (a -> b) -> a -> b
$ Chain es -> (Ptr (Chain es) -> IO b) -> IO b
forall (es :: [*]) a.
PokeChain es =>
Chain es -> (Ptr (Chain es) -> IO a) -> IO a
withChain (Chain es
next)
IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (SpaceLocation es)
p Ptr (SpaceLocation es) -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) Ptr ()
next''
IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr SpaceLocationFlags -> SpaceLocationFlags -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (SpaceLocation es)
p Ptr (SpaceLocation es) -> Int -> Ptr SpaceLocationFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr SpaceLocationFlags)) (SpaceLocationFlags
locationFlags)
IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr Posef -> Posef -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (SpaceLocation es)
p Ptr (SpaceLocation es) -> Int -> Ptr Posef
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 20 :: Ptr Posef)) (Posef
pose)
IO b -> ContT b IO b
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO b -> ContT b IO b) -> IO b -> ContT b IO b
forall a b. (a -> b) -> a -> b
$ IO b
f
cStructSize :: Int
cStructSize = 48
cStructAlignment :: Int
cStructAlignment = 8
pokeZeroCStruct :: Ptr (SpaceLocation es) -> IO b -> IO b
pokeZeroCStruct p :: Ptr (SpaceLocation es)
p f :: IO b
f = ContT b IO b -> IO b
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT b IO b -> IO b) -> ContT b IO b -> IO b
forall a b. (a -> b) -> a -> b
$ do
IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (SpaceLocation es)
p Ptr (SpaceLocation es) -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
TYPE_SPACE_LOCATION)
Ptr ()
pNext' <- (Ptr (Chain es) -> Ptr ())
-> ContT b IO (Ptr (Chain es)) -> ContT b IO (Ptr ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Ptr (Chain es) -> Ptr ()
forall a b. Ptr a -> Ptr b
castPtr (ContT b IO (Ptr (Chain es)) -> ContT b IO (Ptr ()))
-> (((Ptr (Chain es) -> IO b) -> IO b)
-> ContT b IO (Ptr (Chain es)))
-> ((Ptr (Chain es) -> IO b) -> IO b)
-> ContT b IO (Ptr ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Ptr (Chain es) -> IO b) -> IO b) -> ContT b IO (Ptr (Chain es))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr (Chain es) -> IO b) -> IO b) -> ContT b IO (Ptr ()))
-> ((Ptr (Chain es) -> IO b) -> IO b) -> ContT b IO (Ptr ())
forall a b. (a -> b) -> a -> b
$ forall a. PokeChain es => (Ptr (Chain es) -> IO a) -> IO a
forall (es :: [*]) a.
PokeChain es =>
(Ptr (Chain es) -> IO a) -> IO a
withZeroChain @es
IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (SpaceLocation es)
p Ptr (SpaceLocation es) -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) Ptr ()
pNext'
IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr Posef -> Posef -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (SpaceLocation es)
p Ptr (SpaceLocation es) -> Int -> Ptr Posef
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 20 :: Ptr Posef)) (Posef
forall a. Zero a => a
zero)
IO b -> ContT b IO b
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO b -> ContT b IO b) -> IO b -> ContT b IO b
forall a b. (a -> b) -> a -> b
$ IO b
f
instance (Extendss SpaceLocation es, PeekChain es) => FromCStruct (SpaceLocation es) where
peekCStruct :: Ptr (SpaceLocation es) -> IO (SpaceLocation es)
peekCStruct p :: Ptr (SpaceLocation es)
p = do
Ptr ()
next <- Ptr (Ptr ()) -> IO (Ptr ())
forall a. Storable a => Ptr a -> IO a
peek @(Ptr ()) ((Ptr (SpaceLocation es)
p Ptr (SpaceLocation es) -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ())))
Chain es
next' <- Ptr (Chain es) -> IO (Chain es)
forall (es :: [*]). PeekChain es => Ptr (Chain es) -> IO (Chain es)
peekChain (Ptr () -> Ptr (Chain es)
forall a b. Ptr a -> Ptr b
castPtr Ptr ()
next)
SpaceLocationFlags
locationFlags <- Ptr SpaceLocationFlags -> IO SpaceLocationFlags
forall a. Storable a => Ptr a -> IO a
peek @SpaceLocationFlags ((Ptr (SpaceLocation es)
p Ptr (SpaceLocation es) -> Int -> Ptr SpaceLocationFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr SpaceLocationFlags))
Posef
pose <- Ptr Posef -> IO Posef
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @Posef ((Ptr (SpaceLocation es)
p Ptr (SpaceLocation es) -> Int -> Ptr Posef
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 20 :: Ptr Posef))
SpaceLocation es -> IO (SpaceLocation es)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SpaceLocation es -> IO (SpaceLocation es))
-> SpaceLocation es -> IO (SpaceLocation es)
forall a b. (a -> b) -> a -> b
$ Chain es -> SpaceLocationFlags -> Posef -> SpaceLocation es
forall (es :: [*]).
Chain es -> SpaceLocationFlags -> Posef -> SpaceLocation es
SpaceLocation
Chain es
next' SpaceLocationFlags
locationFlags Posef
pose
instance es ~ '[] => Zero (SpaceLocation es) where
zero :: SpaceLocation es
zero = Chain es -> SpaceLocationFlags -> Posef -> SpaceLocation es
forall (es :: [*]).
Chain es -> SpaceLocationFlags -> Posef -> SpaceLocation es
SpaceLocation
()
SpaceLocationFlags
forall a. Zero a => a
zero
Posef
forall a. Zero a => a
zero
data SpaceVelocity = SpaceVelocity
{
SpaceVelocity -> SpaceVelocityFlags
velocityFlags :: SpaceVelocityFlags
,
SpaceVelocity -> Vector3f
linearVelocity :: Vector3f
,
SpaceVelocity -> Vector3f
angularVelocity :: Vector3f
}
deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (SpaceVelocity)
#endif
deriving instance Show SpaceVelocity
instance ToCStruct SpaceVelocity where
withCStruct :: SpaceVelocity -> (Ptr SpaceVelocity -> IO b) -> IO b
withCStruct x :: SpaceVelocity
x f :: Ptr SpaceVelocity -> IO b
f = Int -> Int -> (Ptr SpaceVelocity -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 48 8 ((Ptr SpaceVelocity -> IO b) -> IO b)
-> (Ptr SpaceVelocity -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: Ptr SpaceVelocity
p -> Ptr SpaceVelocity -> SpaceVelocity -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr SpaceVelocity
p SpaceVelocity
x (Ptr SpaceVelocity -> IO b
f Ptr SpaceVelocity
p)
pokeCStruct :: Ptr SpaceVelocity -> SpaceVelocity -> IO b -> IO b
pokeCStruct p :: Ptr SpaceVelocity
p SpaceVelocity{..} f :: IO b
f = do
Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SpaceVelocity
p Ptr SpaceVelocity -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
TYPE_SPACE_VELOCITY)
Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SpaceVelocity
p Ptr SpaceVelocity -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
Ptr SpaceVelocityFlags -> SpaceVelocityFlags -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SpaceVelocity
p Ptr SpaceVelocity -> Int -> Ptr SpaceVelocityFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr SpaceVelocityFlags)) (SpaceVelocityFlags
velocityFlags)
Ptr Vector3f -> Vector3f -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SpaceVelocity
p Ptr SpaceVelocity -> Int -> Ptr Vector3f
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 20 :: Ptr Vector3f)) (Vector3f
linearVelocity)
Ptr Vector3f -> Vector3f -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SpaceVelocity
p Ptr SpaceVelocity -> Int -> Ptr Vector3f
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 32 :: Ptr Vector3f)) (Vector3f
angularVelocity)
IO b
f
cStructSize :: Int
cStructSize = 48
cStructAlignment :: Int
cStructAlignment = 8
pokeZeroCStruct :: Ptr SpaceVelocity -> IO b -> IO b
pokeZeroCStruct p :: Ptr SpaceVelocity
p f :: IO b
f = do
Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SpaceVelocity
p Ptr SpaceVelocity -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
TYPE_SPACE_VELOCITY)
Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SpaceVelocity
p Ptr SpaceVelocity -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
Ptr Vector3f -> Vector3f -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SpaceVelocity
p Ptr SpaceVelocity -> Int -> Ptr Vector3f
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 20 :: Ptr Vector3f)) (Vector3f
forall a. Zero a => a
zero)
Ptr Vector3f -> Vector3f -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SpaceVelocity
p Ptr SpaceVelocity -> Int -> Ptr Vector3f
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 32 :: Ptr Vector3f)) (Vector3f
forall a. Zero a => a
zero)
IO b
f
instance FromCStruct SpaceVelocity where
peekCStruct :: Ptr SpaceVelocity -> IO SpaceVelocity
peekCStruct p :: Ptr SpaceVelocity
p = do
SpaceVelocityFlags
velocityFlags <- Ptr SpaceVelocityFlags -> IO SpaceVelocityFlags
forall a. Storable a => Ptr a -> IO a
peek @SpaceVelocityFlags ((Ptr SpaceVelocity
p Ptr SpaceVelocity -> Int -> Ptr SpaceVelocityFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr SpaceVelocityFlags))
Vector3f
linearVelocity <- Ptr Vector3f -> IO Vector3f
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @Vector3f ((Ptr SpaceVelocity
p Ptr SpaceVelocity -> Int -> Ptr Vector3f
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 20 :: Ptr Vector3f))
Vector3f
angularVelocity <- Ptr Vector3f -> IO Vector3f
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @Vector3f ((Ptr SpaceVelocity
p Ptr SpaceVelocity -> Int -> Ptr Vector3f
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 32 :: Ptr Vector3f))
SpaceVelocity -> IO SpaceVelocity
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SpaceVelocity -> IO SpaceVelocity)
-> SpaceVelocity -> IO SpaceVelocity
forall a b. (a -> b) -> a -> b
$ SpaceVelocityFlags -> Vector3f -> Vector3f -> SpaceVelocity
SpaceVelocity
SpaceVelocityFlags
velocityFlags Vector3f
linearVelocity Vector3f
angularVelocity
instance Storable SpaceVelocity where
sizeOf :: SpaceVelocity -> Int
sizeOf ~SpaceVelocity
_ = 48
alignment :: SpaceVelocity -> Int
alignment ~SpaceVelocity
_ = 8
peek :: Ptr SpaceVelocity -> IO SpaceVelocity
peek = Ptr SpaceVelocity -> IO SpaceVelocity
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
poke :: Ptr SpaceVelocity -> SpaceVelocity -> IO ()
poke ptr :: Ptr SpaceVelocity
ptr poked :: SpaceVelocity
poked = Ptr SpaceVelocity -> SpaceVelocity -> IO () -> IO ()
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr SpaceVelocity
ptr SpaceVelocity
poked (() -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())
instance Zero SpaceVelocity where
zero :: SpaceVelocity
zero = SpaceVelocityFlags -> Vector3f -> Vector3f -> SpaceVelocity
SpaceVelocity
SpaceVelocityFlags
forall a. Zero a => a
zero
Vector3f
forall a. Zero a => a
zero
Vector3f
forall a. Zero a => a
zero