{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- A t'GI.GObject.Structs.ValueArray.ValueArray' contains an array of t'GI.GObject.Structs.Value.Value' elements.

#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif

module GI.GObject.Structs.ValueArray
    ( 

-- * Exported types
    ValueArray(..)                          ,
    newZeroValueArray                       ,


 -- * Methods
-- ** Overloaded methods #method:Overloaded methods#

#if defined(ENABLE_OVERLOADING)
    ResolveValueArrayMethod                 ,
#endif


-- ** append #method:append#

#if defined(ENABLE_OVERLOADING)
    ValueArrayAppendMethodInfo              ,
#endif
    valueArrayAppend                        ,


-- ** copy #method:copy#

#if defined(ENABLE_OVERLOADING)
    ValueArrayCopyMethodInfo                ,
#endif
    valueArrayCopy                          ,


-- ** getNth #method:getNth#

#if defined(ENABLE_OVERLOADING)
    ValueArrayGetNthMethodInfo              ,
#endif
    valueArrayGetNth                        ,


-- ** insert #method:insert#

#if defined(ENABLE_OVERLOADING)
    ValueArrayInsertMethodInfo              ,
#endif
    valueArrayInsert                        ,


-- ** new #method:new#

    valueArrayNew                           ,


-- ** prepend #method:prepend#

#if defined(ENABLE_OVERLOADING)
    ValueArrayPrependMethodInfo             ,
#endif
    valueArrayPrepend                       ,


-- ** remove #method:remove#

#if defined(ENABLE_OVERLOADING)
    ValueArrayRemoveMethodInfo              ,
#endif
    valueArrayRemove                        ,


-- ** sort #method:sort#

#if defined(ENABLE_OVERLOADING)
    ValueArraySortMethodInfo                ,
#endif
    valueArraySort                          ,




 -- * Properties
-- ** nValues #attr:nValues#
-- | number of values contained in the array

    getValueArrayNValues                    ,
    setValueArrayNValues                    ,
#if defined(ENABLE_OVERLOADING)
    valueArray_nValues                      ,
#endif


-- ** values #attr:values#
-- | array of values

    clearValueArrayValues                   ,
    getValueArrayValues                     ,
    setValueArrayValues                     ,
#if defined(ENABLE_OVERLOADING)
    valueArray_values                       ,
#endif




    ) 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.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.Text as T
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 GI.GLib.Callbacks as GLib.Callbacks

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

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

foreign import ccall "g_value_array_get_type" c_g_value_array_get_type :: 
    IO GType

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

instance B.Types.TypedObject ValueArray where
    glibType :: IO GType
glibType = IO GType
c_g_value_array_get_type

instance B.Types.GBoxed ValueArray

-- | Convert 'ValueArray' to and from 'Data.GI.Base.GValue.GValue' with 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'.
instance B.GValue.IsGValue ValueArray where
    toGValue :: ValueArray -> IO GValue
toGValue ValueArray
o = do
        GType
gtype <- IO GType
c_g_value_array_get_type
        ValueArray -> (Ptr ValueArray -> IO GValue) -> IO GValue
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr ValueArray
o (GType
-> (GValue -> Ptr ValueArray -> IO ())
-> Ptr ValueArray
-> IO GValue
forall a. GType -> (GValue -> a -> IO ()) -> a -> IO GValue
B.GValue.buildGValue GType
gtype GValue -> Ptr ValueArray -> IO ()
forall a. GValue -> Ptr a -> IO ()
B.GValue.set_boxed)
        
    fromGValue :: GValue -> IO ValueArray
fromGValue GValue
gv = do
        Ptr ValueArray
ptr <- GValue -> IO (Ptr ValueArray)
forall b. GValue -> IO (Ptr b)
B.GValue.get_boxed GValue
gv :: IO (Ptr ValueArray)
        (ManagedPtr ValueArray -> ValueArray)
-> Ptr ValueArray -> IO ValueArray
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
B.ManagedPtr.newBoxed ManagedPtr ValueArray -> ValueArray
ValueArray Ptr ValueArray
ptr
        
    

-- | Construct a `ValueArray` struct initialized to zero.
newZeroValueArray :: MonadIO m => m ValueArray
newZeroValueArray :: m ValueArray
newZeroValueArray = IO ValueArray -> m ValueArray
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ValueArray -> m ValueArray) -> IO ValueArray -> m ValueArray
forall a b. (a -> b) -> a -> b
$ Int -> IO (Ptr ValueArray)
forall a. GBoxed a => Int -> IO (Ptr a)
callocBoxedBytes Int
24 IO (Ptr ValueArray)
-> (Ptr ValueArray -> IO ValueArray) -> IO ValueArray
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (ManagedPtr ValueArray -> ValueArray)
-> Ptr ValueArray -> IO ValueArray
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr ValueArray -> ValueArray
ValueArray

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


