{-# language CPP #-}
-- | = Name
--
-- XR_KHR_android_create_instance - instance extension
--
-- = Specification
--
-- See
-- <https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#XR_KHR_android_create_instance  XR_KHR_android_create_instance>
-- in the main specification for complete information.
--
-- = Registered Extension Number
--
-- 9
--
-- = Revision
--
-- 3
--
-- = Extension and Version Dependencies
--
-- -   Requires OpenXR 1.0
--
-- = See Also
--
-- 'InstanceCreateInfoAndroidKHR'
--
-- = Document Notes
--
-- For more information, see the
-- <https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#XR_KHR_android_create_instance OpenXR Specification>
--
-- This page is a generated document. Fixes and changes should be made to
-- the generator scripts, not directly.
module OpenXR.Extensions.XR_KHR_android_create_instance  ( InstanceCreateInfoAndroidKHR(..)
                                                         , KHR_android_create_instance_SPEC_VERSION
                                                         , pattern KHR_android_create_instance_SPEC_VERSION
                                                         , KHR_ANDROID_CREATE_INSTANCE_EXTENSION_NAME
                                                         , pattern KHR_ANDROID_CREATE_INSTANCE_EXTENSION_NAME
                                                         ) where

import Foreign.Marshal.Alloc (allocaBytesAligned)
import Foreign.Ptr (nullPtr)
import Foreign.Ptr (plusPtr)
import OpenXR.CStruct (FromCStruct)
import OpenXR.CStruct (FromCStruct(..))
import OpenXR.CStruct (ToCStruct)
import OpenXR.CStruct (ToCStruct(..))
import OpenXR.Zero (Zero(..))
import Data.String (IsString)
import Data.Typeable (Typeable)
import Foreign.Storable (Storable)
import Foreign.Storable (Storable(peek))
import Foreign.Storable (Storable(poke))
import qualified Foreign.Storable (Storable(..))
import GHC.Generics (Generic)
import Foreign.Ptr (Ptr)
import Data.Kind (Type)
import OpenXR.Core10.Enums.StructureType (StructureType)
import OpenXR.Core10.Enums.StructureType (StructureType(TYPE_INSTANCE_CREATE_INFO_ANDROID_KHR))
-- | XrInstanceCreateInfoAndroidKHR - Creates an OpenXR Instance
--
-- == Member Descriptions
--
-- = Description
--
-- 'InstanceCreateInfoAndroidKHR' contains additional Android specific
-- information needed when calling 'OpenXR.Core10.Instance.createInstance'.
-- The @applicationVM@ field should be populated with the @JavaVM@
-- structure received by the @JNI_OnLoad@ function, while the
-- @applicationActivity@ field will typically contain a reference to a Java
-- activity object received through an application-specific native method.
-- The 'InstanceCreateInfoAndroidKHR' structure /must/ be provided in the
-- @next@ chain of the 'OpenXR.Core10.Instance.InstanceCreateInfo'
-- structure when calling 'OpenXR.Core10.Instance.createInstance'.
--
-- == Valid Usage (Implicit)
--
-- -   #VUID-XrInstanceCreateInfoAndroidKHR-extension-notenabled# The @@
--     extension /must/ be enabled prior to using
--     'InstanceCreateInfoAndroidKHR'
--
-- -   #VUID-XrInstanceCreateInfoAndroidKHR-type-type# @type@ /must/ be
--     'OpenXR.Core10.Enums.StructureType.TYPE_INSTANCE_CREATE_INFO_ANDROID_KHR'
--
-- -   #VUID-XrInstanceCreateInfoAndroidKHR-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>
--
-- -   #VUID-XrInstanceCreateInfoAndroidKHR-applicationVM-parameter#
--     @applicationVM@ /must/ be a pointer value
--
-- -   #VUID-XrInstanceCreateInfoAndroidKHR-applicationActivity-parameter#
--     @applicationActivity@ /must/ be a pointer value
--
-- = See Also
--
-- 'OpenXR.Core10.Enums.StructureType.StructureType',
-- 'OpenXR.Core10.Instance.createInstance',
-- 'OpenXR.Core10.Instance.destroyInstance'
data InstanceCreateInfoAndroidKHR = InstanceCreateInfoAndroidKHR
  { -- | @applicationVM@ is a pointer to the JNI’s opaque @JavaVM@ structure,
    -- cast to a void pointer.
    InstanceCreateInfoAndroidKHR -> Ptr ()
applicationVM :: Ptr ()
  , -- | @applicationActivity@ is a JNI reference to an @android.app.Activity@
    -- that will drive the session lifecycle of this instance, cast to a void
    -- pointer.
    InstanceCreateInfoAndroidKHR -> Ptr ()
applicationActivity :: Ptr ()
  }
  deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (InstanceCreateInfoAndroidKHR)
#endif
deriving instance Show InstanceCreateInfoAndroidKHR

instance ToCStruct InstanceCreateInfoAndroidKHR where
  withCStruct :: InstanceCreateInfoAndroidKHR
-> (Ptr InstanceCreateInfoAndroidKHR -> IO b) -> IO b
withCStruct x :: InstanceCreateInfoAndroidKHR
x f :: Ptr InstanceCreateInfoAndroidKHR -> IO b
f = Int -> Int -> (Ptr InstanceCreateInfoAndroidKHR -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 32 8 ((Ptr InstanceCreateInfoAndroidKHR -> IO b) -> IO b)
-> (Ptr InstanceCreateInfoAndroidKHR -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: Ptr InstanceCreateInfoAndroidKHR
p -> Ptr InstanceCreateInfoAndroidKHR
-> InstanceCreateInfoAndroidKHR -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr InstanceCreateInfoAndroidKHR
p InstanceCreateInfoAndroidKHR
x (Ptr InstanceCreateInfoAndroidKHR -> IO b
f Ptr InstanceCreateInfoAndroidKHR
p)
  pokeCStruct :: Ptr InstanceCreateInfoAndroidKHR
-> InstanceCreateInfoAndroidKHR -> IO b -> IO b
pokeCStruct p :: Ptr InstanceCreateInfoAndroidKHR
p InstanceCreateInfoAndroidKHR{..} f :: IO b
f = do
    Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr InstanceCreateInfoAndroidKHR
p Ptr InstanceCreateInfoAndroidKHR -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
TYPE_INSTANCE_CREATE_INFO_ANDROID_KHR)
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr InstanceCreateInfoAndroidKHR
p Ptr InstanceCreateInfoAndroidKHR -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr InstanceCreateInfoAndroidKHR
p Ptr InstanceCreateInfoAndroidKHR -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr (Ptr ()))) (Ptr ()
applicationVM)
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr InstanceCreateInfoAndroidKHR
p Ptr InstanceCreateInfoAndroidKHR -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr (Ptr ()))) (Ptr ()
applicationActivity)
    IO b
