    {-# LANGUAGE TypeApplications #-}

    -- | Copyright  : Will Thompson and Iñaki García Etxebarria
    -- License    : LGPL-2.1
    -- Maintainer : Iñaki García Etxebarria
    --
    -- A constant value in a @GtkExpression@.

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

    module GI.Gtk.Objects.ConstantExpression
        (

    -- * Exported types
        ConstantExpression(..)                  ,
        IsConstantExpression                    ,
        toConstantExpression                    ,

     -- * Methods
    -- |
    --
    --  === __Click to display all available methods, including inherited ones__
    -- ==== Methods
    -- [bind]("GI.Gtk.Objects.Expression#g:method:bind"), [evaluate]("GI.Gtk.Objects.Expression#g:method:evaluate"), [isStatic]("GI.Gtk.Objects.Expression#g:method:isStatic"), [ref]("GI.Gtk.Objects.Expression#g:method:ref"), [unref]("GI.Gtk.Objects.Expression#g:method:unref"), [watch]("GI.Gtk.Objects.Expression#g:method:watch").
    --
    -- ==== Getters
    -- [getValue]("GI.Gtk.Objects.ConstantExpression#g:method:getValue"), [getValueType]("GI.Gtk.Objects.Expression#g:method:getValueType").
    --
    -- ==== Setters
    -- /None/.

    #if defined(ENABLE_OVERLOADING)
        ResolveConstantExpressionMethod         ,
    #endif

    -- ** getValue #method:getValue#

    #if defined(ENABLE_OVERLOADING)
        ConstantExpressionGetValueMethodInfo    ,
    #endif
        constantExpressionGetValue              ,

    -- ** newForValue #method:newForValue#

        constantExpressionNewForValue           ,

        ) 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)
    import qualified GI.GLib.Callbacks as GLib.Callbacks
    import qualified GI.GObject.Objects.Object as GObject.Object
    import qualified GI.Gtk.Callbacks as Gtk.Callbacks
    import {-# SOURCE #-} qualified GI.Gtk.Objects.Expression as Gtk.Expression
    import {-# SOURCE #-} qualified GI.Gtk.Structs.ExpressionWatch as Gtk.ExpressionWatch

    #else
    import {-# SOURCE #-} qualified GI.Gtk.Objects.Expression as Gtk.Expression

    #endif

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

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

    foreign import ccall "gtk_constant_expression_get_type"
        c_gtk_constant_expression_get_type :: IO B.Types.GType

    instance B.Types.TypedObject ConstantExpression where
        glibType :: IO GType
    glibType = IO GType
    c_gtk_constant_expression_get_type

    -- | Type class for types which can be safely cast to t'ConstantExpression', for instance with `toConstantExpression`.
    class (SP.BoxedPtr o, SP.TypedObject o, O.IsDescendantOf ConstantExpression o) => IsConstantExpression o
    instance (SP.BoxedPtr o, SP.TypedObject o, O.IsDescendantOf ConstantExpression o) => IsConstantExpression o

    instance O.HasParentTypes ConstantExpression
    type instance O.ParentTypes ConstantExpression = '[Gtk.Expression.Expression]

    -- | Cast to t'ConstantExpression', for types for which this is known to be safe. For general casts, use 'Data.GI.Base.ManagedPtr.castTo'.
    toConstantExpression :: (MIO.MonadIO m, IsConstantExpression o) => o -> m ConstantExpression
    toConstantExpression :: forall (m :: * -> *) o.
    (MonadIO m, IsConstantExpression o) =>
    o -> m ConstantExpression
    toConstantExpression = IO ConstantExpression -> m ConstantExpression
    forall a. IO a -> m a
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    MIO.liftIO (IO ConstantExpression -> m ConstantExpression)
    -> (o -> IO ConstantExpression) -> o -> m ConstantExpression
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (ManagedPtr ConstantExpression -> ConstantExpression)
    -> o -> IO ConstantExpression
    forall o o'.
    (HasCallStack, ManagedPtrNewtype o, TypedObject o,
     ManagedPtrNewtype o', TypedObject o') =>
    (ManagedPtr o' -> o') -> o -> IO o'
    B.ManagedPtr.unsafeCastTo ManagedPtr ConstantExpression -> ConstantExpression
    ConstantExpression

    --- XXX Missing getter and/or setter, so no GValue instance could be generated.
    #if defined(ENABLE_OVERLOADING)
    type family ResolveConstantExpressionMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
        ResolveConstantExpressionMethod "bind" o = Gtk.Expression.ExpressionBindMethodInfo
        ResolveConstantExpressionMethod "evaluate" o = Gtk.Expression.ExpressionEvaluateMethodInfo
        ResolveConstantExpressionMethod "isStatic" o = Gtk.Expression.ExpressionIsStaticMethodInfo
        ResolveConstantExpressionMethod "ref" o = Gtk.Expression.ExpressionRefMethodInfo
        ResolveConstantExpressionMethod "unref" o = Gtk.Expression.ExpressionUnrefMethodInfo
        ResolveConstantExpressionMethod "watch" o = Gtk.Expression.ExpressionWatchMethodInfo
        ResolveConstantExpressionMethod "getValue" o = ConstantExpressionGetValueMethodInfo
        ResolveConstantExpressionMethod "getValueType" o = Gtk.Expression.ExpressionGetValueTypeMethodInfo
        ResolveConstantExpressionMethod l o = O.MethodResolutionFailed l o

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

    #endif

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

    #endif

    -- XXX Wrapping a foreign struct/union with no known destructor or size, leak?
    instance BoxedPtr ConstantExpression where
        boxedPtrCopy :: ConstantExpression -> IO ConstantExpression
    boxedPtrCopy = ConstantExpression -> IO ConstantExpression
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return
        boxedPtrFree :: ConstantExpression -> IO ()
    boxedPtrFree = \ConstantExpression
    _x -> () -> IO ()
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    -- method ConstantExpression::new_for_value
    -- method type : Constructor
    -- Args: [ Arg
    --           { argCName = "value"
    --           , argType = TGValue
    --           , argCType = Just "const GValue*"
    --           , direction = DirectionIn
    --           , mayBeNull = False
    --           , argDoc =
    --               Documentation
    --                 { rawDocText = Just "a `GValue`" , sinceVersion = Nothing }
    --           , argScope = ScopeTypeInvalid
    --           , argClosure = -1
    --           , argDestroy = -1
    --           , argCallerAllocates = False
    --           , argCallbackUserData = False
    --           , transfer = TransferNothing
    --           }
    --       ]
    -- Lengths: []
    -- returnType: Just
    --               (TInterface
    --                  Name { namespace = "Gtk" , name = "ConstantExpression" })
    -- throws : False
    -- Skip return : False

    foreign import ccall "gtk_constant_expression_new_for_value" gtk_constant_expression_new_for_value ::
        Ptr GValue ->                           -- value : TGValue
        IO (Ptr ConstantExpression)

    -- | Creates an expression that always evaluates to the given @value@.
    constantExpressionNewForValue ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        GValue
        -- ^ /@value@/: a @GValue@
        -> m ConstantExpression
        -- ^ __Returns:__ a new @GtkExpression@
    constantExpressionNewForValue :: forall (m :: * -> *).
    (HasCallStack, MonadIO m) =>
    GValue -> m ConstantExpression
    constantExpressionNewForValue GValue
    value = IO ConstantExpression -> m ConstantExpression
    forall a. IO a -> m a
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO ConstantExpression -> m ConstantExpression)
    -> IO ConstantExpression -> m ConstantExpression
    forall a b. (a -> b) -> a -> b
    $ do
        value' <- GValue -> IO (Ptr GValue)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr GValue
    value
        result <- gtk_constant_expression_new_for_value value'
        checkUnexpectedReturnNULL "constantExpressionNewForValue" result
        result' <- (wrapPtr ConstantExpression) result
        touchManagedPtr value
        return result'

    #if defined(ENABLE_OVERLOADING)
    #endif

    -- method ConstantExpression::get_value
    -- method type : OrdinaryMethod
    -- Args: [ Arg
    --           { argCName = "expression"
    --           , argType =
    --               TInterface Name { namespace = "Gtk" , name = "ConstantExpression" }
    --           , argCType = Just "GtkExpression*"
    --           , direction = DirectionIn
    --           , mayBeNull = False
    --           , argDoc =
    --               Documentation
    --                 { rawDocText = Just "a constant `GtkExpression`"
    --                 , sinceVersion = Nothing
    --                 }
    --           , argScope = ScopeTypeInvalid
    --           , argClosure = -1
    --           , argDestroy = -1
    --           , argCallerAllocates = False
    --           , argCallbackUserData = False
    --           , transfer = TransferNothing
    --           }
    --       ]
    -- Lengths: []
    -- returnType: Just TGValue
    -- throws : False
    -- Skip return : False

    foreign import ccall "gtk_constant_expression_get_value" gtk_constant_expression_get_value ::
        Ptr ConstantExpression ->               -- expression : TInterface (Name {namespace = "Gtk", name = "ConstantExpression"})
        IO (Ptr GValue)

    -- | Gets the value that a constant expression evaluates to.
    constantExpressionGetValue ::
        (B.CallStack.HasCallStack, MonadIO m, IsConstantExpression a) =>
        a
        -- ^ /@expression@/: a constant @GtkExpression@
        -> m GValue
        -- ^ __Returns:__ the value
    constantExpressionGetValue :: forall (m :: * -> *) a.
    (HasCallStack, MonadIO m, IsConstantExpression a) =>
    a -> m GValue
    constantExpressionGetValue a
    expression = IO GValue -> m GValue
    forall a. IO a -> m a
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO GValue -> m GValue) -> IO GValue -> m GValue
    forall a b. (a -> b) -> a -> b
    $ do
        expression' <- a -> IO (Ptr ConstantExpression)
    forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
    unsafeManagedPtrCastPtr a
    expression
        result <- gtk_constant_expression_get_value expression'
        checkUnexpectedReturnNULL "constantExpressionGetValue" result
        result' <- B.GValue.newGValueFromPtr result
        touchManagedPtr expression
        return result'

    #if defined(ENABLE_OVERLOADING)
    data ConstantExpressionGetValueMethodInfo
    instance (signature ~ (m GValue), MonadIO m, IsConstantExpression a) => O.OverloadedMethod ConstantExpressionGetValueMethodInfo a signature where
        overloadedMethod = constantExpressionGetValue

    instance O.OverloadedMethodInfo ConstantExpressionGetValueMethodInfo a where
        overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
            O.resolvedSymbolName = "GI.Gtk.Objects.ConstantExpression.constantExpressionGetValue",
            O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gtk4-4.0.12/docs/GI-Gtk-Objects-ConstantExpression.html#v:constantExpressionGetValue"
            })

    #endif