{-# language CPP #-}
-- No documentation found for Chapter "Instance"
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

-- | xrGetInstanceProcAddr - Gets a function pointer for an OpenXR function
--
-- == Parameter Descriptions
--
-- = Description
--
-- 'getInstanceProcAddr' itself is obtained in a platform- and loader-
-- specific manner. Typically, the loader library will export this function
-- as a function symbol, so applications /can/ link against the loader
-- library, or load it dynamically and look up the symbol using
-- platform-specific APIs. Loaders /must/ export function symbols for all
-- core OpenXR functions. Because of this, applications that use only the
-- core OpenXR functions have no need to use 'getInstanceProcAddr'.
--
-- Because an application /can/ call 'getInstanceProcAddr' before creating
-- an instance, 'getInstanceProcAddr' returns a valid function pointer when
-- the @instance@ parameter is
-- <https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#XR_NULL_HANDLE XR_NULL_HANDLE>
-- and the @name@ parameter is one of the following strings:
--
-- == No Instance Required
--
-- -   'enumerateInstanceExtensionProperties'
--
-- -   'enumerateApiLayerProperties'
--
-- -   'createInstance'
--
-- 'getInstanceProcAddr' /must/ return
-- 'OpenXR.Core10.Enums.Result.ERROR_HANDLE_INVALID' if @name@ is not one
-- of the above strings and @instance@ is
-- <https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#XR_NULL_HANDLE XR_NULL_HANDLE>.
-- 'getInstanceProcAddr' /may/ return
-- 'OpenXR.Core10.Enums.Result.ERROR_HANDLE_INVALID' if @name@ is not one
-- of the above strings and @instance@ is invalid but not
-- <https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#XR_NULL_HANDLE XR_NULL_HANDLE>.
--
-- 'getInstanceProcAddr' /must/ return
-- 'OpenXR.Core10.Enums.Result.ERROR_FUNCTION_UNSUPPORTED' if @instance@ is
-- a valid instance and the string specified in @name@ is not the name of
-- an OpenXR core or enabled extension function.
--
-- If @name@ is the name of an extension function, then the result returned
-- by 'getInstanceProcAddr' will depend upon how the @instance@ was
-- created. If @instance@ was created with the related extension’s name
-- appearing in the 'InstanceCreateInfo'::@enabledExtensionNames@ array,
-- then 'getInstanceProcAddr' returns a valid function pointer. If the
-- related extension’s name did not appear in the
-- 'InstanceCreateInfo'::@enabledExtensionNames@ array during the creation
-- of @instance@, then 'getInstanceProcAddr' returns
-- 'OpenXR.Core10.Enums.Result.ERROR_FUNCTION_UNSUPPORTED'. Because of
-- this, function pointers returned by 'getInstanceProcAddr' using one
-- 'OpenXR.Core10.Handles.Instance' may not be valid when used with objects
-- related to a different 'OpenXR.Core10.Handles.Instance'.
--
-- The returned function pointer is of type
-- 'OpenXR.Core10.FuncPointers.PFN_xrVoidFunction', and must be cast to the
-- type of the function being queried.
--
-- The table below defines the various use cases for 'getInstanceProcAddr'
-- and return value (“fp” is “function pointer”) for each case.
--
-- +----------------------+----------------------------------------+-----------------------+
-- | @instance@ parameter | @name@ parameter                       | return value          |
-- +======================+========================================+=======================+
-- | *                    | @NULL@                                 | undefined             |
-- +----------------------+----------------------------------------+-----------------------+
-- | invalid instance     | *                                      | undefined             |
-- +----------------------+----------------------------------------+-----------------------+
-- | @NULL@               | 'enumerateInstanceExtensionProperties' | fp                    |
-- +----------------------+----------------------------------------+-----------------------+
-- | @NULL@               | 'enumerateApiLayerProperties'          | fp                    |
-- +----------------------+----------------------------------------+-----------------------+
-- | @NULL@               | 'createInstance'                       | fp                    |
-- +----------------------+----------------------------------------+-----------------------+
-- | @NULL@               | * (any @name@ not covered above)       | @NULL@                |
-- +----------------------+----------------------------------------+-----------------------+
-- | instance             | core OpenXR function                   | fp1                   |
-- +----------------------+----------------------------------------+-----------------------+
-- | instance             | enabled extension function for         | fp1                   |
-- |                      | @instance@                             |                       |
-- +----------------------+----------------------------------------+-----------------------+
-- | instance             | * (any @name@ not covered above)       | @NULL@                |
-- +----------------------+----------------------------------------+-----------------------+
--
-- xrGetInstanceProcAddr behavior
--
-- [1]
--     The returned function pointer /must/ only be called with a handle
--     (the first parameter) that is @instance@ or a child of @instance@.
--
-- == Valid Usage (Implicit)
--
-- -   #VUID-xrGetInstanceProcAddr-instance-parameter# If @instance@ is not
--     <https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#XR_NULL_HANDLE XR_NULL_HANDLE>,
--     @instance@ /must/ be a valid 'OpenXR.Core10.Handles.Instance' handle
--
-- -   #VUID-xrGetInstanceProcAddr-name-parameter# @name@ /must/ be a
--     null-terminated UTF-8 string
--
-- -   #VUID-xrGetInstanceProcAddr-function-parameter# @function@ /must/ be
--     a pointer to a 'OpenXR.Core10.FuncPointers.PFN_xrVoidFunction' value
--
-- == Return Codes
--
-- [<https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#fundamentals-successcodes Success>]
--
--     -   'OpenXR.Core10.Enums.Result.SUCCESS'
--
-- [<https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#fundamentals-errorcodes Failure>]
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_HANDLE_INVALID'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_INSTANCE_LOST'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_RUNTIME_FAILURE'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_OUT_OF_MEMORY'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_FUNCTION_UNSUPPORTED'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_VALIDATION_FAILURE'
--
-- = See Also
--
-- 'OpenXR.Core10.FuncPointers.PFN_xrVoidFunction',
-- 'OpenXR.Core10.Handles.Instance'
getInstanceProcAddr :: forall io
                     . (MonadIO io)
                    => -- | @instance@ is the instance that the function pointer will be compatible
                       -- with, or @NULL@ for functions not dependent on any instance.
                       Instance
                    -> -- | @name@ is the name of the function to obtain.
                       ("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

-- | xrEnumerateApiLayerProperties - Returns up to requested number of global
-- layer properties
--
-- == Parameter Descriptions
--
-- -   @propertyCapacityInput@ is the capacity of the properties array, or
--     0 to indicate a request to retrieve the required capacity.
--
-- -   @propertyCountOutput@ is a pointer to the count of properties
--     written, or a pointer to the required capacity in the case that
--     propertyCapacityInput is 0.
--
-- -   @properties@ is a pointer to an array of 'ApiLayerProperties'
--     structures, but /can/ be @NULL@ if propertyCapacityInput is 0.
--
-- -   See the
--     <https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#buffer-size-parameters Buffer Size Parameters>
--     section for a detailed description of retrieving the required
--     @properties@ size.
--
-- = Description
--
-- The list of available layers may change at any time due to actions
-- outside of the OpenXR runtime, so two calls to
-- 'enumerateApiLayerProperties' with the same parameters /may/ return
-- different results, or retrieve different @propertyCountOutput@ values or
-- @properties@ contents.
--
-- Once an instance has been created, the layers enabled for that instance
-- will continue to be enabled and valid for the lifetime of that instance,
-- even if some of them become unavailable for future instances.
--
-- == Valid Usage (Implicit)
--
-- -   #VUID-xrEnumerateApiLayerProperties-propertyCountOutput-parameter#
--     @propertyCountOutput@ /must/ be a pointer to a @uint32_t@ value
--
-- -   #VUID-xrEnumerateApiLayerProperties-properties-parameter# If
--     @propertyCapacityInput@ is not @0@, @properties@ /must/ be a pointer
--     to an array of @propertyCapacityInput@ 'ApiLayerProperties'
--     structures
--
-- == Return Codes
--
-- [<https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#fundamentals-successcodes Success>]
--
--     -   'OpenXR.Core10.Enums.Result.SUCCESS'
--
-- [<https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#fundamentals-errorcodes Failure>]
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_OUT_OF_MEMORY'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_VALIDATION_FAILURE'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_RUNTIME_FAILURE'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_SIZE_INSUFFICIENT'
--
-- = See Also
--
-- 'ApiLayerProperties'
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

-- | xrEnumerateInstanceExtensionProperties - Returns properties of available
-- instance extensions
--
-- == Parameter Descriptions
--
-- -   @layerName@ is either @NULL@ or a pointer to a string naming the API
--     layer to retrieve extensions from, as returned by
--     'enumerateApiLayerProperties'.
--
-- -   @propertyCapacityInput@ is the capacity of the properties array, or
--     @0@ to indicate a request to retrieve the required capacity.
--
-- -   @propertyCountOutput@ is a pointer to the count of properties
--     written, or a pointer to the required capacity in the case that
--     @propertyCapacityInput@ is @0@.
--
-- -   @properties@ is a pointer to an array of 'ExtensionProperties'
--     structures, but /can/ be @NULL@ if @propertyCapacityInput@ is @0@.
--
-- -   See the
--     <https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#buffer-size-parameters Buffer Size Parameters>
--     section for a detailed description of retrieving the required
--     @properties@ size.
--
-- = Description
--
-- If @properties@ is @NULL@, then the number of extensions properties
-- available is returned in @propertyCountOutput@. Otherwise,
-- @propertyCountInput@ must point to a variable set by the user to the
-- number of elements in the @properties@ array. If @propertyCountInput@ is
-- less than the number of extension properties available, the contents of
-- @properties@ will be undefined. If @propertyCountInput@ is smaller than
-- the number of extensions available, the runtime /must/ return the
-- failure code 'OpenXR.Core10.Enums.Result.ERROR_SIZE_INSUFFICIENT' and
-- the contents of @properties@ are undefined.
--
-- Because the list of available layers may change externally between calls
-- to 'enumerateInstanceExtensionProperties', two calls /may/ retrieve
-- different results if a @layerName@ is available in one call but not in
-- another. The extensions supported by a layer may also change between two
-- calls, e.g. if the layer implementation is replaced by a different
-- version between those calls.
--
-- == Valid Usage (Implicit)
--
-- -   #VUID-xrEnumerateInstanceExtensionProperties-layerName-parameter# If
--     @layerName@ is not @NULL@, @layerName@ /must/ be a null-terminated
--     UTF-8 string
--
-- -   #VUID-xrEnumerateInstanceExtensionProperties-propertyCountOutput-parameter#
--     @propertyCountOutput@ /must/ be a pointer to a @uint32_t@ value
--
-- -   #VUID-xrEnumerateInstanceExtensionProperties-properties-parameter#
--     If @propertyCapacityInput@ is not @0@, @properties@ /must/ be a
--     pointer to an array of @propertyCapacityInput@ 'ExtensionProperties'
--     structures
--
-- == Return Codes
--
-- [<https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#fundamentals-successcodes Success>]
--
--     -   'OpenXR.Core10.Enums.Result.SUCCESS'
--
-- [<https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#fundamentals-errorcodes Failure>]
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_OUT_OF_MEMORY'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_API_LAYER_NOT_PRESENT'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_RUNTIME_FAILURE'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_VALIDATION_FAILURE'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_SIZE_INSUFFICIENT'
--
-- = See Also
--
-- 'ExtensionProperties'
enumerateInstanceExtensionProperties :: forall io
                                      . (MonadIO io)
                                     => -- No documentation found for Nested "xrEnumerateInstanceExtensionProperties" "layerName"
                                        ("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

-- | xrCreateInstance - Creates an OpenXR Instance
--
-- == Parameter Descriptions
--
-- = Description
--
-- 'createInstance' creates the 'OpenXR.Core10.Handles.Instance', then
-- enables and initializes global API layers and extensions requested by
-- the application. If an extension is provided by an API layer, both the
-- API layer and extension /must/ be specified at 'createInstance' time. If
-- a specified API layer cannot be found, no
-- 'OpenXR.Core10.Handles.Instance' will be created and the function will
-- return 'OpenXR.Core10.Enums.Result.ERROR_API_LAYER_NOT_PRESENT'.
-- Likewise, if a specified extension cannot be found, the call /must/
-- return 'OpenXR.Core10.Enums.Result.ERROR_EXTENSION_NOT_PRESENT' and no
-- 'OpenXR.Core10.Handles.Instance' will be created. Additionally, some
-- runtimes /may/ limit the number of concurrent instances that may be in
-- use. If the application attempts to create more instances than a runtime
-- can simultaneously support, 'createInstance' /may/ return
-- 'OpenXR.Core10.Enums.Result.ERROR_LIMIT_REACHED'.
--
-- If the 'ApplicationInfo'::@applicationName@ is the empty string the
-- runtime /must/ return 'OpenXR.Core10.Enums.Result.ERROR_NAME_INVALID'.
--
-- If the 'InstanceCreateInfo' structure contains a platform-specific
-- extension for a platform other than the target platform,
-- 'OpenXR.Core10.Enums.Result.ERROR_INITIALIZATION_FAILED' /may/ be
-- returned. If a mandatory platform-specific extension is defined for the
-- target platform but no matching extension struct is provided in
-- 'InstanceCreateInfo' the runtime /must/ return
-- 'OpenXR.Core10.Enums.Result.ERROR_INITIALIZATION_FAILED'.
--
-- == Return Codes
--
-- [<https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#fundamentals-successcodes Success>]
--
--     -   'OpenXR.Core10.Enums.Result.SUCCESS'
--
-- [<https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#fundamentals-errorcodes Failure>]
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_OUT_OF_MEMORY'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_LIMIT_REACHED'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_INSTANCE_LOST'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_RUNTIME_FAILURE'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_INITIALIZATION_FAILED'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_API_VERSION_UNSUPPORTED'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_API_LAYER_NOT_PRESENT'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_EXTENSION_NOT_PRESENT'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_VALIDATION_FAILURE'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_NAME_INVALID'
--
-- = See Also
--
-- 'OpenXR.Core10.Handles.Instance', 'InstanceCreateInfo'
createInstance :: forall a io
                . (Extendss InstanceCreateInfo a, PokeChain a, MonadIO io)
               => -- | @createInfo@ points to an instance of 'InstanceCreateInfo' controlling
                  -- creation of the instance.
                  --
                  -- #VUID-xrCreateInstance-createInfo-parameter# @createInfo@ /must/ be a
                  -- pointer to a valid 'InstanceCreateInfo' structure
                  (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'')

-- | A convenience wrapper to make a compatible pair of calls to
-- 'createInstance' and 'destroyInstance'
--
-- To ensure that 'destroyInstance' is always called: pass
-- 'Control.Exception.bracket' (or the allocate function from your
-- favourite resource management library) as the last argument.
-- To just extract the pair pass '(,)' as the last argument.
--
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

-- | xrDestroyInstance - Destroy an instance of OpenXR
--
-- = Parameters
--
-- The 'destroyInstance' function is used to destroy an
-- 'OpenXR.Core10.Handles.Instance'.
--
-- == Parameter Descriptions
--
-- -   @instance@ is the handle to the instance to destroy.
--
-- 'OpenXR.Core10.Handles.Instance' handles are destroyed using
-- 'destroyInstance'. When an 'OpenXR.Core10.Handles.Instance' is
-- destroyed, all handles that are children of that
-- 'OpenXR.Core10.Handles.Instance' are also destroyed.
--
-- == Valid Usage (Implicit)
--
-- -   #VUID-xrDestroyInstance-instance-parameter# @instance@ /must/ be a
--     valid 'OpenXR.Core10.Handles.Instance' handle
--
-- == Thread Safety
--
-- -   Access to @instance@, and any child handles, /must/ be externally
--     synchronized
--
-- == Return Codes
--
-- [<https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#fundamentals-successcodes Success>]
--
--     -   'OpenXR.Core10.Enums.Result.SUCCESS'
--
-- [<https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#fundamentals-errorcodes Failure>]
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_HANDLE_INVALID'
--
-- = See Also
--
-- 'OpenXR.Core10.Handles.Instance'
destroyInstance :: forall io
                 . (MonadIO io)
                => -- No documentation found for Nested "xrDestroyInstance" "instance"
                   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

-- | xrResultToString - Converts an XrResult to a UTF-8 string
--
-- == Parameter Descriptions
--
-- = Description
--
-- Returns the text version of the provided
-- 'OpenXR.Core10.Enums.Result.Result' value as a UTF-8 string.
--
-- In all cases the returned string /must/ be one of:
--
-- == Result String Return Values
--
-- -   The literal string defined for the provide numeric value in the core
--     spec or extension. (e.g. the value 0 results in the string
--     'OpenXR.Core10.Enums.Result.SUCCESS')
--
-- -   @XR_UNKNOWN_SUCCESS_@ concatenated with the positive result number
--     expressed as a decimal number.
--
-- -   @XR_UNKNOWN_FAILURE_@ concatenated with the negative result number
--     expressed as a decimal number.
--
-- == Valid Usage (Implicit)
--
-- -   #VUID-xrResultToString-instance-parameter# @instance@ /must/ be a
--     valid 'OpenXR.Core10.Handles.Instance' handle
--
-- -   #VUID-xrResultToString-value-parameter# @value@ /must/ be a valid
--     'OpenXR.Core10.Enums.Result.Result' value
--
-- -   #VUID-xrResultToString-buffer-parameter# @buffer@ /must/ be a
--     character array of length
--     'OpenXR.Core10.APIConstants.MAX_RESULT_STRING_SIZE'
--
-- == Return Codes
--
-- [<https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#fundamentals-successcodes Success>]
--
--     -   'OpenXR.Core10.Enums.Result.SUCCESS'
--
-- [<https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#fundamentals-errorcodes Failure>]
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_HANDLE_INVALID'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_INSTANCE_LOST'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_RUNTIME_FAILURE'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_VALIDATION_FAILURE'
--
-- = See Also
--
-- 'OpenXR.Core10.Handles.Instance', 'OpenXR.Core10.Enums.Result.Result',
-- 'structureTypeToString'
resultToString :: forall io
                . (MonadIO io)
               => -- | @instance@ is the handle of the instance to ask for the string.
                  Instance
               -> -- | @value@ is the 'OpenXR.Core10.Enums.Result.Result' value to turn into a
                  -- string.
                  ("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

-- | xrStructureTypeToString - Converts an XrStructureType to a UTF-8 string
--
-- == Parameter Descriptions
--
-- = Description
--
-- Returns the text version of the provided
-- 'OpenXR.Core10.Enums.StructureType.StructureType' value as a UTF-8
-- string.
--
-- In all cases the returned string /must/ be one of:
--
-- == Structure Type String Return Values
--
-- -   The literal string defined for the provide numeric value in the core
--     spec or extension. (e.g. the value of
--     'OpenXR.Core10.Enums.StructureType.TYPE_INSTANCE_CREATE_INFO'
--     results in the string
--     'OpenXR.Core10.Enums.StructureType.TYPE_INSTANCE_CREATE_INFO')
--
-- -   @XR_UNKNOWN_STRUCTURE_TYPE_@ concatenated with the structure type
--     number expressed as a decimal number.
--
-- == Valid Usage (Implicit)
--
-- -   #VUID-xrStructureTypeToString-instance-parameter# @instance@ /must/
--     be a valid 'OpenXR.Core10.Handles.Instance' handle
--
-- -   #VUID-xrStructureTypeToString-value-parameter# @value@ /must/ be a
--     valid 'OpenXR.Core10.Enums.StructureType.StructureType' value
--
-- -   #VUID-xrStructureTypeToString-buffer-parameter# @buffer@ /must/ be a
--     character array of length
--     'OpenXR.Core10.APIConstants.MAX_STRUCTURE_NAME_SIZE'
--
-- == Return Codes
--
-- [<https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#fundamentals-successcodes Success>]
--
--     -   'OpenXR.Core10.Enums.Result.SUCCESS'
--
-- [<https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#fundamentals-errorcodes Failure>]
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_HANDLE_INVALID'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_INSTANCE_LOST'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_RUNTIME_FAILURE'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_VALIDATION_FAILURE'
--
-- = See Also
--
-- 'OpenXR.Core10.Handles.Instance',
-- 'OpenXR.Core10.Enums.StructureType.StructureType', 'resultToString'
structureTypeToString :: forall io
                       . (MonadIO io)
                      => -- | @instance@ is the handle of the instance to ask for the string.
                         Instance
                      -> -- | @value@ is the 'OpenXR.Core10.Enums.StructureType.StructureType' value
                         -- to turn into a string.
                         ("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

-- | xrGetInstanceProperties - Gets information about the instance
--
-- == Parameter Descriptions
--
-- = Description
--
-- The @instanceProperties@ parameter /must/ be filled out by the runtime
-- in response to this call, with information as defined in
-- 'InstanceProperties'.
--
-- == Return Codes
--
-- [<https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#fundamentals-successcodes Success>]
--
--     -   'OpenXR.Core10.Enums.Result.SUCCESS'
--
-- [<https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#fundamentals-errorcodes Failure>]
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_HANDLE_INVALID'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_INSTANCE_LOST'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_RUNTIME_FAILURE'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_VALIDATION_FAILURE'
--
-- = See Also
--
-- 'OpenXR.Core10.Handles.Instance', 'InstanceProperties'
getInstanceProperties :: forall io
                       . (MonadIO io)
                      => -- | @instance@ is a handle to an 'OpenXR.Core10.Handles.Instance' previously
                         -- created with 'createInstance'.
                         --
                         -- #VUID-xrGetInstanceProperties-instance-parameter# @instance@ /must/ be a
                         -- valid 'OpenXR.Core10.Handles.Instance' handle
                         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

-- | xrPollEvent - Polls for events
--
-- = Parameters
--
-- 'pollEvent' polls for the next event and returns an event if one is
-- available. 'pollEvent' returns immediately regardless of whether an
-- event was available. The event (if present) is unilaterally removed from
-- the queue if a valid 'OpenXR.Core10.Handles.Instance' is provided. On
-- return the @eventData@ parameter is filled with the event’s data and the
-- type field is changed to the event’s type. Runtimes /may/ create valid
-- next chains depending on enabled extensions, but they /must/ guarantee
-- that any such chains point only to objects which fit completely within
-- the original 'EventDataBuffer' pointed to by @eventData@.
--
-- == Return Codes
--
-- [<https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#fundamentals-successcodes Success>]
--
--     -   'OpenXR.Core10.Enums.Result.SUCCESS'
--
--     -   'OpenXR.Core10.Enums.Result.EVENT_UNAVAILABLE'
--
-- [<https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#fundamentals-errorcodes Failure>]
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_INSTANCE_LOST'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_RUNTIME_FAILURE'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_HANDLE_INVALID'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_VALIDATION_FAILURE'
--
-- The runtime /must/ discard queued events which contain destroyed or
-- otherwise invalid handles.
--
-- +-----------------------------------------------------------------+-----------------------------------+
-- | Event                                                           | Description                       |
-- +=================================================================+===================================+
-- | 'OpenXR.Core10.OtherTypes.EventDataEventsLost'                  | event queue has overflowed and    |
-- |                                                                 | some events were lost             |
-- +-----------------------------------------------------------------+-----------------------------------+
-- | 'OpenXR.Core10.OtherTypes.EventDataInstanceLossPending'         | application is about to lose the  |
-- |                                                                 | instance                          |
-- +-----------------------------------------------------------------+-----------------------------------+
-- | 'OpenXR.Core10.OtherTypes.EventDataInteractionProfileChanged'   | active input form factor for one  |
-- |                                                                 | or more top level user paths has  |
-- |                                                                 | changed                           |
-- +-----------------------------------------------------------------+-----------------------------------+
-- | 'OpenXR.Core10.OtherTypes.EventDataReferenceSpaceChangePending' | runtime will begin operating with |
-- |                                                                 | updated space bounds              |
-- +-----------------------------------------------------------------+-----------------------------------+
-- | 'OpenXR.Core10.OtherTypes.EventDataSessionStateChanged'         | application has changed lifecycle |
-- |                                                                 | state                             |
-- +-----------------------------------------------------------------+-----------------------------------+
--
-- Event Descriptions
--
-- = See Also
--
-- 'EventDataBuffer', 'OpenXR.Core10.Handles.Instance'
pollEvent :: forall io
           . (MonadIO io)
          => -- | @instance@ is a valid 'OpenXR.Core10.Handles.Instance'.
             --
             -- #VUID-xrPollEvent-instance-parameter# @instance@ /must/ be a valid
             -- 'OpenXR.Core10.Handles.Instance' handle
             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)


-- | XrApiLayerProperties - Structure specifying layer properties
--
-- == Valid Usage (Implicit)
--
-- = See Also
--
-- 'OpenXR.Core10.Enums.StructureType.StructureType',
-- <https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#XrVersion >,
-- 'enumerateApiLayerProperties'
data ApiLayerProperties = ApiLayerProperties
  { -- | @layerName@ is a string specifying the name of the API layer. Use this
    -- name in the 'InstanceCreateInfo'::@enabledApiLayerNames@ array to enable
    -- this API layer for an instance.
    ApiLayerProperties -> "name" ::: ByteString
layerName :: ByteString
  , -- | @specVersion@ is the API version the API layer was written to, encoded
    -- as described in the
    -- <https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#api-version-numbers-and-semantics API Version Numbers and Semantics>
    -- section.
    ApiLayerProperties -> Version
specVersion :: Version
  , -- | @layerVersion@ is the version of this API layer. It is an integer,
    -- increasing with backward compatible changes.
    ApiLayerProperties -> "propertyCapacityInput" ::: Word32
layerVersion :: Word32
  , -- | @description@ is a string providing additional details that /can/ be
    -- used by the application to identify the API layer.
    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


-- | XrExtensionProperties - Returns properties of available instance
-- extensions
--
-- == Valid Usage (Implicit)
--
-- = See Also
--
-- 'OpenXR.Core10.Enums.StructureType.StructureType',
-- 'enumerateInstanceExtensionProperties'
data ExtensionProperties = ExtensionProperties
  { -- | @extensionName@ is a @NULL@ terminated string specifying the name of the
    -- extension.
    ExtensionProperties -> "name" ::: ByteString
extensionName :: ByteString
  , -- | @extensionVersion@ is the version of this extension. It is an integer,
    -- incremented with backward compatible changes.
    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


-- | XrApplicationInfo - Structure specifying application info
--
-- == Valid Usage (Implicit)
--
-- Note
--
-- When using the OpenXR API to implement a reusable engine that will be
-- used by many applications, @engineName@ /should/ be set to a unique
-- string that identifies the engine, and @engineVersion@ /should/ encode a
-- representation of the engine’s version. This way, all applications that
-- share this engine version will provide the same @engineName@ and
-- @engineVersion@ to the runtime. The engine /should/ then enable
-- individual applications to choose their specific @applicationName@ and
-- @applicationVersion@, enabling one application to be distinguished from
-- another application.
--
-- When using the OpenXR API to implement an individual application without
-- a shared engine, the input @engineName@ /should/ be left empty and
-- @engineVersion@ /should/ be set to 0. The @applicationName@ /should/
-- then be filled in with a unique string that identifies the app and the
-- @applicationVersion@ /should/ encode a representation of the
-- application’s version.
--
-- = See Also
--
-- 'InstanceCreateInfo',
-- <https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#XrVersion >
data ApplicationInfo = ApplicationInfo
  { -- | @applicationName@ is a non-empty string containing the name of the
    -- application.
    --
    -- #VUID-XrApplicationInfo-applicationName-parameter# @applicationName@
    -- /must/ be a null-terminated UTF-8 string whose length is less than or
    -- equal to 'OpenXR.Core10.APIConstants.MAX_APPLICATION_NAME_SIZE'
    ApplicationInfo -> "name" ::: ByteString
applicationName :: ByteString
  , -- | @applicationVersion@ is an unsigned integer variable containing the
    -- developer-supplied version number of the application.
    ApplicationInfo -> "propertyCapacityInput" ::: Word32
applicationVersion :: Word32
  , -- | @engineName@ is a string containing the name of the engine (if any) used
    -- to create the application. It may be empty to indicate no specified
    -- engine.
    --
    -- #VUID-XrApplicationInfo-engineName-parameter# @engineName@ /must/ be a
    -- null-terminated UTF-8 string whose length is less than or equal to
    -- 'OpenXR.Core10.APIConstants.MAX_ENGINE_NAME_SIZE'
    ApplicationInfo -> "name" ::: ByteString
engineName :: ByteString
  , -- | @engineVersion@ is an unsigned integer variable containing the
    -- developer-supplied version number of the engine used to create the
    -- application. May be zero to indicate no specified engine.
    ApplicationInfo -> "propertyCapacityInput" ::: Word32
engineVersion :: Word32
  , -- | @apiVersion@ is the version of this API against which the application
    -- will run, encoded as described in the
    -- <https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#api-version-numbers-and-semantics API Version Numbers and Semantics>
    -- section. If the runtime does not support the requested @apiVersion@ it
    -- /must/ return
    -- 'OpenXR.Core10.Enums.Result.ERROR_API_VERSION_UNSUPPORTED'.
    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


-- | XrInstanceCreateInfo - Structure specifying params of a newly created
-- instance
--
-- == Valid Usage (Implicit)
--
-- -   #VUID-XrInstanceCreateInfo-type-type# @type@ /must/ be
--     'OpenXR.Core10.Enums.StructureType.TYPE_INSTANCE_CREATE_INFO'
--
-- -   #VUID-XrInstanceCreateInfo-next-next# @next@ /must/ be @NULL@ or a
--     valid pointer to the
--     <https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#valid-usage-for-structure-pointer-chains next structure in a structure chain>.
--     See also:
--     'OpenXR.Extensions.XR_EXT_debug_utils.DebugUtilsMessengerCreateInfoEXT',
--     'OpenXR.Extensions.XR_KHR_android_create_instance.InstanceCreateInfoAndroidKHR'
--
-- -   #VUID-XrInstanceCreateInfo-createFlags-zerobitmask# @createFlags@
--     /must/ be @0@
--
-- -   #VUID-XrInstanceCreateInfo-applicationInfo-parameter#
--     @applicationInfo@ /must/ be a valid 'ApplicationInfo' structure
--
-- -   #VUID-XrInstanceCreateInfo-enabledApiLayerNames-parameter# If
--     @enabledApiLayerCount@ is not @0@, @enabledApiLayerNames@ /must/ be
--     a pointer to an array of @enabledApiLayerCount@ null-terminated
--     UTF-8 strings
--
-- -   #VUID-XrInstanceCreateInfo-enabledExtensionNames-parameter# If
--     @enabledExtensionCount@ is not @0@, @enabledExtensionNames@ /must/
--     be a pointer to an array of @enabledExtensionCount@ null-terminated
--     UTF-8 strings
--
-- = See Also
--
-- 'ApplicationInfo',
-- 'OpenXR.Core10.Enums.InstanceCreateFlags.InstanceCreateFlags',
-- 'OpenXR.Core10.Enums.StructureType.StructureType', 'createInstance'
data InstanceCreateInfo (es :: [Type]) = InstanceCreateInfo
  { -- | @next@ is @NULL@ or a pointer to the next structure in a structure
    -- chain. No such structures are defined in core OpenXR.
    InstanceCreateInfo es -> Chain es
next :: Chain es
  , -- | @createFlags@ is a bitmask of
    -- 'OpenXR.Core10.Enums.InstanceCreateFlags.InstanceCreateFlags' that
    -- identifies options that apply to the creation.
    InstanceCreateInfo es -> InstanceCreateFlags
createFlags :: InstanceCreateFlags
  , -- | @applicationInfo@ is an instance of 'ApplicationInfo'. This information
    -- helps runtimes recognize behavior inherent to classes of applications.
    -- 'ApplicationInfo' is defined in detail below.
    InstanceCreateInfo es -> ApplicationInfo
applicationInfo :: ApplicationInfo
  , -- | @enabledApiLayerNames@ is a pointer to an array of
    -- @enabledApiLayerCount@ strings containing the names of API layers to
    -- enable for the created instance. See the
    -- <https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#api-layers-and-extensions API Layers And Extensions>
    -- section for further details.
    InstanceCreateInfo es -> Vector ("name" ::: ByteString)
enabledApiLayerNames :: Vector ByteString
  , -- | @enabledExtensionNames@ is a pointer to an array of
    -- @enabledExtensionCount@ strings containing the names of extensions to
    -- enable.
    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


-- | XrInstanceProperties - Contains information about the instance
--
-- == Valid Usage (Implicit)
--
-- = See Also
--
-- 'OpenXR.Core10.Enums.StructureType.StructureType',
-- <https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#XrVersion >,
-- 'getInstanceProperties'
data InstanceProperties = InstanceProperties
  { -- | @runtimeVersion@ is the runtime’s version (not necessarily related to an
    -- OpenXR API version), expressed in the format of
    -- 'OpenXR.Version.MAKE_VERSION'.
    InstanceProperties -> Version
runtimeVersion :: Version
  , -- | @runtimeName@ is the name of the runtime.
    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


-- | XrEventDataBuffer - Event buffer
--
-- == Valid Usage (Implicit)
--
-- = See Also
--
-- 'OpenXR.Core10.OtherTypes.EventDataBaseHeader',
-- 'OpenXR.Core10.Enums.StructureType.StructureType', 'pollEvent'
data EventDataBuffer = EventDataBuffer
  { -- | @varying@ is a fixed sized output buffer big enough to hold returned
    -- data elements for all specified event data types.
    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