-- | Get the value of the “@n_values@” field.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.get' valueArray #nValues
-- @
getValueArrayNValues :: MonadIO m => ValueArray -> m Word32
getValueArrayNValues :: ValueArray -> m Word32
getValueArrayNValues ValueArray
s = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ ValueArray -> (Ptr ValueArray -> IO Word32) -> IO Word32
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr ValueArray
s ((Ptr ValueArray -> IO Word32) -> IO Word32)
-> (Ptr ValueArray -> IO Word32) -> IO Word32
forall a b. (a -> b) -> a -> b
$ \Ptr ValueArray
ptr -> do
    Word32
val <- Ptr Word32 -> IO Word32
forall a. Storable a => Ptr a -> IO a
peek (Ptr ValueArray
ptr Ptr ValueArray -> Int -> Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0) :: IO Word32
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
val

-- | Set the value of the “@n_values@” field.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.set' valueArray [ #nValues 'Data.GI.Base.Attributes.:=' value ]
-- @
setValueArrayNValues :: MonadIO m => ValueArray -> Word32 -> m ()
setValueArrayNValues :: ValueArray -> Word32 -> m ()
setValueArrayNValues ValueArray
s Word32
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ ValueArray -> (Ptr ValueArray -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr ValueArray
s ((Ptr ValueArray -> IO ()) -> IO ())
-> (Ptr ValueArray -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr ValueArray
ptr -> do
    Ptr Word32 -> Word32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr ValueArray
ptr Ptr ValueArray -> Int -> Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0) (Word32
val :: Word32)

#if defined(ENABLE_OVERLOADING)
data ValueArrayNValuesFieldInfo
instance AttrInfo ValueArrayNValuesFieldInfo where
    type AttrBaseTypeConstraint ValueArrayNValuesFieldInfo = (~) ValueArray
    type AttrAllowedOps ValueArrayNValuesFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint ValueArrayNValuesFieldInfo = (~) Word32
    type AttrTransferTypeConstraint ValueArrayNValuesFieldInfo = (~)Word32
    type AttrTransferType ValueArrayNValuesFieldInfo = Word32
    type AttrGetType ValueArrayNValuesFieldInfo = Word32
    type AttrLabel ValueArrayNValuesFieldInfo = "n_values"
    type AttrOrigin ValueArrayNValuesFieldInfo = ValueArray
    attrGet = getValueArrayNValues
    attrSet = setValueArrayNValues
    attrConstruct = undefined
    attrClear = undefined
    attrTransfer _ v = do
        return v

valueArray_nValues :: AttrLabelProxy "nValues"
valueArray_nValues = AttrLabelProxy

#endif


-- | Get the value of the “@values@” field.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.get' valueArray #values
-- @
getValueArrayValues :: MonadIO m => ValueArray -> m (Maybe GValue)
getValueArrayValues :: ValueArray -> m (Maybe GValue)
getValueArrayValues ValueArray
s = IO (Maybe GValue) -> m (Maybe GValue)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe GValue) -> m (Maybe GValue))
-> IO (Maybe GValue) -> m (Maybe GValue)
forall a b. (a -> b) -> a -> b
$ ValueArray
-> (Ptr ValueArray -> IO (Maybe GValue)) -> IO (Maybe GValue)
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr ValueArray
s ((Ptr ValueArray -> IO (Maybe GValue)) -> IO (Maybe GValue))
-> (Ptr ValueArray -> IO (Maybe GValue)) -> IO (Maybe GValue)
forall a b. (a -> b) -> a -> b
$ \Ptr ValueArray
ptr -> do
    Ptr GValue
val <- Ptr (Ptr GValue) -> IO (Ptr GValue)
forall a. Storable a => Ptr a -> IO a
peek (Ptr ValueArray
ptr Ptr ValueArray -> Int -> Ptr (Ptr GValue)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8) :: IO (Ptr GValue)
    Maybe GValue
result <- Ptr GValue -> (Ptr GValue -> IO GValue) -> IO (Maybe GValue)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
SP.convertIfNonNull Ptr GValue
val ((Ptr GValue -> IO GValue) -> IO (Maybe GValue))
-> (Ptr GValue -> IO GValue) -> IO (Maybe GValue)
forall a b. (a -> b) -> a -> b
$ \Ptr GValue
val' -> do
        GValue
val'' <- Ptr GValue -> IO GValue
B.GValue.newGValueFromPtr Ptr GValue
val'
        GValue -> IO GValue
forall (m :: * -> *) a. Monad m => a -> m a
return GValue
val''
    Maybe GValue -> IO (Maybe GValue)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe GValue
result

