{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.Ggit.Structs.RefSpec
(
RefSpec(..) ,
noRefSpec ,
#if defined(ENABLE_OVERLOADING)
ResolveRefSpecMethod ,
#endif
#if defined(ENABLE_OVERLOADING)
RefSpecGetDestinationMethodInfo ,
#endif
refSpecGetDestination ,
#if defined(ENABLE_OVERLOADING)
RefSpecGetSourceMethodInfo ,
#endif
refSpecGetSource ,
#if defined(ENABLE_OVERLOADING)
RefSpecIsForcedMethodInfo ,
#endif
refSpecIsForced ,
#if defined(ENABLE_OVERLOADING)
RefSpecRefMethodInfo ,
#endif
refSpecRef ,
#if defined(ENABLE_OVERLOADING)
RefSpecUnrefMethodInfo ,
#endif
refSpecUnref ,
) 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.GI.Base.Signals as B.Signals
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
newtype RefSpec = RefSpec (ManagedPtr RefSpec)
deriving (Eq)
foreign import ccall "ggit_ref_spec_get_type" c_ggit_ref_spec_get_type ::
IO GType
instance BoxedObject RefSpec where
boxedType _ = c_ggit_ref_spec_get_type
instance B.GValue.IsGValue RefSpec where
toGValue o = do
gtype <- c_ggit_ref_spec_get_type
B.ManagedPtr.withManagedPtr o (B.GValue.buildGValue gtype B.GValue.set_boxed)
fromGValue gv = do
ptr <- B.GValue.get_boxed gv :: IO (Ptr RefSpec)
B.ManagedPtr.newBoxed RefSpec ptr
noRefSpec :: Maybe RefSpec
noRefSpec = Nothing
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList RefSpec
type instance O.AttributeList RefSpec = RefSpecAttributeList
type RefSpecAttributeList = ('[ ] :: [(Symbol, *)])
#endif
foreign import ccall "ggit_ref_spec_get_destination" ggit_ref_spec_get_destination ::
Ptr RefSpec ->
IO CString
refSpecGetDestination ::
(B.CallStack.HasCallStack, MonadIO m) =>
RefSpec
-> m (Maybe T.Text)
refSpecGetDestination refspec = liftIO $ do
refspec' <- unsafeManagedPtrGetPtr refspec
result <- ggit_ref_spec_get_destination refspec'
maybeResult <- convertIfNonNull result $ \result' -> do
result'' <- cstringToText result'
return result''
touchManagedPtr refspec
return maybeResult
#if defined(ENABLE_OVERLOADING)
data RefSpecGetDestinationMethodInfo
instance (signature ~ (m (Maybe T.Text)), MonadIO m) => O.MethodInfo RefSpecGetDestinationMethodInfo RefSpec signature where
overloadedMethod = refSpecGetDestination
#endif
foreign import ccall "ggit_ref_spec_get_source" ggit_ref_spec_get_source ::
Ptr RefSpec ->
IO CString
refSpecGetSource ::
(B.CallStack.HasCallStack, MonadIO m) =>
RefSpec
-> m (Maybe T.Text)
refSpecGetSource refspec = liftIO $ do
refspec' <- unsafeManagedPtrGetPtr refspec
result <- ggit_ref_spec_get_source refspec'
maybeResult <- convertIfNonNull result $ \result' -> do
result'' <- cstringToText result'
return result''
touchManagedPtr refspec
return maybeResult
#if defined(ENABLE_OVERLOADING)
data RefSpecGetSourceMethodInfo
instance (signature ~ (m (Maybe T.Text)), MonadIO m) => O.MethodInfo RefSpecGetSourceMethodInfo RefSpec signature where
overloadedMethod = refSpecGetSource
#endif
foreign import ccall "ggit_ref_spec_is_forced" ggit_ref_spec_is_forced ::
Ptr RefSpec ->
IO CInt
refSpecIsForced ::
(B.CallStack.HasCallStack, MonadIO m) =>
RefSpec
-> m Bool
refSpecIsForced refspec = liftIO $ do
refspec' <- unsafeManagedPtrGetPtr refspec
result <- ggit_ref_spec_is_forced refspec'
let result' = (/= 0) result
touchManagedPtr refspec
return result'
#if defined(ENABLE_OVERLOADING)
data RefSpecIsForcedMethodInfo
instance (signature ~ (m Bool), MonadIO m) => O.MethodInfo RefSpecIsForcedMethodInfo RefSpec signature where
overloadedMethod = refSpecIsForced
#endif
foreign import ccall "ggit_ref_spec_ref" ggit_ref_spec_ref ::
Ptr RefSpec ->
IO (Ptr RefSpec)
refSpecRef ::
(B.CallStack.HasCallStack, MonadIO m) =>
RefSpec
-> m (Maybe RefSpec)
refSpecRef refspec = liftIO $ do
refspec' <- unsafeManagedPtrGetPtr refspec
result <- ggit_ref_spec_ref refspec'
maybeResult <- convertIfNonNull result $ \result' -> do
result'' <- (newBoxed RefSpec) result'
return result''
touchManagedPtr refspec
return maybeResult
#if defined(ENABLE_OVERLOADING)
data RefSpecRefMethodInfo
instance (signature ~ (m (Maybe RefSpec)), MonadIO m) => O.MethodInfo RefSpecRefMethodInfo RefSpec signature where
overloadedMethod = refSpecRef
#endif
foreign import ccall "ggit_ref_spec_unref" ggit_ref_spec_unref ::
Ptr RefSpec ->
IO ()
refSpecUnref ::
(B.CallStack.HasCallStack, MonadIO m) =>
RefSpec
-> m ()
refSpecUnref refspec = liftIO $ do
refspec' <- unsafeManagedPtrGetPtr refspec
ggit_ref_spec_unref refspec'
touchManagedPtr refspec
return ()
#if defined(ENABLE_OVERLOADING)
data RefSpecUnrefMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo RefSpecUnrefMethodInfo RefSpec signature where
overloadedMethod = refSpecUnref
#endif
#if defined(ENABLE_OVERLOADING)
type family ResolveRefSpecMethod (t :: Symbol) (o :: *) :: * where
ResolveRefSpecMethod "isForced" o = RefSpecIsForcedMethodInfo
ResolveRefSpecMethod "ref" o = RefSpecRefMethodInfo
ResolveRefSpecMethod "unref" o = RefSpecUnrefMethodInfo
ResolveRefSpecMethod "getDestination" o = RefSpecGetDestinationMethodInfo
ResolveRefSpecMethod "getSource" o = RefSpecGetSourceMethodInfo
ResolveRefSpecMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveRefSpecMethod t RefSpec, O.MethodInfo info RefSpec p) => OL.IsLabel t (RefSpec -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod @info
#else
fromLabel _ = O.overloadedMethod @info
#endif
#endif