    {-# LANGUAGE TypeApplications #-}

    -- | Copyright  : Will Thompson and Iñaki García Etxebarria
    -- License    : LGPL-2.1
    -- Maintainer : Iñaki García Etxebarria
    --
    -- The t'GI.GLib.Unions.FloatIEEE754.FloatIEEE754' and t'GI.GLib.Unions.DoubleIEEE754.DoubleIEEE754' unions are used to access the sign,
    -- mantissa and exponent of IEEE floats and doubles. These unions are defined
    -- as appropriate for a given platform. IEEE floats and doubles are supported
    -- (used for storage) by at least Intel, PPC and Sparc.

    #if !defined(__HADDOCK_VERSION__)
    #define ENABLE_OVERLOADING
    #endif

    module GI.GLib.Unions.FloatIEEE754
        (

    -- * Exported types
        FloatIEEE754(..)                        ,
        newZeroFloatIEEE754                     ,

     -- * Methods

    #if defined(ENABLE_OVERLOADING)
        ResolveFloatIEEE754Method               ,
    #endif

     -- * Properties

    -- ** vFloat #attr:vFloat#
    -- | the double value

    #if defined(ENABLE_OVERLOADING)
        floatIEEE754_vFloat                     ,
    #endif
        getFloatIEEE754VFloat                   ,
        setFloatIEEE754VFloat                   ,

        ) where

    import Data.GI.Base.ShortPrelude
    import qualified Data.GI.Base.ShortPrelude as SP
    import qualified Data.GI.Base.Overloading as O
    import qualified Prelude as P

    import qualified Data.GI.Base.Attributes as GI.Attributes
    import qualified Data.GI.Base.BasicTypes as B.Types
    import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
    import qualified Data.GI.Base.GArray as B.GArray
    import qualified Data.GI.Base.GClosure as B.GClosure
    import qualified Data.GI.Base.GError as B.GError
    import qualified Data.GI.Base.GHashTable as B.GHT
    import qualified Data.GI.Base.GVariant as B.GVariant
    import qualified Data.GI.Base.GValue as B.GValue
    import qualified Data.GI.Base.GParamSpec as B.GParamSpec
    import qualified Data.GI.Base.CallStack as B.CallStack
    import qualified Data.GI.Base.Properties as B.Properties
    import qualified Data.GI.Base.Signals as B.Signals
    import qualified Control.Monad.IO.Class as MIO
    import qualified Data.Coerce as Coerce
    import qualified Data.Text as T
    import qualified Data.Kind as DK
    import qualified Data.ByteString.Char8 as B
    import qualified Data.Map as Map
    import qualified Foreign.Ptr as FP
    import qualified GHC.OverloadedLabels as OL
    import qualified GHC.Records as R
    import qualified Data.Word as DW
    import qualified Data.Int as DI
    import qualified System.Posix.Types as SPT
    import qualified Foreign.C.Types as FCT

    -- Workaround for https://gitlab.haskell.org/ghc/ghc/-/issues/23392
    #if MIN_VERSION_base(4,18,0)

    #else

    #endif

    -- | Memory-managed wrapper type.
    newtype FloatIEEE754 = FloatIEEE754 (SP.ManagedPtr FloatIEEE754)
        deriving (FloatIEEE754 -> FloatIEEE754 -> Bool
    (FloatIEEE754 -> FloatIEEE754 -> Bool)
    -> (FloatIEEE754 -> FloatIEEE754 -> Bool) -> Eq FloatIEEE754
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: FloatIEEE754 -> FloatIEEE754 -> Bool
    == :: FloatIEEE754 -> FloatIEEE754 -> Bool
    $c/= :: FloatIEEE754 -> FloatIEEE754 -> Bool
    /= :: FloatIEEE754 -> FloatIEEE754 -> Bool
    Eq)

    instance SP.ManagedPtrNewtype FloatIEEE754 where
        toManagedPtr :: FloatIEEE754 -> ManagedPtr FloatIEEE754
    toManagedPtr (FloatIEEE754 ManagedPtr FloatIEEE754
    p) = ManagedPtr FloatIEEE754
    p

    instance BoxedPtr FloatIEEE754 where
        boxedPtrCopy :: FloatIEEE754 -> IO FloatIEEE754
    boxedPtrCopy = \FloatIEEE754
    p -> FloatIEEE754
    -> (Ptr FloatIEEE754 -> IO FloatIEEE754) -> IO FloatIEEE754
    forall a c.
    (HasCallStack, ManagedPtrNewtype a) =>
    a -> (Ptr a -> IO c) -> IO c
    B.ManagedPtr.withManagedPtr FloatIEEE754
    p (Int -> Ptr FloatIEEE754 -> IO (Ptr FloatIEEE754)
    forall a. (HasCallStack, CallocPtr a) => Int -> Ptr a -> IO (Ptr a)
    copyBytes Int
    4 (Ptr FloatIEEE754 -> IO (Ptr FloatIEEE754))
    -> (Ptr FloatIEEE754 -> IO FloatIEEE754)
    -> Ptr FloatIEEE754
    -> IO FloatIEEE754
    forall (m :: * -> *) a b c.
    Monad m =>
    (a -> m b) -> (b -> m c) -> a -> m c
    >=> (ManagedPtr FloatIEEE754 -> FloatIEEE754)
    -> Ptr FloatIEEE754 -> IO FloatIEEE754
    forall a.
    (HasCallStack, BoxedPtr a) =>
    (ManagedPtr a -> a) -> Ptr a -> IO a
    B.ManagedPtr.wrapPtr ManagedPtr FloatIEEE754 -> FloatIEEE754
    FloatIEEE754)
        boxedPtrFree :: FloatIEEE754 -> IO ()
    boxedPtrFree = \FloatIEEE754
    x -> FloatIEEE754 -> (Ptr FloatIEEE754 -> IO ()) -> IO ()
    forall a c.
    (HasCallStack, ManagedPtrNewtype a) =>
    a -> (Ptr a -> IO c) -> IO c
    SP.withManagedPtr FloatIEEE754
    x Ptr FloatIEEE754 -> IO ()
    forall a. Ptr a -> IO ()
    SP.freeMem
    instance CallocPtr FloatIEEE754 where
        boxedPtrCalloc :: IO (Ptr FloatIEEE754)
    boxedPtrCalloc = Int -> IO (Ptr FloatIEEE754)
    forall a. Int -> IO (Ptr a)
    callocBytes Int
    4

    -- | Construct a `FloatIEEE754` struct initialized to zero.
    newZeroFloatIEEE754 :: MonadIO m => m FloatIEEE754
    newZeroFloatIEEE754 :: forall (m :: * -> *). MonadIO m => m FloatIEEE754
    newZeroFloatIEEE754 = IO FloatIEEE754 -> m FloatIEEE754
    forall a. IO a -> m a
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO FloatIEEE754 -> m FloatIEEE754)
    -> IO FloatIEEE754 -> m FloatIEEE754
    forall a b. (a -> b) -> a -> b
    $ IO (Ptr FloatIEEE754)
    forall a. CallocPtr a => IO (Ptr a)
    boxedPtrCalloc IO (Ptr FloatIEEE754)
    -> (Ptr FloatIEEE754 -> IO FloatIEEE754) -> IO FloatIEEE754
    forall a b. IO a -> (a -> IO b) -> IO b
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= (ManagedPtr FloatIEEE754 -> FloatIEEE754)
    -> Ptr FloatIEEE754 -> IO FloatIEEE754
    forall a.
    (HasCallStack, BoxedPtr a) =>
    (ManagedPtr a -> a) -> Ptr a -> IO a
    wrapPtr ManagedPtr FloatIEEE754 -> FloatIEEE754
    FloatIEEE754

    instance tag ~ 'AttrSet => Constructible FloatIEEE754 tag where
        new :: forall (m :: * -> *).
    MonadIO m =>
    (ManagedPtr FloatIEEE754 -> FloatIEEE754)
    -> [AttrOp FloatIEEE754 tag] -> m FloatIEEE754
    new ManagedPtr FloatIEEE754 -> FloatIEEE754
    _ [AttrOp FloatIEEE754 tag]
    attrs = do
            FloatIEEE754
    o <- m FloatIEEE754
    forall (m :: * -> *). MonadIO m => m FloatIEEE754
    newZeroFloatIEEE754
            FloatIEEE754 -> [AttrOp FloatIEEE754 'AttrSet] -> m ()
    forall o (m :: * -> *).
    MonadIO m =>
    o -> [AttrOp o 'AttrSet] -> m ()
    GI.Attributes.set FloatIEEE754
    o [AttrOp FloatIEEE754 tag]
    [AttrOp FloatIEEE754 'AttrSet]
    attrs
            FloatIEEE754 -> m FloatIEEE754
    forall a. a -> m a
    forall (m :: * -> *) a. Monad m => a -> m a
    return FloatIEEE754
    o

    -- | Get the value of the “@v_float@” field.
    -- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
    --
    -- @
    -- 'Data.GI.Base.Attributes.get' floatIEEE754 #vFloat
    -- @
    getFloatIEEE754VFloat :: MonadIO m => FloatIEEE754 -> m Float
    getFloatIEEE754VFloat :: forall (m :: * -> *). MonadIO m => FloatIEEE754 -> m Float
    getFloatIEEE754VFloat FloatIEEE754
    s = IO Float -> m Float
    forall a. IO a -> m a
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO Float -> m Float) -> IO Float -> m Float
    forall a b. (a -> b) -> a -> b
    $ FloatIEEE754 -> (Ptr FloatIEEE754 -> IO Float) -> IO Float
    forall a c.
    (HasCallStack, ManagedPtrNewtype a) =>
    a -> (Ptr a -> IO c) -> IO c
    withManagedPtr FloatIEEE754
    s ((Ptr FloatIEEE754 -> IO Float) -> IO Float)
    -> (Ptr FloatIEEE754 -> IO Float) -> IO Float
    forall a b. (a -> b) -> a -> b
    $ \Ptr FloatIEEE754
    ptr -> do
        CFloat
    val <- Ptr CFloat -> IO CFloat
    forall a. Storable a => Ptr a -> IO a
    peek (Ptr FloatIEEE754
    ptr Ptr FloatIEEE754 -> Int -> Ptr CFloat
    forall a b. Ptr a -> Int -> Ptr b
    `plusPtr` Int
    65535) :: IO CFloat
        let val' :: Float
    val' = CFloat -> Float
    forall a b. (Real a, Fractional b) => a -> b
    realToFrac CFloat
    val
        Float -> IO Float
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return Float
    val'

    -- | Set the value of the “@v_float@” field.
    -- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
    --
    -- @
    -- 'Data.GI.Base.Attributes.set' floatIEEE754 [ #vFloat 'Data.GI.Base.Attributes.:=' value ]
    -- @
    setFloatIEEE754VFloat :: MonadIO m => FloatIEEE754 -> Float -> m ()
    setFloatIEEE754VFloat :: forall (m :: * -> *). MonadIO m => FloatIEEE754 -> Float -> m ()
    setFloatIEEE754VFloat FloatIEEE754
    s Float
    val = IO () -> m ()
    forall a. IO a -> m a
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO () -> m ()) -> IO () -> m ()
    forall a b. (a -> b) -> a -> b
    $ FloatIEEE754 -> (Ptr FloatIEEE754 -> IO ()) -> IO ()
    forall a c.
    (HasCallStack, ManagedPtrNewtype a) =>
    a -> (Ptr a -> IO c) -> IO c
    withManagedPtr FloatIEEE754
    s ((Ptr FloatIEEE754 -> IO ()) -> IO ())
    -> (Ptr FloatIEEE754 -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ \Ptr FloatIEEE754
    ptr -> do
        let val' :: CFloat
    val' = Float -> CFloat
    forall a b. (Real a, Fractional b) => a -> b
    realToFrac Float
    val
        Ptr CFloat -> CFloat -> IO ()
    forall a. Storable a => Ptr a -> a -> IO ()
    poke (Ptr FloatIEEE754
    ptr Ptr FloatIEEE754 -> Int -> Ptr CFloat
    forall a b. Ptr a -> Int -> Ptr b
    `plusPtr` Int
    65535) (CFloat
    val' :: CFloat)

    #if defined(ENABLE_OVERLOADING)
    data FloatIEEE754VFloatFieldInfo
    instance AttrInfo FloatIEEE754VFloatFieldInfo where
        type AttrBaseTypeConstraint FloatIEEE754VFloatFieldInfo = (~) FloatIEEE754
        type AttrAllowedOps FloatIEEE754VFloatFieldInfo = '[ 'AttrSet, 'AttrGet]
        type AttrSetTypeConstraint FloatIEEE754VFloatFieldInfo = (~) Float
        type AttrTransferTypeConstraint FloatIEEE754VFloatFieldInfo = (~)Float
        type AttrTransferType FloatIEEE754VFloatFieldInfo = Float
        type AttrGetType FloatIEEE754VFloatFieldInfo = Float
        type AttrLabel FloatIEEE754VFloatFieldInfo = "v_float"
        type AttrOrigin FloatIEEE754VFloatFieldInfo = FloatIEEE754
        attrGet = getFloatIEEE754VFloat
        attrSet = setFloatIEEE754VFloat
        attrConstruct = undefined
        attrClear = undefined
        attrTransfer _ v = do
            return v
        dbgAttrInfo = P.Just (O.ResolvedSymbolInfo {
            O.resolvedSymbolName = "GI.GLib.Unions.FloatIEEE754.vFloat"
            , O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.30/docs/GI-GLib-Unions-FloatIEEE754.html#g:attr:vFloat"
            })

    floatIEEE754_vFloat :: AttrLabelProxy "vFloat"
    floatIEEE754_vFloat = AttrLabelProxy

    #endif

    #if defined(ENABLE_OVERLOADING)
    instance O.HasAttributeList FloatIEEE754
    type instance O.AttributeList FloatIEEE754 = FloatIEEE754AttributeList
    type FloatIEEE754AttributeList = ('[ '("vFloat", FloatIEEE754VFloatFieldInfo)] :: [(Symbol, DK.Type)])
    #endif

    #if defined(ENABLE_OVERLOADING)
    type family ResolveFloatIEEE754Method (t :: Symbol) (o :: DK.Type) :: DK.Type where
        ResolveFloatIEEE754Method l o = O.MethodResolutionFailed l o

    instance (info ~ ResolveFloatIEEE754Method t FloatIEEE754, O.OverloadedMethod info FloatIEEE754 p) => OL.IsLabel t (FloatIEEE754 -> p) where
    #if MIN_VERSION_base(4,10,0)
        fromLabel = O.overloadedMethod @info
    #else
        fromLabel _ = O.overloadedMethod @info
    #endif

    #if MIN_VERSION_base(4,13,0)
    instance (info ~ ResolveFloatIEEE754Method t FloatIEEE754, O.OverloadedMethod info FloatIEEE754 p, R.HasField t FloatIEEE754 p) => R.HasField t FloatIEEE754 p where
        getField = O.overloadedMethod @info

    #endif

    instance (info ~ ResolveFloatIEEE754Method t FloatIEEE754, O.OverloadedMethodInfo info FloatIEEE754) => OL.IsLabel t (O.MethodProxy info FloatIEEE754) where
    #if MIN_VERSION_base(4,10,0)
        fromLabel = O.MethodProxy
    #else
        fromLabel _ = O.MethodProxy
    #endif

    #endif