    {-# 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.DoubleIEEE754
        (

    -- * Exported types
        DoubleIEEE754(..)                       ,
        newZeroDoubleIEEE754                    ,

     -- * Methods

    #if defined(ENABLE_OVERLOADING)
        ResolveDoubleIEEE754Method              ,
    #endif

     -- * Properties

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

    #if defined(ENABLE_OVERLOADING)
        doubleIEEE754_vDouble                   ,
    #endif
        getDoubleIEEE754VDouble                 ,
        setDoubleIEEE754VDouble                 ,

        ) 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 DoubleIEEE754 = DoubleIEEE754 (SP.ManagedPtr DoubleIEEE754)
        deriving (DoubleIEEE754 -> DoubleIEEE754 -> Bool
    (DoubleIEEE754 -> DoubleIEEE754 -> Bool)
    -> (DoubleIEEE754 -> DoubleIEEE754 -> Bool) -> Eq DoubleIEEE754
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: DoubleIEEE754 -> DoubleIEEE754 -> Bool
    == :: DoubleIEEE754 -> DoubleIEEE754 -> Bool
    $c/= :: DoubleIEEE754 -> DoubleIEEE754 -> Bool
    /= :: DoubleIEEE754 -> DoubleIEEE754 -> Bool
    Eq)

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

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

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

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

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

    -- | Set the value of the “@v_double@” field.
    -- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
    --
    -- @
    -- 'Data.GI.Base.Attributes.set' doubleIEEE754 [ #vDouble 'Data.GI.Base.Attributes.:=' value ]
    -- @
    setDoubleIEEE754VDouble :: MonadIO m => DoubleIEEE754 -> Double -> m ()
    setDoubleIEEE754VDouble :: forall (m :: * -> *). MonadIO m => DoubleIEEE754 -> Double -> m ()
    setDoubleIEEE754VDouble DoubleIEEE754
    s Double
    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
    $ DoubleIEEE754 -> (Ptr DoubleIEEE754 -> IO ()) -> IO ()
    forall a c.
    (HasCallStack, ManagedPtrNewtype a) =>
    a -> (Ptr a -> IO c) -> IO c
    withManagedPtr DoubleIEEE754
    s ((Ptr DoubleIEEE754 -> IO ()) -> IO ())
    -> (Ptr DoubleIEEE754 -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ \Ptr DoubleIEEE754
    ptr -> do
        let val' :: CDouble
    val' = Double -> CDouble
    forall a b. (Real a, Fractional b) => a -> b
    realToFrac Double
    val
        Ptr CDouble -> CDouble -> IO ()
    forall a. Storable a => Ptr a -> a -> IO ()
    poke (Ptr DoubleIEEE754
    ptr Ptr DoubleIEEE754 -> Int -> Ptr CDouble
    forall a b. Ptr a -> Int -> Ptr b
    `plusPtr` Int
    65535) (CDouble
    val' :: CDouble)

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

    doubleIEEE754_vDouble :: AttrLabelProxy "vDouble"
    doubleIEEE754_vDouble = AttrLabelProxy

    #endif

    #if defined(ENABLE_OVERLOADING)
    instance O.HasAttributeList DoubleIEEE754
    type instance O.AttributeList DoubleIEEE754 = DoubleIEEE754AttributeList
    type DoubleIEEE754AttributeList = ('[ '("vDouble", DoubleIEEE754VDoubleFieldInfo)] :: [(Symbol, DK.Type)])
    #endif

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

    instance (info ~ ResolveDoubleIEEE754Method t DoubleIEEE754, O.OverloadedMethod info DoubleIEEE754 p) => OL.IsLabel t (DoubleIEEE754 -> 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 ~ ResolveDoubleIEEE754Method t DoubleIEEE754, O.OverloadedMethod info DoubleIEEE754 p, R.HasField t DoubleIEEE754 p) => R.HasField t DoubleIEEE754 p where
        getField = O.overloadedMethod @info

    #endif

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

    #endif