{-# language CPP #-}
-- | = Name
--
-- XR_KHR_loader_init_android - instance extension
--
-- = Specification
--
-- See
-- <https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#XR_KHR_loader_init_android  XR_KHR_loader_init_android>
-- in the main specification for complete information.
--
-- = Registered Extension Number
--
-- 90
--
-- = Revision
--
-- 1
--
-- = Extension and Version Dependencies
--
-- -   Requires OpenXR 1.0
--
-- -   Requires @@
--
-- = See Also
--
-- 'LoaderInitInfoAndroidKHR'
--
-- = Document Notes
--
-- For more information, see the
-- <https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#XR_KHR_loader_init_android 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_loader_init_android  ( LoaderInitInfoAndroidKHR(..)
                                                     , KHR_loader_init_android_SPEC_VERSION
                                                     , pattern KHR_loader_init_android_SPEC_VERSION
                                                     , KHR_LOADER_INIT_ANDROID_EXTENSION_NAME
                                                     , pattern KHR_LOADER_INIT_ANDROID_EXTENSION_NAME
                                                     , IsLoaderInitInfoKHR(..)
                                                     , LoaderInitInfoBaseHeaderKHR(..)
                                                     ) 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.Extensions.XR_KHR_loader_init (IsLoaderInitInfoKHR(..))
import OpenXR.Extensions.XR_KHR_loader_init (LoaderInitInfoBaseHeaderKHR(..))
import OpenXR.Core10.Enums.StructureType (StructureType)
import OpenXR.Core10.Enums.StructureType (StructureType(TYPE_LOADER_INIT_INFO_ANDROID_KHR))
import OpenXR.Extensions.XR_KHR_loader_init (IsLoaderInitInfoKHR(..))
import OpenXR.Extensions.XR_KHR_loader_init (LoaderInitInfoBaseHeaderKHR(..))
-- | XrLoaderInitInfoAndroidKHR - Initializes OpenXR loader on Android
--
-- == Valid Usage (Implicit)
--
-- -   #VUID-XrLoaderInitInfoAndroidKHR-extension-notenabled# The @@
--     extension /must/ be enabled prior to using
--     'LoaderInitInfoAndroidKHR'
--
-- -   #VUID-XrLoaderInitInfoAndroidKHR-type-type# @type@ /must/ be
--     'OpenXR.Core10.Enums.StructureType.TYPE_LOADER_INIT_INFO_ANDROID_KHR'
--
-- -   #VUID-XrLoaderInitInfoAndroidKHR-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-XrLoaderInitInfoAndroidKHR-applicationVM-parameter#
--     @applicationVM@ /must/ be a pointer value
--
-- -   #VUID-XrLoaderInitInfoAndroidKHR-applicationContext-parameter#
--     @applicationContext@ /must/ be a pointer value
--
-- = See Also
--
-- 'OpenXR.Core10.Enums.StructureType.StructureType',
-- 'OpenXR.Extensions.XR_KHR_loader_init.initializeLoaderKHR'
data LoaderInitInfoAndroidKHR = LoaderInitInfoAndroidKHR
  { -- | @applicationVM@ is a pointer to the JNI’s opaque @JavaVM@ structure,
    -- cast to a void pointer.
    LoaderInitInfoAndroidKHR -> Ptr ()
applicationVM :: Ptr ()
  , -- | @applicationContext@ is a JNI reference to an @android.content.Context@
    -- associated with the application, cast to a void pointer.
    LoaderInitInfoAndroidKHR -> Ptr ()
applicationContext :: Ptr ()
  }
  deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (LoaderInitInfoAndroidKHR)
#endif
deriving instance Show LoaderInitInfoAndroidKHR

instance IsLoaderInitInfoKHR LoaderInitInfoAndroidKHR where
  toLoaderInitInfoBaseHeaderKHR :: LoaderInitInfoAndroidKHR -> LoaderInitInfoBaseHeaderKHR
toLoaderInitInfoBaseHeaderKHR LoaderInitInfoAndroidKHR{} = $WLoaderInitInfoBaseHeaderKHR :: StructureType -> LoaderInitInfoBaseHeaderKHR
LoaderInitInfoBaseHeaderKHR{$sel:type':LoaderInitInfoBaseHeaderKHR :: StructureType
type' = StructureType
TYPE_LOADER_INIT_INFO_ANDROID_KHR}

instance ToCStruct LoaderInitInfoAndroidKHR where
  withCStruct :: LoaderInitInfoAndroidKHR
