{-# language CPP #-}
module OpenXR.Extensions.XR_MSFT_perception_anchor_interop ( createSpatialAnchorFromPerceptionAnchorMSFT
, withSpatialAnchorFromPerceptionAnchorMSFT
, tryGetPerceptionAnchorFromSpatialAnchorMSFT
, MSFT_perception_anchor_interop_SPEC_VERSION
, pattern MSFT_perception_anchor_interop_SPEC_VERSION
, MSFT_PERCEPTION_ANCHOR_INTEROP_EXTENSION_NAME
, pattern MSFT_PERCEPTION_ANCHOR_INTEROP_EXTENSION_NAME
, IUnknown
, SpatialAnchorMSFT(..)
, destroySpatialAnchorMSFT
) where
import OpenXR.Internal.Utils (traceAroundEvent)
import Control.Exception.Base (bracket)
import Control.Monad (unless)
import Control.Monad.IO.Class (liftIO)
import Foreign.Marshal.Alloc (callocBytes)
import Foreign.Marshal.Alloc (free)
import GHC.Base (when)
import GHC.IO (throwIO)
import GHC.Ptr (nullFunPtr)
import Control.Monad.Trans.Class (lift)
import Control.Monad.Trans.Cont (evalContT)
import Control.Monad.IO.Class (MonadIO)
import Data.String (IsString)
import Foreign.Storable (Storable(peek))
import GHC.IO.Exception (IOErrorType(..))
import GHC.IO.Exception (IOException(..))
import Foreign.Ptr (FunPtr)
import Foreign.Ptr (Ptr)
import Control.Monad.Trans.Cont (ContT(..))
import OpenXR.Extensions.XR_MSFT_spatial_anchor (destroySpatialAnchorMSFT)
import OpenXR.NamedType ((:::))
import OpenXR.Dynamic (InstanceCmds(pXrCreateSpatialAnchorFromPerceptionAnchorMSFT))
import OpenXR.Dynamic (InstanceCmds(pXrTryGetPerceptionAnchorFromSpatialAnchorMSFT))
import OpenXR.Exception (OpenXrException(..))
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.Extensions.Handles (SpatialAnchorMSFT)
import OpenXR.Extensions.Handles (SpatialAnchorMSFT(..))
import OpenXR.Extensions.Handles (SpatialAnchorMSFT(SpatialAnchorMSFT))
import OpenXR.Extensions.Handles (SpatialAnchorMSFT_T)
import OpenXR.Core10.Enums.Result (Result(SUCCESS))
import OpenXR.Extensions.XR_MSFT_spatial_anchor (destroySpatialAnchorMSFT)
import OpenXR.Extensions.Handles (SpatialAnchorMSFT(..))
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkXrCreateSpatialAnchorFromPerceptionAnchorMSFT
:: FunPtr (Ptr Session_T -> Ptr IUnknown -> Ptr (Ptr SpatialAnchorMSFT_T) -> IO Result) -> Ptr Session_T -> Ptr IUnknown -> Ptr (Ptr SpatialAnchorMSFT_T) -> IO Result
createSpatialAnchorFromPerceptionAnchorMSFT :: forall io
. (MonadIO io)
=>
Session
->
("perceptionAnchor" ::: Ptr IUnknown)
-> io (SpatialAnchorMSFT)
createSpatialAnchorFromPerceptionAnchorMSFT :: Session
-> ("perceptionAnchor" ::: Ptr IUnknown) -> io SpatialAnchorMSFT
createSpatialAnchorFromPerceptionAnchorMSFT session :: Session
session perceptionAnchor :: "perceptionAnchor" ::: Ptr IUnknown
perceptionAnchor = IO SpatialAnchorMSFT -> io SpatialAnchorMSFT
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SpatialAnchorMSFT -> io SpatialAnchorMSFT)
-> (ContT SpatialAnchorMSFT IO SpatialAnchorMSFT
-> IO SpatialAnchorMSFT)
-> ContT SpatialAnchorMSFT IO SpatialAnchorMSFT
-> io SpatialAnchorMSFT
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT SpatialAnchorMSFT IO SpatialAnchorMSFT
-> IO SpatialAnchorMSFT
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT SpatialAnchorMSFT IO SpatialAnchorMSFT
-> io SpatialAnchorMSFT)
-> ContT SpatialAnchorMSFT IO SpatialAnchorMSFT
-> io SpatialAnchorMSFT
forall a b. (a -> b) -> a -> b
$ do
let cmds :: InstanceCmds
cmds = Session -> InstanceCmds
instanceCmds (Session
session :: Session)
let xrCreateSpatialAnchorFromPerceptionAnchorMSFTPtr :: FunPtr
(Ptr Session_T
-> ("perceptionAnchor" ::: Ptr IUnknown)
-> ("anchor" ::: Ptr (Ptr SpatialAnchorMSFT_T))
-> IO Result)
xrCreateSpatialAnchorFromPerceptionAnchorMSFTPtr = InstanceCmds
-> FunPtr
(Ptr Session_T
-> ("perceptionAnchor" ::: Ptr IUnknown)
-> ("anchor" ::: Ptr (Ptr SpatialAnchorMSFT_T))
-> IO Result)
pXrCreateSpatialAnchorFromPerceptionAnchorMSFT InstanceCmds
cmds
IO () -> ContT SpatialAnchorMSFT IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT SpatialAnchorMSFT IO ())
-> IO () -> ContT SpatialAnchorMSFT IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
(Ptr Session_T
-> ("perceptionAnchor" ::: Ptr IUnknown)
-> ("anchor" ::: Ptr (Ptr SpatialAnchorMSFT_T))
-> IO Result)
xrCreateSpatialAnchorFromPerceptionAnchorMSFTPtr FunPtr
(Ptr Session_T
-> ("perceptionAnchor" ::: Ptr IUnknown)
-> ("anchor" ::: Ptr (Ptr SpatialAnchorMSFT_T))
-> IO Result)
-> FunPtr
(Ptr Session_T
-> ("perceptionAnchor" ::: Ptr IUnknown)
-> ("anchor" ::: Ptr (Ptr SpatialAnchorMSFT_T))
-> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
(Ptr Session_T
-> ("perceptionAnchor" ::: Ptr IUnknown)
-> ("anchor" ::: Ptr (Ptr SpatialAnchorMSFT_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 xrCreateSpatialAnchorFromPerceptionAnchorMSFT is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
let xrCreateSpatialAnchorFromPerceptionAnchorMSFT' :: Ptr Session_T
-> ("perceptionAnchor" ::: Ptr IUnknown)
-> ("anchor" ::: Ptr (Ptr SpatialAnchorMSFT_T))
-> IO Result
xrCreateSpatialAnchorFromPerceptionAnchorMSFT' = FunPtr
(Ptr Session_T
-> ("perceptionAnchor" ::: Ptr IUnknown)
-> ("anchor" ::: Ptr (Ptr SpatialAnchorMSFT_T))
-> IO Result)
-> Ptr Session_T
-> ("perceptionAnchor" ::: Ptr IUnknown)
-> ("anchor" ::: Ptr (Ptr SpatialAnchorMSFT_T))
-> IO Result
mkXrCreateSpatialAnchorFromPerceptionAnchorMSFT FunPtr
(Ptr Session_T
-> ("perceptionAnchor" ::: Ptr IUnknown)
-> ("anchor" ::: Ptr (Ptr SpatialAnchorMSFT_T))
-> IO Result)
xrCreateSpatialAnchorFromPerceptionAnchorMSFTPtr
"anchor" ::: Ptr (Ptr SpatialAnchorMSFT_T)
pAnchor <- ((("anchor" ::: Ptr (Ptr SpatialAnchorMSFT_T))
-> IO SpatialAnchorMSFT)
-> IO SpatialAnchorMSFT)
-> ContT
SpatialAnchorMSFT IO ("anchor" ::: Ptr (Ptr SpatialAnchorMSFT_T))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("anchor" ::: Ptr (Ptr SpatialAnchorMSFT_T))
-> IO SpatialAnchorMSFT)
-> IO SpatialAnchorMSFT)
-> ContT
SpatialAnchorMSFT IO ("anchor" ::: Ptr (Ptr SpatialAnchorMSFT_T)))
-> ((("anchor" ::: Ptr (Ptr SpatialAnchorMSFT_T))
-> IO SpatialAnchorMSFT)
-> IO SpatialAnchorMSFT)
-> ContT
SpatialAnchorMSFT IO ("anchor" ::: Ptr (Ptr SpatialAnchorMSFT_T))
forall a b. (a -> b) -> a -> b
$ IO ("anchor" ::: Ptr (Ptr SpatialAnchorMSFT_T))
-> (("anchor" ::: Ptr (Ptr SpatialAnchorMSFT_T)) -> IO ())
-> (("anchor" ::: Ptr (Ptr SpatialAnchorMSFT_T))
-> IO SpatialAnchorMSFT)
-> IO SpatialAnchorMSFT
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO ("anchor" ::: Ptr (Ptr SpatialAnchorMSFT_T))
forall a. Int -> IO (Ptr a)
callocBytes @(Ptr SpatialAnchorMSFT_T) 8) ("anchor" ::: Ptr (Ptr SpatialAnchorMSFT_T)) -> IO ()
forall a. Ptr a -> IO ()
free
Result
r <- IO Result -> ContT SpatialAnchorMSFT IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT SpatialAnchorMSFT IO Result)
-> IO Result -> ContT SpatialAnchorMSFT IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent "xrCreateSpatialAnchorFromPerceptionAnchorMSFT" (Ptr Session_T
-> ("perceptionAnchor" ::: Ptr IUnknown)
-> ("anchor" ::: Ptr (Ptr SpatialAnchorMSFT_T))
-> IO Result
xrCreateSpatialAnchorFromPerceptionAnchorMSFT' (Session -> Ptr Session_T
sessionHandle (Session
session)) ("perceptionAnchor" ::: Ptr IUnknown
perceptionAnchor) ("anchor" ::: Ptr (Ptr SpatialAnchorMSFT_T)
pAnchor))
IO () -> ContT SpatialAnchorMSFT IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT SpatialAnchorMSFT IO ())
-> IO () -> ContT SpatialAnchorMSFT 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 SpatialAnchorMSFT_T
anchor <- IO (Ptr SpatialAnchorMSFT_T)
-> ContT SpatialAnchorMSFT IO (Ptr SpatialAnchorMSFT_T)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO (Ptr SpatialAnchorMSFT_T)
-> ContT SpatialAnchorMSFT IO (Ptr SpatialAnchorMSFT_T))
-> IO (Ptr SpatialAnchorMSFT_T)
-> ContT SpatialAnchorMSFT IO (Ptr SpatialAnchorMSFT_T)
forall a b. (a -> b) -> a -> b
$ ("anchor" ::: Ptr (Ptr SpatialAnchorMSFT_T))
-> IO (Ptr SpatialAnchorMSFT_T)
forall a. Storable a => Ptr a -> IO a
peek @(Ptr SpatialAnchorMSFT_T) "anchor" ::: Ptr (Ptr SpatialAnchorMSFT_T)
pAnchor
SpatialAnchorMSFT -> ContT SpatialAnchorMSFT IO SpatialAnchorMSFT
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SpatialAnchorMSFT -> ContT SpatialAnchorMSFT IO SpatialAnchorMSFT)
-> SpatialAnchorMSFT
-> ContT SpatialAnchorMSFT IO SpatialAnchorMSFT
forall a b. (a -> b) -> a -> b
$ (((\h :: Ptr SpatialAnchorMSFT_T
h -> Ptr SpatialAnchorMSFT_T -> InstanceCmds -> SpatialAnchorMSFT
SpatialAnchorMSFT Ptr SpatialAnchorMSFT_T
h InstanceCmds
cmds ) Ptr SpatialAnchorMSFT_T
anchor))
withSpatialAnchorFromPerceptionAnchorMSFT :: forall io r . MonadIO io => Session -> Ptr IUnknown -> (io SpatialAnchorMSFT -> (SpatialAnchorMSFT -> io ()) -> r) -> r
withSpatialAnchorFromPerceptionAnchorMSFT :: Session
-> ("perceptionAnchor" ::: Ptr IUnknown)
-> (io SpatialAnchorMSFT -> (SpatialAnchorMSFT -> io ()) -> r)
-> r
withSpatialAnchorFromPerceptionAnchorMSFT session :: Session
session perceptionAnchor :: "perceptionAnchor" ::: Ptr IUnknown
perceptionAnchor b :: io SpatialAnchorMSFT -> (SpatialAnchorMSFT -> io ()) -> r
b =
io SpatialAnchorMSFT -> (SpatialAnchorMSFT -> io ()) -> r
b (Session
-> ("perceptionAnchor" ::: Ptr IUnknown) -> io SpatialAnchorMSFT
forall (io :: * -> *).
MonadIO io =>
Session
-> ("perceptionAnchor" ::: Ptr IUnknown) -> io SpatialAnchorMSFT
createSpatialAnchorFromPerceptionAnchorMSFT Session
session "perceptionAnchor" ::: Ptr IUnknown
perceptionAnchor)
(\(SpatialAnchorMSFT
o0) -> SpatialAnchorMSFT -> io ()
forall (io :: * -> *). MonadIO io => SpatialAnchorMSFT -> io ()
destroySpatialAnchorMSFT SpatialAnchorMSFT
o0)
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkXrTryGetPerceptionAnchorFromSpatialAnchorMSFT
:: FunPtr (Ptr Session_T -> Ptr SpatialAnchorMSFT_T -> Ptr (Ptr IUnknown) -> IO Result) -> Ptr Session_T -> Ptr SpatialAnchorMSFT_T -> Ptr (Ptr IUnknown) -> IO Result
tryGetPerceptionAnchorFromSpatialAnchorMSFT :: forall io
. (MonadIO io)
=>
Session
->
SpatialAnchorMSFT
-> io (("perceptionAnchor" ::: Ptr IUnknown))
tryGetPerceptionAnchorFromSpatialAnchorMSFT :: Session
-> SpatialAnchorMSFT -> io ("perceptionAnchor" ::: Ptr IUnknown)
tryGetPerceptionAnchorFromSpatialAnchorMSFT session :: Session
session anchor :: SpatialAnchorMSFT
anchor = IO ("perceptionAnchor" ::: Ptr IUnknown)
-> io ("perceptionAnchor" ::: Ptr IUnknown)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ("perceptionAnchor" ::: Ptr IUnknown)
-> io ("perceptionAnchor" ::: Ptr IUnknown))
-> (ContT
("perceptionAnchor" ::: Ptr IUnknown)
IO
("perceptionAnchor" ::: Ptr IUnknown)
-> IO ("perceptionAnchor" ::: Ptr IUnknown))
-> ContT
("perceptionAnchor" ::: Ptr IUnknown)
IO
("perceptionAnchor" ::: Ptr IUnknown)
-> io ("perceptionAnchor" ::: Ptr IUnknown)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT
("perceptionAnchor" ::: Ptr IUnknown)
IO
("perceptionAnchor" ::: Ptr IUnknown)
-> IO ("perceptionAnchor" ::: Ptr IUnknown)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT
("perceptionAnchor" ::: Ptr IUnknown)
IO
("perceptionAnchor" ::: Ptr IUnknown)
-> io ("perceptionAnchor" ::: Ptr IUnknown))
-> ContT
("perceptionAnchor" ::: Ptr IUnknown)
IO
("perceptionAnchor" ::: Ptr IUnknown)
-> io ("perceptionAnchor" ::: Ptr IUnknown)
forall a b. (a -> b) -> a -> b
$ do
let xrTryGetPerceptionAnchorFromSpatialAnchorMSFTPtr :: FunPtr
(Ptr Session_T
-> Ptr SpatialAnchorMSFT_T
-> ("perceptionAnchor"
::: Ptr ("perceptionAnchor" ::: Ptr IUnknown))
-> IO Result)
xrTryGetPerceptionAnchorFromSpatialAnchorMSFTPtr = InstanceCmds
-> FunPtr
(Ptr Session_T
-> Ptr SpatialAnchorMSFT_T
-> ("perceptionAnchor"
::: Ptr ("perceptionAnchor" ::: Ptr IUnknown))
-> IO Result)
pXrTryGetPerceptionAnchorFromSpatialAnchorMSFT (Session -> InstanceCmds
instanceCmds (Session
session :: Session))
IO () -> ContT ("perceptionAnchor" ::: Ptr IUnknown) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT ("perceptionAnchor" ::: Ptr IUnknown) IO ())
-> IO () -> ContT ("perceptionAnchor" ::: Ptr IUnknown) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
(Ptr Session_T
-> Ptr SpatialAnchorMSFT_T
-> ("perceptionAnchor"
::: Ptr ("perceptionAnchor" ::: Ptr IUnknown))
-> IO Result)
xrTryGetPerceptionAnchorFromSpatialAnchorMSFTPtr FunPtr
(Ptr Session_T
-> Ptr SpatialAnchorMSFT_T
-> ("perceptionAnchor"
::: Ptr ("perceptionAnchor" ::: Ptr IUnknown))
-> IO Result)
-> FunPtr
(Ptr Session_T
-> Ptr SpatialAnchorMSFT_T
-> ("perceptionAnchor"
::: Ptr ("perceptionAnchor" ::: Ptr IUnknown))
-> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
(Ptr Session_T
-> Ptr SpatialAnchorMSFT_T
-> ("perceptionAnchor"
::: Ptr ("perceptionAnchor" ::: Ptr IUnknown))
-> 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 xrTryGetPerceptionAnchorFromSpatialAnchorMSFT is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
let xrTryGetPerceptionAnchorFromSpatialAnchorMSFT' :: Ptr Session_T
-> Ptr SpatialAnchorMSFT_T
-> ("perceptionAnchor"
::: Ptr ("perceptionAnchor" ::: Ptr IUnknown))
-> IO Result
xrTryGetPerceptionAnchorFromSpatialAnchorMSFT' = FunPtr
(Ptr Session_T
-> Ptr SpatialAnchorMSFT_T
-> ("perceptionAnchor"
::: Ptr ("perceptionAnchor" ::: Ptr IUnknown))
-> IO Result)
-> Ptr Session_T
-> Ptr SpatialAnchorMSFT_T
-> ("perceptionAnchor"
::: Ptr ("perceptionAnchor" ::: Ptr IUnknown))
-> IO Result
mkXrTryGetPerceptionAnchorFromSpatialAnchorMSFT FunPtr
(Ptr Session_T
-> Ptr SpatialAnchorMSFT_T
-> ("perceptionAnchor"
::: Ptr ("perceptionAnchor" ::: Ptr IUnknown))
-> IO Result)
xrTryGetPerceptionAnchorFromSpatialAnchorMSFTPtr
"perceptionAnchor" ::: Ptr ("perceptionAnchor" ::: Ptr IUnknown)
pPerceptionAnchor <- ((("perceptionAnchor"
::: Ptr ("perceptionAnchor" ::: Ptr IUnknown))
-> IO ("perceptionAnchor" ::: Ptr IUnknown))
-> IO ("perceptionAnchor" ::: Ptr IUnknown))
-> ContT
("perceptionAnchor" ::: Ptr IUnknown)
IO
("perceptionAnchor" ::: Ptr ("perceptionAnchor" ::: Ptr IUnknown))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("perceptionAnchor"
::: Ptr ("perceptionAnchor" ::: Ptr IUnknown))
-> IO ("perceptionAnchor" ::: Ptr IUnknown))
-> IO ("perceptionAnchor" ::: Ptr IUnknown))
-> ContT
("perceptionAnchor" ::: Ptr IUnknown)
IO
("perceptionAnchor" ::: Ptr ("perceptionAnchor" ::: Ptr IUnknown)))
-> ((("perceptionAnchor"
::: Ptr ("perceptionAnchor" ::: Ptr IUnknown))
-> IO ("perceptionAnchor" ::: Ptr IUnknown))
-> IO ("perceptionAnchor" ::: Ptr IUnknown))
-> ContT
("perceptionAnchor" ::: Ptr IUnknown)
IO
("perceptionAnchor" ::: Ptr ("perceptionAnchor" ::: Ptr IUnknown))
forall a b. (a -> b) -> a -> b
$ IO
("perceptionAnchor" ::: Ptr ("perceptionAnchor" ::: Ptr IUnknown))
-> (("perceptionAnchor"
::: Ptr ("perceptionAnchor" ::: Ptr IUnknown))
-> IO ())
-> (("perceptionAnchor"
::: Ptr ("perceptionAnchor" ::: Ptr IUnknown))
-> IO ("perceptionAnchor" ::: Ptr IUnknown))
-> IO ("perceptionAnchor" ::: Ptr IUnknown)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int
-> IO
("perceptionAnchor" ::: Ptr ("perceptionAnchor" ::: Ptr IUnknown))
forall a. Int -> IO (Ptr a)
callocBytes @(Ptr IUnknown) 8) ("perceptionAnchor" ::: Ptr ("perceptionAnchor" ::: Ptr IUnknown))
-> IO ()
forall a. Ptr a -> IO ()
free
Result
r <- IO Result -> ContT ("perceptionAnchor" ::: Ptr IUnknown) IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result
-> ContT ("perceptionAnchor" ::: Ptr IUnknown) IO Result)
-> IO Result
-> ContT ("perceptionAnchor" ::: Ptr IUnknown) IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent "xrTryGetPerceptionAnchorFromSpatialAnchorMSFT" (Ptr Session_T
-> Ptr SpatialAnchorMSFT_T
-> ("perceptionAnchor"
::: Ptr ("perceptionAnchor" ::: Ptr IUnknown))
-> IO Result
xrTryGetPerceptionAnchorFromSpatialAnchorMSFT' (Session -> Ptr Session_T
sessionHandle (Session
session)) (SpatialAnchorMSFT -> Ptr SpatialAnchorMSFT_T
spatialAnchorMSFTHandle (SpatialAnchorMSFT
anchor)) ("perceptionAnchor" ::: Ptr ("perceptionAnchor" ::: Ptr IUnknown)
pPerceptionAnchor))
IO () -> ContT ("perceptionAnchor" ::: Ptr IUnknown) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT ("perceptionAnchor" ::: Ptr IUnknown) IO ())
-> IO () -> ContT ("perceptionAnchor" ::: Ptr IUnknown) 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))
"perceptionAnchor" ::: Ptr IUnknown
perceptionAnchor <- IO ("perceptionAnchor" ::: Ptr IUnknown)
-> ContT
("perceptionAnchor" ::: Ptr IUnknown)
IO
("perceptionAnchor" ::: Ptr IUnknown)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ("perceptionAnchor" ::: Ptr IUnknown)
-> ContT
("perceptionAnchor" ::: Ptr IUnknown)
IO
("perceptionAnchor" ::: Ptr IUnknown))
-> IO ("perceptionAnchor" ::: Ptr IUnknown)
-> ContT
("perceptionAnchor" ::: Ptr IUnknown)
IO
("perceptionAnchor" ::: Ptr IUnknown)
forall a b. (a -> b) -> a -> b
$ ("perceptionAnchor" ::: Ptr ("perceptionAnchor" ::: Ptr IUnknown))
-> IO ("perceptionAnchor" ::: Ptr IUnknown)
forall a. Storable a => Ptr a -> IO a
peek @(Ptr IUnknown) "perceptionAnchor" ::: Ptr ("perceptionAnchor" ::: Ptr IUnknown)
pPerceptionAnchor
("perceptionAnchor" ::: Ptr IUnknown)
-> ContT
("perceptionAnchor" ::: Ptr IUnknown)
IO
("perceptionAnchor" ::: Ptr IUnknown)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (("perceptionAnchor" ::: Ptr IUnknown)
-> ContT
("perceptionAnchor" ::: Ptr IUnknown)
IO
("perceptionAnchor" ::: Ptr IUnknown))
-> ("perceptionAnchor" ::: Ptr IUnknown)
-> ContT
("perceptionAnchor" ::: Ptr IUnknown)
IO
("perceptionAnchor" ::: Ptr IUnknown)
forall a b. (a -> b) -> a -> b
$ ("perceptionAnchor" ::: Ptr IUnknown
perceptionAnchor)
type MSFT_perception_anchor_interop_SPEC_VERSION = 1
pattern MSFT_perception_anchor_interop_SPEC_VERSION :: forall a . Integral a => a
pattern $bMSFT_perception_anchor_interop_SPEC_VERSION :: a
$mMSFT_perception_anchor_interop_SPEC_VERSION :: forall r a. Integral a => a -> (Void# -> r) -> (Void# -> r) -> r
MSFT_perception_anchor_interop_SPEC_VERSION = 1
type MSFT_PERCEPTION_ANCHOR_INTEROP_EXTENSION_NAME = "XR_MSFT_perception_anchor_interop"
pattern MSFT_PERCEPTION_ANCHOR_INTEROP_EXTENSION_NAME :: forall a . (Eq a, IsString a) => a
pattern $bMSFT_PERCEPTION_ANCHOR_INTEROP_EXTENSION_NAME :: a
$mMSFT_PERCEPTION_ANCHOR_INTEROP_EXTENSION_NAME :: forall r a.
(Eq a, IsString a) =>
a -> (Void# -> r) -> (Void# -> r) -> r
MSFT_PERCEPTION_ANCHOR_INTEROP_EXTENSION_NAME = "XR_MSFT_perception_anchor_interop"
data IUnknown