-- | Set the value of the “@values@” field.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.set' valueArray [ #values 'Data.GI.Base.Attributes.:=' value ]
-- @
setValueArrayValues :: MonadIO m => ValueArray -> Ptr GValue -> m ()
setValueArrayValues :: ValueArray -> Ptr GValue -> m ()
setValueArrayValues ValueArray
s Ptr GValue
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ ValueArray -> (Ptr ValueArray -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr ValueArray
s ((Ptr ValueArray -> IO ()) -> IO ())
-> (Ptr ValueArray -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr ValueArray
ptr -> do
    Ptr (Ptr GValue) -> Ptr GValue -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr ValueArray
ptr Ptr ValueArray -> Int -> Ptr (Ptr GValue)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8) (Ptr GValue
val :: Ptr GValue)

-- | Set the value of the “@values@” field to `Nothing`.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.clear' #values
-- @
clearValueArrayValues :: MonadIO m => ValueArray -> m ()
clearValueArrayValues :: ValueArray -> m ()
clearValueArrayValues ValueArray
s = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ ValueArray -> (Ptr ValueArray -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr ValueArray
s ((Ptr ValueArray -> IO ()) -> IO ())
-> (Ptr ValueArray -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr ValueArray
ptr -> do
    Ptr (Ptr GValue) -> Ptr GValue -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr ValueArray
ptr Ptr ValueArray -> Int -> Ptr (Ptr GValue)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8) (Ptr GValue
forall a. Ptr a
FP.nullPtr :: Ptr GValue)

#if defined(ENABLE_OVERLOADING)
data ValueArrayValuesFieldInfo
instance AttrInfo ValueArrayValuesFieldInfo where
    type AttrBaseTypeConstraint ValueArrayValuesFieldInfo = (~) ValueArray
    type AttrAllowedOps ValueArrayValuesFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint ValueArrayValuesFieldInfo = (~) (Ptr GValue)
    type AttrTransferTypeConstraint ValueArrayValuesFieldInfo = (~)(Ptr GValue)
    type AttrTransferType ValueArrayValuesFieldInfo = (Ptr GValue)
    type AttrGetType ValueArrayValuesFieldInfo = Maybe GValue
    type AttrLabel ValueArrayValuesFieldInfo = "values"
    type AttrOrigin ValueArrayValuesFieldInfo = ValueArray
    attrGet = getValueArrayValues
    attrSet = setValueArrayValues
    attrConstruct = undefined
    attrClear = clearValueArrayValues
    attrTransfer _ v = do
        return v

valueArray_values :: AttrLabelProxy "values"
valueArray_values = AttrLabelProxy

#endif



#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList ValueArray
type instance O.AttributeList ValueArray = ValueArrayAttributeList
type ValueArrayAttributeList = ('[ '("nValues", ValueArrayNValuesFieldInfo), '("values", ValueArrayValuesFieldInfo)] :: [(Symbol, *)])
#endif

-- method ValueArray::new
-- method type : Constructor
-- Args: [ Arg
--           { argCName = "n_prealloced"
--           , argType = TBasicType TUInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "number of values to preallocate space for"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface Name { namespace = "GObject" , name = "ValueArray" })
-- throws : False
-- Skip return : False

foreign import ccall "g_value_array_new" g_value_array_new :: 
    Word32 ->                               -- n_prealloced : TBasicType TUInt
    IO (Ptr ValueArray)

{-# DEPRECATED valueArrayNew ["(Since version 2.32)","Use t'GI.GLib.Structs.Array.Array' and @/g_array_sized_new()/@ instead."] #-}
-- | Allocate and initialize a new t'GI.GObject.Structs.ValueArray.ValueArray', optionally preserve space
-- for /@nPrealloced@/ elements. New arrays always contain 0 elements,
-- regardless of the value of /@nPrealloced@/.
valueArrayNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word32
    -- ^ /@nPrealloced@/: number of values to preallocate space for
    -> m ValueArray
    -- ^ __Returns:__ a newly allocated t'GI.GObject.Structs.ValueArray.ValueArray' with 0 values
valueArrayNew :: Word32 -> m ValueArray
valueArrayNew Word32
nPrealloced = IO ValueArray -> m ValueArray
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ValueArray -> m ValueArray) -> IO ValueArray -> m ValueArray
forall a b. (a -> b) -> a -> b
$ do
    Ptr ValueArray
result <- Word32 -> IO (Ptr ValueArray)
g_value_array_new Word32
nPrealloced
    Text -> Ptr ValueArray -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"valueArrayNew" Ptr ValueArray
result
    ValueArray
result' <- ((ManagedPtr ValueArray -> ValueArray)
-> Ptr ValueArray -> IO ValueArray
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr ValueArray -> ValueArray
ValueArray) Ptr ValueArray
result
    ValueArray -> IO ValueArray
forall (m :: * -> *) a. Monad m => a -> m a
return ValueArray
result'

#if defined(ENABLE_OVERLOADING)
#endif

-- method ValueArray::append
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "value_array"
--           , argType =
--               TInterface Name { namespace = "GObject" , name = "ValueArray" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "#GValueArray to add an element to"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "value"
--           , argType = TGValue
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "#GValue to copy into #GValueArray, or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface Name { namespace = "GObject" , name = "ValueArray" })
-- throws : False
-- Skip return : False

foreign import ccall "g_value_array_append" g_value_array_append :: 
    Ptr ValueArray ->                       -- value_array : TInterface (Name {namespace = "GObject", name = "ValueArray"})
    Ptr GValue ->                           -- value : TGValue
    IO (Ptr ValueArray)

{-# DEPRECATED valueArrayAppend ["(Since version 2.32)","Use t'GI.GLib.Structs.Array.Array' and @/g_array_append_val()/@ instead."] #-}
-- | Insert a copy of /@value@/ as last element of /@valueArray@/. If /@value@/ is
-- 'P.Nothing', an uninitialized value is appended.
valueArrayAppend ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    ValueArray
    -- ^ /@valueArray@/: t'GI.GObject.Structs.ValueArray.ValueArray' to add an element to
    -> Maybe (GValue)
    -- ^ /@value@/: t'GI.GObject.Structs.Value.Value' to copy into t'GI.GObject.Structs.ValueArray.ValueArray', or 'P.Nothing'
    -> m ValueArray
    -- ^ __Returns:__ the t'GI.GObject.Structs.ValueArray.ValueArray' passed in as /@valueArray@/
valueArrayAppend :: ValueArray -> Maybe GValue -> m ValueArray
valueArrayAppend ValueArray
valueArray Maybe GValue
value = IO ValueArray -> m ValueArray
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ValueArray -> m ValueArray) -> IO ValueArray -> m ValueArray
forall a b. (a -> b) -> a -> b
$ do
    Ptr ValueArray
valueArray' <- ValueArray -> IO (Ptr ValueArray)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr ValueArray
valueArray
    Ptr GValue
maybeValue <- case Maybe GValue
value of
        Maybe GValue
Nothing -> Ptr GValue -> IO (Ptr GValue)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr GValue
forall a. Ptr a
nullPtr
        Just GValue
jValue -> do
            Ptr GValue
jValue' <- GValue -> IO (Ptr GValue)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr GValue
jValue
            Ptr GValue -> IO (Ptr GValue)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr GValue
jValue'
    Ptr ValueArray
result <- Ptr ValueArray -> Ptr GValue -> IO (Ptr ValueArray)
g_value_array_append Ptr ValueArray
valueArray' Ptr GValue
maybeValue
    Text -> Ptr ValueArray -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"valueArrayAppend" Ptr ValueArray
result
    ValueArray
result' <- ((ManagedPtr ValueArray -> ValueArray)
-> Ptr ValueArray -> IO ValueArray
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr ValueArray -> ValueArray
ValueArray) Ptr ValueArray
result
    ValueArray -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr ValueArray
valueArray
    Maybe GValue -> (GValue -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe GValue
value GValue -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    Ptr GValue -> IO ()
B.GValue.unsetGValue Ptr GValue
maybeValue
    ValueArray -> IO ValueArray
forall (m :: * -> *) a. Monad m => a -> m a
return ValueArray
result'

#if defined(ENABLE_OVERLOADING)
data ValueArrayAppendMethodInfo
instance (signature ~ (Maybe (GValue) -> m ValueArray), MonadIO m) => O.MethodInfo ValueArrayAppendMethodInfo ValueArray signature where
    overloadedMethod = valueArrayAppend

#endif

-- method ValueArray::copy
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "value_array"
--           , argType =
--               TInterface Name { namespace = "GObject" , name = "ValueArray" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "#GValueArray to copy"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface Name { namespace = "GObject" , name = "ValueArray" })
-- throws : False
-- Skip return : False

foreign import ccall "g_value_array_copy" g_value_array_copy :: 
    Ptr ValueArray ->                       -- value_array : TInterface (Name {namespace = "GObject", name = "ValueArray"})
    IO (Ptr ValueArray)

{-# DEPRECATED valueArrayCopy ["(Since version 2.32)","Use t'GI.GLib.Structs.Array.Array' and @/g_array_ref()/@ instead."] #-}
-- | Construct an exact copy of a t'GI.GObject.Structs.ValueArray.ValueArray' by duplicating all its
-- contents.
valueArrayCopy ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    ValueArray
    -- ^ /@valueArray@/: t'GI.GObject.Structs.ValueArray.ValueArray' to copy
    -> m ValueArray
    -- ^ __Returns:__ Newly allocated copy of t'GI.GObject.Structs.ValueArray.ValueArray'
valueArrayCopy :: ValueArray -> m ValueArray
valueArrayCopy ValueArray
valueArray = IO ValueArray -> m ValueArray
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ValueArray -> m ValueArray) -> IO ValueArray -> m ValueArray
forall a b. (a -> b) -> a -> b
$ do
    Ptr ValueArray
valueArray' <- ValueArray -> IO (Ptr ValueArray)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr ValueArray
valueArray
    Ptr ValueArray
result <- Ptr ValueArray -> IO (Ptr ValueArray)
g_value_array_copy Ptr ValueArray
valueArray'
    Text -> Ptr ValueArray -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"valueArrayCopy" Ptr ValueArray
result
    ValueArray
result' <- ((ManagedPtr ValueArray -> ValueArray)
-> Ptr ValueArray -> IO ValueArray
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr ValueArray -> ValueArray
ValueArray) Ptr ValueArray
result
    ValueArray -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr ValueArray
valueArray
    ValueArray -> IO ValueArray
forall (m :: * -> *) a. Monad m => a -> m a
return ValueArray
result'

#if defined(ENABLE_OVERLOADING)
data ValueArrayCopyMethodInfo
instance (signature ~ (m ValueArray), MonadIO m) => O.MethodInfo ValueArrayCopyMethodInfo ValueArray signature where
    overloadedMethod = valueArrayCopy

#endif

-- method ValueArray::get_nth
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "value_array"
--           , argType =
--               TInterface Name { namespace = "GObject" , name = "ValueArray" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "#GValueArray to get a value from"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "index_"
--           , argType = TBasicType TUInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "index of the value of interest"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just TGValue
-- throws : False
-- Skip return : False

foreign import ccall "g_value_array_get_nth" g_value_array_get_nth :: 
    Ptr ValueArray ->                       -- value_array : TInterface (Name {namespace = "GObject", name = "ValueArray"})
    Word32 ->                               -- index_ : TBasicType TUInt
    IO (Ptr GValue)

{-# DEPRECATED valueArrayGetNth ["(Since version 2.32)","Use @/g_array_index()/@ instead."] #-}
-- | Return a pointer to the value at /@index_@/ containd in /@valueArray@/.
valueArrayGetNth ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    ValueArray
    -- ^ /@valueArray@/: t'GI.GObject.Structs.ValueArray.ValueArray' to get a value from
    -> Word32
    -- ^ /@index_@/: index of the value of interest
    -> m GValue
    -- ^ __Returns:__ pointer to a value at /@index_@/ in /@valueArray@/
valueArrayGetNth :: ValueArray -> Word32 -> m GValue
valueArrayGetNth ValueArray
valueArray Word32
index_ = IO GValue -> m GValue
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
    Ptr ValueArray
valueArray' <- ValueArray -> IO (Ptr ValueArray)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr ValueArray
valueArray
    Ptr GValue
result <- Ptr ValueArray -> Word32 -> IO (Ptr GValue)
g_value_array_get_nth Ptr ValueArray
valueArray' Word32
index_
    Text -> Ptr GValue -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"valueArrayGetNth" Ptr GValue
result
    GValue
result' <- Ptr GValue -> IO GValue
B.GValue.newGValueFromPtr Ptr GValue
result
    ValueArray -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr ValueArray
valueArray
    GValue -> IO GValue
forall (m :: * -> *) a. Monad m => a -> m a
return GValue
result'

#if defined(ENABLE_OVERLOADING)
data ValueArrayGetNthMethodInfo
instance (signature ~ (Word32 -> m GValue), MonadIO m) => O.MethodInfo ValueArrayGetNthMethodInfo ValueArray signature where
    overloadedMethod = valueArrayGetNth

#endif

-- method ValueArray::insert
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "value_array"
--           , argType =
--               TInterface Name { namespace = "GObject" , name = "ValueArray" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "#GValueArray to add an element to"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "index_"
--           , argType = TBasicType TUInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "insertion position, must be <= value_array->;n_values"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "value"
--           , argType = TGValue
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "#GValue to copy into #GValueArray, or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface Name { namespace = "GObject" , name = "ValueArray" })
-- throws : False
-- Skip return : False

foreign import ccall "g_value_array_insert" g_value_array_insert :: 
    Ptr ValueArray ->                       -- value_array : TInterface (Name {namespace = "GObject", name = "ValueArray"})
    Word32 ->                               -- index_ : TBasicType TUInt
    Ptr GValue ->                           -- value : TGValue
    IO (Ptr ValueArray)

{-# DEPRECATED valueArrayInsert ["(Since version 2.32)","Use t'GI.GLib.Structs.Array.Array' and @/g_array_insert_val()/@ instead."] #-}
-- | Insert a copy of /@value@/ at specified position into /@valueArray@/. If /@value@/
-- is 'P.Nothing', an uninitialized value is inserted.
valueArrayInsert ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    ValueArray
    -- ^ /@valueArray@/: t'GI.GObject.Structs.ValueArray.ValueArray' to add an element to
    -> Word32
    -- ^ /@index_@/: insertion position, must be \<= value_array->;n_values
    -> Maybe (GValue)
    -- ^ /@value@/: t'GI.GObject.Structs.Value.Value' to copy into t'GI.GObject.Structs.ValueArray.ValueArray', or 'P.Nothing'
    -> m ValueArray
    -- ^ __Returns:__ the t'GI.GObject.Structs.ValueArray.ValueArray' passed in as /@valueArray@/
valueArrayInsert :: ValueArray -> Word32 -> Maybe GValue -> m ValueArray
valueArrayInsert ValueArray
valueArray Word32
index_ Maybe GValue
value = IO ValueArray -> m ValueArray
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ValueArray -> m ValueArray) -> IO ValueArray -> m ValueArray
forall a b. (a -> b) -> a -> b
$ do
    Ptr ValueArray
valueArray' <- ValueArray -> IO (Ptr ValueArray)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr ValueArray
valueArray
    Ptr GValue
maybeValue <- case Maybe GValue
value of
        Maybe GValue
Nothing -> Ptr GValue -> IO (Ptr GValue)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr GValue
forall a. Ptr a
nullPtr
        Just GValue
jValue -> do
            Ptr GValue
jValue' <- GValue -> IO (Ptr GValue)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr GValue
jValue
            Ptr GValue -> IO (Ptr GValue)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr GValue
jValue'
    Ptr ValueArray
result <- Ptr ValueArray -> Word32 -> Ptr GValue -> IO (Ptr ValueArray)
g_value_array_insert Ptr ValueArray
valueArray' Word32
index_ Ptr GValue
maybeValue
    Text -> Ptr ValueArray -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"valueArrayInsert" Ptr ValueArray
result
    ValueArray
result' <- ((ManagedPtr ValueArray -> ValueArray)
-> Ptr ValueArray -> IO ValueArray
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr ValueArray -> ValueArray
ValueArray) Ptr ValueArray
result
    ValueArray -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr ValueArray
valueArray
    Maybe GValue -> (GValue -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe GValue
value GValue -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    Ptr GValue -> IO ()
B.GValue.unsetGValue Ptr GValue
maybeValue
    ValueArray -> IO ValueArray
forall (m :: * -> *) a. Monad m => a -> m a
return ValueArray
result'

#if defined(ENABLE_OVERLOADING)
data ValueArrayInsertMethodInfo
instance (signature ~ (Word32 -> Maybe (GValue) -> m ValueArray), MonadIO m) => O.MethodInfo ValueArrayInsertMethodInfo ValueArray signature where
    overloadedMethod = valueArrayInsert

#endif

-- method ValueArray::prepend
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "value_array"
--           , argType =
--               TInterface Name { namespace = "GObject" , name = "ValueArray" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "#GValueArray to add an element to"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "value"
--           , argType = TGValue
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "#GValue to copy into #GValueArray, or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface Name { namespace = "GObject" , name = "ValueArray" })
-- throws : False
-- Skip return : False

foreign import ccall "g_value_array_prepend" g_value_array_prepend :: 
    Ptr ValueArray ->                       -- value_array : TInterface (Name {namespace = "GObject", name = "ValueArray"})
    Ptr GValue ->                           -- value : TGValue
    IO (Ptr ValueArray)

{-# DEPRECATED valueArrayPrepend ["(Since version 2.32)","Use t'GI.GLib.Structs.Array.Array' and @/g_array_prepend_val()/@ instead."] #-}
-- | Insert a copy of /@value@/ as first element of /@valueArray@/. If /@value@/ is
-- 'P.Nothing', an uninitialized value is prepended.
valueArrayPrepend ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    ValueArray
    -- ^ /@valueArray@/: t'GI.GObject.Structs.ValueArray.ValueArray' to add an element to
    -> Maybe (GValue)
    -- ^ /@value@/: t'GI.GObject.Structs.Value.Value' to copy into t'GI.GObject.Structs.ValueArray.ValueArray', or 'P.Nothing'
    -> m ValueArray
    -- ^ __Returns:__ the t'GI.GObject.Structs.ValueArray.ValueArray' passed in as /@valueArray@/
valueArrayPrepend :: ValueArray -> Maybe GValue -> m ValueArray
valueArrayPrepend ValueArray
valueArray Maybe GValue
value = IO ValueArray -> m ValueArray
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ValueArray -> m ValueArray) -> IO ValueArray -> m ValueArray
forall a b. (a -> b) -> a -> b
$ do
    Ptr ValueArray
valueArray' <- ValueArray -> IO (Ptr ValueArray)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr ValueArray
valueArray
    Ptr GValue
maybeValue <- case Maybe GValue
value of
        Maybe GValue
Nothing -> Ptr GValue -> IO (Ptr GValue)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr GValue
forall a. Ptr a
nullPtr
        Just GValue
jValue -> do
            Ptr GValue
jValue' <- GValue -> IO (Ptr GValue)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr GValue
jValue
            Ptr GValue -> IO (Ptr GValue)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr GValue
jValue'
    Ptr ValueArray
result <- Ptr ValueArray -> Ptr GValue -> IO (Ptr ValueArray)
g_value_array_prepend Ptr ValueArray
valueArray' Ptr GValue
maybeValue
    Text -> Ptr ValueArray -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"valueArrayPrepend" Ptr ValueArray
result
    ValueArray
result' <- ((ManagedPtr ValueArray -> ValueArray)
-> Ptr ValueArray -> IO ValueArray
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr ValueArray -> ValueArray
ValueArray) Ptr ValueArray
result
    ValueArray -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr ValueArray
valueArray
    Maybe GValue -> (GValue -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe GValue
value GValue -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    Ptr GValue -> IO ()
B.GValue.unsetGValue Ptr GValue
maybeValue
    ValueArray -> IO ValueArray
forall (m :: * -> *) a. Monad m => a -> m a
return ValueArray
result'

#if defined(ENABLE_OVERLOADING)
data ValueArrayPrependMethodInfo
instance (signature ~ (Maybe (GValue) -> m ValueArray), MonadIO m) => O.MethodInfo ValueArrayPrependMethodInfo ValueArray signature where
    overloadedMethod = valueArrayPrepend

#endif

-- method ValueArray::remove
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "value_array"
--           , argType =
--               TInterface Name { namespace = "GObject" , name = "ValueArray" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "#GValueArray to remove an element from"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "index_"
--           , argType = TBasicType TUInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "position of value to remove, which must be less than\n    @value_array->n_values"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface Name { namespace = "GObject" , name = "ValueArray" })
-- throws : False
-- Skip return : False

foreign import ccall "g_value_array_remove" g_value_array_remove :: 
    Ptr ValueArray ->                       -- value_array : TInterface (Name {namespace = "GObject", name = "ValueArray"})
    Word32 ->                               -- index_ : TBasicType TUInt
    IO (Ptr ValueArray)

{-# DEPRECATED valueArrayRemove ["(Since version 2.32)","Use t'GI.GLib.Structs.Array.Array' and @/g_array_remove_index()/@ instead."] #-}
-- | Remove the value at position /@index_@/ from /@valueArray@/.
valueArrayRemove ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    ValueArray
    -- ^ /@valueArray@/: t'GI.GObject.Structs.ValueArray.ValueArray' to remove an element from
    -> Word32
    -- ^ /@index_@/: position of value to remove, which must be less than
    --     /@valueArray@/->n_values
    -> m ValueArray
    -- ^ __Returns:__ the t'GI.GObject.Structs.ValueArray.ValueArray' passed in as /@valueArray@/
valueArrayRemove :: ValueArray -> Word32 -> m ValueArray
valueArrayRemove ValueArray
valueArray Word32
index_ = IO ValueArray -> m ValueArray
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ValueArray -> m ValueArray) -> IO ValueArray -> m ValueArray
forall a b. (a -> b) -> a -> b
$ do
    Ptr ValueArray
valueArray' <- ValueArray -> IO (Ptr ValueArray)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr ValueArray
valueArray
    Ptr ValueArray
result <- Ptr ValueArray -> Word32 -> IO (Ptr ValueArray)
g_value_array_remove Ptr ValueArray
valueArray' Word32
index_
    Text -> Ptr ValueArray -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"valueArrayRemove" Ptr ValueArray
result
    ValueArray
result' <- ((ManagedPtr ValueArray -> ValueArray)
-> Ptr ValueArray -> IO ValueArray
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr ValueArray -> ValueArray
ValueArray) Ptr ValueArray
result
    ValueArray -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr ValueArray
valueArray
    ValueArray -> IO ValueArray
forall (m :: * -> *) a. Monad m => a -> m a
return ValueArray
result'

#if defined(ENABLE_OVERLOADING)
data ValueArrayRemoveMethodInfo
instance (signature ~ (Word32 -> m ValueArray), MonadIO m) => O.MethodInfo ValueArrayRemoveMethodInfo ValueArray signature where
    overloadedMethod = valueArrayRemove

#endif

-- method ValueArray::sort
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "value_array"
--           , argType =
--               TInterface Name { namespace = "GObject" , name = "ValueArray" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "#GValueArray to sort"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "compare_func"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "CompareDataFunc" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "function to compare elements"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeCall
--           , argClosure = 2
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "user_data"
--           , argType = TBasicType TPtr
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "extra data argument provided for @compare_func"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface Name { namespace = "GObject" , name = "ValueArray" })
-- throws : False
-- Skip return : False

foreign import ccall "g_value_array_sort_with_data" g_value_array_sort_with_data :: 
    Ptr ValueArray ->                       -- value_array : TInterface (Name {namespace = "GObject", name = "ValueArray"})
    FunPtr GLib.Callbacks.C_CompareDataFunc -> -- compare_func : TInterface (Name {namespace = "GLib", name = "CompareDataFunc"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO (Ptr ValueArray)

{-# DEPRECATED valueArraySort ["(Since version 2.32)","Use t'GI.GLib.Structs.Array.Array' and @/g_array_sort_with_data()/@."] #-}
-- | Sort /@valueArray@/ using /@compareFunc@/ to compare the elements according
-- to the semantics of t'GI.GLib.Callbacks.CompareDataFunc'.
-- 
-- The current implementation uses the same sorting algorithm as standard
-- C @/qsort()/@ function.
valueArraySort ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    ValueArray
    -- ^ /@valueArray@/: t'GI.GObject.Structs.ValueArray.ValueArray' to sort
    -> GLib.Callbacks.CompareDataFunc
    -- ^ /@compareFunc@/: function to compare elements
    -> m ValueArray
    -- ^ __Returns:__ the t'GI.GObject.Structs.ValueArray.ValueArray' passed in as /@valueArray@/
valueArraySort :: ValueArray -> CompareDataFunc -> m ValueArray
valueArraySort ValueArray
valueArray CompareDataFunc
compareFunc = IO ValueArray -> m ValueArray
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ValueArray -> m ValueArray) -> IO ValueArray -> m ValueArray
forall a b. (a -> b) -> a -> b
$ do
    Ptr ValueArray
valueArray' <- ValueArray -> IO (Ptr ValueArray)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr ValueArray
valueArray
    FunPtr C_CompareDataFunc
compareFunc' <- C_CompareDataFunc -> IO (FunPtr C_CompareDataFunc)
GLib.Callbacks.mk_CompareDataFunc (Maybe (Ptr (FunPtr C_CompareDataFunc))
-> C_CompareDataFunc -> C_CompareDataFunc
GLib.Callbacks.wrap_CompareDataFunc Maybe (Ptr (FunPtr C_CompareDataFunc))
forall a. Maybe a
Nothing (CompareDataFunc -> C_CompareDataFunc
GLib.Callbacks.drop_closures_CompareDataFunc CompareDataFunc
compareFunc))
    let userData :: Ptr a
userData = Ptr a
forall a. Ptr a
nullPtr
    Ptr ValueArray
result <- Ptr ValueArray
-> FunPtr C_CompareDataFunc -> Ptr () -> IO (Ptr ValueArray)
g_value_array_sort_with_data Ptr ValueArray
valueArray' FunPtr C_CompareDataFunc
compareFunc' Ptr ()
forall a. Ptr a
userData
    Text -> Ptr ValueArray -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"valueArraySort" Ptr ValueArray
result
    ValueArray
result' <- ((ManagedPtr ValueArray -> ValueArray)
-> Ptr ValueArray -> IO ValueArray
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr ValueArray -> ValueArray
ValueArray) Ptr ValueArray
result
    Ptr Any -> IO ()
forall a. Ptr a -> IO ()
safeFreeFunPtr (Ptr Any -> IO ()) -> Ptr Any -> IO ()
forall a b. (a -> b) -> a -> b
$ FunPtr C_CompareDataFunc -> Ptr Any
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr FunPtr C_CompareDataFunc
compareFunc'
    ValueArray -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr ValueArray
valueArray
    ValueArray -> IO ValueArray
forall (m :: * -> *) a. Monad m => a -> m a
return ValueArray
result'

#if defined(ENABLE_OVERLOADING)
data ValueArraySortMethodInfo
instance (signature ~ (GLib.Callbacks.CompareDataFunc -> m ValueArray), MonadIO m) => O.MethodInfo ValueArraySortMethodInfo ValueArray signature where
    overloadedMethod = valueArraySort

#endif

#if defined(ENABLE_OVERLOADING)
type family ResolveValueArrayMethod (t :: Symbol) (o :: *) :: * where
    ResolveValueArrayMethod "append" o = ValueArrayAppendMethodInfo
    ResolveValueArrayMethod "copy" o = ValueArrayCopyMethodInfo
    ResolveValueArrayMethod "insert" o = ValueArrayInsertMethodInfo
    ResolveValueArrayMethod "prepend" o = ValueArrayPrependMethodInfo
    ResolveValueArrayMethod "remove" o = ValueArrayRemoveMethodInfo
    ResolveValueArrayMethod "sort" o = ValueArraySortMethodInfo
    ResolveValueArrayMethod "getNth" o = ValueArrayGetNthMethodInfo
    ResolveValueArrayMethod l o = O.MethodResolutionFailed l o

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

#endif