{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE NoFieldSelectors #-}
{-# LANGUAGE NoImplicitPrelude #-}

module SDL3.Sys.Bindgen.Main (
  SDL3.Sys.Bindgen.Main.SDL_main_func_Aux (..),
  SDL3.Sys.Bindgen.Main.SDL_main_func (..),
)
where

import Prelude (Eq, IO, Ord, Show, fmap, type (~))

import HsBindgen.Runtime.HasCField qualified as HasCField
import HsBindgen.Runtime.IncompleteArray qualified as IA
import HsBindgen.Runtime.IsArray qualified as IsA
import HsBindgen.Runtime.Marshal qualified as Marshal
import HsBindgen.Runtime.Support qualified as BG
import HsBindgen.Runtime.Support.CompatHasField qualified as BG.CompatHasField

-- | Auxiliary type used by 'SDL_main_func'
--
--     [C declaration]: @SDL_main_func@, defined at @SDL3\/SDL_main.h 499:23@
newtype SDL_main_func_Aux = SDL_main_func_Aux
  { SDL_main_func_Aux
-> CInt -> Ptr (Elem (IncompleteArray (Ptr CChar))) -> IO CInt
unwrap :: BG.CInt -> BG.Ptr (IsA.Elem (IA.IncompleteArray (BG.Ptr BG.CChar))) -> IO BG.CInt
  }
  deriving stock ((forall x. SDL_main_func_Aux -> Rep SDL_main_func_Aux x)
-> (forall x. Rep SDL_main_func_Aux x -> SDL_main_func_Aux)
-> Generic SDL_main_func_Aux
forall x. Rep SDL_main_func_Aux x -> SDL_main_func_Aux
forall x. SDL_main_func_Aux -> Rep SDL_main_func_Aux x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. SDL_main_func_Aux -> Rep SDL_main_func_Aux x
from :: forall x. SDL_main_func_Aux -> Rep SDL_main_func_Aux x
$cto :: forall x. Rep SDL_main_func_Aux x -> SDL_main_func_Aux
to :: forall x. Rep SDL_main_func_Aux x -> SDL_main_func_Aux
BG.Generic)

-- __unique:__ @toSDL_main_func_Aux@
foreign import ccall safe "wrapper"
  hs_bindgen_637d4c26522acb68_base
    :: (BG.CInt -> BG.Ptr BG.Void -> IO BG.CInt)
    -> IO (BG.FunPtr (BG.CInt -> BG.Ptr BG.Void -> IO BG.CInt))

-- __unique:__ @toSDL_main_func_Aux@
hs_bindgen_637d4c26522acb68
  :: SDL_main_func_Aux
  -> IO (BG.FunPtr SDL_main_func_Aux)
hs_bindgen_637d4c26522acb68 :: SDL_main_func_Aux -> IO (FunPtr SDL_main_func_Aux)
hs_bindgen_637d4c26522acb68 =
  \SDL_main_func_Aux
fun0 ->
    (FunPtr (CInt -> Ptr Void -> IO CInt) -> FunPtr SDL_main_func_Aux)
-> IO (FunPtr (CInt -> Ptr Void -> IO CInt))
-> IO (FunPtr SDL_main_func_Aux)
forall a b. (a -> b) -> IO a -> IO b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap
      FunPtr (CInt -> Ptr Void -> IO CInt) -> FunPtr SDL_main_func_Aux
forall a b. FunPtr a -> FunPtr b
BG.castFunPtr
      ( (CInt -> Ptr Void -> IO CInt)
-> IO (FunPtr (CInt -> Ptr Void -> IO CInt))
hs_bindgen_637d4c26522acb68_base
          ( \CInt
x1 ->
              \Ptr Void
x2 ->
                (CInt -> CInt) -> IO CInt -> IO CInt
forall a b. (a -> b) -> IO a -> IO b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap CInt -> CInt
CInt -> FFIType CInt
forall a. HasFFIType a => a -> FFIType a
BG.toFFIType (forall {k} (x :: k) r a. HasField x r a => r -> a
forall (x :: Symbol) r a. HasField x r a => r -> a
BG.getField @"unwrap" SDL_main_func_Aux
fun0 (FFIType CInt -> CInt
forall a. HasFFIType a => FFIType a -> a
BG.fromFFIType CInt
FFIType CInt
x1) (FFIType (Ptr (Ptr CChar)) -> Ptr (Ptr CChar)
forall a. HasFFIType a => FFIType a -> a
BG.fromFFIType Ptr Void
FFIType (Ptr (Ptr CChar))
x2))
          )
      )

-- __unique:__ @fromSDL_main_func_Aux@
foreign import ccall safe "dynamic"
  hs_bindgen_7875a01662c70189_base
    :: BG.FunPtr (BG.CInt -> BG.Ptr BG.Void -> IO BG.CInt)
    -> BG.CInt
    -> BG.Ptr BG.Void
    -> IO BG.CInt

-- __unique:__ @fromSDL_main_func_Aux@
hs_bindgen_7875a01662c70189
  :: BG.FunPtr SDL_main_func_Aux
  -> SDL_main_func_Aux
hs_bindgen_7875a01662c70189 :: FunPtr SDL_main_func_Aux -> SDL_main_func_Aux
hs_bindgen_7875a01662c70189 =
  \FunPtr SDL_main_func_Aux
funPtr0 ->
    (CInt -> Ptr (Elem (IncompleteArray (Ptr CChar))) -> IO CInt)
-> SDL_main_func_Aux
SDL_main_func_Aux
      ( \CInt
x1 ->
          \Ptr (Elem (IncompleteArray (Ptr CChar)))
x2 ->
            (CInt -> CInt) -> IO CInt -> IO CInt
forall a b. (a -> b) -> IO a -> IO b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap
              CInt -> CInt
FFIType CInt -> CInt
forall a. HasFFIType a => FFIType a -> a
BG.fromFFIType
              (FunPtr (CInt -> Ptr Void -> IO CInt) -> CInt -> Ptr Void -> IO CInt
hs_bindgen_7875a01662c70189_base (FunPtr SDL_main_func_Aux -> FunPtr (CInt -> Ptr Void -> IO CInt)
forall a b. FunPtr a -> FunPtr b
BG.castFunPtr FunPtr SDL_main_func_Aux
funPtr0) (CInt -> FFIType CInt
forall a. HasFFIType a => a -> FFIType a
BG.toFFIType CInt
x1) (Ptr (Ptr CChar) -> FFIType (Ptr (Ptr CChar))
forall a. HasFFIType a => a -> FFIType a
BG.toFFIType Ptr (Ptr CChar)
Ptr (Elem (IncompleteArray (Ptr CChar)))
x2))
      )

instance BG.ToFunPtr SDL_main_func_Aux where
  toFunPtr :: SDL_main_func_Aux -> IO (FunPtr SDL_main_func_Aux)
toFunPtr = SDL_main_func_Aux -> IO (FunPtr SDL_main_func_Aux)
hs_bindgen_637d4c26522acb68

instance BG.FromFunPtr SDL_main_func_Aux where
  fromFunPtr :: FunPtr SDL_main_func_Aux -> SDL_main_func_Aux
fromFunPtr = FunPtr SDL_main_func_Aux -> SDL_main_func_Aux
hs_bindgen_7875a01662c70189

instance
  (ty ~ (BG.CInt -> BG.Ptr (IsA.Elem (IA.IncompleteArray (BG.Ptr BG.CChar))) -> IO BG.CInt))
  => BG.CompatHasField.HasField "unwrap" SDL_main_func_Aux ty
  where
  hasField :: SDL_main_func_Aux -> (ty -> SDL_main_func_Aux, ty)
hasField =
    \SDL_main_func_Aux
x0 ->
      ( \ty
y1 ->
          SDL_main_func_Aux{unwrap :: CInt -> Ptr (Elem (IncompleteArray (Ptr CChar))) -> IO CInt
unwrap = ty
CInt -> Ptr (Elem (IncompleteArray (Ptr CChar))) -> IO CInt
y1}
      , forall {k} (x :: k) r a. HasField x r a => r -> a
forall (x :: Symbol) r a. HasField x r a => r -> a
BG.getField @"unwrap" SDL_main_func_Aux
x0
      )

instance
  (ty ~ (BG.CInt -> BG.Ptr (IsA.Elem (IA.IncompleteArray (BG.Ptr BG.CChar))) -> IO BG.CInt))
  => BG.HasField "unwrap" (BG.Ptr SDL_main_func_Aux) (BG.Ptr ty)
  where
  getField :: Ptr SDL_main_func_Aux -> Ptr ty
getField = Proxy "unwrap"
-> Ptr SDL_main_func_Aux
-> Ptr (CFieldType SDL_main_func_Aux "unwrap")
forall a (field :: Symbol).
HasCField a field =>
Proxy field -> Ptr a -> Ptr (CFieldType a field)
HasCField.fromPtr (forall {k} (t :: k). Proxy t
forall (t :: Symbol). Proxy t
BG.Proxy @"unwrap")

instance HasCField.HasCField SDL_main_func_Aux "unwrap" where
  type
    CFieldType SDL_main_func_Aux "unwrap" =
      BG.CInt -> BG.Ptr (IsA.Elem (IA.IncompleteArray (BG.Ptr BG.CChar))) -> IO BG.CInt

  offset# :: Proxy# SDL_main_func_Aux -> Proxy# "unwrap" -> Int
offset# = \Proxy# SDL_main_func_Aux
_ -> \Proxy# "unwrap"
_ -> Int
0

-- | The prototype for the application\'s main() function
--
--     [@argc@]: an ANSI-C style main function\'s argc.
--
--     [@argv@]: an ANSI-C style main function\'s argv.
--
--     [Returns]: an ANSI-C main return code; generally 0 is considered successful program completion, and small non-zero values are considered errors.
--
--     @since 3.2.0
--
--     [C declaration]: @SDL_main_func@, defined at @SDL3\/SDL_main.h 499:23@
newtype SDL_main_func = SDL_main_func
  { SDL_main_func -> FunPtr SDL_main_func_Aux
unwrap :: BG.FunPtr SDL_main_func_Aux
  }
  deriving stock ((forall x. SDL_main_func -> Rep SDL_main_func x)
-> (forall x. Rep SDL_main_func x -> SDL_main_func)
-> Generic SDL_main_func
forall x. Rep SDL_main_func x -> SDL_main_func
forall x. SDL_main_func -> Rep SDL_main_func x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. SDL_main_func -> Rep SDL_main_func x
from :: forall x. SDL_main_func -> Rep SDL_main_func x
$cto :: forall x. Rep SDL_main_func x -> SDL_main_func
to :: forall x. Rep SDL_main_func x -> SDL_main_func
BG.Generic, SDL_main_func -> SDL_main_func -> Bool
(SDL_main_func -> SDL_main_func -> Bool)
-> (SDL_main_func -> SDL_main_func -> Bool) -> Eq SDL_main_func
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SDL_main_func -> SDL_main_func -> Bool
== :: SDL_main_func -> SDL_main_func -> Bool
$c/= :: SDL_main_func -> SDL_main_func -> Bool
/= :: SDL_main_func -> SDL_main_func -> Bool
Eq, Eq SDL_main_func
Eq SDL_main_func =>
(SDL_main_func -> SDL_main_func -> Ordering)
-> (SDL_main_func -> SDL_main_func -> Bool)
-> (SDL_main_func -> SDL_main_func -> Bool)
-> (SDL_main_func -> SDL_main_func -> Bool)
-> (SDL_main_func -> SDL_main_func -> Bool)
-> (SDL_main_func -> SDL_main_func -> SDL_main_func)
-> (SDL_main_func -> SDL_main_func -> SDL_main_func)
-> Ord SDL_main_func
SDL_main_func -> SDL_main_func -> Bool
SDL_main_func -> SDL_main_func -> Ordering
SDL_main_func -> SDL_main_func -> SDL_main_func
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: SDL_main_func -> SDL_main_func -> Ordering
compare :: SDL_main_func -> SDL_main_func -> Ordering
$c< :: SDL_main_func -> SDL_main_func -> Bool
< :: SDL_main_func -> SDL_main_func -> Bool
$c<= :: SDL_main_func -> SDL_main_func -> Bool
<= :: SDL_main_func -> SDL_main_func -> Bool
$c> :: SDL_main_func -> SDL_main_func -> Bool
> :: SDL_main_func -> SDL_main_func -> Bool
$c>= :: SDL_main_func -> SDL_main_func -> Bool
>= :: SDL_main_func -> SDL_main_func -> Bool
$cmax :: SDL_main_func -> SDL_main_func -> SDL_main_func
max :: SDL_main_func -> SDL_main_func -> SDL_main_func
$cmin :: SDL_main_func -> SDL_main_func -> SDL_main_func
min :: SDL_main_func -> SDL_main_func -> SDL_main_func
Ord, Int -> SDL_main_func -> ShowS
[SDL_main_func] -> ShowS
SDL_main_func -> String
(Int -> SDL_main_func -> ShowS)
-> (SDL_main_func -> String)
-> ([SDL_main_func] -> ShowS)
-> Show SDL_main_func
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SDL_main_func -> ShowS
showsPrec :: Int -> SDL_main_func -> ShowS
$cshow :: SDL_main_func -> String
show :: SDL_main_func -> String
$cshowList :: [SDL_main_func] -> ShowS
showList :: [SDL_main_func] -> ShowS
Show)
  deriving newtype
    ( FFIType SDL_main_func -> SDL_main_func
SDL_main_func -> FFIType SDL_main_func
(SDL_main_func -> FFIType SDL_main_func)
-> (FFIType SDL_main_func -> SDL_main_func)
-> HasFFIType SDL_main_func
forall a. (a -> FFIType a) -> (FFIType a -> a) -> HasFFIType a
$ctoFFIType :: SDL_main_func -> FFIType SDL_main_func
toFFIType :: SDL_main_func -> FFIType SDL_main_func
$cfromFFIType :: FFIType SDL_main_func -> SDL_main_func
fromFFIType :: FFIType SDL_main_func -> SDL_main_func
BG.HasFFIType
    , Ptr SDL_main_func -> IO SDL_main_func
Ptr SDL_main_func -> Int -> IO SDL_main_func
Ptr SDL_main_func -> Int -> SDL_main_func -> IO ()
Ptr SDL_main_func -> SDL_main_func -> IO ()
SDL_main_func -> Int
(SDL_main_func -> Int)
-> (SDL_main_func -> Int)
-> (Ptr SDL_main_func -> Int -> IO SDL_main_func)
-> (Ptr SDL_main_func -> Int -> SDL_main_func -> IO ())
-> (forall b. Ptr b -> Int -> IO SDL_main_func)
-> (forall b. Ptr b -> Int -> SDL_main_func -> IO ())
-> (Ptr SDL_main_func -> IO SDL_main_func)
-> (Ptr SDL_main_func -> SDL_main_func -> IO ())
-> Storable SDL_main_func
forall b. Ptr b -> Int -> IO SDL_main_func
forall b. Ptr b -> Int -> SDL_main_func -> IO ()
forall a.
(a -> Int)
-> (a -> Int)
-> (Ptr a -> Int -> IO a)
-> (Ptr a -> Int -> a -> IO ())
-> (forall b. Ptr b -> Int -> IO a)
-> (forall b. Ptr b -> Int -> a -> IO ())
-> (Ptr a -> IO a)
-> (Ptr a -> a -> IO ())
-> Storable a
$csizeOf :: SDL_main_func -> Int
sizeOf :: SDL_main_func -> Int
$calignment :: SDL_main_func -> Int
alignment :: SDL_main_func -> Int
$cpeekElemOff :: Ptr SDL_main_func -> Int -> IO SDL_main_func
peekElemOff :: Ptr SDL_main_func -> Int -> IO SDL_main_func
$cpokeElemOff :: Ptr SDL_main_func -> Int -> SDL_main_func -> IO ()
pokeElemOff :: Ptr SDL_main_func -> Int -> SDL_main_func -> IO ()
$cpeekByteOff :: forall b. Ptr b -> Int -> IO SDL_main_func
peekByteOff :: forall b. Ptr b -> Int -> IO SDL_main_func
$cpokeByteOff :: forall b. Ptr b -> Int -> SDL_main_func -> IO ()
pokeByteOff :: forall b. Ptr b -> Int -> SDL_main_func -> IO ()
$cpeek :: Ptr SDL_main_func -> IO SDL_main_func
peek :: Ptr SDL_main_func -> IO SDL_main_func
$cpoke :: Ptr SDL_main_func -> SDL_main_func -> IO ()
poke :: Ptr SDL_main_func -> SDL_main_func -> IO ()
BG.Storable
    , Ptr SDL_main_func -> IO SDL_main_func
(Ptr SDL_main_func -> IO SDL_main_func) -> ReadRaw SDL_main_func
forall a. (Ptr a -> IO a) -> ReadRaw a
$creadRaw :: Ptr SDL_main_func -> IO SDL_main_func
readRaw :: Ptr SDL_main_func -> IO SDL_main_func
Marshal.ReadRaw
    , Proxy SDL_main_func -> Int
(Proxy SDL_main_func -> Int)
-> (Proxy SDL_main_func -> Int) -> StaticSize SDL_main_func
forall a. (Proxy a -> Int) -> (Proxy a -> Int) -> StaticSize a
$cstaticSizeOf :: Proxy SDL_main_func -> Int
staticSizeOf :: Proxy SDL_main_func -> Int
$cstaticAlignment :: Proxy SDL_main_func -> Int
staticAlignment :: Proxy SDL_main_func -> Int
Marshal.StaticSize
    , Ptr SDL_main_func -> SDL_main_func -> IO ()
(Ptr SDL_main_func -> SDL_main_func -> IO ())
-> WriteRaw SDL_main_func
forall a. (Ptr a -> a -> IO ()) -> WriteRaw a
$cwriteRaw :: Ptr SDL_main_func -> SDL_main_func -> IO ()
writeRaw :: Ptr SDL_main_func -> SDL_main_func -> IO ()
Marshal.WriteRaw
    )

instance
  (ty ~ BG.FunPtr SDL_main_func_Aux)
  => BG.CompatHasField.HasField "unwrap" SDL_main_func ty
  where
  hasField :: SDL_main_func -> (ty -> SDL_main_func, ty)
hasField =
    \SDL_main_func
x0 ->
      ( \ty
y1 ->
          SDL_main_func{unwrap :: FunPtr SDL_main_func_Aux
unwrap = ty
FunPtr SDL_main_func_Aux
y1}
      , forall {k} (x :: k) r a. HasField x r a => r -> a
forall (x :: Symbol) r a. HasField x r a => r -> a
BG.getField @"unwrap" SDL_main_func
x0
      )

instance
  (ty ~ BG.FunPtr SDL_main_func_Aux)
  => BG.HasField "unwrap" (BG.Ptr SDL_main_func) (BG.Ptr ty)
  where
  getField :: Ptr SDL_main_func -> Ptr ty
getField = Proxy "unwrap"
-> Ptr SDL_main_func -> Ptr (CFieldType SDL_main_func "unwrap")
forall a (field :: Symbol).
HasCField a field =>
Proxy field -> Ptr a -> Ptr (CFieldType a field)
HasCField.fromPtr (forall {k} (t :: k). Proxy t
forall (t :: Symbol). Proxy t
BG.Proxy @"unwrap")

instance HasCField.HasCField SDL_main_func "unwrap" where
  type
    CFieldType SDL_main_func "unwrap" =
      BG.FunPtr SDL_main_func_Aux

  offset# :: Proxy# SDL_main_func -> Proxy# "unwrap" -> Int
offset# = \Proxy# SDL_main_func
_ -> \Proxy# "unwrap"
_ -> Int
0