{-# language CPP #-}
module OpenXR.Core10.Instance ( getInstanceProcAddr
, enumerateApiLayerProperties
, enumerateInstanceExtensionProperties
, createInstance
, withInstance
, destroyInstance
, resultToString
, structureTypeToString
, getInstanceProperties
, pollEvent
, ApiLayerProperties(..)
, ExtensionProperties(..)
, ApplicationInfo(..)
, InstanceCreateInfo(..)
, InstanceProperties(..)
, EventDataBuffer(..)
) where
import OpenXR.CStruct.Utils (FixedArray)
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 Foreign.Ptr (castFunPtr)
import GHC.Ptr (castPtr)
import GHC.Ptr (nullFunPtr)
import Foreign.Ptr (nullPtr)
import Foreign.Ptr (plusPtr)
import Data.ByteString (packCString)
import Data.ByteString (useAsCString)
import Control.Monad.Trans.Class (lift)
import Control.Monad.Trans.Cont (evalContT)
import Data.Vector (generateM)
import qualified Data.Vector (imapM_)
import qualified Data.Vector (length)
import Foreign.C.Types (CChar(..))
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 (CChar)
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 GHC.Ptr (Ptr(Ptr))
import Data.Word (Word32)
import Data.Word (Word8)
import Data.ByteString (ByteString)
import Data.Kind (Type)
import Control.Monad.Trans.Cont (ContT(..))
import Data.Vector (Vector)
import OpenXR.CStruct.Utils (advancePtrBytes)
import OpenXR.CStruct.Utils (callocFixedArray)
import OpenXR.CStruct.Extends (forgetExtensions)
import OpenXR.Dynamic (getInstanceProcAddr')
import OpenXR.Dynamic (initInstanceCmds)
import OpenXR.CStruct.Utils (lowerArrayPtr)
import OpenXR.CStruct.Utils (peekByteStringFromSizedVectorPtr)
import OpenXR.CStruct.Utils (pokeFixedLengthByteString)
import OpenXR.CStruct.Utils (pokeFixedLengthNullTerminatedByteString)
import OpenXR.NamedType ((:::))
import OpenXR.CStruct.Extends (Chain)
import {-# SOURCE #-} OpenXR.Extensions.XR_EXT_debug_utils (DebugUtilsMessengerCreateInfoEXT)
import OpenXR.CStruct.Extends (Extends)
import OpenXR.CStruct.Extends (Extendss)
import OpenXR.CStruct.Extends (Extensible(..))
import OpenXR.Core10.Handles (Instance)
import OpenXR.Core10.Handles (Instance(..))
import OpenXR.Core10.Handles (Instance(Instance))
import OpenXR.Dynamic (InstanceCmds(pXrDestroyInstance))
import OpenXR.Dynamic (InstanceCmds(pXrGetInstanceProcAddr))
import OpenXR.Dynamic (InstanceCmds(pXrGetInstanceProperties))
import OpenXR.Dynamic (InstanceCmds(pXrPollEvent))
import OpenXR.Dynamic (InstanceCmds(pXrResultToString))
import OpenXR.Dynamic (InstanceCmds(pXrStructureTypeToString))
import OpenXR.Core10.Enums.InstanceCreateFlags (InstanceCreateFlags)
import {-# SOURCE #-} OpenXR.Extensions.XR_KHR_android_create_instance (InstanceCreateInfoAndroidKHR)
import OpenXR.Core10.Handles (Instance_T)
import OpenXR.Core10.APIConstants (MAX_API_LAYER_DESCRIPTION_SIZE)
import OpenXR.Core10.APIConstants (MAX_API_LAYER_NAME_SIZE)
import OpenXR.Core10.APIConstants (MAX_APPLICATION_NAME_SIZE)
import OpenXR.Core10.APIConstants (MAX_ENGINE_NAME_SIZE)
import OpenXR.Core10.APIConstants (MAX_EXTENSION_NAME_SIZE)
import OpenXR.Core10.APIConstants (MAX_RESULT_STRING_SIZE)
import OpenXR.Core10.APIConstants (MAX_RUNTIME_NAME_SIZE)
import OpenXR.Core10.APIConstants (MAX_STRUCTURE_NAME_SIZE)
import OpenXR.Exception (OpenXrException(..))
import OpenXR.Core10.FuncPointers (PFN_xrVoidFunction)
import OpenXR.CStruct.Extends (PeekChain)
import OpenXR.CStruct.Extends (PeekChain(..))
import OpenXR.CStruct.Extends (PokeChain)
import OpenXR.CStruct.Extends (PokeChain(..))
import OpenXR.Core10.Enums.Result (Result)
import OpenXR.Core10.Enums.Result (Result(..))
import OpenXR.CStruct.Extends (SomeStruct)
import OpenXR.Core10.Enums.StructureType (StructureType)
import OpenXR.Core10.Enums.StructureType (StructureType(..))
import OpenXR.Version (Version)
import OpenXR.Core10.APIConstants (pattern MAX_RESULT_STRING_SIZE)
import OpenXR.Core10.APIConstants (pattern MAX_STRUCTURE_NAME_SIZE)
import OpenXR.Core10.Enums.Result (Result(SUCCESS))
import OpenXR.Core10.Enums.StructureType (StructureType(TYPE_API_LAYER_PROPERTIES))
import OpenXR.Core10.Enums.StructureType (StructureType(TYPE_EVENT_DATA_BUFFER))
import OpenXR.Core10.Enums.StructureType (StructureType(TYPE_EXTENSION_PROPERTIES))
import OpenXR.Core10.Enums.StructureType (StructureType(TYPE_INSTANCE_CREATE_INFO))
import OpenXR.Core10.Enums.StructureType (StructureType(TYPE_INSTANCE_PROPERTIES))
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkXrGetInstanceProcAddr
:: FunPtr (Ptr Instance_T -> Ptr CChar -> Ptr PFN_xrVoidFunction -> IO Result) -> Ptr Instance_T -> Ptr CChar -> Ptr PFN_xrVoidFunction -> IO Result
getInstanceProcAddr :: forall io
. (MonadIO io)
=>
Instance
->
("name" ::: ByteString)
-> io (PFN_xrVoidFunction)
getInstanceProcAddr :: Instance -> ("name" ::: ByteString) -> io PFN_xrVoidFunction
getInstanceProcAddr instance' :: Instance
instance' name :: "name" ::: ByteString
name = IO PFN_xrVoidFunction -> io PFN_xrVoidFunction
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO PFN_xrVoidFunction -> io PFN_xrVoidFunction)
-> (ContT PFN_xrVoidFunction IO PFN_xrVoidFunction
-> IO PFN_xrVoidFunction)
-> ContT PFN_xrVoidFunction IO PFN_xrVoidFunction
-> io PFN_xrVoidFunction
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT PFN_xrVoidFunction IO PFN_xrVoidFunction
-> IO PFN_xrVoidFunction
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT PFN_xrVoidFunction IO PFN_xrVoidFunction
-> io PFN_xrVoidFunction)
-> ContT PFN_xrVoidFunction IO PFN_xrVoidFunction
-> io PFN_xrVoidFunction
forall a b. (a -> b) -> a -> b
$ do
let xrGetInstanceProcAddrPtr :: FunPtr
(Ptr Instance_T
-> ("name" ::: Ptr CChar) -> Ptr PFN_xrVoidFunction -> IO Result)
xrGetInstanceProcAddrPtr = InstanceCmds
-> FunPtr
(Ptr Instance_T
-> ("name" ::: Ptr CChar) -> Ptr PFN_xrVoidFunction -> IO Result)
pXrGetInstanceProcAddr (Instance -> InstanceCmds
instanceCmds (Instance
instance' :: Instance))
IO () -> ContT PFN_xrVoidFunction IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT PFN_xrVoidFunction IO ())
-> IO () -> ContT PFN_xrVoidFunction IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
(Ptr Instance_T
-> ("name" ::: Ptr CChar) -> Ptr PFN_xrVoidFunction -> IO Result)
xrGetInstanceProcAddrPtr FunPtr
(Ptr Instance_T
-> ("name" ::: Ptr CChar) -> Ptr PFN_xrVoidFunction -> IO Result)
-> FunPtr
(Ptr Instance_T
-> ("name" ::: Ptr CChar) -> Ptr PFN_xrVoidFunction -> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
(Ptr Instance_T
-> ("name" ::: Ptr CChar) -> Ptr PFN_xrVoidFunction -> 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 xrGetInstanceProcAddr is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
let xrGetInstanceProcAddr' :: Ptr Instance_T
-> ("name" ::: Ptr CChar) -> Ptr PFN_xrVoidFunction -> IO Result
xrGetInstanceProcAddr' = FunPtr
(Ptr Instance_T
-> ("name" ::: Ptr CChar) -> Ptr PFN_xrVoidFunction -> IO Result)
-> Ptr Instance_T
-> ("name" ::: Ptr CChar)
-> Ptr PFN_xrVoidFunction
-> IO Result
mkXrGetInstanceProcAddr FunPtr
(Ptr Instance_T
-> ("name" ::: Ptr CChar) -> Ptr PFN_xrVoidFunction -> IO Result)
xrGetInstanceProcAddrPtr
"name" ::: Ptr CChar
name' <- ((("name" ::: Ptr CChar) -> IO PFN_xrVoidFunction)
-> IO PFN_xrVoidFunction)
-> ContT PFN_xrVoidFunction IO ("name" ::: Ptr CChar)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("name" ::: Ptr CChar) -> IO PFN_xrVoidFunction)
-> IO PFN_xrVoidFunction)
-> ContT PFN_xrVoidFunction IO ("name" ::: Ptr CChar))
-> ((("name" ::: Ptr CChar) -> IO PFN_xrVoidFunction)
-> IO PFN_xrVoidFunction)
-> ContT PFN_xrVoidFunction IO ("name" ::: Ptr CChar)
forall a b. (a -> b) -> a -> b
$ ("name" ::: ByteString)
-> (("name" ::: Ptr CChar) -> IO PFN_xrVoidFunction)
-> IO PFN_xrVoidFunction
forall a.
("name" ::: ByteString) -> (("name" ::: Ptr CChar) -> IO a) -> IO a
useAsCString ("name" ::: ByteString
name)
Ptr PFN_xrVoidFunction
pFunction <- ((Ptr PFN_xrVoidFunction -> IO PFN_xrVoidFunction)
-> IO PFN_xrVoidFunction)
-> ContT PFN_xrVoidFunction IO (Ptr PFN_xrVoidFunction)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr PFN_xrVoidFunction -> IO PFN_xrVoidFunction)
-> IO PFN_xrVoidFunction)
-> ContT PFN_xrVoidFunction IO (Ptr PFN_xrVoidFunction))
-> ((Ptr PFN_xrVoidFunction -> IO PFN_xrVoidFunction)
-> IO PFN_xrVoidFunction)
-> ContT PFN_xrVoidFunction IO (Ptr PFN_xrVoidFunction)
forall a b. (a -> b) -> a -> b
$ IO (Ptr PFN_xrVoidFunction)
-> (Ptr PFN_xrVoidFunction -> IO ())
-> (Ptr PFN_xrVoidFunction -> IO PFN_xrVoidFunction)
-> IO PFN_xrVoidFunction
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO (Ptr PFN_xrVoidFunction)
forall a. Int -> IO (Ptr a)
callocBytes @PFN_xrVoidFunction 8) Ptr PFN_xrVoidFunction -> IO ()
forall a. Ptr a -> IO ()
free
Result
r <- IO Result -> ContT PFN_xrVoidFunction IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT PFN_xrVoidFunction IO Result)
-> IO Result -> ContT PFN_xrVoidFunction IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent "xrGetInstanceProcAddr" (Ptr Instance_T
-> ("name" ::: Ptr CChar) -> Ptr PFN_xrVoidFunction -> IO Result
xrGetInstanceProcAddr' (Instance -> Ptr Instance_T
instanceHandle (Instance
instance')) "name" ::: Ptr CChar
name' (Ptr PFN_xrVoidFunction
pFunction))
IO () -> ContT PFN_xrVoidFunction IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT PFN_xrVoidFunction IO ())
-> IO () -> ContT PFN_xrVoidFunction 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))
PFN_xrVoidFunction
function <- IO PFN_xrVoidFunction
-> ContT PFN_xrVoidFunction IO PFN_xrVoidFunction
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO PFN_xrVoidFunction
-> ContT PFN_xrVoidFunction IO PFN_xrVoidFunction)
-> IO PFN_xrVoidFunction
-> ContT PFN_xrVoidFunction IO PFN_xrVoidFunction
forall a b. (a -> b) -> a -> b
$ Ptr PFN_xrVoidFunction -> IO PFN_xrVoidFunction
forall a. Storable a => Ptr a -> IO a
peek @PFN_xrVoidFunction Ptr PFN_xrVoidFunction
pFunction
PFN_xrVoidFunction
-> ContT PFN_xrVoidFunction IO PFN_xrVoidFunction
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PFN_xrVoidFunction
-> ContT PFN_xrVoidFunction IO PFN_xrVoidFunction)
-> PFN_xrVoidFunction
-> ContT PFN_xrVoidFunction IO PFN_xrVoidFunction
forall a b. (a -> b) -> a -> b
$ (PFN_xrVoidFunction
function)
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkXrEnumerateApiLayerProperties
:: FunPtr (Word32 -> Ptr Word32 -> Ptr ApiLayerProperties -> IO Result) -> Word32 -> Ptr Word32 -> Ptr ApiLayerProperties -> IO Result
enumerateApiLayerProperties :: forall io
. (MonadIO io)
=> io (("properties" ::: Vector ApiLayerProperties))
enumerateApiLayerProperties :: io ("properties" ::: Vector ApiLayerProperties)
enumerateApiLayerProperties = IO ("properties" ::: Vector ApiLayerProperties)
-> io ("properties" ::: Vector ApiLayerProperties)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ("properties" ::: Vector ApiLayerProperties)
-> io ("properties" ::: Vector ApiLayerProperties))
-> (ContT
("properties" ::: Vector ApiLayerProperties)
IO
("properties" ::: Vector ApiLayerProperties)
-> IO ("properties" ::: Vector ApiLayerProperties))
-> ContT
("properties" ::: Vector ApiLayerProperties)
IO
("properties" ::: Vector ApiLayerProperties)
-> io ("properties" ::: Vector ApiLayerProperties)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT
("properties" ::: Vector ApiLayerProperties)
IO
("properties" ::: Vector ApiLayerProperties)
-> IO ("properties" ::: Vector ApiLayerProperties)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT
("properties" ::: Vector ApiLayerProperties)
IO
("properties" ::: Vector ApiLayerProperties)
-> io ("properties" ::: Vector ApiLayerProperties))
-> ContT
("properties" ::: Vector ApiLayerProperties)
IO
("properties" ::: Vector ApiLayerProperties)
-> io ("properties" ::: Vector ApiLayerProperties)
forall a b. (a -> b) -> a -> b
$ do
FunPtr
(("propertyCapacityInput" ::: Word32)
-> ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> Ptr ApiLayerProperties
-> IO Result)
xrEnumerateApiLayerPropertiesPtr <- IO
(FunPtr
(("propertyCapacityInput" ::: Word32)
-> ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> Ptr ApiLayerProperties
-> IO Result))
-> ContT
("properties" ::: Vector ApiLayerProperties)
IO
(FunPtr
(("propertyCapacityInput" ::: Word32)
-> ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> Ptr ApiLayerProperties
-> IO Result))
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO
(FunPtr
(("propertyCapacityInput" ::: Word32)
-> ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> Ptr ApiLayerProperties
-> IO Result))
-> ContT
("properties" ::: Vector ApiLayerProperties)
IO
(FunPtr
(("propertyCapacityInput" ::: Word32)
-> ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> Ptr ApiLayerProperties
-> IO Result)))
-> IO
(FunPtr
(("propertyCapacityInput" ::: Word32)
-> ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> Ptr ApiLayerProperties
-> IO Result))
-> ContT
("properties" ::: Vector ApiLayerProperties)
IO
(FunPtr
(("propertyCapacityInput" ::: Word32)
-> ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> Ptr ApiLayerProperties
-> IO Result))
forall a b. (a -> b) -> a -> b
$ PFN_xrVoidFunction
-> FunPtr
(("propertyCapacityInput" ::: Word32)
-> ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> Ptr ApiLayerProperties
-> IO Result)
forall a b. FunPtr a -> FunPtr b
castFunPtr @_ @(("propertyCapacityInput" ::: Word32) -> ("propertyCountOutput" ::: Ptr Word32) -> Ptr ApiLayerProperties -> IO Result) (PFN_xrVoidFunction
-> FunPtr
(("propertyCapacityInput" ::: Word32)
-> ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> Ptr ApiLayerProperties
-> IO Result))
-> IO PFN_xrVoidFunction
-> IO
(FunPtr
(("propertyCapacityInput" ::: Word32)
-> ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> Ptr ApiLayerProperties
-> IO Result))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Ptr Instance_T -> ("name" ::: Ptr CChar) -> IO PFN_xrVoidFunction
getInstanceProcAddr' Ptr Instance_T
forall a. Ptr a
nullPtr (Addr# -> "name" ::: Ptr CChar
forall a. Addr# -> Ptr a
Ptr "xrEnumerateApiLayerProperties"#)
IO () -> ContT ("properties" ::: Vector ApiLayerProperties) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT ("properties" ::: Vector ApiLayerProperties) IO ())
-> IO ()
-> ContT ("properties" ::: Vector ApiLayerProperties) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
(("propertyCapacityInput" ::: Word32)
-> ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> Ptr ApiLayerProperties
-> IO Result)
xrEnumerateApiLayerPropertiesPtr FunPtr
(("propertyCapacityInput" ::: Word32)
-> ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> Ptr ApiLayerProperties
-> IO Result)
-> FunPtr
(("propertyCapacityInput" ::: Word32)
-> ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> Ptr ApiLayerProperties
-> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
(("propertyCapacityInput" ::: Word32)
-> ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> Ptr ApiLayerProperties
-> 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 xrEnumerateApiLayerProperties is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
let xrEnumerateApiLayerProperties' :: ("propertyCapacityInput" ::: Word32)
-> ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> Ptr ApiLayerProperties
-> IO Result
xrEnumerateApiLayerProperties' = FunPtr
(("propertyCapacityInput" ::: Word32)
-> ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> Ptr ApiLayerProperties
-> IO Result)
-> ("propertyCapacityInput" ::: Word32)
-> ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> Ptr ApiLayerProperties
-> IO Result
mkXrEnumerateApiLayerProperties FunPtr
(("propertyCapacityInput" ::: Word32)
-> ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> Ptr ApiLayerProperties
-> IO Result)
xrEnumerateApiLayerPropertiesPtr
"propertyCountOutput" ::: Ptr ("propertyCapacityInput" ::: Word32)
pPropertyCountOutput <- ((("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> IO ("properties" ::: Vector ApiLayerProperties))
-> IO ("properties" ::: Vector ApiLayerProperties))
-> ContT
("properties" ::: Vector ApiLayerProperties)
IO
("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> IO ("properties" ::: Vector ApiLayerProperties))
-> IO ("properties" ::: Vector ApiLayerProperties))
-> ContT
("properties" ::: Vector ApiLayerProperties)
IO
("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32)))
-> ((("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> IO ("properties" ::: Vector ApiLayerProperties))
-> IO ("properties" ::: Vector ApiLayerProperties))
-> ContT
("properties" ::: Vector ApiLayerProperties)
IO
("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
forall a b. (a -> b) -> a -> b
$ IO
("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> (("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> IO ())
-> (("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> IO ("properties" ::: Vector ApiLayerProperties))
-> IO ("properties" ::: Vector ApiLayerProperties)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int
-> IO
("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
forall a. Int -> IO (Ptr a)
callocBytes @Word32 4) ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> IO ()
forall a. Ptr a -> IO ()
free
Result
r <- IO Result
-> ContT ("properties" ::: Vector ApiLayerProperties) IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result
-> ContT ("properties" ::: Vector ApiLayerProperties) IO Result)
-> IO Result
-> ContT ("properties" ::: Vector ApiLayerProperties) IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent "xrEnumerateApiLayerProperties" (("propertyCapacityInput" ::: Word32)
-> ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> Ptr ApiLayerProperties
-> IO Result
xrEnumerateApiLayerProperties' (0) ("propertyCountOutput" ::: Ptr ("propertyCapacityInput" ::: Word32)
pPropertyCountOutput) (Ptr ApiLayerProperties
forall a. Ptr a
nullPtr))
IO () -> ContT ("properties" ::: Vector ApiLayerProperties) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT ("properties" ::: Vector ApiLayerProperties) IO ())
-> IO ()
-> ContT ("properties" ::: Vector ApiLayerProperties) 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))
"propertyCapacityInput" ::: Word32
propertyCountOutput <- IO ("propertyCapacityInput" ::: Word32)
-> ContT
("properties" ::: Vector ApiLayerProperties)
IO
("propertyCapacityInput" ::: Word32)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ("propertyCapacityInput" ::: Word32)
-> ContT
("properties" ::: Vector ApiLayerProperties)
IO
("propertyCapacityInput" ::: Word32))
-> IO ("propertyCapacityInput" ::: Word32)
-> ContT
("properties" ::: Vector ApiLayerProperties)
IO
("propertyCapacityInput" ::: Word32)
forall a b. (a -> b) -> a -> b
$ ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> IO ("propertyCapacityInput" ::: Word32)
forall a. Storable a => Ptr a -> IO a
peek @Word32 "propertyCountOutput" ::: Ptr ("propertyCapacityInput" ::: Word32)
pPropertyCountOutput
Ptr ApiLayerProperties
pProperties <- ((Ptr ApiLayerProperties
-> IO ("properties" ::: Vector ApiLayerProperties))
-> IO ("properties" ::: Vector ApiLayerProperties))
-> ContT
("properties" ::: Vector ApiLayerProperties)
IO
(Ptr ApiLayerProperties)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr ApiLayerProperties
-> IO ("properties" ::: Vector ApiLayerProperties))
-> IO ("properties" ::: Vector ApiLayerProperties))
-> ContT
("properties" ::: Vector ApiLayerProperties)
IO
(Ptr ApiLayerProperties))
-> ((Ptr ApiLayerProperties
-> IO ("properties" ::: Vector ApiLayerProperties))
-> IO ("properties" ::: Vector ApiLayerProperties))
-> ContT
("properties" ::: Vector ApiLayerProperties)
IO
(Ptr ApiLayerProperties)
forall a b. (a -> b) -> a -> b
$ IO (Ptr ApiLayerProperties)
-> (Ptr ApiLayerProperties -> IO ())
-> (Ptr ApiLayerProperties
-> IO ("properties" ::: Vector ApiLayerProperties))
-> IO ("properties" ::: Vector ApiLayerProperties)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO (Ptr ApiLayerProperties)
forall a. Int -> IO (Ptr a)
callocBytes @ApiLayerProperties ((("propertyCapacityInput" ::: Word32) -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral ("propertyCapacityInput" ::: Word32
propertyCountOutput)) Int -> Int -> Int
forall a. Num a => a -> a -> a
* 544)) Ptr ApiLayerProperties -> IO ()
forall a. Ptr a -> IO ()
free
[()]
_ <- (Int -> ContT ("properties" ::: Vector ApiLayerProperties) IO ())
-> [Int]
-> ContT ("properties" ::: Vector ApiLayerProperties) IO [()]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (\i :: Int
i -> ((() -> IO ("properties" ::: Vector ApiLayerProperties))
-> IO ("properties" ::: Vector ApiLayerProperties))
-> ContT ("properties" ::: Vector ApiLayerProperties) IO ()
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((() -> IO ("properties" ::: Vector ApiLayerProperties))
-> IO ("properties" ::: Vector ApiLayerProperties))
-> ContT ("properties" ::: Vector ApiLayerProperties) IO ())
-> ((() -> IO ("properties" ::: Vector ApiLayerProperties))
-> IO ("properties" ::: Vector ApiLayerProperties))
-> ContT ("properties" ::: Vector ApiLayerProperties) IO ()
forall a b. (a -> b) -> a -> b
$ Ptr ApiLayerProperties
-> IO ("properties" ::: Vector ApiLayerProperties)
-> IO ("properties" ::: Vector ApiLayerProperties)
forall a b. ToCStruct a => Ptr a -> IO b -> IO b
pokeZeroCStruct (Ptr ApiLayerProperties
pProperties Ptr ApiLayerProperties -> Int -> Ptr ApiLayerProperties
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (Int
i Int -> Int -> Int
forall a. Num a => a -> a -> a
* 544) :: Ptr ApiLayerProperties) (IO ("properties" ::: Vector ApiLayerProperties)
-> IO ("properties" ::: Vector ApiLayerProperties))
-> ((() -> IO ("properties" ::: Vector ApiLayerProperties))
-> IO ("properties" ::: Vector ApiLayerProperties))
-> (() -> IO ("properties" ::: Vector ApiLayerProperties))
-> IO ("properties" ::: Vector ApiLayerProperties)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((() -> IO ("properties" ::: Vector ApiLayerProperties))
-> () -> IO ("properties" ::: Vector ApiLayerProperties)
forall a b. (a -> b) -> a -> b
$ ())) [0..(("propertyCapacityInput" ::: Word32) -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral ("propertyCapacityInput" ::: Word32
propertyCountOutput)) Int -> Int -> Int
forall a. Num a => a -> a -> a
- 1]
Result
r' <- IO Result
-> ContT ("properties" ::: Vector ApiLayerProperties) IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result
-> ContT ("properties" ::: Vector ApiLayerProperties) IO Result)
-> IO Result
-> ContT ("properties" ::: Vector ApiLayerProperties) IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent "xrEnumerateApiLayerProperties" (("propertyCapacityInput" ::: Word32)
-> ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> Ptr ApiLayerProperties
-> IO Result
xrEnumerateApiLayerProperties' (("propertyCapacityInput" ::: Word32
propertyCountOutput)) ("propertyCountOutput" ::: Ptr ("propertyCapacityInput" ::: Word32)
pPropertyCountOutput) ((Ptr ApiLayerProperties
pProperties)))
IO () -> ContT ("properties" ::: Vector ApiLayerProperties) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT ("properties" ::: Vector ApiLayerProperties) IO ())
-> IO ()
-> ContT ("properties" ::: Vector ApiLayerProperties) 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'))
"propertyCapacityInput" ::: Word32
propertyCountOutput' <- IO ("propertyCapacityInput" ::: Word32)
-> ContT
("properties" ::: Vector ApiLayerProperties)
IO
("propertyCapacityInput" ::: Word32)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ("propertyCapacityInput" ::: Word32)
-> ContT
("properties" ::: Vector ApiLayerProperties)
IO
("propertyCapacityInput" ::: Word32))
-> IO ("propertyCapacityInput" ::: Word32)
-> ContT
("properties" ::: Vector ApiLayerProperties)
IO
("propertyCapacityInput" ::: Word32)
forall a b. (a -> b) -> a -> b
$ ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> IO ("propertyCapacityInput" ::: Word32)
forall a. Storable a => Ptr a -> IO a
peek @Word32 "propertyCountOutput" ::: Ptr ("propertyCapacityInput" ::: Word32)
pPropertyCountOutput
"properties" ::: Vector ApiLayerProperties
properties' <- IO ("properties" ::: Vector ApiLayerProperties)
-> ContT
("properties" ::: Vector ApiLayerProperties)
IO
("properties" ::: Vector ApiLayerProperties)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ("properties" ::: Vector ApiLayerProperties)
-> ContT
("properties" ::: Vector ApiLayerProperties)
IO
("properties" ::: Vector ApiLayerProperties))
-> IO ("properties" ::: Vector ApiLayerProperties)
-> ContT
("properties" ::: Vector ApiLayerProperties)
IO
("properties" ::: Vector ApiLayerProperties)
forall a b. (a -> b) -> a -> b
$ Int
-> (Int -> IO ApiLayerProperties)
-> IO ("properties" ::: Vector ApiLayerProperties)
forall (m :: * -> *) a.
Monad m =>
Int -> (Int -> m a) -> m (Vector a)
generateM (("propertyCapacityInput" ::: Word32) -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral ("propertyCapacityInput" ::: Word32
propertyCountOutput')) (\i :: Int
i -> Ptr ApiLayerProperties -> IO ApiLayerProperties
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @ApiLayerProperties (((Ptr ApiLayerProperties
pProperties) Ptr ApiLayerProperties -> Int -> Ptr ApiLayerProperties
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (544 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr ApiLayerProperties)))
("properties" ::: Vector ApiLayerProperties)
-> ContT
("properties" ::: Vector ApiLayerProperties)
IO
("properties" ::: Vector ApiLayerProperties)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (("properties" ::: Vector ApiLayerProperties)
-> ContT
("properties" ::: Vector ApiLayerProperties)
IO
("properties" ::: Vector ApiLayerProperties))
-> ("properties" ::: Vector ApiLayerProperties)
-> ContT
("properties" ::: Vector ApiLayerProperties)
IO
("properties" ::: Vector ApiLayerProperties)
forall a b. (a -> b) -> a -> b
$ ("properties" ::: Vector ApiLayerProperties
properties')
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkXrEnumerateInstanceExtensionProperties
:: FunPtr (Ptr CChar -> Word32 -> Ptr Word32 -> Ptr ExtensionProperties -> IO Result) -> Ptr CChar -> Word32 -> Ptr Word32 -> Ptr ExtensionProperties -> IO Result
enumerateInstanceExtensionProperties :: forall io
. (MonadIO io)
=>
("layerName" ::: Maybe ByteString)
-> io (("properties" ::: Vector ExtensionProperties))
enumerateInstanceExtensionProperties :: ("layerName" ::: Maybe ("name" ::: ByteString))
-> io ("properties" ::: Vector ExtensionProperties)
enumerateInstanceExtensionProperties layerName :: "layerName" ::: Maybe ("name" ::: ByteString)
layerName = IO ("properties" ::: Vector ExtensionProperties)
-> io ("properties" ::: Vector ExtensionProperties)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ("properties" ::: Vector ExtensionProperties)
-> io ("properties" ::: Vector ExtensionProperties))
-> (ContT
("properties" ::: Vector ExtensionProperties)
IO
("properties" ::: Vector ExtensionProperties)
-> IO ("properties" ::: Vector ExtensionProperties))
-> ContT
("properties" ::: Vector ExtensionProperties)
IO
("properties" ::: Vector ExtensionProperties)
-> io ("properties" ::: Vector ExtensionProperties)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT
("properties" ::: Vector ExtensionProperties)
IO
("properties" ::: Vector ExtensionProperties)
-> IO ("properties" ::: Vector ExtensionProperties)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT
("properties" ::: Vector ExtensionProperties)
IO
("properties" ::: Vector ExtensionProperties)
-> io ("properties" ::: Vector ExtensionProperties))
-> ContT
("properties" ::: Vector ExtensionProperties)
IO
("properties" ::: Vector ExtensionProperties)
-> io ("properties" ::: Vector ExtensionProperties)
forall a b. (a -> b) -> a -> b
$ do
FunPtr
(("name" ::: Ptr CChar)
-> ("propertyCapacityInput" ::: Word32)
-> ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> Ptr ExtensionProperties
-> IO Result)
xrEnumerateInstanceExtensionPropertiesPtr <- IO
(FunPtr
(("name" ::: Ptr CChar)
-> ("propertyCapacityInput" ::: Word32)
-> ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> Ptr ExtensionProperties
-> IO Result))
-> ContT
("properties" ::: Vector ExtensionProperties)
IO
(FunPtr
(("name" ::: Ptr CChar)
-> ("propertyCapacityInput" ::: Word32)
-> ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> Ptr ExtensionProperties
-> IO Result))
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO
(FunPtr
(("name" ::: Ptr CChar)
-> ("propertyCapacityInput" ::: Word32)
-> ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> Ptr ExtensionProperties
-> IO Result))
-> ContT
("properties" ::: Vector ExtensionProperties)
IO
(FunPtr
(("name" ::: Ptr CChar)
-> ("propertyCapacityInput" ::: Word32)
-> ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> Ptr ExtensionProperties
-> IO Result)))
-> IO
(FunPtr
(("name" ::: Ptr CChar)
-> ("propertyCapacityInput" ::: Word32)
-> ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> Ptr ExtensionProperties
-> IO Result))
-> ContT
("properties" ::: Vector ExtensionProperties)
IO
(FunPtr
(("name" ::: Ptr CChar)
-> ("propertyCapacityInput" ::: Word32)
-> ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> Ptr ExtensionProperties
-> IO Result))
forall a b. (a -> b) -> a -> b
$ PFN_xrVoidFunction
-> FunPtr
(("name" ::: Ptr CChar)
-> ("propertyCapacityInput" ::: Word32)
-> ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> Ptr ExtensionProperties
-> IO Result)
forall a b. FunPtr a -> FunPtr b
castFunPtr @_ @(("layerName" ::: Ptr CChar) -> ("propertyCapacityInput" ::: Word32) -> ("propertyCountOutput" ::: Ptr Word32) -> Ptr ExtensionProperties -> IO Result) (PFN_xrVoidFunction
-> FunPtr
(("name" ::: Ptr CChar)
-> ("propertyCapacityInput" ::: Word32)
-> ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> Ptr ExtensionProperties
-> IO Result))
-> IO PFN_xrVoidFunction
-> IO
(FunPtr
(("name" ::: Ptr CChar)
-> ("propertyCapacityInput" ::: Word32)
-> ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> Ptr ExtensionProperties
-> IO Result))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Ptr Instance_T -> ("name" ::: Ptr CChar) -> IO PFN_xrVoidFunction
getInstanceProcAddr' Ptr Instance_T
forall a. Ptr a
nullPtr (Addr# -> "name" ::: Ptr CChar
forall a. Addr# -> Ptr a
Ptr "xrEnumerateInstanceExtensionProperties"#)
IO () -> ContT ("properties" ::: Vector ExtensionProperties) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ()
-> ContT ("properties" ::: Vector ExtensionProperties) IO ())
-> IO ()
-> ContT ("properties" ::: Vector ExtensionProperties) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
(("name" ::: Ptr CChar)
-> ("propertyCapacityInput" ::: Word32)
-> ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> Ptr ExtensionProperties
-> IO Result)
xrEnumerateInstanceExtensionPropertiesPtr FunPtr
(("name" ::: Ptr CChar)
-> ("propertyCapacityInput" ::: Word32)
-> ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> Ptr ExtensionProperties
-> IO Result)
-> FunPtr
(("name" ::: Ptr CChar)
-> ("propertyCapacityInput" ::: Word32)
-> ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> Ptr ExtensionProperties
-> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
(("name" ::: Ptr CChar)
-> ("propertyCapacityInput" ::: Word32)
-> ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> Ptr ExtensionProperties
-> 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 xrEnumerateInstanceExtensionProperties is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
let xrEnumerateInstanceExtensionProperties' :: ("name" ::: Ptr CChar)
-> ("propertyCapacityInput" ::: Word32)
-> ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> Ptr ExtensionProperties
-> IO Result
xrEnumerateInstanceExtensionProperties' = FunPtr
(("name" ::: Ptr CChar)
-> ("propertyCapacityInput" ::: Word32)
-> ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> Ptr ExtensionProperties
-> IO Result)
-> ("name" ::: Ptr CChar)
-> ("propertyCapacityInput" ::: Word32)
-> ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> Ptr ExtensionProperties
-> IO Result
mkXrEnumerateInstanceExtensionProperties FunPtr
(("name" ::: Ptr CChar)
-> ("propertyCapacityInput" ::: Word32)
-> ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> Ptr ExtensionProperties
-> IO Result)
xrEnumerateInstanceExtensionPropertiesPtr
"name" ::: Ptr CChar
layerName' <- case ("layerName" ::: Maybe ("name" ::: ByteString)
layerName) of
Nothing -> ("name" ::: Ptr CChar)
-> ContT
("properties" ::: Vector ExtensionProperties)
IO
("name" ::: Ptr CChar)
forall (f :: * -> *) a. Applicative f => a -> f a
pure "name" ::: Ptr CChar
forall a. Ptr a
nullPtr
Just j :: "name" ::: ByteString
j -> ((("name" ::: Ptr CChar)
-> IO ("properties" ::: Vector ExtensionProperties))
-> IO ("properties" ::: Vector ExtensionProperties))
-> ContT
("properties" ::: Vector ExtensionProperties)
IO
("name" ::: Ptr CChar)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("name" ::: Ptr CChar)
-> IO ("properties" ::: Vector ExtensionProperties))
-> IO ("properties" ::: Vector ExtensionProperties))
-> ContT
("properties" ::: Vector ExtensionProperties)
IO
("name" ::: Ptr CChar))
-> ((("name" ::: Ptr CChar)
-> IO ("properties" ::: Vector ExtensionProperties))
-> IO ("properties" ::: Vector ExtensionProperties))
-> ContT
("properties" ::: Vector ExtensionProperties)
IO
("name" ::: Ptr CChar)
forall a b. (a -> b) -> a -> b
$ ("name" ::: ByteString)
-> (("name" ::: Ptr CChar)
-> IO ("properties" ::: Vector ExtensionProperties))
-> IO ("properties" ::: Vector ExtensionProperties)
forall a.
("name" ::: ByteString) -> (("name" ::: Ptr CChar) -> IO a) -> IO a
useAsCString ("name" ::: ByteString
j)
"propertyCountOutput" ::: Ptr ("propertyCapacityInput" ::: Word32)
pPropertyCountOutput <- ((("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> IO ("properties" ::: Vector ExtensionProperties))
-> IO ("properties" ::: Vector ExtensionProperties))
-> ContT
("properties" ::: Vector ExtensionProperties)
IO
("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> IO ("properties" ::: Vector ExtensionProperties))
-> IO ("properties" ::: Vector ExtensionProperties))
-> ContT
("properties" ::: Vector ExtensionProperties)
IO
("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32)))
-> ((("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> IO ("properties" ::: Vector ExtensionProperties))
-> IO ("properties" ::: Vector ExtensionProperties))
-> ContT
("properties" ::: Vector ExtensionProperties)
IO
("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
forall a b. (a -> b) -> a -> b
$ IO
("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> (("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> IO ())
-> (("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> IO ("properties" ::: Vector ExtensionProperties))
-> IO ("properties" ::: Vector ExtensionProperties)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int
-> IO
("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
forall a. Int -> IO (Ptr a)
callocBytes @Word32 4) ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> IO ()
forall a. Ptr a -> IO ()
free
Result
r <- IO Result
-> ContT ("properties" ::: Vector ExtensionProperties) IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result
-> ContT ("properties" ::: Vector ExtensionProperties) IO Result)
-> IO Result
-> ContT ("properties" ::: Vector ExtensionProperties) IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent "xrEnumerateInstanceExtensionProperties" (("name" ::: Ptr CChar)
-> ("propertyCapacityInput" ::: Word32)
-> ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> Ptr ExtensionProperties
-> IO Result
xrEnumerateInstanceExtensionProperties' "name" ::: Ptr CChar
layerName' (0) ("propertyCountOutput" ::: Ptr ("propertyCapacityInput" ::: Word32)
pPropertyCountOutput) (Ptr ExtensionProperties
forall a. Ptr a
nullPtr))
IO () -> ContT ("properties" ::: Vector ExtensionProperties) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ()
-> ContT ("properties" ::: Vector ExtensionProperties) IO ())
-> IO ()
-> ContT ("properties" ::: Vector ExtensionProperties) 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))
"propertyCapacityInput" ::: Word32
propertyCountOutput <- IO ("propertyCapacityInput" ::: Word32)
-> ContT
("properties" ::: Vector ExtensionProperties)
IO
("propertyCapacityInput" ::: Word32)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ("propertyCapacityInput" ::: Word32)
-> ContT
("properties" ::: Vector ExtensionProperties)
IO
("propertyCapacityInput" ::: Word32))
-> IO ("propertyCapacityInput" ::: Word32)
-> ContT
("properties" ::: Vector ExtensionProperties)
IO
("propertyCapacityInput" ::: Word32)
forall a b. (a -> b) -> a -> b
$ ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> IO ("propertyCapacityInput" ::: Word32)
forall a. Storable a => Ptr a -> IO a
peek @Word32 "propertyCountOutput" ::: Ptr ("propertyCapacityInput" ::: Word32)
pPropertyCountOutput
Ptr ExtensionProperties
pProperties <- ((Ptr ExtensionProperties
-> IO ("properties" ::: Vector ExtensionProperties))
-> IO ("properties" ::: Vector ExtensionProperties))
-> ContT
("properties" ::: Vector ExtensionProperties)
IO
(Ptr ExtensionProperties)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr ExtensionProperties
-> IO ("properties" ::: Vector ExtensionProperties))
-> IO ("properties" ::: Vector ExtensionProperties))
-> ContT
("properties" ::: Vector ExtensionProperties)
IO
(Ptr ExtensionProperties))
-> ((Ptr ExtensionProperties
-> IO ("properties" ::: Vector ExtensionProperties))
-> IO ("properties" ::: Vector ExtensionProperties))
-> ContT
("properties" ::: Vector ExtensionProperties)
IO
(Ptr ExtensionProperties)
forall a b. (a -> b) -> a -> b
$ IO (Ptr ExtensionProperties)
-> (Ptr ExtensionProperties -> IO ())
-> (Ptr ExtensionProperties
-> IO ("properties" ::: Vector ExtensionProperties))
-> IO ("properties" ::: Vector ExtensionProperties)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO (Ptr ExtensionProperties)
forall a. Int -> IO (Ptr a)
callocBytes @ExtensionProperties ((("propertyCapacityInput" ::: Word32) -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral ("propertyCapacityInput" ::: Word32
propertyCountOutput)) Int -> Int -> Int
forall a. Num a => a -> a -> a
* 152)) Ptr ExtensionProperties -> IO ()
forall a. Ptr a -> IO ()
free
[()]
_ <- (Int -> ContT ("properties" ::: Vector ExtensionProperties) IO ())
-> [Int]
-> ContT ("properties" ::: Vector ExtensionProperties) IO [()]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (\i :: Int
i -> ((() -> IO ("properties" ::: Vector ExtensionProperties))
-> IO ("properties" ::: Vector ExtensionProperties))
-> ContT ("properties" ::: Vector ExtensionProperties) IO ()
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((() -> IO ("properties" ::: Vector ExtensionProperties))
-> IO ("properties" ::: Vector ExtensionProperties))
-> ContT ("properties" ::: Vector ExtensionProperties) IO ())
-> ((() -> IO ("properties" ::: Vector ExtensionProperties))
-> IO ("properties" ::: Vector ExtensionProperties))
-> ContT ("properties" ::: Vector ExtensionProperties) IO ()
forall a b. (a -> b) -> a -> b
$ Ptr ExtensionProperties
-> IO ("properties" ::: Vector ExtensionProperties)
-> IO ("properties" ::: Vector ExtensionProperties)
forall a b. ToCStruct a => Ptr a -> IO b -> IO b
pokeZeroCStruct (Ptr ExtensionProperties
pProperties Ptr ExtensionProperties -> Int -> Ptr ExtensionProperties
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (Int
i Int -> Int -> Int
forall a. Num a => a -> a -> a
* 152) :: Ptr ExtensionProperties) (IO ("properties" ::: Vector ExtensionProperties)
-> IO ("properties" ::: Vector ExtensionProperties))
-> ((() -> IO ("properties" ::: Vector ExtensionProperties))
-> IO ("properties" ::: Vector ExtensionProperties))
-> (() -> IO ("properties" ::: Vector ExtensionProperties))
-> IO ("properties" ::: Vector ExtensionProperties)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((() -> IO ("properties" ::: Vector ExtensionProperties))
-> () -> IO ("properties" ::: Vector ExtensionProperties)
forall a b. (a -> b) -> a -> b
$ ())) [0..(("propertyCapacityInput" ::: Word32) -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral ("propertyCapacityInput" ::: Word32
propertyCountOutput)) Int -> Int -> Int
forall a. Num a => a -> a -> a
- 1]
Result
r' <- IO Result
-> ContT ("properties" ::: Vector ExtensionProperties) IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result
-> ContT ("properties" ::: Vector ExtensionProperties) IO Result)
-> IO Result
-> ContT ("properties" ::: Vector ExtensionProperties) IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent "xrEnumerateInstanceExtensionProperties" (("name" ::: Ptr CChar)
-> ("propertyCapacityInput" ::: Word32)
-> ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> Ptr ExtensionProperties
-> IO Result
xrEnumerateInstanceExtensionProperties' "name" ::: Ptr CChar
layerName' (("propertyCapacityInput" ::: Word32
propertyCountOutput)) ("propertyCountOutput" ::: Ptr ("propertyCapacityInput" ::: Word32)
pPropertyCountOutput) ((Ptr ExtensionProperties
pProperties)))
IO () -> ContT ("properties" ::: Vector ExtensionProperties) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ()
-> ContT ("properties" ::: Vector ExtensionProperties) IO ())
-> IO ()
-> ContT ("properties" ::: Vector ExtensionProperties) 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'))
"propertyCapacityInput" ::: Word32
propertyCountOutput' <- IO ("propertyCapacityInput" ::: Word32)
-> ContT
("properties" ::: Vector ExtensionProperties)
IO
("propertyCapacityInput" ::: Word32)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ("propertyCapacityInput" ::: Word32)
-> ContT
("properties" ::: Vector ExtensionProperties)
IO
("propertyCapacityInput" ::: Word32))
-> IO ("propertyCapacityInput" ::: Word32)
-> ContT
("properties" ::: Vector ExtensionProperties)
IO
("propertyCapacityInput" ::: Word32)
forall a b. (a -> b) -> a -> b
$ ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> IO ("propertyCapacityInput" ::: Word32)
forall a. Storable a => Ptr a -> IO a
peek @Word32 "propertyCountOutput" ::: Ptr ("propertyCapacityInput" ::: Word32)
pPropertyCountOutput
"properties" ::: Vector ExtensionProperties
properties' <- IO ("properties" ::: Vector ExtensionProperties)
-> ContT
("properties" ::: Vector ExtensionProperties)
IO
("properties" ::: Vector ExtensionProperties)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ("properties" ::: Vector ExtensionProperties)
-> ContT
("properties" ::: Vector ExtensionProperties)
IO
("properties" ::: Vector ExtensionProperties))
-> IO ("properties" ::: Vector ExtensionProperties)
-> ContT
("properties" ::: Vector ExtensionProperties)
IO
("properties" ::: Vector ExtensionProperties)
forall a b. (a -> b) -> a -> b
$ Int
-> (Int -> IO ExtensionProperties)
-> IO ("properties" ::: Vector ExtensionProperties)
forall (m :: * -> *) a.
Monad m =>
Int -> (Int -> m a) -> m (Vector a)
generateM (("propertyCapacityInput" ::: Word32) -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral ("propertyCapacityInput" ::: Word32
propertyCountOutput')) (\i :: Int
i -> Ptr ExtensionProperties -> IO ExtensionProperties
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @ExtensionProperties (((Ptr ExtensionProperties
pProperties) Ptr ExtensionProperties -> Int -> Ptr ExtensionProperties
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (152 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr ExtensionProperties)))
("properties" ::: Vector ExtensionProperties)
-> ContT
("properties" ::: Vector ExtensionProperties)
IO
("properties" ::: Vector ExtensionProperties)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (("properties" ::: Vector ExtensionProperties)
-> ContT
("properties" ::: Vector ExtensionProperties)
IO
("properties" ::: Vector ExtensionProperties))
-> ("properties" ::: Vector ExtensionProperties)
-> ContT
("properties" ::: Vector ExtensionProperties)
IO
("properties" ::: Vector ExtensionProperties)
forall a b. (a -> b) -> a -> b
$ ("properties" ::: Vector ExtensionProperties
properties')
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkXrCreateInstance
:: FunPtr (Ptr (SomeStruct InstanceCreateInfo) -> Ptr (Ptr Instance_T) -> IO Result) -> Ptr (SomeStruct InstanceCreateInfo) -> Ptr (Ptr Instance_T) -> IO Result
createInstance :: forall a io
. (Extendss InstanceCreateInfo a, PokeChain a, MonadIO io)
=>
(InstanceCreateInfo a)
-> io (Instance)
createInstance :: InstanceCreateInfo a -> io Instance
createInstance createInfo :: InstanceCreateInfo a
createInfo = IO Instance -> io Instance
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Instance -> io Instance)
-> (ContT Instance IO Instance -> IO Instance)
-> ContT Instance IO Instance
-> io Instance
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT Instance IO Instance -> IO Instance
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT Instance IO Instance -> io Instance)
-> ContT Instance IO Instance -> io Instance
forall a b. (a -> b) -> a -> b
$ do
FunPtr
(("createInfo" ::: Ptr (SomeStruct InstanceCreateInfo))
-> ("instance" ::: Ptr (Ptr Instance_T)) -> IO Result)
xrCreateInstancePtr <- IO
(FunPtr
(("createInfo" ::: Ptr (SomeStruct InstanceCreateInfo))
-> ("instance" ::: Ptr (Ptr Instance_T)) -> IO Result))
-> ContT
Instance
IO
(FunPtr
(("createInfo" ::: Ptr (SomeStruct InstanceCreateInfo))
-> ("instance" ::: Ptr (Ptr Instance_T)) -> IO Result))
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO
(FunPtr
(("createInfo" ::: Ptr (SomeStruct InstanceCreateInfo))
-> ("instance" ::: Ptr (Ptr Instance_T)) -> IO Result))
-> ContT
Instance
IO
(FunPtr
(("createInfo" ::: Ptr (SomeStruct InstanceCreateInfo))
-> ("instance" ::: Ptr (Ptr Instance_T)) -> IO Result)))
-> IO
(FunPtr
(("createInfo" ::: Ptr (SomeStruct InstanceCreateInfo))
-> ("instance" ::: Ptr (Ptr Instance_T)) -> IO Result))
-> ContT
Instance
IO
(FunPtr
(("createInfo" ::: Ptr (SomeStruct InstanceCreateInfo))
-> ("instance" ::: Ptr (Ptr Instance_T)) -> IO Result))
forall a b. (a -> b) -> a -> b
$ PFN_xrVoidFunction
-> FunPtr
(("createInfo" ::: Ptr (SomeStruct InstanceCreateInfo))
-> ("instance" ::: Ptr (Ptr Instance_T)) -> IO Result)
forall a b. FunPtr a -> FunPtr b
castFunPtr @_ @(("createInfo" ::: Ptr (SomeStruct InstanceCreateInfo)) -> ("instance" ::: Ptr (Ptr Instance_T)) -> IO Result) (PFN_xrVoidFunction
-> FunPtr
(("createInfo" ::: Ptr (SomeStruct InstanceCreateInfo))
-> ("instance" ::: Ptr (Ptr Instance_T)) -> IO Result))
-> IO PFN_xrVoidFunction
-> IO
(FunPtr
(("createInfo" ::: Ptr (SomeStruct InstanceCreateInfo))
-> ("instance" ::: Ptr (Ptr Instance_T)) -> IO Result))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Ptr Instance_T -> ("name" ::: Ptr CChar) -> IO PFN_xrVoidFunction
getInstanceProcAddr' Ptr Instance_T
forall a. Ptr a
nullPtr (Addr# -> "name" ::: Ptr CChar
forall a. Addr# -> Ptr a
Ptr "xrCreateInstance"#)
IO () -> ContT Instance IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT Instance IO ()) -> IO () -> ContT Instance IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
(("createInfo" ::: Ptr (SomeStruct InstanceCreateInfo))
-> ("instance" ::: Ptr (Ptr Instance_T)) -> IO Result)
xrCreateInstancePtr FunPtr
(("createInfo" ::: Ptr (SomeStruct InstanceCreateInfo))
-> ("instance" ::: Ptr (Ptr Instance_T)) -> IO Result)
-> FunPtr
(("createInfo" ::: Ptr (SomeStruct InstanceCreateInfo))
-> ("instance" ::: Ptr (Ptr Instance_T)) -> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
(("createInfo" ::: Ptr (SomeStruct InstanceCreateInfo))
-> ("instance" ::: Ptr (Ptr Instance_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 xrCreateInstance is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
let xrCreateInstance' :: ("createInfo" ::: Ptr (SomeStruct InstanceCreateInfo))
-> ("instance" ::: Ptr (Ptr Instance_T)) -> IO Result
xrCreateInstance' = FunPtr
(("createInfo" ::: Ptr (SomeStruct InstanceCreateInfo))
-> ("instance" ::: Ptr (Ptr Instance_T)) -> IO Result)
-> ("createInfo" ::: Ptr (SomeStruct InstanceCreateInfo))
-> ("instance" ::: Ptr (Ptr Instance_T))
-> IO Result
mkXrCreateInstance FunPtr
(("createInfo" ::: Ptr (SomeStruct InstanceCreateInfo))
-> ("instance" ::: Ptr (Ptr Instance_T)) -> IO Result)
xrCreateInstancePtr
Ptr (InstanceCreateInfo a)
createInfo' <- ((Ptr (InstanceCreateInfo a) -> IO Instance) -> IO Instance)
-> ContT Instance IO (Ptr (InstanceCreateInfo a))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr (InstanceCreateInfo a) -> IO Instance) -> IO Instance)
-> ContT Instance IO (Ptr (InstanceCreateInfo a)))
-> ((Ptr (InstanceCreateInfo a) -> IO Instance) -> IO Instance)
-> ContT Instance IO (Ptr (InstanceCreateInfo a))
forall a b. (a -> b) -> a -> b
$ InstanceCreateInfo a
-> (Ptr (InstanceCreateInfo a) -> IO Instance) -> IO Instance
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (InstanceCreateInfo a
createInfo)
"instance" ::: Ptr (Ptr Instance_T)
pInstance <- ((("instance" ::: Ptr (Ptr Instance_T)) -> IO Instance)
-> IO Instance)
-> ContT Instance IO ("instance" ::: Ptr (Ptr Instance_T))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("instance" ::: Ptr (Ptr Instance_T)) -> IO Instance)
-> IO Instance)
-> ContT Instance IO ("instance" ::: Ptr (Ptr Instance_T)))
-> ((("instance" ::: Ptr (Ptr Instance_T)) -> IO Instance)
-> IO Instance)
-> ContT Instance IO ("instance" ::: Ptr (Ptr Instance_T))
forall a b. (a -> b) -> a -> b
$ IO ("instance" ::: Ptr (Ptr Instance_T))
-> (("instance" ::: Ptr (Ptr Instance_T)) -> IO ())
-> (("instance" ::: Ptr (Ptr Instance_T)) -> IO Instance)
-> IO Instance
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO ("instance" ::: Ptr (Ptr Instance_T))
forall a. Int -> IO (Ptr a)
callocBytes @(Ptr Instance_T) 8) ("instance" ::: Ptr (Ptr Instance_T)) -> IO ()
forall a. Ptr a -> IO ()
free
Result
r <- IO Result -> ContT Instance IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT Instance IO Result)
-> IO Result -> ContT Instance IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent "xrCreateInstance" (("createInfo" ::: Ptr (SomeStruct InstanceCreateInfo))
-> ("instance" ::: Ptr (Ptr Instance_T)) -> IO Result
xrCreateInstance' (Ptr (InstanceCreateInfo a)
-> "createInfo" ::: Ptr (SomeStruct InstanceCreateInfo)
forall (a :: [*] -> *) (es :: [*]).
Ptr (a es) -> Ptr (SomeStruct a)
forgetExtensions Ptr (InstanceCreateInfo a)
createInfo') ("instance" ::: Ptr (Ptr Instance_T)
pInstance))
IO () -> ContT Instance IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT Instance IO ()) -> IO () -> ContT Instance 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 Instance_T
instance' <- IO (Ptr Instance_T) -> ContT Instance IO (Ptr Instance_T)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO (Ptr Instance_T) -> ContT Instance IO (Ptr Instance_T))
-> IO (Ptr Instance_T) -> ContT Instance IO (Ptr Instance_T)
forall a b. (a -> b) -> a -> b
$ ("instance" ::: Ptr (Ptr Instance_T)) -> IO (Ptr Instance_T)
forall a. Storable a => Ptr a -> IO a
peek @(Ptr Instance_T) "instance" ::: Ptr (Ptr Instance_T)
pInstance
Instance
instance'' <- IO Instance -> ContT Instance IO Instance
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Instance -> ContT Instance IO Instance)
-> IO Instance -> ContT Instance IO Instance
forall a b. (a -> b) -> a -> b
$ (\h :: Ptr Instance_T
h -> Ptr Instance_T -> InstanceCmds -> Instance
Instance Ptr Instance_T
h (InstanceCmds -> Instance) -> IO InstanceCmds -> IO Instance
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Ptr Instance_T -> IO InstanceCmds
initInstanceCmds Ptr Instance_T
h) Ptr Instance_T
instance'
Instance -> ContT Instance IO Instance
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Instance -> ContT Instance IO Instance)
-> Instance -> ContT Instance IO Instance
forall a b. (a -> b) -> a -> b
$ (Instance
instance'')
withInstance :: forall a io r . (Extendss InstanceCreateInfo a, PokeChain a, MonadIO io) => InstanceCreateInfo a -> (io Instance -> (Instance -> io ()) -> r) -> r
withInstance :: InstanceCreateInfo a
-> (io Instance -> (Instance -> io ()) -> r) -> r
withInstance createInfo :: InstanceCreateInfo a
createInfo b :: io Instance -> (Instance -> io ()) -> r
b =
io Instance -> (Instance -> io ()) -> r
b (InstanceCreateInfo a -> io Instance
forall (a :: [*]) (io :: * -> *).
(Extendss InstanceCreateInfo a, PokeChain a, MonadIO io) =>
InstanceCreateInfo a -> io Instance
createInstance InstanceCreateInfo a
createInfo)
(\(Instance
o0) -> Instance -> io ()
forall (io :: * -> *). MonadIO io => Instance -> io ()
destroyInstance Instance
o0)
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkXrDestroyInstance
:: FunPtr (Ptr Instance_T -> IO Result) -> Ptr Instance_T -> IO Result
destroyInstance :: forall io
. (MonadIO io)
=>
Instance
-> io ()
destroyInstance :: Instance -> io ()
destroyInstance instance' :: Instance
instance' = 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 xrDestroyInstancePtr :: FunPtr (Ptr Instance_T -> IO Result)
xrDestroyInstancePtr = InstanceCmds -> FunPtr (Ptr Instance_T -> IO Result)
pXrDestroyInstance (Instance -> InstanceCmds
instanceCmds (Instance
instance' :: Instance))
Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr (Ptr Instance_T -> IO Result)
xrDestroyInstancePtr FunPtr (Ptr Instance_T -> IO Result)
-> FunPtr (Ptr Instance_T -> IO Result) -> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr (Ptr Instance_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 xrDestroyInstance is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
let xrDestroyInstance' :: Ptr Instance_T -> IO Result
xrDestroyInstance' = FunPtr (Ptr Instance_T -> IO Result) -> Ptr Instance_T -> IO Result
mkXrDestroyInstance FunPtr (Ptr Instance_T -> IO Result)
xrDestroyInstancePtr
Result
r <- String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent "xrDestroyInstance" (Ptr Instance_T -> IO Result
xrDestroyInstance' (Instance -> Ptr Instance_T
instanceHandle (Instance
instance')))
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" mkXrResultToString
:: FunPtr (Ptr Instance_T -> Result -> Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar) -> IO Result) -> Ptr Instance_T -> Result -> Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar) -> IO Result
resultToString :: forall io
. (MonadIO io)
=>
Instance
->
("value" ::: Result)
-> io (("buffer" ::: ByteString))
resultToString :: Instance -> Result -> io ("name" ::: ByteString)
resultToString instance' :: Instance
instance' value :: Result
value = IO ("name" ::: ByteString) -> io ("name" ::: ByteString)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ("name" ::: ByteString) -> io ("name" ::: ByteString))
-> (ContT ("name" ::: ByteString) IO ("name" ::: ByteString)
-> IO ("name" ::: ByteString))
-> ContT ("name" ::: ByteString) IO ("name" ::: ByteString)
-> io ("name" ::: ByteString)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT ("name" ::: ByteString) IO ("name" ::: ByteString)
-> IO ("name" ::: ByteString)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT ("name" ::: ByteString) IO ("name" ::: ByteString)
-> io ("name" ::: ByteString))
-> ContT ("name" ::: ByteString) IO ("name" ::: ByteString)
-> io ("name" ::: ByteString)
forall a b. (a -> b) -> a -> b
$ do
let xrResultToStringPtr :: FunPtr
(Ptr Instance_T
-> Result
-> ("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
-> IO Result)
xrResultToStringPtr = InstanceCmds
-> FunPtr
(Ptr Instance_T
-> Result
-> ("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
-> IO Result)
pXrResultToString (Instance -> InstanceCmds
instanceCmds (Instance
instance' :: Instance))
IO () -> ContT ("name" ::: ByteString) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT ("name" ::: ByteString) IO ())
-> IO () -> ContT ("name" ::: ByteString) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
(Ptr Instance_T
-> Result
-> ("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
-> IO Result)
xrResultToStringPtr FunPtr
(Ptr Instance_T
-> Result
-> ("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
-> IO Result)
-> FunPtr
(Ptr Instance_T
-> Result
-> ("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
-> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
(Ptr Instance_T
-> Result
-> ("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
-> 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 xrResultToString is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
let xrResultToString' :: Ptr Instance_T
-> Result
-> ("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
-> IO Result
xrResultToString' = FunPtr
(Ptr Instance_T
-> Result
-> ("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
-> IO Result)
-> Ptr Instance_T
-> Result
-> ("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
-> IO Result
mkXrResultToString FunPtr
(Ptr Instance_T
-> Result
-> ("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
-> IO Result)
xrResultToStringPtr
"buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar)
buffer <- ((("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
-> IO ("name" ::: ByteString))
-> IO ("name" ::: ByteString))
-> ContT
("name" ::: ByteString)
IO
("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
-> IO ("name" ::: ByteString))
-> IO ("name" ::: ByteString))
-> ContT
("name" ::: ByteString)
IO
("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar)))
-> ((("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
-> IO ("name" ::: ByteString))
-> IO ("name" ::: ByteString))
-> ContT
("name" ::: ByteString)
IO
("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
forall a b. (a -> b) -> a -> b
$ IO ("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
-> (("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
-> IO ())
-> (("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
-> IO ("name" ::: ByteString))
-> IO ("name" ::: ByteString)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket ((KnownNat MAX_RESULT_STRING_SIZE, Storable CChar) =>
IO ("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
forall (n :: Nat) a.
(KnownNat n, Storable a) =>
IO (Ptr (FixedArray n a))
callocFixedArray @MAX_RESULT_STRING_SIZE @CChar) ("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
-> IO ()
forall a. Ptr a -> IO ()
free
Result
r <- IO Result -> ContT ("name" ::: ByteString) IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT ("name" ::: ByteString) IO Result)
-> IO Result -> ContT ("name" ::: ByteString) IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent "xrResultToString" (Ptr Instance_T
-> Result
-> ("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
-> IO Result
xrResultToString' (Instance -> Ptr Instance_T
instanceHandle (Instance
instance')) (Result
value) ("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar)
buffer))
IO () -> ContT ("name" ::: ByteString) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT ("name" ::: ByteString) IO ())
-> IO () -> ContT ("name" ::: ByteString) 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))
"name" ::: ByteString
buffer' <- IO ("name" ::: ByteString)
-> ContT ("name" ::: ByteString) IO ("name" ::: ByteString)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ("name" ::: ByteString)
-> ContT ("name" ::: ByteString) IO ("name" ::: ByteString))
-> IO ("name" ::: ByteString)
-> ContT ("name" ::: ByteString) IO ("name" ::: ByteString)
forall a b. (a -> b) -> a -> b
$ ("name" ::: Ptr CChar) -> IO ("name" ::: ByteString)
packCString (("name" ::: Ptr CChar) -> IO ("name" ::: ByteString))
-> (("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
-> "name" ::: Ptr CChar)
-> ("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
-> IO ("name" ::: ByteString)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
-> "name" ::: Ptr CChar
forall a (n :: Nat). Ptr (FixedArray n a) -> Ptr a
lowerArrayPtr @CChar @MAX_RESULT_STRING_SIZE (("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
-> IO ("name" ::: ByteString))
-> ("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
-> IO ("name" ::: ByteString)
forall a b. (a -> b) -> a -> b
$ "buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar)
buffer
("name" ::: ByteString)
-> ContT ("name" ::: ByteString) IO ("name" ::: ByteString)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (("name" ::: ByteString)
-> ContT ("name" ::: ByteString) IO ("name" ::: ByteString))
-> ("name" ::: ByteString)
-> ContT ("name" ::: ByteString) IO ("name" ::: ByteString)
forall a b. (a -> b) -> a -> b
$ ("name" ::: ByteString
buffer')
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkXrStructureTypeToString
:: FunPtr (Ptr Instance_T -> StructureType -> Ptr (FixedArray MAX_STRUCTURE_NAME_SIZE CChar) -> IO Result) -> Ptr Instance_T -> StructureType -> Ptr (FixedArray MAX_STRUCTURE_NAME_SIZE CChar) -> IO Result
structureTypeToString :: forall io
. (MonadIO io)
=>
Instance
->
("value" ::: StructureType)
-> io (("buffer" ::: ByteString))
structureTypeToString :: Instance
-> ("value" ::: StructureType) -> io ("name" ::: ByteString)
structureTypeToString instance' :: Instance
instance' value :: "value" ::: StructureType
value = IO ("name" ::: ByteString) -> io ("name" ::: ByteString)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ("name" ::: ByteString) -> io ("name" ::: ByteString))
-> (ContT ("name" ::: ByteString) IO ("name" ::: ByteString)
-> IO ("name" ::: ByteString))
-> ContT ("name" ::: ByteString) IO ("name" ::: ByteString)
-> io ("name" ::: ByteString)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT ("name" ::: ByteString) IO ("name" ::: ByteString)
-> IO ("name" ::: ByteString)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT ("name" ::: ByteString) IO ("name" ::: ByteString)
-> io ("name" ::: ByteString))
-> ContT ("name" ::: ByteString) IO ("name" ::: ByteString)
-> io ("name" ::: ByteString)
forall a b. (a -> b) -> a -> b
$ do
let xrStructureTypeToStringPtr :: FunPtr
(Ptr Instance_T
-> ("value" ::: StructureType)
-> ("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
-> IO Result)
xrStructureTypeToStringPtr = InstanceCmds
-> FunPtr
(Ptr Instance_T
-> ("value" ::: StructureType)
-> ("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
-> IO Result)
pXrStructureTypeToString (Instance -> InstanceCmds
instanceCmds (Instance
instance' :: Instance))
IO () -> ContT ("name" ::: ByteString) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT ("name" ::: ByteString) IO ())
-> IO () -> ContT ("name" ::: ByteString) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
(Ptr Instance_T
-> ("value" ::: StructureType)
-> ("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
-> IO Result)
xrStructureTypeToStringPtr FunPtr
(Ptr Instance_T
-> ("value" ::: StructureType)
-> ("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
-> IO Result)
-> FunPtr
(Ptr Instance_T
-> ("value" ::: StructureType)
-> ("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
-> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
(Ptr Instance_T
-> ("value" ::: StructureType)
-> ("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
-> 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 xrStructureTypeToString is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
let xrStructureTypeToString' :: Ptr Instance_T
-> ("value" ::: StructureType)
-> ("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
-> IO Result
xrStructureTypeToString' = FunPtr
(Ptr Instance_T
-> ("value" ::: StructureType)
-> ("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
-> IO Result)
-> Ptr Instance_T
-> ("value" ::: StructureType)
-> ("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
-> IO Result
mkXrStructureTypeToString FunPtr
(Ptr Instance_T
-> ("value" ::: StructureType)
-> ("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
-> IO Result)
xrStructureTypeToStringPtr
"buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar)
buffer <- ((("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
-> IO ("name" ::: ByteString))
-> IO ("name" ::: ByteString))
-> ContT
("name" ::: ByteString)
IO
("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
-> IO ("name" ::: ByteString))
-> IO ("name" ::: ByteString))
-> ContT
("name" ::: ByteString)
IO
("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar)))
-> ((("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
-> IO ("name" ::: ByteString))
-> IO ("name" ::: ByteString))
-> ContT
("name" ::: ByteString)
IO
("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
forall a b. (a -> b) -> a -> b
$ IO ("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
-> (("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
-> IO ())
-> (("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
-> IO ("name" ::: ByteString))
-> IO ("name" ::: ByteString)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket ((KnownNat MAX_RESULT_STRING_SIZE, Storable CChar) =>
IO ("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
forall (n :: Nat) a.
(KnownNat n, Storable a) =>
IO (Ptr (FixedArray n a))
callocFixedArray @MAX_STRUCTURE_NAME_SIZE @CChar) ("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
-> IO ()
forall a. Ptr a -> IO ()
free
Result
r <- IO Result -> ContT ("name" ::: ByteString) IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT ("name" ::: ByteString) IO Result)
-> IO Result -> ContT ("name" ::: ByteString) IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent "xrStructureTypeToString" (Ptr Instance_T
-> ("value" ::: StructureType)
-> ("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
-> IO Result
xrStructureTypeToString' (Instance -> Ptr Instance_T
instanceHandle (Instance
instance')) ("value" ::: StructureType
value) ("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar)
buffer))
IO () -> ContT ("name" ::: ByteString) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT ("name" ::: ByteString) IO ())
-> IO () -> ContT ("name" ::: ByteString) 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))
"name" ::: ByteString
buffer' <- IO ("name" ::: ByteString)
-> ContT ("name" ::: ByteString) IO ("name" ::: ByteString)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ("name" ::: ByteString)
-> ContT ("name" ::: ByteString) IO ("name" ::: ByteString))
-> IO ("name" ::: ByteString)
-> ContT ("name" ::: ByteString) IO ("name" ::: ByteString)
forall a b. (a -> b) -> a -> b
$ ("name" ::: Ptr CChar) -> IO ("name" ::: ByteString)
packCString (("name" ::: Ptr CChar) -> IO ("name" ::: ByteString))
-> (("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
-> "name" ::: Ptr CChar)
-> ("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
-> IO ("name" ::: ByteString)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
-> "name" ::: Ptr CChar
forall a (n :: Nat). Ptr (FixedArray n a) -> Ptr a
lowerArrayPtr @CChar @MAX_STRUCTURE_NAME_SIZE (("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
-> IO ("name" ::: ByteString))
-> ("buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar))
-> IO ("name" ::: ByteString)
forall a b. (a -> b) -> a -> b
$ "buffer" ::: Ptr (FixedArray MAX_RESULT_STRING_SIZE CChar)
buffer
("name" ::: ByteString)
-> ContT ("name" ::: ByteString) IO ("name" ::: ByteString)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (("name" ::: ByteString)
-> ContT ("name" ::: ByteString) IO ("name" ::: ByteString))
-> ("name" ::: ByteString)
-> ContT ("name" ::: ByteString) IO ("name" ::: ByteString)
forall a b. (a -> b) -> a -> b
$ ("name" ::: ByteString
buffer')
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkXrGetInstanceProperties
:: FunPtr (Ptr Instance_T -> Ptr InstanceProperties -> IO Result) -> Ptr Instance_T -> Ptr InstanceProperties -> IO Result
getInstanceProperties :: forall io
. (MonadIO io)
=>
Instance
-> io (InstanceProperties)
getInstanceProperties :: Instance -> io InstanceProperties
getInstanceProperties instance' :: Instance
instance' = IO InstanceProperties -> io InstanceProperties
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO InstanceProperties -> io InstanceProperties)
-> (ContT InstanceProperties IO InstanceProperties
-> IO InstanceProperties)
-> ContT InstanceProperties IO InstanceProperties
-> io InstanceProperties
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT InstanceProperties IO InstanceProperties
-> IO InstanceProperties
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT InstanceProperties IO InstanceProperties
-> io InstanceProperties)
-> ContT InstanceProperties IO InstanceProperties
-> io InstanceProperties
forall a b. (a -> b) -> a -> b
$ do
let xrGetInstancePropertiesPtr :: FunPtr (Ptr Instance_T -> Ptr InstanceProperties -> IO Result)
xrGetInstancePropertiesPtr = InstanceCmds
-> FunPtr (Ptr Instance_T -> Ptr InstanceProperties -> IO Result)
pXrGetInstanceProperties (Instance -> InstanceCmds
instanceCmds (Instance
instance' :: Instance))
IO () -> ContT InstanceProperties IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT InstanceProperties IO ())
-> IO () -> ContT InstanceProperties IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr (Ptr Instance_T -> Ptr InstanceProperties -> IO Result)
xrGetInstancePropertiesPtr FunPtr (Ptr Instance_T -> Ptr InstanceProperties -> IO Result)
-> FunPtr (Ptr Instance_T -> Ptr InstanceProperties -> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr (Ptr Instance_T -> Ptr InstanceProperties -> 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 xrGetInstanceProperties is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
let xrGetInstanceProperties' :: Ptr Instance_T -> Ptr InstanceProperties -> IO Result
xrGetInstanceProperties' = FunPtr (Ptr Instance_T -> Ptr InstanceProperties -> IO Result)
-> Ptr Instance_T -> Ptr InstanceProperties -> IO Result
mkXrGetInstanceProperties FunPtr (Ptr Instance_T -> Ptr InstanceProperties -> IO Result)
xrGetInstancePropertiesPtr
Ptr InstanceProperties
pInstanceProperties <- ((Ptr InstanceProperties -> IO InstanceProperties)
-> IO InstanceProperties)
-> ContT InstanceProperties IO (Ptr InstanceProperties)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (forall b.
ToCStruct InstanceProperties =>
(Ptr InstanceProperties -> IO b) -> IO b
forall a b. ToCStruct a => (Ptr a -> IO b) -> IO b
withZeroCStruct @InstanceProperties)
Result
r <- IO Result -> ContT InstanceProperties IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT InstanceProperties IO Result)
-> IO Result -> ContT InstanceProperties IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent "xrGetInstanceProperties" (Ptr Instance_T -> Ptr InstanceProperties -> IO Result
xrGetInstanceProperties' (Instance -> Ptr Instance_T
instanceHandle (Instance
instance')) (Ptr InstanceProperties
pInstanceProperties))
IO () -> ContT InstanceProperties IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT InstanceProperties IO ())
-> IO () -> ContT InstanceProperties 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))
InstanceProperties
instanceProperties <- IO InstanceProperties
-> ContT InstanceProperties IO InstanceProperties
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO InstanceProperties
-> ContT InstanceProperties IO InstanceProperties)
-> IO InstanceProperties
-> ContT InstanceProperties IO InstanceProperties
forall a b. (a -> b) -> a -> b
$ Ptr InstanceProperties -> IO InstanceProperties
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @InstanceProperties Ptr InstanceProperties
pInstanceProperties
InstanceProperties
-> ContT InstanceProperties IO InstanceProperties
forall (f :: * -> *) a. Applicative f => a -> f a
pure (InstanceProperties
-> ContT InstanceProperties IO InstanceProperties)
-> InstanceProperties
-> ContT InstanceProperties IO InstanceProperties
forall a b. (a -> b) -> a -> b
$ (InstanceProperties
instanceProperties)
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkXrPollEvent
:: FunPtr (Ptr Instance_T -> Ptr EventDataBuffer -> IO Result) -> Ptr Instance_T -> Ptr EventDataBuffer -> IO Result
pollEvent :: forall io
. (MonadIO io)
=>
Instance
-> io (Result, EventDataBuffer)
pollEvent :: Instance -> io (Result, EventDataBuffer)
pollEvent instance' :: Instance
instance' = IO (Result, EventDataBuffer) -> io (Result, EventDataBuffer)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Result, EventDataBuffer) -> io (Result, EventDataBuffer))
-> (ContT (Result, EventDataBuffer) IO (Result, EventDataBuffer)
-> IO (Result, EventDataBuffer))
-> ContT (Result, EventDataBuffer) IO (Result, EventDataBuffer)
-> io (Result, EventDataBuffer)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT (Result, EventDataBuffer) IO (Result, EventDataBuffer)
-> IO (Result, EventDataBuffer)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT (Result, EventDataBuffer) IO (Result, EventDataBuffer)
-> io (Result, EventDataBuffer))
-> ContT (Result, EventDataBuffer) IO (Result, EventDataBuffer)
-> io (Result, EventDataBuffer)
forall a b. (a -> b) -> a -> b
$ do
let xrPollEventPtr :: FunPtr (Ptr Instance_T -> Ptr EventDataBuffer -> IO Result)
xrPollEventPtr = InstanceCmds
-> FunPtr (Ptr Instance_T -> Ptr EventDataBuffer -> IO Result)
pXrPollEvent (Instance -> InstanceCmds
instanceCmds (Instance
instance' :: Instance))
IO () -> ContT (Result, EventDataBuffer) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT (Result, EventDataBuffer) IO ())
-> IO () -> ContT (Result, EventDataBuffer) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr (Ptr Instance_T -> Ptr EventDataBuffer -> IO Result)
xrPollEventPtr FunPtr (Ptr Instance_T -> Ptr EventDataBuffer -> IO Result)
-> FunPtr (Ptr Instance_T -> Ptr EventDataBuffer -> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr (Ptr Instance_T -> Ptr EventDataBuffer -> 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 xrPollEvent is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
let xrPollEvent' :: Ptr Instance_T -> Ptr EventDataBuffer -> IO Result
xrPollEvent' = FunPtr (Ptr Instance_T -> Ptr EventDataBuffer -> IO Result)
-> Ptr Instance_T -> Ptr EventDataBuffer -> IO Result
mkXrPollEvent FunPtr (Ptr Instance_T -> Ptr EventDataBuffer -> IO Result)
xrPollEventPtr
Ptr EventDataBuffer
pEventData <- ((Ptr EventDataBuffer -> IO (Result, EventDataBuffer))
-> IO (Result, EventDataBuffer))
-> ContT (Result, EventDataBuffer) IO (Ptr EventDataBuffer)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (forall b.
ToCStruct EventDataBuffer =>
(Ptr EventDataBuffer -> IO b) -> IO b
forall a b. ToCStruct a => (Ptr a -> IO b) -> IO b
withZeroCStruct @EventDataBuffer)
Result
r <- IO Result -> ContT (Result, EventDataBuffer) IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT (Result, EventDataBuffer) IO Result)
-> IO Result -> ContT (Result, EventDataBuffer) IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent "xrPollEvent" (Ptr Instance_T -> Ptr EventDataBuffer -> IO Result
xrPollEvent' (Instance -> Ptr Instance_T
instanceHandle (Instance
instance')) (Ptr EventDataBuffer
pEventData))
IO () -> ContT (Result, EventDataBuffer) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT (Result, EventDataBuffer) IO ())
-> IO () -> ContT (Result, EventDataBuffer) 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))
EventDataBuffer
eventData <- IO EventDataBuffer
-> ContT (Result, EventDataBuffer) IO EventDataBuffer
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO EventDataBuffer
-> ContT (Result, EventDataBuffer) IO EventDataBuffer)
-> IO EventDataBuffer
-> ContT (Result, EventDataBuffer) IO EventDataBuffer
forall a b. (a -> b) -> a -> b
$ Ptr EventDataBuffer -> IO EventDataBuffer
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @EventDataBuffer Ptr EventDataBuffer
pEventData
(Result, EventDataBuffer)
-> ContT (Result, EventDataBuffer) IO (Result, EventDataBuffer)
forall (f :: * -> *) a. Applicative f => a -> f a
pure ((Result, EventDataBuffer)
-> ContT (Result, EventDataBuffer) IO (Result, EventDataBuffer))
-> (Result, EventDataBuffer)
-> ContT (Result, EventDataBuffer) IO (Result, EventDataBuffer)
forall a b. (a -> b) -> a -> b
$ (Result
r, EventDataBuffer
eventData)
data ApiLayerProperties = ApiLayerProperties
{
ApiLayerProperties -> "name" ::: ByteString
layerName :: ByteString
,
ApiLayerProperties -> Version
specVersion :: Version
,
ApiLayerProperties -> "propertyCapacityInput" ::: Word32
layerVersion :: Word32
,
ApiLayerProperties -> "name" ::: ByteString
description :: ByteString
}
deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (ApiLayerProperties)
#endif
deriving instance Show ApiLayerProperties
instance ToCStruct ApiLayerProperties where
withCStruct :: ApiLayerProperties -> (Ptr ApiLayerProperties -> IO b) -> IO b
withCStruct x :: ApiLayerProperties
x f :: Ptr ApiLayerProperties -> IO b
f = Int -> Int -> (Ptr ApiLayerProperties -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 544 8 ((Ptr ApiLayerProperties -> IO b) -> IO b)
-> (Ptr ApiLayerProperties -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: Ptr ApiLayerProperties
p -> Ptr ApiLayerProperties -> ApiLayerProperties -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr ApiLayerProperties
p ApiLayerProperties
x (Ptr ApiLayerProperties -> IO b
f Ptr ApiLayerProperties
p)
pokeCStruct :: Ptr ApiLayerProperties -> ApiLayerProperties -> IO b -> IO b
pokeCStruct p :: Ptr ApiLayerProperties
p ApiLayerProperties{..} f :: IO b
f = do
Ptr ("value" ::: StructureType)
-> ("value" ::: StructureType) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ApiLayerProperties
p Ptr ApiLayerProperties -> Int -> Ptr ("value" ::: StructureType)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) ("value" ::: StructureType
TYPE_API_LAYER_PROPERTIES)
Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ApiLayerProperties
p Ptr ApiLayerProperties -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
Ptr (FixedArray MAX_API_LAYER_NAME_SIZE CChar)
-> ("name" ::: ByteString) -> IO ()
forall (n :: Nat).
KnownNat n =>
Ptr (FixedArray n CChar) -> ("name" ::: ByteString) -> IO ()
pokeFixedLengthNullTerminatedByteString ((Ptr ApiLayerProperties
p Ptr ApiLayerProperties
-> Int -> Ptr (FixedArray MAX_API_LAYER_NAME_SIZE CChar)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr (FixedArray MAX_API_LAYER_NAME_SIZE CChar))) ("name" ::: ByteString
layerName)
Ptr Version -> Version -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ApiLayerProperties
p Ptr ApiLayerProperties -> Int -> Ptr Version
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 272 :: Ptr Version)) (Version
specVersion)
("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> ("propertyCapacityInput" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ApiLayerProperties
p Ptr ApiLayerProperties
-> Int
-> "propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 280 :: Ptr Word32)) ("propertyCapacityInput" ::: Word32
layerVersion)
Ptr (FixedArray MAX_API_LAYER_NAME_SIZE CChar)
-> ("name" ::: ByteString) -> IO ()
forall (n :: Nat).
KnownNat n =>
Ptr (FixedArray n CChar) -> ("name" ::: ByteString) -> IO ()
pokeFixedLengthNullTerminatedByteString ((Ptr ApiLayerProperties
p Ptr ApiLayerProperties
-> Int -> Ptr (FixedArray MAX_API_LAYER_NAME_SIZE CChar)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 284 :: Ptr (FixedArray MAX_API_LAYER_DESCRIPTION_SIZE CChar))) ("name" ::: ByteString
description)
IO b
f
cStructSize :: Int
cStructSize = 544
cStructAlignment :: Int
cStructAlignment = 8
pokeZeroCStruct :: Ptr ApiLayerProperties -> IO b -> IO b
pokeZeroCStruct p :: Ptr ApiLayerProperties
p f :: IO b
f = do
Ptr ("value" ::: StructureType)
-> ("value" ::: StructureType) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ApiLayerProperties
p Ptr ApiLayerProperties -> Int -> Ptr ("value" ::: StructureType)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) ("value" ::: StructureType
TYPE_API_LAYER_PROPERTIES)
Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ApiLayerProperties
p Ptr ApiLayerProperties -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
Ptr (FixedArray MAX_API_LAYER_NAME_SIZE CChar)
-> ("name" ::: ByteString) -> IO ()
forall (n :: Nat).
KnownNat n =>
Ptr (FixedArray n CChar) -> ("name" ::: ByteString) -> IO ()
pokeFixedLengthNullTerminatedByteString ((Ptr ApiLayerProperties
p Ptr ApiLayerProperties
-> Int -> Ptr (FixedArray MAX_API_LAYER_NAME_SIZE CChar)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr (FixedArray MAX_API_LAYER_NAME_SIZE CChar))) ("name" ::: ByteString
forall a. Monoid a => a
mempty)
Ptr Version -> Version -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ApiLayerProperties
p Ptr ApiLayerProperties -> Int -> Ptr Version
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 272 :: Ptr Version)) (Version
forall a. Zero a => a
zero)
("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> ("propertyCapacityInput" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ApiLayerProperties
p Ptr ApiLayerProperties
-> Int
-> "propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 280 :: Ptr Word32)) ("propertyCapacityInput" ::: Word32
forall a. Zero a => a
zero)
Ptr (FixedArray MAX_API_LAYER_NAME_SIZE CChar)
-> ("name" ::: ByteString) -> IO ()
forall (n :: Nat).
KnownNat n =>
Ptr (FixedArray n CChar) -> ("name" ::: ByteString) -> IO ()
pokeFixedLengthNullTerminatedByteString ((Ptr ApiLayerProperties
p Ptr ApiLayerProperties
-> Int -> Ptr (FixedArray MAX_API_LAYER_NAME_SIZE CChar)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 284 :: Ptr (FixedArray MAX_API_LAYER_DESCRIPTION_SIZE CChar))) ("name" ::: ByteString
forall a. Monoid a => a
mempty)
IO b
f
instance FromCStruct ApiLayerProperties where
peekCStruct :: Ptr ApiLayerProperties -> IO ApiLayerProperties
peekCStruct p :: Ptr ApiLayerProperties
p = do
"name" ::: ByteString
layerName <- ("name" ::: Ptr CChar) -> IO ("name" ::: ByteString)
packCString (Ptr (FixedArray MAX_API_LAYER_NAME_SIZE CChar)
-> "name" ::: Ptr CChar
forall a (n :: Nat). Ptr (FixedArray n a) -> Ptr a
lowerArrayPtr ((Ptr ApiLayerProperties
p Ptr ApiLayerProperties
-> Int -> Ptr (FixedArray MAX_API_LAYER_NAME_SIZE CChar)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr (FixedArray MAX_API_LAYER_NAME_SIZE CChar))))
Version
specVersion <- Ptr Version -> IO Version
forall a. Storable a => Ptr a -> IO a
peek @Version ((Ptr ApiLayerProperties
p Ptr ApiLayerProperties -> Int -> Ptr Version
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 272 :: Ptr Version))
"propertyCapacityInput" ::: Word32
layerVersion <- ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> IO ("propertyCapacityInput" ::: Word32)
forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr ApiLayerProperties
p Ptr ApiLayerProperties
-> Int
-> "propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 280 :: Ptr Word32))
"name" ::: ByteString
description <- ("name" ::: Ptr CChar) -> IO ("name" ::: ByteString)
packCString (Ptr (FixedArray MAX_API_LAYER_NAME_SIZE CChar)
-> "name" ::: Ptr CChar
forall a (n :: Nat). Ptr (FixedArray n a) -> Ptr a
lowerArrayPtr ((Ptr ApiLayerProperties
p Ptr ApiLayerProperties
-> Int -> Ptr (FixedArray MAX_API_LAYER_NAME_SIZE CChar)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 284 :: Ptr (FixedArray MAX_API_LAYER_DESCRIPTION_SIZE CChar))))
ApiLayerProperties -> IO ApiLayerProperties
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ApiLayerProperties -> IO ApiLayerProperties)
-> ApiLayerProperties -> IO ApiLayerProperties
forall a b. (a -> b) -> a -> b
$ ("name" ::: ByteString)
-> Version
-> ("propertyCapacityInput" ::: Word32)
-> ("name" ::: ByteString)
-> ApiLayerProperties
ApiLayerProperties
"name" ::: ByteString
layerName Version
specVersion "propertyCapacityInput" ::: Word32
layerVersion "name" ::: ByteString
description
instance Storable ApiLayerProperties where
sizeOf :: ApiLayerProperties -> Int
sizeOf ~ApiLayerProperties
_ = 544
alignment :: ApiLayerProperties -> Int
alignment ~ApiLayerProperties
_ = 8
peek :: Ptr ApiLayerProperties -> IO ApiLayerProperties
peek = Ptr ApiLayerProperties -> IO ApiLayerProperties
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
poke :: Ptr ApiLayerProperties -> ApiLayerProperties -> IO ()
poke ptr :: Ptr ApiLayerProperties
ptr poked :: ApiLayerProperties
poked = Ptr ApiLayerProperties -> ApiLayerProperties -> IO () -> IO ()
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr ApiLayerProperties
ptr ApiLayerProperties
poked (() -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())
instance Zero ApiLayerProperties where
zero :: ApiLayerProperties
zero = ("name" ::: ByteString)
-> Version
-> ("propertyCapacityInput" ::: Word32)
-> ("name" ::: ByteString)
-> ApiLayerProperties
ApiLayerProperties
"name" ::: ByteString
forall a. Monoid a => a
mempty
Version
forall a. Zero a => a
zero
"propertyCapacityInput" ::: Word32
forall a. Zero a => a
zero
"name" ::: ByteString
forall a. Monoid a => a
mempty
data ExtensionProperties = ExtensionProperties
{
ExtensionProperties -> "name" ::: ByteString
extensionName :: ByteString
,
ExtensionProperties -> "propertyCapacityInput" ::: Word32
extensionVersion :: Word32
}
deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (ExtensionProperties)
#endif
deriving instance Show ExtensionProperties
instance ToCStruct ExtensionProperties where
withCStruct :: ExtensionProperties -> (Ptr ExtensionProperties -> IO b) -> IO b
withCStruct x :: ExtensionProperties
x f :: Ptr ExtensionProperties -> IO b
f = Int -> Int -> (Ptr ExtensionProperties -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 152 8 ((Ptr ExtensionProperties -> IO b) -> IO b)
-> (Ptr ExtensionProperties -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: Ptr ExtensionProperties
p -> Ptr ExtensionProperties -> ExtensionProperties -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr ExtensionProperties
p ExtensionProperties
x (Ptr ExtensionProperties -> IO b
f Ptr ExtensionProperties
p)
pokeCStruct :: Ptr ExtensionProperties -> ExtensionProperties -> IO b -> IO b
pokeCStruct p :: Ptr ExtensionProperties
p ExtensionProperties{..} f :: IO b
f = do
Ptr ("value" ::: StructureType)
-> ("value" ::: StructureType) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ExtensionProperties
p Ptr ExtensionProperties -> Int -> Ptr ("value" ::: StructureType)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) ("value" ::: StructureType
TYPE_EXTENSION_PROPERTIES)
Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ExtensionProperties
p Ptr ExtensionProperties -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
Ptr (FixedArray MAX_EXTENSION_NAME_SIZE CChar)
-> ("name" ::: ByteString) -> IO ()
forall (n :: Nat).
KnownNat n =>
Ptr (FixedArray n CChar) -> ("name" ::: ByteString) -> IO ()
pokeFixedLengthNullTerminatedByteString ((Ptr ExtensionProperties
p Ptr ExtensionProperties
-> Int -> Ptr (FixedArray MAX_EXTENSION_NAME_SIZE CChar)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr (FixedArray MAX_EXTENSION_NAME_SIZE CChar))) ("name" ::: ByteString
extensionName)
("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> ("propertyCapacityInput" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ExtensionProperties
p Ptr ExtensionProperties
-> Int
-> "propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 144 :: Ptr Word32)) ("propertyCapacityInput" ::: Word32
extensionVersion)
IO b
f
cStructSize :: Int
cStructSize = 152
cStructAlignment :: Int
cStructAlignment = 8
pokeZeroCStruct :: Ptr ExtensionProperties -> IO b -> IO b
pokeZeroCStruct p :: Ptr ExtensionProperties
p f :: IO b
f = do
Ptr ("value" ::: StructureType)
-> ("value" ::: StructureType) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ExtensionProperties
p Ptr ExtensionProperties -> Int -> Ptr ("value" ::: StructureType)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) ("value" ::: StructureType
TYPE_EXTENSION_PROPERTIES)
Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ExtensionProperties
p Ptr ExtensionProperties -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
Ptr (FixedArray MAX_EXTENSION_NAME_SIZE CChar)
-> ("name" ::: ByteString) -> IO ()
forall (n :: Nat).
KnownNat n =>
Ptr (FixedArray n CChar) -> ("name" ::: ByteString) -> IO ()
pokeFixedLengthNullTerminatedByteString ((Ptr ExtensionProperties
p Ptr ExtensionProperties
-> Int -> Ptr (FixedArray MAX_EXTENSION_NAME_SIZE CChar)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr (FixedArray MAX_EXTENSION_NAME_SIZE CChar))) ("name" ::: ByteString
forall a. Monoid a => a
mempty)
("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> ("propertyCapacityInput" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ExtensionProperties
p Ptr ExtensionProperties
-> Int
-> "propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 144 :: Ptr Word32)) ("propertyCapacityInput" ::: Word32
forall a. Zero a => a
zero)
IO b
f
instance FromCStruct ExtensionProperties where
peekCStruct :: Ptr ExtensionProperties -> IO ExtensionProperties
peekCStruct p :: Ptr ExtensionProperties
p = do
"name" ::: ByteString
extensionName <- ("name" ::: Ptr CChar) -> IO ("name" ::: ByteString)
packCString (Ptr (FixedArray MAX_EXTENSION_NAME_SIZE CChar)
-> "name" ::: Ptr CChar
forall a (n :: Nat). Ptr (FixedArray n a) -> Ptr a
lowerArrayPtr ((Ptr ExtensionProperties
p Ptr ExtensionProperties
-> Int -> Ptr (FixedArray MAX_EXTENSION_NAME_SIZE CChar)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr (FixedArray MAX_EXTENSION_NAME_SIZE CChar))))
"propertyCapacityInput" ::: Word32
extensionVersion <- ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> IO ("propertyCapacityInput" ::: Word32)
forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr ExtensionProperties
p Ptr ExtensionProperties
-> Int
-> "propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 144 :: Ptr Word32))
ExtensionProperties -> IO ExtensionProperties
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ExtensionProperties -> IO ExtensionProperties)
-> ExtensionProperties -> IO ExtensionProperties
forall a b. (a -> b) -> a -> b
$ ("name" ::: ByteString)
-> ("propertyCapacityInput" ::: Word32) -> ExtensionProperties
ExtensionProperties
"name" ::: ByteString
extensionName "propertyCapacityInput" ::: Word32
extensionVersion
instance Storable ExtensionProperties where
sizeOf :: ExtensionProperties -> Int
sizeOf ~ExtensionProperties
_ = 152
alignment :: ExtensionProperties -> Int
alignment ~ExtensionProperties
_ = 8
peek :: Ptr ExtensionProperties -> IO ExtensionProperties
peek = Ptr ExtensionProperties -> IO ExtensionProperties
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
poke :: Ptr ExtensionProperties -> ExtensionProperties -> IO ()
poke ptr :: Ptr ExtensionProperties
ptr poked :: ExtensionProperties
poked = Ptr ExtensionProperties -> ExtensionProperties -> IO () -> IO ()
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr ExtensionProperties
ptr ExtensionProperties
poked (() -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())
instance Zero ExtensionProperties where
zero :: ExtensionProperties
zero = ("name" ::: ByteString)
-> ("propertyCapacityInput" ::: Word32) -> ExtensionProperties
ExtensionProperties
"name" ::: ByteString
forall a. Monoid a => a
mempty
"propertyCapacityInput" ::: Word32
forall a. Zero a => a
zero
data ApplicationInfo = ApplicationInfo
{
ApplicationInfo -> "name" ::: ByteString
applicationName :: ByteString
,
ApplicationInfo -> "propertyCapacityInput" ::: Word32
applicationVersion :: Word32
,
ApplicationInfo -> "name" ::: ByteString
engineName :: ByteString
,
ApplicationInfo -> "propertyCapacityInput" ::: Word32
engineVersion :: Word32
,
ApplicationInfo -> Version
apiVersion :: Version
}
deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (ApplicationInfo)
#endif
deriving instance Show ApplicationInfo
instance ToCStruct ApplicationInfo where
withCStruct :: ApplicationInfo -> (Ptr ApplicationInfo -> IO b) -> IO b
withCStruct x :: ApplicationInfo
x f :: Ptr ApplicationInfo -> IO b
f = Int -> Int -> (Ptr ApplicationInfo -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 272 8 ((Ptr ApplicationInfo -> IO b) -> IO b)
-> (Ptr ApplicationInfo -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: Ptr ApplicationInfo
p -> Ptr ApplicationInfo -> ApplicationInfo -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr ApplicationInfo
p ApplicationInfo
x (Ptr ApplicationInfo -> IO b
f Ptr ApplicationInfo
p)
pokeCStruct :: Ptr ApplicationInfo -> ApplicationInfo -> IO b -> IO b
pokeCStruct p :: Ptr ApplicationInfo
p ApplicationInfo{..} f :: IO b
f = do
Ptr (FixedArray MAX_EXTENSION_NAME_SIZE CChar)
-> ("name" ::: ByteString) -> IO ()
forall (n :: Nat).
KnownNat n =>
Ptr (FixedArray n CChar) -> ("name" ::: ByteString) -> IO ()
pokeFixedLengthNullTerminatedByteString ((Ptr ApplicationInfo
p Ptr ApplicationInfo
-> Int -> Ptr (FixedArray MAX_EXTENSION_NAME_SIZE CChar)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr (FixedArray MAX_APPLICATION_NAME_SIZE CChar))) ("name" ::: ByteString
applicationName)
("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> ("propertyCapacityInput" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ApplicationInfo
p Ptr ApplicationInfo
-> Int
-> "propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 128 :: Ptr Word32)) ("propertyCapacityInput" ::: Word32
applicationVersion)
Ptr (FixedArray MAX_EXTENSION_NAME_SIZE CChar)
-> ("name" ::: ByteString) -> IO ()
forall (n :: Nat).
KnownNat n =>
Ptr (FixedArray n CChar) -> ("name" ::: ByteString) -> IO ()
pokeFixedLengthNullTerminatedByteString ((Ptr ApplicationInfo
p Ptr ApplicationInfo
-> Int -> Ptr (FixedArray MAX_EXTENSION_NAME_SIZE CChar)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 132 :: Ptr (FixedArray MAX_ENGINE_NAME_SIZE CChar))) ("name" ::: ByteString
engineName)
("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> ("propertyCapacityInput" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ApplicationInfo
p Ptr ApplicationInfo
-> Int
-> "propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 260 :: Ptr Word32)) ("propertyCapacityInput" ::: Word32
engineVersion)
Ptr Version -> Version -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ApplicationInfo
p Ptr ApplicationInfo -> Int -> Ptr Version
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 264 :: Ptr Version)) (Version
apiVersion)
IO b
f
cStructSize :: Int
cStructSize = 272
cStructAlignment :: Int
cStructAlignment = 8
pokeZeroCStruct :: Ptr ApplicationInfo -> IO b -> IO b
pokeZeroCStruct p :: Ptr ApplicationInfo
p f :: IO b
f = do
Ptr (FixedArray MAX_EXTENSION_NAME_SIZE CChar)
-> ("name" ::: ByteString) -> IO ()
forall (n :: Nat).
KnownNat n =>
Ptr (FixedArray n CChar) -> ("name" ::: ByteString) -> IO ()
pokeFixedLengthNullTerminatedByteString ((Ptr ApplicationInfo
p Ptr ApplicationInfo
-> Int -> Ptr (FixedArray MAX_EXTENSION_NAME_SIZE CChar)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr (FixedArray MAX_APPLICATION_NAME_SIZE CChar))) ("name" ::: ByteString
forall a. Monoid a => a
mempty)
("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> ("propertyCapacityInput" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ApplicationInfo
p Ptr ApplicationInfo
-> Int
-> "propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 128 :: Ptr Word32)) ("propertyCapacityInput" ::: Word32
forall a. Zero a => a
zero)
Ptr (FixedArray MAX_EXTENSION_NAME_SIZE CChar)
-> ("name" ::: ByteString) -> IO ()
forall (n :: Nat).
KnownNat n =>
Ptr (FixedArray n CChar) -> ("name" ::: ByteString) -> IO ()
pokeFixedLengthNullTerminatedByteString ((Ptr ApplicationInfo
p Ptr ApplicationInfo
-> Int -> Ptr (FixedArray MAX_EXTENSION_NAME_SIZE CChar)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 132 :: Ptr (FixedArray MAX_ENGINE_NAME_SIZE CChar))) ("name" ::: ByteString
forall a. Monoid a => a
mempty)
("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> ("propertyCapacityInput" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ApplicationInfo
p Ptr ApplicationInfo
-> Int
-> "propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 260 :: Ptr Word32)) ("propertyCapacityInput" ::: Word32
forall a. Zero a => a
zero)
Ptr Version -> Version -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ApplicationInfo
p Ptr ApplicationInfo -> Int -> Ptr Version
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 264 :: Ptr Version)) (Version
forall a. Zero a => a
zero)
IO b
f
instance FromCStruct ApplicationInfo where
peekCStruct :: Ptr ApplicationInfo -> IO ApplicationInfo
peekCStruct p :: Ptr ApplicationInfo
p = do
"name" ::: ByteString
applicationName <- ("name" ::: Ptr CChar) -> IO ("name" ::: ByteString)
packCString (Ptr (FixedArray MAX_EXTENSION_NAME_SIZE CChar)
-> "name" ::: Ptr CChar
forall a (n :: Nat). Ptr (FixedArray n a) -> Ptr a
lowerArrayPtr ((Ptr ApplicationInfo
p Ptr ApplicationInfo
-> Int -> Ptr (FixedArray MAX_EXTENSION_NAME_SIZE CChar)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr (FixedArray MAX_APPLICATION_NAME_SIZE CChar))))
"propertyCapacityInput" ::: Word32
applicationVersion <- ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> IO ("propertyCapacityInput" ::: Word32)
forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr ApplicationInfo
p Ptr ApplicationInfo
-> Int
-> "propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 128 :: Ptr Word32))
"name" ::: ByteString
engineName <- ("name" ::: Ptr CChar) -> IO ("name" ::: ByteString)
packCString (Ptr (FixedArray MAX_EXTENSION_NAME_SIZE CChar)
-> "name" ::: Ptr CChar
forall a (n :: Nat). Ptr (FixedArray n a) -> Ptr a
lowerArrayPtr ((Ptr ApplicationInfo
p Ptr ApplicationInfo
-> Int -> Ptr (FixedArray MAX_EXTENSION_NAME_SIZE CChar)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 132 :: Ptr (FixedArray MAX_ENGINE_NAME_SIZE CChar))))
"propertyCapacityInput" ::: Word32
engineVersion <- ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> IO ("propertyCapacityInput" ::: Word32)
forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr ApplicationInfo
p Ptr ApplicationInfo
-> Int
-> "propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 260 :: Ptr Word32))
Version
apiVersion <- Ptr Version -> IO Version
forall a. Storable a => Ptr a -> IO a
peek @Version ((Ptr ApplicationInfo
p Ptr ApplicationInfo -> Int -> Ptr Version
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 264 :: Ptr Version))
ApplicationInfo -> IO ApplicationInfo
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ApplicationInfo -> IO ApplicationInfo)
-> ApplicationInfo -> IO ApplicationInfo
forall a b. (a -> b) -> a -> b
$ ("name" ::: ByteString)
-> ("propertyCapacityInput" ::: Word32)
-> ("name" ::: ByteString)
-> ("propertyCapacityInput" ::: Word32)
-> Version
-> ApplicationInfo
ApplicationInfo
"name" ::: ByteString
applicationName "propertyCapacityInput" ::: Word32
applicationVersion "name" ::: ByteString
engineName "propertyCapacityInput" ::: Word32
engineVersion Version
apiVersion
instance Storable ApplicationInfo where
sizeOf :: ApplicationInfo -> Int
sizeOf ~ApplicationInfo
_ = 272
alignment :: ApplicationInfo -> Int
alignment ~ApplicationInfo
_ = 8
peek :: Ptr ApplicationInfo -> IO ApplicationInfo
peek = Ptr ApplicationInfo -> IO ApplicationInfo
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
poke :: Ptr ApplicationInfo -> ApplicationInfo -> IO ()
poke ptr :: Ptr ApplicationInfo
ptr poked :: ApplicationInfo
poked = Ptr ApplicationInfo -> ApplicationInfo -> IO () -> IO ()
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr ApplicationInfo
ptr ApplicationInfo
poked (() -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())
instance Zero ApplicationInfo where
zero :: ApplicationInfo
zero = ("name" ::: ByteString)
-> ("propertyCapacityInput" ::: Word32)
-> ("name" ::: ByteString)
-> ("propertyCapacityInput" ::: Word32)
-> Version
-> ApplicationInfo
ApplicationInfo
"name" ::: ByteString
forall a. Monoid a => a
mempty
"propertyCapacityInput" ::: Word32
forall a. Zero a => a
zero
"name" ::: ByteString
forall a. Monoid a => a
mempty
"propertyCapacityInput" ::: Word32
forall a. Zero a => a
zero
Version
forall a. Zero a => a
zero
data InstanceCreateInfo (es :: [Type]) = InstanceCreateInfo
{
InstanceCreateInfo es -> Chain es
next :: Chain es
,
InstanceCreateInfo es -> InstanceCreateFlags
createFlags :: InstanceCreateFlags
,
InstanceCreateInfo es -> ApplicationInfo
applicationInfo :: ApplicationInfo
,
InstanceCreateInfo es -> Vector ("name" ::: ByteString)
enabledApiLayerNames :: Vector ByteString
,
InstanceCreateInfo es -> Vector ("name" ::: ByteString)
enabledExtensionNames :: Vector ByteString
}
deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (InstanceCreateInfo (es :: [Type]))
#endif
deriving instance Show (Chain es) => Show (InstanceCreateInfo es)
instance Extensible InstanceCreateInfo where
extensibleTypeName :: String
extensibleTypeName = "InstanceCreateInfo"
setNext :: InstanceCreateInfo ds -> Chain es -> InstanceCreateInfo es
setNext x :: InstanceCreateInfo ds
x next :: Chain es
next = InstanceCreateInfo ds
x{$sel:next:InstanceCreateInfo :: Chain es
next = Chain es
next}
getNext :: InstanceCreateInfo es -> Chain es
getNext InstanceCreateInfo{..} = Chain es
next
extends :: forall e b proxy. Typeable e => proxy e -> (Extends InstanceCreateInfo e => b) -> Maybe b
extends :: proxy e -> (Extends InstanceCreateInfo e => b) -> Maybe b
extends _ f :: Extends InstanceCreateInfo e => b
f
| Just Refl <- (Typeable e, Typeable DebugUtilsMessengerCreateInfoEXT) =>
Maybe (e :~: DebugUtilsMessengerCreateInfoEXT)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @DebugUtilsMessengerCreateInfoEXT = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends InstanceCreateInfo e => b
f
| Just Refl <- (Typeable e, Typeable InstanceCreateInfoAndroidKHR) =>
Maybe (e :~: InstanceCreateInfoAndroidKHR)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @InstanceCreateInfoAndroidKHR = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends InstanceCreateInfo e => b
f
| Bool
otherwise = Maybe b
forall a. Maybe a
Nothing
instance (Extendss InstanceCreateInfo es, PokeChain es) => ToCStruct (InstanceCreateInfo es) where
withCStruct :: InstanceCreateInfo es
-> (Ptr (InstanceCreateInfo es) -> IO b) -> IO b
withCStruct x :: InstanceCreateInfo es
x f :: Ptr (InstanceCreateInfo es) -> IO b
f = Int -> Int -> (Ptr (InstanceCreateInfo es) -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 328 8 ((Ptr (InstanceCreateInfo es) -> IO b) -> IO b)
-> (Ptr (InstanceCreateInfo es) -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: Ptr (InstanceCreateInfo es)
p -> Ptr (InstanceCreateInfo es)
-> InstanceCreateInfo es -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr (InstanceCreateInfo es)
p InstanceCreateInfo es
x (Ptr (InstanceCreateInfo es) -> IO b
f Ptr (InstanceCreateInfo es)
p)
pokeCStruct :: Ptr (InstanceCreateInfo es)
-> InstanceCreateInfo es -> IO b -> IO b
pokeCStruct p :: Ptr (InstanceCreateInfo es)
p InstanceCreateInfo{..} 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 ("value" ::: StructureType)
-> ("value" ::: StructureType) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (InstanceCreateInfo es)
p Ptr (InstanceCreateInfo es)
-> Int -> Ptr ("value" ::: StructureType)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) ("value" ::: StructureType
TYPE_INSTANCE_CREATE_INFO)
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 (InstanceCreateInfo es)
p Ptr (InstanceCreateInfo 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 InstanceCreateFlags -> InstanceCreateFlags -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (InstanceCreateInfo es)
p Ptr (InstanceCreateInfo es) -> Int -> Ptr InstanceCreateFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr InstanceCreateFlags)) (InstanceCreateFlags
createFlags)
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 ApplicationInfo -> ApplicationInfo -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (InstanceCreateInfo es)
p Ptr (InstanceCreateInfo es) -> Int -> Ptr ApplicationInfo
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr ApplicationInfo)) (ApplicationInfo
applicationInfo)
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
$ ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> ("propertyCapacityInput" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (InstanceCreateInfo es)
p Ptr (InstanceCreateInfo es)
-> Int
-> "propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 296 :: Ptr Word32)) ((Int -> "propertyCapacityInput" ::: Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Vector ("name" ::: ByteString) -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector ("name" ::: ByteString) -> Int)
-> Vector ("name" ::: ByteString) -> Int
forall a b. (a -> b) -> a -> b
$ (Vector ("name" ::: ByteString)
enabledApiLayerNames)) :: Word32))
Ptr ("name" ::: Ptr CChar)
pEnabledApiLayerNames' <- ((Ptr ("name" ::: Ptr CChar) -> IO b) -> IO b)
-> ContT b IO (Ptr ("name" ::: Ptr CChar))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr ("name" ::: Ptr CChar) -> IO b) -> IO b)
-> ContT b IO (Ptr ("name" ::: Ptr CChar)))
-> ((Ptr ("name" ::: Ptr CChar) -> IO b) -> IO b)
-> ContT b IO (Ptr ("name" ::: Ptr CChar))
forall a b. (a -> b) -> a -> b
$ Int -> Int -> (Ptr ("name" ::: Ptr CChar) -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned @(Ptr CChar) ((Vector ("name" ::: ByteString) -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector ("name" ::: ByteString)
enabledApiLayerNames)) Int -> Int -> Int
forall a. Num a => a -> a -> a
* 8) 8
(Int -> ("name" ::: ByteString) -> ContT b IO ())
-> Vector ("name" ::: ByteString) -> ContT b IO ()
forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\i :: Int
i e :: "name" ::: ByteString
e -> do
"name" ::: Ptr CChar
enabledApiLayerNames'' <- ((("name" ::: Ptr CChar) -> IO b) -> IO b)
-> ContT b IO ("name" ::: Ptr CChar)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("name" ::: Ptr CChar) -> IO b) -> IO b)
-> ContT b IO ("name" ::: Ptr CChar))
-> ((("name" ::: Ptr CChar) -> IO b) -> IO b)
-> ContT b IO ("name" ::: Ptr CChar)
forall a b. (a -> b) -> a -> b
$ ("name" ::: ByteString) -> (("name" ::: Ptr CChar) -> IO b) -> IO b
forall a.
("name" ::: ByteString) -> (("name" ::: Ptr CChar) -> IO a) -> IO a
useAsCString ("name" ::: ByteString
e)
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 ("name" ::: Ptr CChar) -> ("name" ::: Ptr CChar) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr ("name" ::: Ptr CChar)
pEnabledApiLayerNames' Ptr ("name" ::: Ptr CChar) -> Int -> Ptr ("name" ::: Ptr CChar)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr (Ptr CChar)) "name" ::: Ptr CChar
enabledApiLayerNames'') (Vector ("name" ::: ByteString)
enabledApiLayerNames)
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 ("name" ::: Ptr CChar))
-> Ptr ("name" ::: Ptr CChar) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (InstanceCreateInfo es)
p Ptr (InstanceCreateInfo es)
-> Int -> Ptr (Ptr ("name" ::: Ptr CChar))
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 304 :: Ptr (Ptr (Ptr CChar)))) (Ptr ("name" ::: Ptr CChar)
pEnabledApiLayerNames')
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
$ ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> ("propertyCapacityInput" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (InstanceCreateInfo es)
p Ptr (InstanceCreateInfo es)
-> Int
-> "propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 312 :: Ptr Word32)) ((Int -> "propertyCapacityInput" ::: Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Vector ("name" ::: ByteString) -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector ("name" ::: ByteString) -> Int)
-> Vector ("name" ::: ByteString) -> Int
forall a b. (a -> b) -> a -> b
$ (Vector ("name" ::: ByteString)
enabledExtensionNames)) :: Word32))
Ptr ("name" ::: Ptr CChar)
pEnabledExtensionNames' <- ((Ptr ("name" ::: Ptr CChar) -> IO b) -> IO b)
-> ContT b IO (Ptr ("name" ::: Ptr CChar))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr ("name" ::: Ptr CChar) -> IO b) -> IO b)
-> ContT b IO (Ptr ("name" ::: Ptr CChar)))
-> ((Ptr ("name" ::: Ptr CChar) -> IO b) -> IO b)
-> ContT b IO (Ptr ("name" ::: Ptr CChar))
forall a b. (a -> b) -> a -> b
$ Int -> Int -> (Ptr ("name" ::: Ptr CChar) -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned @(Ptr CChar) ((Vector ("name" ::: ByteString) -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector ("name" ::: ByteString)
enabledExtensionNames)) Int -> Int -> Int
forall a. Num a => a -> a -> a
* 8) 8
(Int -> ("name" ::: ByteString) -> ContT b IO ())
-> Vector ("name" ::: ByteString) -> ContT b IO ()
forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\i :: Int
i e :: "name" ::: ByteString
e -> do
"name" ::: Ptr CChar
enabledExtensionNames'' <- ((("name" ::: Ptr CChar) -> IO b) -> IO b)
-> ContT b IO ("name" ::: Ptr CChar)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("name" ::: Ptr CChar) -> IO b) -> IO b)
-> ContT b IO ("name" ::: Ptr CChar))
-> ((("name" ::: Ptr CChar) -> IO b) -> IO b)
-> ContT b IO ("name" ::: Ptr CChar)
forall a b. (a -> b) -> a -> b
$ ("name" ::: ByteString) -> (("name" ::: Ptr CChar) -> IO b) -> IO b
forall a.
("name" ::: ByteString) -> (("name" ::: Ptr CChar) -> IO a) -> IO a
useAsCString ("name" ::: ByteString
e)
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 ("name" ::: Ptr CChar) -> ("name" ::: Ptr CChar) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr ("name" ::: Ptr CChar)
pEnabledExtensionNames' Ptr ("name" ::: Ptr CChar) -> Int -> Ptr ("name" ::: Ptr CChar)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr (Ptr CChar)) "name" ::: Ptr CChar
enabledExtensionNames'') (Vector ("name" ::: ByteString)
enabledExtensionNames)
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 ("name" ::: Ptr CChar))
-> Ptr ("name" ::: Ptr CChar) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (InstanceCreateInfo es)
p Ptr (InstanceCreateInfo es)
-> Int -> Ptr (Ptr ("name" ::: Ptr CChar))
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 320 :: Ptr (Ptr (Ptr CChar)))) (Ptr ("name" ::: Ptr CChar)
pEnabledExtensionNames')
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 = 328
cStructAlignment :: Int
cStructAlignment = 8
pokeZeroCStruct :: Ptr (InstanceCreateInfo es) -> IO b -> IO b
pokeZeroCStruct p :: Ptr (InstanceCreateInfo 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 ("value" ::: StructureType)
-> ("value" ::: StructureType) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (InstanceCreateInfo es)
p Ptr (InstanceCreateInfo es)
-> Int -> Ptr ("value" ::: StructureType)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) ("value" ::: StructureType
TYPE_INSTANCE_CREATE_INFO)
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 (InstanceCreateInfo es)
p Ptr (InstanceCreateInfo 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 ApplicationInfo -> ApplicationInfo -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (InstanceCreateInfo es)
p Ptr (InstanceCreateInfo es) -> Int -> Ptr ApplicationInfo
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr ApplicationInfo)) (ApplicationInfo
forall a. Zero a => a
zero)
Ptr ("name" ::: Ptr CChar)
pEnabledApiLayerNames' <- ((Ptr ("name" ::: Ptr CChar) -> IO b) -> IO b)
-> ContT b IO (Ptr ("name" ::: Ptr CChar))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr ("name" ::: Ptr CChar) -> IO b) -> IO b)
-> ContT b IO (Ptr ("name" ::: Ptr CChar)))
-> ((Ptr ("name" ::: Ptr CChar) -> IO b) -> IO b)
-> ContT b IO (Ptr ("name" ::: Ptr CChar))
forall a b. (a -> b) -> a -> b
$ Int -> Int -> (Ptr ("name" ::: Ptr CChar) -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned @(Ptr CChar) ((Vector Any -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector Any
forall a. Monoid a => a
mempty)) Int -> Int -> Int
forall a. Num a => a -> a -> a
* 8) 8
(Int -> ("name" ::: ByteString) -> ContT b IO ())
-> Vector ("name" ::: ByteString) -> ContT b IO ()
forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\i :: Int
i e :: "name" ::: ByteString
e -> do
"name" ::: Ptr CChar
enabledApiLayerNames'' <- ((("name" ::: Ptr CChar) -> IO b) -> IO b)
-> ContT b IO ("name" ::: Ptr CChar)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("name" ::: Ptr CChar) -> IO b) -> IO b)
-> ContT b IO ("name" ::: Ptr CChar))
-> ((("name" ::: Ptr CChar) -> IO b) -> IO b)
-> ContT b IO ("name" ::: Ptr CChar)
forall a b. (a -> b) -> a -> b
$ ("name" ::: ByteString) -> (("name" ::: Ptr CChar) -> IO b) -> IO b
forall a.
("name" ::: ByteString) -> (("name" ::: Ptr CChar) -> IO a) -> IO a
useAsCString ("name" ::: ByteString
e)
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 ("name" ::: Ptr CChar) -> ("name" ::: Ptr CChar) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr ("name" ::: Ptr CChar)
pEnabledApiLayerNames' Ptr ("name" ::: Ptr CChar) -> Int -> Ptr ("name" ::: Ptr CChar)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr (Ptr CChar)) "name" ::: Ptr CChar
enabledApiLayerNames'') (Vector ("name" ::: ByteString)
forall a. Monoid a => a
mempty)
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 ("name" ::: Ptr CChar))
-> Ptr ("name" ::: Ptr CChar) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (InstanceCreateInfo es)
p Ptr (InstanceCreateInfo es)
-> Int -> Ptr (Ptr ("name" ::: Ptr CChar))
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 304 :: Ptr (Ptr (Ptr CChar)))) (Ptr ("name" ::: Ptr CChar)
pEnabledApiLayerNames')
Ptr ("name" ::: Ptr CChar)
pEnabledExtensionNames' <- ((Ptr ("name" ::: Ptr CChar) -> IO b) -> IO b)
-> ContT b IO (Ptr ("name" ::: Ptr CChar))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr ("name" ::: Ptr CChar) -> IO b) -> IO b)
-> ContT b IO (Ptr ("name" ::: Ptr CChar)))
-> ((Ptr ("name" ::: Ptr CChar) -> IO b) -> IO b)
-> ContT b IO (Ptr ("name" ::: Ptr CChar))
forall a b. (a -> b) -> a -> b
$ Int -> Int -> (Ptr ("name" ::: Ptr CChar) -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned @(Ptr CChar) ((Vector Any -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector Any
forall a. Monoid a => a
mempty)) Int -> Int -> Int
forall a. Num a => a -> a -> a
* 8) 8
(Int -> ("name" ::: ByteString) -> ContT b IO ())
-> Vector ("name" ::: ByteString) -> ContT b IO ()
forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\i :: Int
i e :: "name" ::: ByteString
e -> do
"name" ::: Ptr CChar
enabledExtensionNames'' <- ((("name" ::: Ptr CChar) -> IO b) -> IO b)
-> ContT b IO ("name" ::: Ptr CChar)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("name" ::: Ptr CChar) -> IO b) -> IO b)
-> ContT b IO ("name" ::: Ptr CChar))
-> ((("name" ::: Ptr CChar) -> IO b) -> IO b)
-> ContT b IO ("name" ::: Ptr CChar)
forall a b. (a -> b) -> a -> b
$ ("name" ::: ByteString) -> (("name" ::: Ptr CChar) -> IO b) -> IO b
forall a.
("name" ::: ByteString) -> (("name" ::: Ptr CChar) -> IO a) -> IO a
useAsCString ("name" ::: ByteString
e)
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 ("name" ::: Ptr CChar) -> ("name" ::: Ptr CChar) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr ("name" ::: Ptr CChar)
pEnabledExtensionNames' Ptr ("name" ::: Ptr CChar) -> Int -> Ptr ("name" ::: Ptr CChar)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr (Ptr CChar)) "name" ::: Ptr CChar
enabledExtensionNames'') (Vector ("name" ::: ByteString)
forall a. Monoid a => a
mempty)
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 ("name" ::: Ptr CChar))
-> Ptr ("name" ::: Ptr CChar) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (InstanceCreateInfo es)
p Ptr (InstanceCreateInfo es)
-> Int -> Ptr (Ptr ("name" ::: Ptr CChar))
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 320 :: Ptr (Ptr (Ptr CChar)))) (Ptr ("name" ::: Ptr CChar)
pEnabledExtensionNames')
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 InstanceCreateInfo es, PeekChain es) => FromCStruct (InstanceCreateInfo es) where
peekCStruct :: Ptr (InstanceCreateInfo es) -> IO (InstanceCreateInfo es)
peekCStruct p :: Ptr (InstanceCreateInfo es)
p = do
Ptr ()
next <- Ptr (Ptr ()) -> IO (Ptr ())
forall a. Storable a => Ptr a -> IO a
peek @(Ptr ()) ((Ptr (InstanceCreateInfo es)
p Ptr (InstanceCreateInfo 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)
InstanceCreateFlags
createFlags <- Ptr InstanceCreateFlags -> IO InstanceCreateFlags
forall a. Storable a => Ptr a -> IO a
peek @InstanceCreateFlags ((Ptr (InstanceCreateInfo es)
p Ptr (InstanceCreateInfo es) -> Int -> Ptr InstanceCreateFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr InstanceCreateFlags))
ApplicationInfo
applicationInfo <- Ptr ApplicationInfo -> IO ApplicationInfo
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @ApplicationInfo ((Ptr (InstanceCreateInfo es)
p Ptr (InstanceCreateInfo es) -> Int -> Ptr ApplicationInfo
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr ApplicationInfo))
"propertyCapacityInput" ::: Word32
enabledApiLayerCount <- ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> IO ("propertyCapacityInput" ::: Word32)
forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr (InstanceCreateInfo es)
p Ptr (InstanceCreateInfo es)
-> Int
-> "propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 296 :: Ptr Word32))
Ptr ("name" ::: Ptr CChar)
enabledApiLayerNames <- Ptr (Ptr ("name" ::: Ptr CChar)) -> IO (Ptr ("name" ::: Ptr CChar))
forall a. Storable a => Ptr a -> IO a
peek @(Ptr (Ptr CChar)) ((Ptr (InstanceCreateInfo es)
p Ptr (InstanceCreateInfo es)
-> Int -> Ptr (Ptr ("name" ::: Ptr CChar))
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 304 :: Ptr (Ptr (Ptr CChar))))
Vector ("name" ::: ByteString)
enabledApiLayerNames' <- Int
-> (Int -> IO ("name" ::: ByteString))
-> IO (Vector ("name" ::: ByteString))
forall (m :: * -> *) a.
Monad m =>
Int -> (Int -> m a) -> m (Vector a)
generateM (("propertyCapacityInput" ::: Word32) -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral "propertyCapacityInput" ::: Word32
enabledApiLayerCount) (\i :: Int
i -> ("name" ::: Ptr CChar) -> IO ("name" ::: ByteString)
packCString (("name" ::: Ptr CChar) -> IO ("name" ::: ByteString))
-> IO ("name" ::: Ptr CChar) -> IO ("name" ::: ByteString)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Ptr ("name" ::: Ptr CChar) -> IO ("name" ::: Ptr CChar)
forall a. Storable a => Ptr a -> IO a
peek ((Ptr ("name" ::: Ptr CChar)
enabledApiLayerNames Ptr ("name" ::: Ptr CChar) -> Int -> Ptr ("name" ::: Ptr CChar)
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr (Ptr CChar))))
"propertyCapacityInput" ::: Word32
enabledExtensionCount <- ("propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32))
-> IO ("propertyCapacityInput" ::: Word32)
forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr (InstanceCreateInfo es)
p Ptr (InstanceCreateInfo es)
-> Int
-> "propertyCountOutput"
::: Ptr ("propertyCapacityInput" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 312 :: Ptr Word32))
Ptr ("name" ::: Ptr CChar)
enabledExtensionNames <- Ptr (Ptr ("name" ::: Ptr CChar)) -> IO (Ptr ("name" ::: Ptr CChar))
forall a. Storable a => Ptr a -> IO a
peek @(Ptr (Ptr CChar)) ((Ptr (InstanceCreateInfo es)
p Ptr (InstanceCreateInfo es)
-> Int -> Ptr (Ptr ("name" ::: Ptr CChar))
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 320 :: Ptr (Ptr (Ptr CChar))))
Vector ("name" ::: ByteString)
enabledExtensionNames' <- Int
-> (Int -> IO ("name" ::: ByteString))
-> IO (Vector ("name" ::: ByteString))
forall (m :: * -> *) a.
Monad m =>
Int -> (Int -> m a) -> m (Vector a)
generateM (("propertyCapacityInput" ::: Word32) -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral "propertyCapacityInput" ::: Word32
enabledExtensionCount) (\i :: Int
i -> ("name" ::: Ptr CChar) -> IO ("name" ::: ByteString)
packCString (("name" ::: Ptr CChar) -> IO ("name" ::: ByteString))
-> IO ("name" ::: Ptr CChar) -> IO ("name" ::: ByteString)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Ptr ("name" ::: Ptr CChar) -> IO ("name" ::: Ptr CChar)
forall a. Storable a => Ptr a -> IO a
peek ((Ptr ("name" ::: Ptr CChar)
enabledExtensionNames Ptr ("name" ::: Ptr CChar) -> Int -> Ptr ("name" ::: Ptr CChar)
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr (Ptr CChar))))
InstanceCreateInfo es -> IO (InstanceCreateInfo es)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (InstanceCreateInfo es -> IO (InstanceCreateInfo es))
-> InstanceCreateInfo es -> IO (InstanceCreateInfo es)
forall a b. (a -> b) -> a -> b
$ Chain es
-> InstanceCreateFlags
-> ApplicationInfo
-> Vector ("name" ::: ByteString)
-> Vector ("name" ::: ByteString)
-> InstanceCreateInfo es
forall (es :: [*]).
Chain es
-> InstanceCreateFlags
-> ApplicationInfo
-> Vector ("name" ::: ByteString)
-> Vector ("name" ::: ByteString)
-> InstanceCreateInfo es
InstanceCreateInfo
Chain es
next' InstanceCreateFlags
createFlags ApplicationInfo
applicationInfo Vector ("name" ::: ByteString)
enabledApiLayerNames' Vector ("name" ::: ByteString)
enabledExtensionNames'
instance es ~ '[] => Zero (InstanceCreateInfo es) where
zero :: InstanceCreateInfo es
zero = Chain es
-> InstanceCreateFlags
-> ApplicationInfo
-> Vector ("name" ::: ByteString)
-> Vector ("name" ::: ByteString)
-> InstanceCreateInfo es
forall (es :: [*]).
Chain es
-> InstanceCreateFlags
-> ApplicationInfo
-> Vector ("name" ::: ByteString)
-> Vector ("name" ::: ByteString)
-> InstanceCreateInfo es
InstanceCreateInfo
()
InstanceCreateFlags
forall a. Zero a => a
zero
ApplicationInfo
forall a. Zero a => a
zero
Vector ("name" ::: ByteString)
forall a. Monoid a => a
mempty
Vector ("name" ::: ByteString)
forall a. Monoid a => a
mempty
data InstanceProperties = InstanceProperties
{
InstanceProperties -> Version
runtimeVersion :: Version
,
InstanceProperties -> "name" ::: ByteString
runtimeName :: ByteString
}
deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (InstanceProperties)
#endif
deriving instance Show InstanceProperties
instance ToCStruct InstanceProperties where
withCStruct :: InstanceProperties -> (Ptr InstanceProperties -> IO b) -> IO b
withCStruct x :: InstanceProperties
x f :: Ptr InstanceProperties -> IO b
f = Int -> Int -> (Ptr InstanceProperties -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 152 8 ((Ptr InstanceProperties -> IO b) -> IO b)
-> (Ptr InstanceProperties -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: Ptr InstanceProperties
p -> Ptr InstanceProperties -> InstanceProperties -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr InstanceProperties
p InstanceProperties
x (Ptr InstanceProperties -> IO b
f Ptr InstanceProperties
p)
pokeCStruct :: Ptr InstanceProperties -> InstanceProperties -> IO b -> IO b
pokeCStruct p :: Ptr InstanceProperties
p InstanceProperties{..} f :: IO b
f = do
Ptr ("value" ::: StructureType)
-> ("value" ::: StructureType) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr InstanceProperties
p Ptr InstanceProperties -> Int -> Ptr ("value" ::: StructureType)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) ("value" ::: StructureType
TYPE_INSTANCE_PROPERTIES)
Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr InstanceProperties
p Ptr InstanceProperties -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
Ptr Version -> Version -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr InstanceProperties
p Ptr InstanceProperties -> Int -> Ptr Version
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr Version)) (Version
runtimeVersion)
Ptr (FixedArray MAX_EXTENSION_NAME_SIZE CChar)
-> ("name" ::: ByteString) -> IO ()
forall (n :: Nat).
KnownNat n =>
Ptr (FixedArray n CChar) -> ("name" ::: ByteString) -> IO ()
pokeFixedLengthNullTerminatedByteString ((Ptr InstanceProperties
p Ptr InstanceProperties
-> Int -> Ptr (FixedArray MAX_EXTENSION_NAME_SIZE CChar)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr (FixedArray MAX_RUNTIME_NAME_SIZE CChar))) ("name" ::: ByteString
runtimeName)
IO b
f
cStructSize :: Int
cStructSize = 152
cStructAlignment :: Int
cStructAlignment = 8
pokeZeroCStruct :: Ptr InstanceProperties -> IO b -> IO b
pokeZeroCStruct p :: Ptr InstanceProperties
p f :: IO b
f = do
Ptr ("value" ::: StructureType)
-> ("value" ::: StructureType) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr InstanceProperties
p Ptr InstanceProperties -> Int -> Ptr ("value" ::: StructureType)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) ("value" ::: StructureType
TYPE_INSTANCE_PROPERTIES)
Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr InstanceProperties
p Ptr InstanceProperties -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
Ptr Version -> Version -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr InstanceProperties
p Ptr InstanceProperties -> Int -> Ptr Version
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr Version)) (Version
forall a. Zero a => a
zero)
Ptr (FixedArray MAX_EXTENSION_NAME_SIZE CChar)
-> ("name" ::: ByteString) -> IO ()
forall (n :: Nat).
KnownNat n =>
Ptr (FixedArray n CChar) -> ("name" ::: ByteString) -> IO ()
pokeFixedLengthNullTerminatedByteString ((Ptr InstanceProperties
p Ptr InstanceProperties
-> Int -> Ptr (FixedArray MAX_EXTENSION_NAME_SIZE CChar)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr (FixedArray MAX_RUNTIME_NAME_SIZE CChar))) ("name" ::: ByteString
forall a. Monoid a => a
mempty)
IO b
f
instance FromCStruct InstanceProperties where
peekCStruct :: Ptr InstanceProperties -> IO InstanceProperties
peekCStruct p :: Ptr InstanceProperties
p = do
Version
runtimeVersion <- Ptr Version -> IO Version
forall a. Storable a => Ptr a -> IO a
peek @Version ((Ptr InstanceProperties
p Ptr InstanceProperties -> Int -> Ptr Version
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr Version))
"name" ::: ByteString
runtimeName <- ("name" ::: Ptr CChar) -> IO ("name" ::: ByteString)
packCString (Ptr (FixedArray MAX_EXTENSION_NAME_SIZE CChar)
-> "name" ::: Ptr CChar
forall a (n :: Nat). Ptr (FixedArray n a) -> Ptr a
lowerArrayPtr ((Ptr InstanceProperties
p Ptr InstanceProperties
-> Int -> Ptr (FixedArray MAX_EXTENSION_NAME_SIZE CChar)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr (FixedArray MAX_RUNTIME_NAME_SIZE CChar))))
InstanceProperties -> IO InstanceProperties
forall (f :: * -> *) a. Applicative f => a -> f a
pure (InstanceProperties -> IO InstanceProperties)
-> InstanceProperties -> IO InstanceProperties
forall a b. (a -> b) -> a -> b
$ Version -> ("name" ::: ByteString) -> InstanceProperties
InstanceProperties
Version
runtimeVersion "name" ::: ByteString
runtimeName
instance Storable InstanceProperties where
sizeOf :: InstanceProperties -> Int
sizeOf ~InstanceProperties
_ = 152
alignment :: InstanceProperties -> Int
alignment ~InstanceProperties
_ = 8
peek :: Ptr InstanceProperties -> IO InstanceProperties
peek = Ptr InstanceProperties -> IO InstanceProperties
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
poke :: Ptr InstanceProperties -> InstanceProperties -> IO ()
poke ptr :: Ptr InstanceProperties
ptr poked :: InstanceProperties
poked = Ptr InstanceProperties -> InstanceProperties -> IO () -> IO ()
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr InstanceProperties
ptr InstanceProperties
poked (() -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())
instance Zero InstanceProperties where
zero :: InstanceProperties
zero = Version -> ("name" ::: ByteString) -> InstanceProperties
InstanceProperties
Version
forall a. Zero a => a
zero
"name" ::: ByteString
forall a. Monoid a => a
mempty
data EventDataBuffer = EventDataBuffer
{
EventDataBuffer -> "name" ::: ByteString
varying :: ByteString }
deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (EventDataBuffer)
#endif
deriving instance Show EventDataBuffer
instance ToCStruct EventDataBuffer where
withCStruct :: EventDataBuffer -> (Ptr EventDataBuffer -> IO b) -> IO b
withCStruct x :: EventDataBuffer
x f :: Ptr EventDataBuffer -> IO b
f = Int -> Int -> (Ptr EventDataBuffer -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 4016 8 ((Ptr EventDataBuffer -> IO b) -> IO b)
-> (Ptr EventDataBuffer -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: Ptr EventDataBuffer
p -> Ptr EventDataBuffer -> EventDataBuffer -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr EventDataBuffer
p EventDataBuffer
x (Ptr EventDataBuffer -> IO b
f Ptr EventDataBuffer
p)
pokeCStruct :: Ptr EventDataBuffer -> EventDataBuffer -> IO b -> IO b
pokeCStruct p :: Ptr EventDataBuffer
p EventDataBuffer{..} f :: IO b
f = do
Ptr ("value" ::: StructureType)
-> ("value" ::: StructureType) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr EventDataBuffer
p Ptr EventDataBuffer -> Int -> Ptr ("value" ::: StructureType)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) ("value" ::: StructureType
TYPE_EVENT_DATA_BUFFER)
Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr EventDataBuffer
p Ptr EventDataBuffer -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
Ptr (FixedArray 4000 Word8) -> ("name" ::: ByteString) -> IO ()
forall (n :: Nat).
KnownNat n =>
Ptr (FixedArray n Word8) -> ("name" ::: ByteString) -> IO ()
pokeFixedLengthByteString ((Ptr EventDataBuffer
p Ptr EventDataBuffer -> Int -> Ptr (FixedArray 4000 Word8)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr (FixedArray 4000 Word8))) ("name" ::: ByteString
varying)
IO b
f
cStructSize :: Int
cStructSize = 4016
cStructAlignment :: Int
cStructAlignment = 8
pokeZeroCStruct :: Ptr EventDataBuffer -> IO b -> IO b
pokeZeroCStruct p :: Ptr EventDataBuffer
p f :: IO b
f = do
Ptr ("value" ::: StructureType)
-> ("value" ::: StructureType) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr EventDataBuffer
p Ptr EventDataBuffer -> Int -> Ptr ("value" ::: StructureType)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) ("value" ::: StructureType
TYPE_EVENT_DATA_BUFFER)
Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr EventDataBuffer
p Ptr EventDataBuffer -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
Ptr (FixedArray 4000 Word8) -> ("name" ::: ByteString) -> IO ()
forall (n :: Nat).
KnownNat n =>
Ptr (FixedArray n Word8) -> ("name" ::: ByteString) -> IO ()
pokeFixedLengthByteString ((Ptr EventDataBuffer
p Ptr EventDataBuffer -> Int -> Ptr (FixedArray 4000 Word8)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr (FixedArray 4000 Word8))) ("name" ::: ByteString
forall a. Monoid a => a
mempty)
IO b
f
instance FromCStruct EventDataBuffer where
peekCStruct :: Ptr EventDataBuffer -> IO EventDataBuffer
peekCStruct p :: Ptr EventDataBuffer
p = do
"name" ::: ByteString
varying <- Ptr (FixedArray 4000 Word8) -> IO ("name" ::: ByteString)
forall (n :: Nat).
KnownNat n =>
Ptr (FixedArray n Word8) -> IO ("name" ::: ByteString)
peekByteStringFromSizedVectorPtr ((Ptr EventDataBuffer
p Ptr EventDataBuffer -> Int -> Ptr (FixedArray 4000 Word8)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr (FixedArray 4000 Word8)))
EventDataBuffer -> IO EventDataBuffer
forall (f :: * -> *) a. Applicative f => a -> f a
pure (EventDataBuffer -> IO EventDataBuffer)
-> EventDataBuffer -> IO EventDataBuffer
forall a b. (a -> b) -> a -> b
$ ("name" ::: ByteString) -> EventDataBuffer
EventDataBuffer
"name" ::: ByteString
varying
instance Storable EventDataBuffer where
sizeOf :: EventDataBuffer -> Int
sizeOf ~EventDataBuffer
_ = 4016
alignment :: EventDataBuffer -> Int
alignment ~EventDataBuffer
_ = 8
peek :: Ptr EventDataBuffer -> IO EventDataBuffer
peek = Ptr EventDataBuffer -> IO EventDataBuffer
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
poke :: Ptr EventDataBuffer -> EventDataBuffer -> IO ()
poke ptr :: Ptr EventDataBuffer
ptr poked :: EventDataBuffer
poked = Ptr EventDataBuffer -> EventDataBuffer -> IO () -> IO ()
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr EventDataBuffer
ptr EventDataBuffer
poked (() -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())
instance Zero EventDataBuffer where
zero :: EventDataBuffer
zero = ("name" ::: ByteString) -> EventDataBuffer
EventDataBuffer
"name" ::: ByteString
forall a. Monoid a => a
mempty