gi-ggit-1.0.4: GI/Ggit/Structs/StatusOptions.hs
{- |
Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License : LGPL-2.1
Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc)
Represents the options used when creating getting file status.
-}
#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
&& !defined(__HADDOCK_VERSION__))
module GI.Ggit.Structs.StatusOptions
(
-- * Exported types
StatusOptions(..) ,
noStatusOptions ,
-- * Methods
-- ** copy #method:copy#
#if ENABLE_OVERLOADING
StatusOptionsCopyMethodInfo ,
#endif
statusOptionsCopy ,
-- ** free #method:free#
#if ENABLE_OVERLOADING
StatusOptionsFreeMethodInfo ,
#endif
statusOptionsFree ,
-- ** new #method:new#
statusOptionsNew ,
) 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.ManagedPtr as B.ManagedPtr
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.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 {-# SOURCE #-} qualified GI.Ggit.Enums as Ggit.Enums
import {-# SOURCE #-} qualified GI.Ggit.Flags as Ggit.Flags
-- | Memory-managed wrapper type.
newtype StatusOptions = StatusOptions (ManagedPtr StatusOptions)
foreign import ccall "ggit_status_options_get_type" c_ggit_status_options_get_type ::
IO GType
instance BoxedObject StatusOptions where
boxedType _ = c_ggit_status_options_get_type
-- | A convenience alias for `Nothing` :: `Maybe` `StatusOptions`.
noStatusOptions :: Maybe StatusOptions
noStatusOptions = Nothing
#if ENABLE_OVERLOADING
instance O.HasAttributeList StatusOptions
type instance O.AttributeList StatusOptions = StatusOptionsAttributeList
type StatusOptionsAttributeList = ('[ ] :: [(Symbol, *)])
#endif
-- method StatusOptions::new
-- method type : Constructor
-- Args : [Arg {argCName = "options", argType = TInterface (Name {namespace = "Ggit", name = "StatusOption"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "status options.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "show", argType = TInterface (Name {namespace = "Ggit", name = "StatusShow"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "status show options.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "pathspec", argType = TCArray True (-1) (-1) (TBasicType TUTF8), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "which paths to show, defaults to showing all paths.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Ggit", name = "StatusOptions"}))
-- throws : False
-- Skip return : False
foreign import ccall "ggit_status_options_new" ggit_status_options_new ::
CUInt -> -- options : TInterface (Name {namespace = "Ggit", name = "StatusOption"})
CUInt -> -- show : TInterface (Name {namespace = "Ggit", name = "StatusShow"})
Ptr CString -> -- pathspec : TCArray True (-1) (-1) (TBasicType TUTF8)
IO (Ptr StatusOptions)
{- |
Creates a new 'GI.Ggit.Structs.StatusOptions.StatusOptions' for use in @/ggit_repository_stash_foreach/@.
-}
statusOptionsNew ::
(B.CallStack.HasCallStack, MonadIO m) =>
[Ggit.Flags.StatusOption]
{- ^ /@options@/: status options. -}
-> Ggit.Enums.StatusShow
{- ^ /@show@/: status show options. -}
-> Maybe ([T.Text])
{- ^ /@pathspec@/: which paths to show, defaults to showing all paths. -}
-> m StatusOptions
{- ^ __Returns:__ a newly allocated 'GI.Ggit.Structs.StatusOptions.StatusOptions'. -}
statusOptionsNew options show_ pathspec = liftIO $ do
let options' = gflagsToWord options
let show_' = (fromIntegral . fromEnum) show_
maybePathspec <- case pathspec of
Nothing -> return nullPtr
Just jPathspec -> do
jPathspec' <- packZeroTerminatedUTF8CArray jPathspec
return jPathspec'
result <- ggit_status_options_new options' show_' maybePathspec
checkUnexpectedReturnNULL "statusOptionsNew" result
result' <- (wrapBoxed StatusOptions) result
mapZeroTerminatedCArray freeMem maybePathspec
freeMem maybePathspec
return result'
#if ENABLE_OVERLOADING
#endif
-- method StatusOptions::copy
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "status_options", argType = TInterface (Name {namespace = "Ggit", name = "StatusOptions"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitStatusOptions.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Ggit", name = "StatusOptions"}))
-- throws : False
-- Skip return : False
foreign import ccall "ggit_status_options_copy" ggit_status_options_copy ::
Ptr StatusOptions -> -- status_options : TInterface (Name {namespace = "Ggit", name = "StatusOptions"})
IO (Ptr StatusOptions)
{- |
Copies /@statusOptions@/ into a newly allocated 'GI.Ggit.Structs.StatusOptions.StatusOptions'.
-}
statusOptionsCopy ::
(B.CallStack.HasCallStack, MonadIO m) =>
StatusOptions
{- ^ /@statusOptions@/: a 'GI.Ggit.Structs.StatusOptions.StatusOptions'. -}
-> m (Maybe StatusOptions)
{- ^ __Returns:__ a newly allocated 'GI.Ggit.Structs.StatusOptions.StatusOptions' or 'Nothing'. -}
statusOptionsCopy statusOptions = liftIO $ do
statusOptions' <- unsafeManagedPtrGetPtr statusOptions
result <- ggit_status_options_copy statusOptions'
maybeResult <- convertIfNonNull result $ \result' -> do
result'' <- (wrapBoxed StatusOptions) result'
return result''
touchManagedPtr statusOptions
return maybeResult
#if ENABLE_OVERLOADING
data StatusOptionsCopyMethodInfo
instance (signature ~ (m (Maybe StatusOptions)), MonadIO m) => O.MethodInfo StatusOptionsCopyMethodInfo StatusOptions signature where
overloadedMethod _ = statusOptionsCopy
#endif
-- method StatusOptions::free
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "status_options", argType = TInterface (Name {namespace = "Ggit", name = "StatusOptions"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitStatusOptions.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False
foreign import ccall "ggit_status_options_free" ggit_status_options_free ::
Ptr StatusOptions -> -- status_options : TInterface (Name {namespace = "Ggit", name = "StatusOptions"})
IO ()
{- |
Frees /@statusOptions@/.
-}
statusOptionsFree ::
(B.CallStack.HasCallStack, MonadIO m) =>
StatusOptions
{- ^ /@statusOptions@/: a 'GI.Ggit.Structs.StatusOptions.StatusOptions'. -}
-> m ()
statusOptionsFree statusOptions = liftIO $ do
statusOptions' <- unsafeManagedPtrGetPtr statusOptions
ggit_status_options_free statusOptions'
touchManagedPtr statusOptions
return ()
#if ENABLE_OVERLOADING
data StatusOptionsFreeMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo StatusOptionsFreeMethodInfo StatusOptions signature where
overloadedMethod _ = statusOptionsFree
#endif
#if ENABLE_OVERLOADING
type family ResolveStatusOptionsMethod (t :: Symbol) (o :: *) :: * where
ResolveStatusOptionsMethod "copy" o = StatusOptionsCopyMethodInfo
ResolveStatusOptionsMethod "free" o = StatusOptionsFreeMethodInfo
ResolveStatusOptionsMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveStatusOptionsMethod t StatusOptions, O.MethodInfo info StatusOptions p) => OL.IsLabel t (StatusOptions -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#else
fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif
#endif