    {-# LANGUAGE TypeApplications #-}

    -- | Copyright  : Will Thompson and Iñaki García Etxebarria
    -- License    : LGPL-2.1
    -- Maintainer : Iñaki García Etxebarria
    --
    -- An opaque type which identifies a specific node in a t'GI.GLib.Structs.Tree.Tree'.
    --
    -- /Since: 2.68/

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

    module GI.GLib.Structs.TreeNode
        (

    -- * Exported types
        TreeNode(..)                            ,

     -- * Methods
    -- |
    --
    --  === __Click to display all available methods, including inherited ones__
    -- ==== Methods
    -- [key]("GI.GLib.Structs.TreeNode#g:method:key"), [next]("GI.GLib.Structs.TreeNode#g:method:next"), [previous]("GI.GLib.Structs.TreeNode#g:method:previous"), [value]("GI.GLib.Structs.TreeNode#g:method:value").
    --
    -- ==== Getters
    -- /None/.
    --
    -- ==== Setters
    -- /None/.

    #if defined(ENABLE_OVERLOADING)
        ResolveTreeNodeMethod                   ,
    #endif

    -- ** key #method:key#

    #if defined(ENABLE_OVERLOADING)
        TreeNodeKeyMethodInfo                   ,
    #endif
        treeNodeKey                             ,

    -- ** next #method:next#

    #if defined(ENABLE_OVERLOADING)
        TreeNodeNextMethodInfo                  ,
    #endif
        treeNodeNext                            ,

    -- ** previous #method:previous#

    #if defined(ENABLE_OVERLOADING)
        TreeNodePreviousMethodInfo              ,
    #endif
        treeNodePrevious                        ,

    -- ** value #method:value#

    #if defined(ENABLE_OVERLOADING)
        TreeNodeValueMethodInfo                 ,
    #endif
        treeNodeValue                           ,

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

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

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

    #if defined(ENABLE_OVERLOADING)
    instance O.HasAttributeList TreeNode
    type instance O.AttributeList TreeNode = TreeNodeAttributeList
    type TreeNodeAttributeList = ('[ ] :: [(Symbol, DK.Type)])
    #endif

    -- method TreeNode::key
    -- method type : OrdinaryMethod
    -- Args: [ Arg
    --           { argCName = "node"
    --           , argType =
    --               TInterface Name { namespace = "GLib" , name = "TreeNode" }
    --           , direction = DirectionIn
    --           , mayBeNull = False
    --           , argDoc =
    --               Documentation
    --                 { rawDocText = Just "a #GTree node" , sinceVersion = Nothing }
    --           , argScope = ScopeTypeInvalid
    --           , argClosure = -1
    --           , argDestroy = -1
    --           , argCallerAllocates = False
    --           , argCallbackUserData = False
    --           , transfer = TransferNothing
    --           }
    --       ]
    -- Lengths: []
    -- returnType: Just (TBasicType TPtr)
    -- throws : False
    -- Skip return : False

    foreign import ccall "g_tree_node_key" g_tree_node_key ::
        Ptr TreeNode ->                         -- node : TInterface (Name {namespace = "GLib", name = "TreeNode"})
        IO (Ptr ())

    -- | Gets the key stored at a particular tree node.
    --
    -- /Since: 2.68/
    treeNodeKey ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        TreeNode
        -- ^ /@node@/: a t'GI.GLib.Structs.Tree.Tree' node
        -> m (Ptr ())
        -- ^ __Returns:__ the key at the node.
    treeNodeKey :: forall (m :: * -> *).
    (HasCallStack, MonadIO m) =>
    TreeNode -> m (Ptr ())
    treeNodeKey TreeNode
    node = IO (Ptr ()) -> m (Ptr ())
    forall a. IO a -> m a
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO (Ptr ()) -> m (Ptr ())) -> IO (Ptr ()) -> m (Ptr ())
    forall a b. (a -> b) -> a -> b
    $ do
        Ptr TreeNode
    node' <- TreeNode -> IO (Ptr TreeNode)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr TreeNode
    node
        Ptr ()
    result <- Ptr TreeNode -> IO (Ptr ())
    g_tree_node_key Ptr TreeNode
    node'
        TreeNode -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr TreeNode
    node
        Ptr () -> IO (Ptr ())
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return Ptr ()
    result

    #if defined(ENABLE_OVERLOADING)
    data TreeNodeKeyMethodInfo
    instance (signature ~ (m (Ptr ())), MonadIO m) => O.OverloadedMethod TreeNodeKeyMethodInfo TreeNode signature where
        overloadedMethod = treeNodeKey

    instance O.OverloadedMethodInfo TreeNodeKeyMethodInfo TreeNode where
        overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
            O.resolvedSymbolName = "GI.GLib.Structs.TreeNode.treeNodeKey",
            O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.30/docs/GI-GLib-Structs-TreeNode.html#v:treeNodeKey"
            })

    #endif

    -- method TreeNode::next
    -- method type : OrdinaryMethod
    -- Args: [ Arg
    --           { argCName = "node"
    --           , argType =
    --               TInterface Name { namespace = "GLib" , name = "TreeNode" }
    --           , direction = DirectionIn
    --           , mayBeNull = False
    --           , argDoc =
    --               Documentation
    --                 { rawDocText = Just "a #GTree node" , sinceVersion = Nothing }
    --           , argScope = ScopeTypeInvalid
    --           , argClosure = -1
    --           , argDestroy = -1
    --           , argCallerAllocates = False
    --           , argCallbackUserData = False
    --           , transfer = TransferNothing
    --           }
    --       ]
    -- Lengths: []
    -- returnType: Just (TInterface Name { namespace = "GLib" , name = "TreeNode" })
    -- throws : False
    -- Skip return : False

    foreign import ccall "g_tree_node_next" g_tree_node_next ::
        Ptr TreeNode ->                         -- node : TInterface (Name {namespace = "GLib", name = "TreeNode"})
        IO (Ptr TreeNode)

    -- | Returns the next in-order node of the tree, or 'P.Nothing'
    -- if the passed node was already the last one.
    --
    -- /Since: 2.68/
    treeNodeNext ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        TreeNode
        -- ^ /@node@/: a t'GI.GLib.Structs.Tree.Tree' node
        -> m (Maybe TreeNode)
        -- ^ __Returns:__ the next node in the tree
    treeNodeNext :: forall (m :: * -> *).
    (HasCallStack, MonadIO m) =>
    TreeNode -> m (Maybe TreeNode)
    treeNodeNext TreeNode
    node = IO (Maybe TreeNode) -> m (Maybe TreeNode)
    forall a. IO a -> m a
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO (Maybe TreeNode) -> m (Maybe TreeNode))
    -> IO (Maybe TreeNode) -> m (Maybe TreeNode)
    forall a b. (a -> b) -> a -> b
    $ do
        Ptr TreeNode
    node' <- TreeNode -> IO (Ptr TreeNode)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr TreeNode
    node
        Ptr TreeNode
    result <- Ptr TreeNode -> IO (Ptr TreeNode)
    g_tree_node_next Ptr TreeNode
    node'
        Maybe TreeNode
    maybeResult <- Ptr TreeNode
    -> (Ptr TreeNode -> IO TreeNode) -> IO (Maybe TreeNode)
    forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
    convertIfNonNull Ptr TreeNode
    result ((Ptr TreeNode -> IO TreeNode) -> IO (Maybe TreeNode))
    -> (Ptr TreeNode -> IO TreeNode) -> IO (Maybe TreeNode)
    forall a b. (a -> b) -> a -> b
    $ \Ptr TreeNode
    result' -> do
            TreeNode
    result'' <- ((ManagedPtr TreeNode -> TreeNode) -> Ptr TreeNode -> IO TreeNode
    forall a.
    (HasCallStack, BoxedPtr a) =>
    (ManagedPtr a -> a) -> Ptr a -> IO a
    newPtr ManagedPtr TreeNode -> TreeNode
    TreeNode) Ptr TreeNode
    result'
            TreeNode -> IO TreeNode
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return TreeNode
    result''
        TreeNode -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr TreeNode
    node
        Maybe TreeNode -> IO (Maybe TreeNode)
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return Maybe TreeNode
    maybeResult

    #if defined(ENABLE_OVERLOADING)
    data TreeNodeNextMethodInfo
    instance (signature ~ (m (Maybe TreeNode)), MonadIO m) => O.OverloadedMethod TreeNodeNextMethodInfo TreeNode signature where
        overloadedMethod = treeNodeNext

    instance O.OverloadedMethodInfo TreeNodeNextMethodInfo TreeNode where
        overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
            O.resolvedSymbolName = "GI.GLib.Structs.TreeNode.treeNodeNext",
            O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.30/docs/GI-GLib-Structs-TreeNode.html#v:treeNodeNext"
            })

    #endif

    -- method TreeNode::previous
    -- method type : OrdinaryMethod
    -- Args: [ Arg
    --           { argCName = "node"
    --           , argType =
    --               TInterface Name { namespace = "GLib" , name = "TreeNode" }
    --           , direction = DirectionIn
    --           , mayBeNull = False
    --           , argDoc =
    --               Documentation
    --                 { rawDocText = Just "a #GTree node" , sinceVersion = Nothing }
    --           , argScope = ScopeTypeInvalid
    --           , argClosure = -1
    --           , argDestroy = -1
    --           , argCallerAllocates = False
    --           , argCallbackUserData = False
    --           , transfer = TransferNothing
    --           }
    --       ]
    -- Lengths: []
    -- returnType: Just (TInterface Name { namespace = "GLib" , name = "TreeNode" })
    -- throws : False
    -- Skip return : False

    foreign import ccall "g_tree_node_previous" g_tree_node_previous ::
        Ptr TreeNode ->                         -- node : TInterface (Name {namespace = "GLib", name = "TreeNode"})
        IO (Ptr TreeNode)

    -- | Returns the previous in-order node of the tree, or 'P.Nothing'
    -- if the passed node was already the first one.
    --
    -- /Since: 2.68/
    treeNodePrevious ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        TreeNode
        -- ^ /@node@/: a t'GI.GLib.Structs.Tree.Tree' node
        -> m (Maybe TreeNode)
        -- ^ __Returns:__ the previous node in the tree
    treeNodePrevious :: forall (m :: * -> *).
    (HasCallStack, MonadIO m) =>
    TreeNode -> m (Maybe TreeNode)
    treeNodePrevious TreeNode
    node = IO (Maybe TreeNode) -> m (Maybe TreeNode)
    forall a. IO a -> m a
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO (Maybe TreeNode) -> m (Maybe TreeNode))
    -> IO (Maybe TreeNode) -> m (Maybe TreeNode)
    forall a b. (a -> b) -> a -> b
    $ do
        Ptr TreeNode
    node' <- TreeNode -> IO (Ptr TreeNode)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr TreeNode
    node
        Ptr TreeNode
    result <- Ptr TreeNode -> IO (Ptr TreeNode)
    g_tree_node_previous Ptr TreeNode
    node'
        Maybe TreeNode
    maybeResult <- Ptr TreeNode
    -> (Ptr TreeNode -> IO TreeNode) -> IO (Maybe TreeNode)
    forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
    convertIfNonNull Ptr TreeNode
    result ((Ptr TreeNode -> IO TreeNode) -> IO (Maybe TreeNode))
    -> (Ptr TreeNode -> IO TreeNode) -> IO (Maybe TreeNode)
    forall a b. (a -> b) -> a -> b
    $ \Ptr TreeNode
    result' -> do
            TreeNode
    result'' <- ((ManagedPtr TreeNode -> TreeNode) -> Ptr TreeNode -> IO TreeNode
    forall a.
    (HasCallStack, BoxedPtr a) =>
    (ManagedPtr a -> a) -> Ptr a -> IO a
    newPtr ManagedPtr TreeNode -> TreeNode
    TreeNode) Ptr TreeNode
    result'
            TreeNode -> IO TreeNode
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return TreeNode
    result''
        TreeNode -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr TreeNode
    node
        Maybe TreeNode -> IO (Maybe TreeNode)
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return Maybe TreeNode
    maybeResult

    #if defined(ENABLE_OVERLOADING)
    data TreeNodePreviousMethodInfo
    instance (signature ~ (m (Maybe TreeNode)), MonadIO m) => O.OverloadedMethod TreeNodePreviousMethodInfo TreeNode signature where
        overloadedMethod = treeNodePrevious

    instance O.OverloadedMethodInfo TreeNodePreviousMethodInfo TreeNode where
        overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
            O.resolvedSymbolName = "GI.GLib.Structs.TreeNode.treeNodePrevious",
            O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.30/docs/GI-GLib-Structs-TreeNode.html#v:treeNodePrevious"
            })

    #endif

    -- method TreeNode::value
    -- method type : OrdinaryMethod
    -- Args: [ Arg
    --           { argCName = "node"
    --           , argType =
    --               TInterface Name { namespace = "GLib" , name = "TreeNode" }
    --           , direction = DirectionIn
    --           , mayBeNull = False
    --           , argDoc =
    --               Documentation
    --                 { rawDocText = Just "a #GTree node" , sinceVersion = Nothing }
    --           , argScope = ScopeTypeInvalid
    --           , argClosure = -1
    --           , argDestroy = -1
    --           , argCallerAllocates = False
    --           , argCallbackUserData = False
    --           , transfer = TransferNothing
    --           }
    --       ]
    -- Lengths: []
    -- returnType: Just (TBasicType TPtr)
    -- throws : False
    -- Skip return : False

    foreign import ccall "g_tree_node_value" g_tree_node_value ::
        Ptr TreeNode ->                         -- node : TInterface (Name {namespace = "GLib", name = "TreeNode"})
        IO (Ptr ())

    -- | Gets the value stored at a particular tree node.
    --
    -- /Since: 2.68/
    treeNodeValue ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        TreeNode
        -- ^ /@node@/: a t'GI.GLib.Structs.Tree.Tree' node
        -> m (Ptr ())
        -- ^ __Returns:__ the value at the node.
    treeNodeValue :: forall (m :: * -> *).
    (HasCallStack, MonadIO m) =>
    TreeNode -> m (Ptr ())
    treeNodeValue TreeNode
    node = IO (Ptr ()) -> m (Ptr ())
    forall a. IO a -> m a
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO (Ptr ()) -> m (Ptr ())) -> IO (Ptr ()) -> m (Ptr ())
    forall a b. (a -> b) -> a -> b
    $ do
        Ptr TreeNode
    node' <- TreeNode -> IO (Ptr TreeNode)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr TreeNode
    node
        Ptr ()
    result <- Ptr TreeNode -> IO (Ptr ())
    g_tree_node_value Ptr TreeNode
    node'
        TreeNode -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr TreeNode
    node
        Ptr () -> IO (Ptr ())
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return Ptr ()
    result

    #if defined(ENABLE_OVERLOADING)
    data TreeNodeValueMethodInfo
    instance (signature ~ (m (Ptr ())), MonadIO m) => O.OverloadedMethod TreeNodeValueMethodInfo TreeNode signature where
        overloadedMethod = treeNodeValue

    instance O.OverloadedMethodInfo TreeNodeValueMethodInfo TreeNode where
        overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
            O.resolvedSymbolName = "GI.GLib.Structs.TreeNode.treeNodeValue",
            O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.30/docs/GI-GLib-Structs-TreeNode.html#v:treeNodeValue"
            })

    #endif

    #if defined(ENABLE_OVERLOADING)
    type family ResolveTreeNodeMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
        ResolveTreeNodeMethod "key" o = TreeNodeKeyMethodInfo
        ResolveTreeNodeMethod "next" o = TreeNodeNextMethodInfo
        ResolveTreeNodeMethod "previous" o = TreeNodePreviousMethodInfo
        ResolveTreeNodeMethod "value" o = TreeNodeValueMethodInfo
        ResolveTreeNodeMethod l o = O.MethodResolutionFailed l o

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

    #endif

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

    #endif