#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
&& !defined(__HADDOCK_VERSION__))
module GI.Ggit.Structs.RefSpec
(
RefSpec(..) ,
noRefSpec ,
#if ENABLE_OVERLOADING
RefSpecGetDestinationMethodInfo ,
#endif
refSpecGetDestination ,
#if ENABLE_OVERLOADING
RefSpecGetSourceMethodInfo ,
#endif
refSpecGetSource ,
#if ENABLE_OVERLOADING
RefSpecIsForcedMethodInfo ,
#endif
refSpecIsForced ,
#if ENABLE_OVERLOADING
RefSpecRefMethodInfo ,
#endif
refSpecRef ,
#if 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.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)
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
noRefSpec :: Maybe RefSpec
noRefSpec = Nothing
#if 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 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 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 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 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 ENABLE_OVERLOADING
data RefSpecUnrefMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo RefSpecUnrefMethodInfo RefSpec signature where
overloadedMethod _ = refSpecUnref
#endif
#if 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 (O.MethodProxy :: O.MethodProxy info)
#else
fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif
#endif