-> (Ptr LoaderInitInfoAndroidKHR -> IO b) -> IO b
withCStruct x :: LoaderInitInfoAndroidKHR
x f :: Ptr LoaderInitInfoAndroidKHR -> IO b
f = Int -> Int -> (Ptr LoaderInitInfoAndroidKHR -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 32 8 ((Ptr LoaderInitInfoAndroidKHR -> IO b) -> IO b)
-> (Ptr LoaderInitInfoAndroidKHR -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: Ptr LoaderInitInfoAndroidKHR
p -> Ptr LoaderInitInfoAndroidKHR
-> LoaderInitInfoAndroidKHR -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr LoaderInitInfoAndroidKHR
p LoaderInitInfoAndroidKHR
x (Ptr LoaderInitInfoAndroidKHR -> IO b
f Ptr LoaderInitInfoAndroidKHR
p)
  pokeCStruct :: Ptr LoaderInitInfoAndroidKHR
-> LoaderInitInfoAndroidKHR -> IO b -> IO b
pokeCStruct p :: Ptr LoaderInitInfoAndroidKHR
p LoaderInitInfoAndroidKHR{..} f :: IO b
f = do
    Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr LoaderInitInfoAndroidKHR
p Ptr LoaderInitInfoAndroidKHR -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
TYPE_LOADER_INIT_INFO_ANDROID_KHR)
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr LoaderInitInfoAndroidKHR
p Ptr LoaderInitInfoAndroidKHR -> 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 LoaderInitInfoAndroidKHR
p Ptr LoaderInitInfoAndroidKHR -> 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 LoaderInitInfoAndroidKHR
p Ptr LoaderInitInfoAndroidKHR -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr (Ptr ()))) (Ptr ()
applicationContext)
    IO b
f
  cStructSize :: Int
cStructSize = 32
  cStructAlignment :: Int
cStructAlignment = 8
  pokeZeroCStruct :: Ptr LoaderInitInfoAndroidKHR -> IO b -> IO b
pokeZeroCStruct p :: Ptr LoaderInitInfoAndroidKHR
p f :: IO b
f = do
    Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr LoaderInitInfoAndroidKHR
p Ptr LoaderInitInfoAndroidKHR -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
TYPE_LOADER_INIT_INFO_ANDROID_KHR)
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr LoaderInitInfoAndroidKHR
p Ptr LoaderInitInfoAndroidKHR -> 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 LoaderInitInfoAndroidKHR
p Ptr LoaderInitInfoAndroidKHR -> 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 LoaderInitInfoAndroidKHR
p Ptr LoaderInitInfoAndroidKHR -> 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 LoaderInitInfoAndroidKHR where
  peekCStruct :: Ptr LoaderInitInfoAndroidKHR -> IO LoaderInitInfoAndroidKHR
peekCStruct p :: Ptr LoaderInitInfoAndroidKHR
p = do
    Ptr ()
applicationVM <- Ptr (Ptr ()) -> IO (Ptr ())
forall a. Storable a => Ptr a -> IO a
peek @(Ptr ()) ((Ptr LoaderInitInfoAndroidKHR
p Ptr LoaderInitInfoAndroidKHR -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr (Ptr ())))
    Ptr ()
applicationContext <- Ptr (Ptr ()) -> IO (Ptr ())
forall a. Storable a => Ptr a -> IO a
peek @(Ptr ()) ((Ptr LoaderInitInfoAndroidKHR
p Ptr LoaderInitInfoAndroidKHR -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr (Ptr ())))
    LoaderInitInfoAndroidKHR -> IO LoaderInitInfoAndroidKHR
forall (f :: * -> *) a. Applicative f => a -> f a
pure (LoaderInitInfoAndroidKHR -> IO LoaderInitInfoAndroidKHR)
-> LoaderInitInfoAndroidKHR -> IO LoaderInitInfoAndroidKHR
forall a b. (a -> b) -> a -> b
$ Ptr () -> Ptr () -> LoaderInitInfoAndroidKHR
LoaderInitInfoAndroidKHR
             Ptr ()
applicationVM Ptr ()
applicationContext

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

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


type KHR_loader_init_android_SPEC_VERSION = 1

-- No documentation found for TopLevel "XR_KHR_loader_init_android_SPEC_VERSION"
pattern KHR_loader_init_android_SPEC_VERSION :: forall a . Integral a => a
pattern $bKHR_loader_init_android_SPEC_VERSION :: a
$mKHR_loader_init_android_SPEC_VERSION :: forall r a. Integral a => a -> (Void# -> r) -> (Void# -> r) -> r
KHR_loader_init_android_SPEC_VERSION = 1


type KHR_LOADER_INIT_ANDROID_EXTENSION_NAME = "XR_KHR_loader_init_android"

-- No documentation found for TopLevel "XR_KHR_LOADER_INIT_ANDROID_EXTENSION_NAME"
pattern KHR_LOADER_INIT_ANDROID_EXTENSION_NAME :: forall a . (Eq a, IsString a) => a
pattern $bKHR_LOADER_INIT_ANDROID_EXTENSION_NAME :: a
$mKHR_LOADER_INIT_ANDROID_EXTENSION_NAME :: forall r a.
(Eq a, IsString a) =>
a -> (Void# -> r) -> (Void# -> r) -> r
KHR_LOADER_INIT_ANDROID_EXTENSION_NAME = "XR_KHR_loader_init_android"