f
  cStructSize :: Int
cStructSize = 32
  cStructAlignment :: Int
cStructAlignment = 8
  pokeZeroCStruct :: Ptr InstanceCreateInfoAndroidKHR -> IO b -> IO b
pokeZeroCStruct p :: Ptr InstanceCreateInfoAndroidKHR
p f :: IO b
f = do
    Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr InstanceCreateInfoAndroidKHR
p Ptr InstanceCreateInfoAndroidKHR -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
TYPE_INSTANCE_CREATE_INFO_ANDROID_KHR)
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr InstanceCreateInfoAndroidKHR
p Ptr InstanceCreateInfoAndroidKHR -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr InstanceCreateInfoAndroidKHR
p Ptr InstanceCreateInfoAndroidKHR -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr (Ptr ()))) (Ptr ()
forall a. Zero a => a
zero)
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr InstanceCreateInfoAndroidKHR
p Ptr InstanceCreateInfoAndroidKHR -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr (Ptr ()))) (Ptr ()
forall a. Zero a => a
zero)
    IO b
f

instance FromCStruct InstanceCreateInfoAndroidKHR where
  peekCStruct :: Ptr InstanceCreateInfoAndroidKHR -> IO InstanceCreateInfoAndroidKHR
peekCStruct p :: Ptr InstanceCreateInfoAndroidKHR
p = do
    Ptr ()
