    {-# LANGUAGE TypeApplications #-}

    -- | Copyright  : Will Thompson and Iñaki García Etxebarria
    -- License    : LGPL-2.1
    -- Maintainer : Iñaki García Etxebarria
    --
    -- A utility type for constructing container-type t'GVariant' instances.
    --
    -- This is an opaque structure and may only be accessed using the
    -- following functions.
    --
    -- t'GI.GLib.Structs.VariantBuilder.VariantBuilder' is not threadsafe in any way.  Do not attempt to
    -- access it from more than one thread.

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

    module GI.GLib.Structs.VariantBuilder
        (

    -- * Exported types
        VariantBuilder(..)                      ,

     -- * Methods
    -- |
    --
    --  === __Click to display all available methods, including inherited ones__
    -- ==== Methods
    -- [addValue]("GI.GLib.Structs.VariantBuilder#g:method:addValue"), [close]("GI.GLib.Structs.VariantBuilder#g:method:close"), [end]("GI.GLib.Structs.VariantBuilder#g:method:end"), [open]("GI.GLib.Structs.VariantBuilder#g:method:open"), [ref]("GI.GLib.Structs.VariantBuilder#g:method:ref"), [unref]("GI.GLib.Structs.VariantBuilder#g:method:unref").
    --
    -- ==== Getters
    -- /None/.
    --
    -- ==== Setters
    -- /None/.

    #if defined(ENABLE_OVERLOADING)
        ResolveVariantBuilderMethod             ,
    #endif

    -- ** addValue #method:addValue#

    #if defined(ENABLE_OVERLOADING)
        VariantBuilderAddValueMethodInfo        ,
    #endif
        variantBuilderAddValue                  ,

    -- ** close #method:close#

    #if defined(ENABLE_OVERLOADING)
        VariantBuilderCloseMethodInfo           ,
    #endif
        variantBuilderClose                     ,

    -- ** end #method:end#

    #if defined(ENABLE_OVERLOADING)
        VariantBuilderEndMethodInfo             ,
    #endif
        variantBuilderEnd                       ,

    -- ** new #method:new#

        variantBuilderNew                       ,

    -- ** open #method:open#

    #if defined(ENABLE_OVERLOADING)
        VariantBuilderOpenMethodInfo            ,
    #endif
        variantBuilderOpen                      ,

    -- ** ref #method:ref#

    #if defined(ENABLE_OVERLOADING)
        VariantBuilderRefMethodInfo             ,
    #endif
        variantBuilderRef                       ,

    -- ** unref #method:unref#

    #if defined(ENABLE_OVERLOADING)
        VariantBuilderUnrefMethodInfo           ,
    #endif
        variantBuilderUnref                     ,

        ) 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 {-# SOURCE #-} qualified GI.GLib.Structs.VariantType as GLib.VariantType

    #else
    import {-# SOURCE #-} qualified GI.GLib.Structs.VariantType as GLib.VariantType

    #endif

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

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

    foreign import ccall "g_variant_builder_get_type" c_g_variant_builder_get_type ::
        IO GType

    type instance O.ParentTypes VariantBuilder = '[]
    instance O.HasParentTypes VariantBuilder

    instance B.Types.TypedObject VariantBuilder where
        glibType :: IO GType
    glibType = IO GType
    c_g_variant_builder_get_type

    instance B.Types.GBoxed VariantBuilder

    -- | Convert 'VariantBuilder' to and from 'Data.GI.Base.GValue.GValue'. See 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'.
    instance B.GValue.IsGValue (Maybe VariantBuilder) where
        gvalueGType_ :: IO GType
    gvalueGType_ = IO GType
    c_g_variant_builder_get_type
        gvalueSet_ :: Ptr GValue -> Maybe VariantBuilder -> IO ()
    gvalueSet_ Ptr GValue
    gv Maybe VariantBuilder
    P.Nothing = Ptr GValue -> Ptr VariantBuilder -> IO ()
    forall a. Ptr GValue -> Ptr a -> IO ()
    B.GValue.set_boxed Ptr GValue
    gv (Ptr VariantBuilder
    forall a. Ptr a
    FP.nullPtr :: FP.Ptr VariantBuilder)
        gvalueSet_ Ptr GValue
    gv (P.Just VariantBuilder
    obj) = VariantBuilder -> (Ptr VariantBuilder -> IO ()) -> IO ()
    forall a c.
    (HasCallStack, ManagedPtrNewtype a) =>
    a -> (Ptr a -> IO c) -> IO c
    B.ManagedPtr.withManagedPtr VariantBuilder
    obj (Ptr GValue -> Ptr VariantBuilder -> IO ()
    forall a. Ptr GValue -> Ptr a -> IO ()
    B.GValue.set_boxed Ptr GValue
    gv)
        gvalueGet_ :: Ptr GValue -> IO (Maybe VariantBuilder)
    gvalueGet_ Ptr GValue
    gv = do
            Ptr VariantBuilder
    ptr <- Ptr GValue -> IO (Ptr VariantBuilder)
    forall b. Ptr GValue -> IO (Ptr b)
    B.GValue.get_boxed Ptr GValue
    gv :: IO (Ptr VariantBuilder)
            if Ptr VariantBuilder
    ptr Ptr VariantBuilder -> Ptr VariantBuilder -> Bool
    forall a. Eq a => a -> a -> Bool
    /= Ptr VariantBuilder
    forall a. Ptr a
    FP.nullPtr
            then VariantBuilder -> Maybe VariantBuilder
    forall a. a -> Maybe a
    P.Just (VariantBuilder -> Maybe VariantBuilder)
    -> IO VariantBuilder -> IO (Maybe VariantBuilder)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (ManagedPtr VariantBuilder -> VariantBuilder)
    -> Ptr VariantBuilder -> IO VariantBuilder
    forall a.
    (HasCallStack, GBoxed a) =>
    (ManagedPtr a -> a) -> Ptr a -> IO a
    B.ManagedPtr.newBoxed ManagedPtr VariantBuilder -> VariantBuilder
    VariantBuilder Ptr VariantBuilder
    ptr
            else Maybe VariantBuilder -> IO (Maybe VariantBuilder)
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return Maybe VariantBuilder
    forall a. Maybe a
    P.Nothing

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

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

    foreign import ccall "g_variant_builder_new" g_variant_builder_new ::
        Ptr GLib.VariantType.VariantType ->     -- type : TInterface (Name {namespace = "GLib", name = "VariantType"})
        IO (Ptr VariantBuilder)

    -- | Allocates and initialises a new t'GI.GLib.Structs.VariantBuilder.VariantBuilder'.
    --
    -- You should call 'GI.GLib.Structs.VariantBuilder.variantBuilderUnref' on the return value when it
    -- is no longer needed.  The memory will not be automatically freed by
    -- any other call.
    --
    -- In most cases it is easier to place a t'GI.GLib.Structs.VariantBuilder.VariantBuilder' directly on
    -- the stack of the calling function and initialise it with
    -- @/g_variant_builder_init()/@.
    --
    -- /Since: 2.24/
    variantBuilderNew ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        GLib.VariantType.VariantType
        -- ^ /@type@/: a container type
        -> m VariantBuilder
        -- ^ __Returns:__ a t'GI.GLib.Structs.VariantBuilder.VariantBuilder'
    variantBuilderNew :: forall (m :: * -> *).
    (HasCallStack, MonadIO m) =>
    VariantType -> m VariantBuilder
    variantBuilderNew VariantType
    type_ = IO VariantBuilder -> m VariantBuilder
    forall a. IO a -> m a
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO VariantBuilder -> m VariantBuilder)
    -> IO VariantBuilder -> m VariantBuilder
    forall a b. (a -> b) -> a -> b
    $ do
        Ptr VariantType
    type_' <- VariantType -> IO (Ptr VariantType)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr VariantType
    type_
        Ptr VariantBuilder
    result <- Ptr VariantType -> IO (Ptr VariantBuilder)
    g_variant_builder_new Ptr VariantType
    type_'
        Text -> Ptr VariantBuilder -> IO ()
    forall a. HasCallStack => Text -> Ptr a -> IO ()
    checkUnexpectedReturnNULL Text
    "variantBuilderNew" Ptr VariantBuilder
    result
        VariantBuilder
    result' <- ((ManagedPtr VariantBuilder -> VariantBuilder)
    -> Ptr VariantBuilder -> IO VariantBuilder
    forall a.
    (HasCallStack, GBoxed a) =>
    (ManagedPtr a -> a) -> Ptr a -> IO a
    wrapBoxed ManagedPtr VariantBuilder -> VariantBuilder
    VariantBuilder) Ptr VariantBuilder
    result
        VariantType -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr VariantType
    type_
        VariantBuilder -> IO VariantBuilder
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return VariantBuilder
    result'

    #if defined(ENABLE_OVERLOADING)
    #endif

    -- method VariantBuilder::add_value
    -- method type : OrdinaryMethod
    -- Args: [ Arg
    --           { argCName = "builder"
    --           , argType =
    --               TInterface Name { namespace = "GLib" , name = "VariantBuilder" }
    --           , direction = DirectionIn
    --           , mayBeNull = False
    --           , argDoc =
    --               Documentation
    --                 { rawDocText = Just "a #GVariantBuilder" , sinceVersion = Nothing }
    --           , argScope = ScopeTypeInvalid
    --           , argClosure = -1
    --           , argDestroy = -1
    --           , argCallerAllocates = False
    --           , argCallbackUserData = False
    --           , transfer = TransferNothing
    --           }
    --       , Arg
    --           { argCName = "value"
    --           , argType = TVariant
    --           , direction = DirectionIn
    --           , mayBeNull = False
    --           , argDoc =
    --               Documentation
    --                 { rawDocText = Just "a #GVariant" , sinceVersion = Nothing }
    --           , argScope = ScopeTypeInvalid
    --           , argClosure = -1
    --           , argDestroy = -1
    --           , argCallerAllocates = False
    --           , argCallbackUserData = False
    --           , transfer = TransferNothing
    --           }
    --       ]
    -- Lengths: []
    -- returnType: Nothing
    -- throws : False
    -- Skip return : False

    foreign import ccall "g_variant_builder_add_value" g_variant_builder_add_value ::
        Ptr VariantBuilder ->                   -- builder : TInterface (Name {namespace = "GLib", name = "VariantBuilder"})
        Ptr GVariant ->                         -- value : TVariant
        IO ()

    -- | Adds /@value@/ to /@builder@/.
    --
    -- It is an error to call this function in any way that would create an
    -- inconsistent value to be constructed.  Some examples of this are
    -- putting different types of items into an array, putting the wrong
    -- types or number of items in a tuple, putting more than one value into
    -- a variant, etc.
    --
    -- If /@value@/ is a floating reference (see 'GI.GLib.Structs.Variant.variantRefSink'),
    -- the /@builder@/ instance takes ownership of /@value@/.
    --
    -- /Since: 2.24/
    variantBuilderAddValue ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        VariantBuilder
        -- ^ /@builder@/: a t'GI.GLib.Structs.VariantBuilder.VariantBuilder'
        -> GVariant
        -- ^ /@value@/: a t'GVariant'
        -> m ()
    variantBuilderAddValue :: forall (m :: * -> *).
    (HasCallStack, MonadIO m) =>
    VariantBuilder -> GVariant -> m ()
    variantBuilderAddValue VariantBuilder
    builder GVariant
    value = 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
    $ do
        Ptr VariantBuilder
    builder' <- VariantBuilder -> IO (Ptr VariantBuilder)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr VariantBuilder
    builder
        Ptr GVariant
    value' <- GVariant -> IO (Ptr GVariant)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr GVariant
    value
        Ptr VariantBuilder -> Ptr GVariant -> IO ()
    g_variant_builder_add_value Ptr VariantBuilder
    builder' Ptr GVariant
    value'
        VariantBuilder -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr VariantBuilder
    builder
        GVariant -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr GVariant
    value
        () -> IO ()
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    #if defined(ENABLE_OVERLOADING)
    data VariantBuilderAddValueMethodInfo
    instance (signature ~ (GVariant -> m ()), MonadIO m) => O.OverloadedMethod VariantBuilderAddValueMethodInfo VariantBuilder signature where
        overloadedMethod = variantBuilderAddValue

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

    #endif

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

    foreign import ccall "g_variant_builder_close" g_variant_builder_close ::
        Ptr VariantBuilder ->                   -- builder : TInterface (Name {namespace = "GLib", name = "VariantBuilder"})
        IO ()

    -- | Closes the subcontainer inside the given /@builder@/ that was opened by
    -- the most recent call to 'GI.GLib.Structs.VariantBuilder.variantBuilderOpen'.
    --
    -- It is an error to call this function in any way that would create an
    -- inconsistent value to be constructed (ie: too few values added to the
    -- subcontainer).
    --
    -- /Since: 2.24/
    variantBuilderClose ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        VariantBuilder
        -- ^ /@builder@/: a t'GI.GLib.Structs.VariantBuilder.VariantBuilder'
        -> m ()
    variantBuilderClose :: forall (m :: * -> *).
    (HasCallStack, MonadIO m) =>
    VariantBuilder -> m ()
    variantBuilderClose VariantBuilder
    builder = 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
    $ do
        Ptr VariantBuilder
    builder' <- VariantBuilder -> IO (Ptr VariantBuilder)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr VariantBuilder
    builder
        Ptr VariantBuilder -> IO ()
    g_variant_builder_close Ptr VariantBuilder
    builder'
        VariantBuilder -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr VariantBuilder
    builder
        () -> IO ()
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    #if defined(ENABLE_OVERLOADING)
    data VariantBuilderCloseMethodInfo
    instance (signature ~ (m ()), MonadIO m) => O.OverloadedMethod VariantBuilderCloseMethodInfo VariantBuilder signature where
        overloadedMethod = variantBuilderClose

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

    #endif

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

    foreign import ccall "g_variant_builder_end" g_variant_builder_end ::
        Ptr VariantBuilder ->                   -- builder : TInterface (Name {namespace = "GLib", name = "VariantBuilder"})
        IO (Ptr GVariant)

    -- | Ends the builder process and returns the constructed value.
    --
    -- It is not permissible to use /@builder@/ in any way after this call
    -- except for reference counting operations (in the case of a
    -- heap-allocated t'GI.GLib.Structs.VariantBuilder.VariantBuilder') or by reinitialising it with
    -- @/g_variant_builder_init()/@ (in the case of stack-allocated). This
    -- means that for the stack-allocated builders there is no need to
    -- call @/g_variant_builder_clear()/@ after the call to
    -- 'GI.GLib.Structs.VariantBuilder.variantBuilderEnd'.
    --
    -- It is an error to call this function in any way that would create an
    -- inconsistent value to be constructed (ie: insufficient number of
    -- items added to a container with a specific number of children
    -- required).  It is also an error to call this function if the builder
    -- was created with an indefinite array or maybe type and no children
    -- have been added; in this case it is impossible to infer the type of
    -- the empty array.
    --
    -- /Since: 2.24/
    variantBuilderEnd ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        VariantBuilder
        -- ^ /@builder@/: a t'GI.GLib.Structs.VariantBuilder.VariantBuilder'
        -> m GVariant
        -- ^ __Returns:__ a new, floating, t'GVariant'
    variantBuilderEnd :: forall (m :: * -> *).
    (HasCallStack, MonadIO m) =>
    VariantBuilder -> m GVariant
    variantBuilderEnd VariantBuilder
    builder = IO GVariant -> m GVariant
    forall a. IO a -> m a
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO GVariant -> m GVariant) -> IO GVariant -> m GVariant
    forall a b. (a -> b) -> a -> b
    $ do
        Ptr VariantBuilder
    builder' <- VariantBuilder -> IO (Ptr VariantBuilder)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr VariantBuilder
    builder
        Ptr GVariant
    result <- Ptr VariantBuilder -> IO (Ptr GVariant)
    g_variant_builder_end Ptr VariantBuilder
    builder'
        Text -> Ptr GVariant -> IO ()
    forall a. HasCallStack => Text -> Ptr a -> IO ()
    checkUnexpectedReturnNULL Text
    "variantBuilderEnd" Ptr GVariant
    result
        GVariant
    result' <- Ptr GVariant -> IO GVariant
    B.GVariant.newGVariantFromPtr Ptr GVariant
    result
        VariantBuilder -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr VariantBuilder
    builder
        GVariant -> IO GVariant
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return GVariant
    result'

    #if defined(ENABLE_OVERLOADING)
    data VariantBuilderEndMethodInfo
    instance (signature ~ (m GVariant), MonadIO m) => O.OverloadedMethod VariantBuilderEndMethodInfo VariantBuilder signature where
        overloadedMethod = variantBuilderEnd

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

    #endif

    -- method VariantBuilder::open
    -- method type : OrdinaryMethod
    -- Args: [ Arg
    --           { argCName = "builder"
    --           , argType =
    --               TInterface Name { namespace = "GLib" , name = "VariantBuilder" }
    --           , direction = DirectionIn
    --           , mayBeNull = False
    --           , argDoc =
    --               Documentation
    --                 { rawDocText = Just "a #GVariantBuilder" , sinceVersion = Nothing }
    --           , argScope = ScopeTypeInvalid
    --           , argClosure = -1
    --           , argDestroy = -1
    --           , argCallerAllocates = False
    --           , argCallbackUserData = False
    --           , transfer = TransferNothing
    --           }
    --       , Arg
    --           { argCName = "type"
    --           , argType =
    --               TInterface Name { namespace = "GLib" , name = "VariantType" }
    --           , direction = DirectionIn
    --           , mayBeNull = False
    --           , argDoc =
    --               Documentation
    --                 { rawDocText = Just "the #GVariantType of the container"
    --                 , sinceVersion = Nothing
    --                 }
    --           , argScope = ScopeTypeInvalid
    --           , argClosure = -1
    --           , argDestroy = -1
    --           , argCallerAllocates = False
    --           , argCallbackUserData = False
    --           , transfer = TransferNothing
    --           }
    --       ]
    -- Lengths: []
    -- returnType: Nothing
    -- throws : False
    -- Skip return : False

    foreign import ccall "g_variant_builder_open" g_variant_builder_open ::
        Ptr VariantBuilder ->                   -- builder : TInterface (Name {namespace = "GLib", name = "VariantBuilder"})
        Ptr GLib.VariantType.VariantType ->     -- type : TInterface (Name {namespace = "GLib", name = "VariantType"})
        IO ()

    -- | Opens a subcontainer inside the given /@builder@/.  When done adding
    -- items to the subcontainer, 'GI.GLib.Structs.VariantBuilder.variantBuilderClose' must be called. /@type@/
    -- is the type of the container: so to build a tuple of several values, /@type@/
    -- must include the tuple itself.
    --
    -- It is an error to call this function in any way that would cause an
    -- inconsistent value to be constructed (ie: adding too many values or
    -- a value of an incorrect type).
    --
    -- Example of building a nested variant:
    --
    -- === /C code/
    -- >
    -- >GVariantBuilder builder;
    -- >guint32 some_number = get_number ();
    -- >g_autoptr (GHashTable) some_dict = get_dict ();
    -- >GHashTableIter iter;
    -- >const gchar *key;
    -- >const GVariant *value;
    -- >g_autoptr (GVariant) output = NULL;
    -- >
    -- >g_variant_builder_init (&builder, G_VARIANT_TYPE ("(ua{sv})"));
    -- >g_variant_builder_add (&builder, "u", some_number);
    -- >g_variant_builder_open (&builder, G_VARIANT_TYPE ("a{sv}"));
    -- >
    -- >g_hash_table_iter_init (&iter, some_dict);
    -- >while (g_hash_table_iter_next (&iter, (gpointer *) &key, (gpointer *) &value))
    -- >  {
    -- >    g_variant_builder_open (&builder, G_VARIANT_TYPE ("{sv}"));
    -- >    g_variant_builder_add (&builder, "s", key);
    -- >    g_variant_builder_add (&builder, "v", value);
    -- >    g_variant_builder_close (&builder);
    -- >  }
    -- >
    -- >g_variant_builder_close (&builder);
    -- >
    -- >output = g_variant_builder_end (&builder);
    --
    --
    -- /Since: 2.24/
    variantBuilderOpen ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        VariantBuilder
        -- ^ /@builder@/: a t'GI.GLib.Structs.VariantBuilder.VariantBuilder'
        -> GLib.VariantType.VariantType
        -- ^ /@type@/: the t'GI.GLib.Structs.VariantType.VariantType' of the container
        -> m ()
    variantBuilderOpen :: forall (m :: * -> *).
    (HasCallStack, MonadIO m) =>
    VariantBuilder -> VariantType -> m ()
    variantBuilderOpen VariantBuilder
    builder VariantType
    type_ = 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
    $ do
        Ptr VariantBuilder
    builder' <- VariantBuilder -> IO (Ptr VariantBuilder)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr VariantBuilder
    builder
        Ptr VariantType
    type_' <- VariantType -> IO (Ptr VariantType)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr VariantType
    type_
        Ptr VariantBuilder -> Ptr VariantType -> IO ()
    g_variant_builder_open Ptr VariantBuilder
    builder' Ptr VariantType
    type_'
        VariantBuilder -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr VariantBuilder
    builder
        VariantType -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr VariantType
    type_
        () -> IO ()
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    #if defined(ENABLE_OVERLOADING)
    data VariantBuilderOpenMethodInfo
    instance (signature ~ (GLib.VariantType.VariantType -> m ()), MonadIO m) => O.OverloadedMethod VariantBuilderOpenMethodInfo VariantBuilder signature where
        overloadedMethod = variantBuilderOpen

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

    #endif

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

    foreign import ccall "g_variant_builder_ref" g_variant_builder_ref ::
        Ptr VariantBuilder ->                   -- builder : TInterface (Name {namespace = "GLib", name = "VariantBuilder"})
        IO (Ptr VariantBuilder)

    -- | Increases the reference count on /@builder@/.
    --
    -- Don\'t call this on stack-allocated t'GI.GLib.Structs.VariantBuilder.VariantBuilder' instances or bad
    -- things will happen.
    --
    -- /Since: 2.24/
    variantBuilderRef ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        VariantBuilder
        -- ^ /@builder@/: a t'GI.GLib.Structs.VariantBuilder.VariantBuilder' allocated by 'GI.GLib.Structs.VariantBuilder.variantBuilderNew'
        -> m VariantBuilder
        -- ^ __Returns:__ a new reference to /@builder@/
    variantBuilderRef :: forall (m :: * -> *).
    (HasCallStack, MonadIO m) =>
    VariantBuilder -> m VariantBuilder
    variantBuilderRef VariantBuilder
    builder = IO VariantBuilder -> m VariantBuilder
    forall a. IO a -> m a
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO VariantBuilder -> m VariantBuilder)
    -> IO VariantBuilder -> m VariantBuilder
    forall a b. (a -> b) -> a -> b
    $ do
        Ptr VariantBuilder
    builder' <- VariantBuilder -> IO (Ptr VariantBuilder)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr VariantBuilder
    builder
        Ptr VariantBuilder
    result <- Ptr VariantBuilder -> IO (Ptr VariantBuilder)
    g_variant_builder_ref Ptr VariantBuilder
    builder'
        Text -> Ptr VariantBuilder -> IO ()
    forall a. HasCallStack => Text -> Ptr a -> IO ()
    checkUnexpectedReturnNULL Text
    "variantBuilderRef" Ptr VariantBuilder
    result
        VariantBuilder
    result' <- ((ManagedPtr VariantBuilder -> VariantBuilder)
    -> Ptr VariantBuilder -> IO VariantBuilder
    forall a.
    (HasCallStack, GBoxed a) =>
    (ManagedPtr a -> a) -> Ptr a -> IO a
    wrapBoxed ManagedPtr VariantBuilder -> VariantBuilder
    VariantBuilder) Ptr VariantBuilder
    result
        VariantBuilder -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr VariantBuilder
    builder
        VariantBuilder -> IO VariantBuilder
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return VariantBuilder
    result'

    #if defined(ENABLE_OVERLOADING)
    data VariantBuilderRefMethodInfo
    instance (signature ~ (m VariantBuilder), MonadIO m) => O.OverloadedMethod VariantBuilderRefMethodInfo VariantBuilder signature where
        overloadedMethod = variantBuilderRef

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

    #endif

    -- method VariantBuilder::unref
    -- method type : OrdinaryMethod
    -- Args: [ Arg
    --           { argCName = "builder"
    --           , argType =
    --               TInterface Name { namespace = "GLib" , name = "VariantBuilder" }
    --           , direction = DirectionIn
    --           , mayBeNull = False
    --           , argDoc =
    --               Documentation
    --                 { rawDocText =
    --                     Just "a #GVariantBuilder allocated by g_variant_builder_new()"
    --                 , sinceVersion = Nothing
    --                 }
    --           , argScope = ScopeTypeInvalid
    --           , argClosure = -1
    --           , argDestroy = -1
    --           , argCallerAllocates = False
    --           , argCallbackUserData = False
    --           , transfer = TransferEverything
    --           }
    --       ]
    -- Lengths: []
    -- returnType: Nothing
    -- throws : False
    -- Skip return : False

    foreign import ccall "g_variant_builder_unref" g_variant_builder_unref ::
        Ptr VariantBuilder ->                   -- builder : TInterface (Name {namespace = "GLib", name = "VariantBuilder"})
        IO ()

    -- | Decreases the reference count on /@builder@/.
    --
    -- In the event that there are no more references, releases all memory
    -- associated with the t'GI.GLib.Structs.VariantBuilder.VariantBuilder'.
    --
    -- Don\'t call this on stack-allocated t'GI.GLib.Structs.VariantBuilder.VariantBuilder' instances or bad
    -- things will happen.
    --
    -- /Since: 2.24/
    variantBuilderUnref ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        VariantBuilder
        -- ^ /@builder@/: a t'GI.GLib.Structs.VariantBuilder.VariantBuilder' allocated by 'GI.GLib.Structs.VariantBuilder.variantBuilderNew'
        -> m ()
    variantBuilderUnref :: forall (m :: * -> *).
    (HasCallStack, MonadIO m) =>
    VariantBuilder -> m ()
    variantBuilderUnref VariantBuilder
    builder = 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
    $ do
        Ptr VariantBuilder
    builder' <- VariantBuilder -> IO (Ptr VariantBuilder)
    forall a. (HasCallStack, GBoxed a) => a -> IO (Ptr a)
    B.ManagedPtr.disownBoxed VariantBuilder
    builder
        Ptr VariantBuilder -> IO ()
    g_variant_builder_unref Ptr VariantBuilder
    builder'
        VariantBuilder -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr VariantBuilder
    builder
        () -> IO ()
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    #if defined(ENABLE_OVERLOADING)
    data VariantBuilderUnrefMethodInfo
    instance (signature ~ (m ()), MonadIO m) => O.OverloadedMethod VariantBuilderUnrefMethodInfo VariantBuilder signature where
        overloadedMethod = variantBuilderUnref

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

    #endif

    #if defined(ENABLE_OVERLOADING)
    type family ResolveVariantBuilderMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
        ResolveVariantBuilderMethod "addValue" o = VariantBuilderAddValueMethodInfo
        ResolveVariantBuilderMethod "close" o = VariantBuilderCloseMethodInfo
        ResolveVariantBuilderMethod "end" o = VariantBuilderEndMethodInfo
        ResolveVariantBuilderMethod "open" o = VariantBuilderOpenMethodInfo
        ResolveVariantBuilderMethod "ref" o = VariantBuilderRefMethodInfo
        ResolveVariantBuilderMethod "unref" o = VariantBuilderUnrefMethodInfo
        ResolveVariantBuilderMethod l o = O.MethodResolutionFailed l o

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

    #endif

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

    #endif