applicationVM <- Ptr (Ptr ()) -> IO (Ptr ())
forall a. Storable a => Ptr a -> IO a
peek @(Ptr ()) ((Ptr InstanceCreateInfoAndroidKHR
p Ptr InstanceCreateInfoAndroidKHR -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr (Ptr ())))
    Ptr ()
applicationActivity <- Ptr (Ptr ()) -> IO (Ptr ())
forall a. Storable a => Ptr a -> IO a
peek @(Ptr ()) ((Ptr InstanceCreateInfoAndroidKHR
p Ptr InstanceCreateInfoAndroidKHR -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr (Ptr ())))
    InstanceCreateInfoAndroidKHR -> IO InstanceCreateInfoAndroidKHR
forall (f :: * -> *) a. Applicative f => a -> f a
pure (InstanceCreateInfoAndroidKHR -> IO InstanceCreateInfoAndroidKHR)
-> InstanceCreateInfoAndroidKHR -> IO InstanceCreateInfoAndroidKHR
forall a b. (a -> b) -> a -> b
$ Ptr () -> Ptr () -> InstanceCreateInfoAndroidKHR
InstanceCreateInfoAndroidKHR
             Ptr ()
applicationVM Ptr ()
applicationActivity

instance Storable InstanceCreateInfoAndroidKHR where
  sizeOf :: InstanceCreateInfoAndroidKHR -> Int
sizeOf ~InstanceCreateInfoAndroidKHR
_ = 32
  alignment :: InstanceCreateInfoAndroidKHR -> Int
alignment ~InstanceCreateInfoAndroidKHR
_ = 8
  peek :: Ptr InstanceCreateInfoAndroidKHR -> IO InstanceCreateInfoAndroidKHR
peek = Ptr InstanceCreateInfoAndroidKHR -> IO InstanceCreateInfoAndroidKHR
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
  poke :: Ptr InstanceCreateInfoAndroidKHR
-> InstanceCreateInfoAndroidKHR -> IO ()
poke ptr :: Ptr InstanceCreateInfoAndroidKHR
ptr poked :: InstanceCreateInfoAndroidKHR
poked = Ptr InstanceCreateInfoAndroidKHR
-> InstanceCreateInfoAndroidKHR -> IO () -> IO ()
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr InstanceCreateInfoAndroidKHR
ptr InstanceCreateInfoAndroidKHR
poked (() -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())

instance Zero InstanceCreateInfoAndroidKHR where
  zero :: InstanceCreateInfoAndroidKHR
zero = Ptr () -> Ptr () -> InstanceCreateInfoAndroidKHR
InstanceCreateInfoAndroidKHR
           Ptr ()
forall a. Zero a => a
zero
           Ptr ()
forall a. Zero a => a
zero


type KHR_android_create_instance_SPEC_VERSION = 3

-- No documentation found for TopLevel "XR_KHR_android_create_instance_SPEC_VERSION"
pattern KHR_android_create_instance_SPEC_VERSION :: forall a . Integral a => a
pattern $bKHR_android_create_instance_SPEC_VERSION :: a
$mKHR_android_create_instance_SPEC_VERSION :: forall r a. Integral a => a -> (Void# -> r) -> (Void# -> r) -> r
KHR_android_create_instance_SPEC_VERSION = 3


type KHR_ANDROID_CREATE_INSTANCE_EXTENSION_NAME = "XR_KHR_android_create_instance"

-- No documentation found for TopLevel "XR_KHR_ANDROID_CREATE_INSTANCE_EXTENSION_NAME"
pattern KHR_ANDROID_CREATE_INSTANCE_EXTENSION_NAME :: forall a . (Eq a, IsString a) => a
pattern $bKHR_ANDROID_CREATE_INSTANCE_EXTENSION_NAME :: a
$mKHR_ANDROID_CREATE_INSTANCE_EXTENSION_NAME :: forall r a.
(Eq a, IsString a) =>
a -> (Void# -> r) -> (Void# -> r) -> r
KHR_ANDROID_CREATE_INSTANCE_EXTENSION_NAME = "XR_KHR_android_create_instance"