{- | Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte License : LGPL-2.1 Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc) -} #define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \ && !defined(__HADDOCK_VERSION__)) module GI.Ggit.Functions ( -- * Methods -- ** getFeatures #method:getFeatures# getFeatures , -- ** init #method:init# init , -- ** messagePrettify #method:messagePrettify# messagePrettify , ) 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.Flags as Ggit.Flags -- function ggit_message_prettify -- Args : [Arg {argCName = "message", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the message.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "strip_comments", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "whether to strip comments.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "comment_char", argType = TBasicType TInt8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "comment character.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "ggit_message_prettify" ggit_message_prettify :: CString -> -- message : TBasicType TUTF8 CInt -> -- strip_comments : TBasicType TBoolean Int8 -> -- comment_char : TBasicType TInt8 IO CString {- | Prettify a commit message by removing excess whitespace and making sure the last line ends with a newline. If /@stripComments@/ is 'True', then lines starting with a /@commentChar@/ will be removed. -} messagePrettify :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@message@/: the message. -} -> Bool {- ^ /@stripComments@/: whether to strip comments. -} -> Int8 {- ^ /@commentChar@/: comment character. -} -> m T.Text {- ^ __Returns:__ the prettified message. -} messagePrettify message stripComments commentChar = liftIO $ do message' <- textToCString message let stripComments' = (fromIntegral . fromEnum) stripComments result <- ggit_message_prettify message' stripComments' commentChar checkUnexpectedReturnNULL "messagePrettify" result result' <- cstringToText result freeMem result freeMem message' return result' -- function ggit_init -- Args : [] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "ggit_init" ggit_init :: IO () {- | Call this function before using any other libgit2-glib function. -} init :: (B.CallStack.HasCallStack, MonadIO m) => m () init = liftIO $ do ggit_init return () -- function ggit_get_features -- Args : [] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "Ggit", name = "FeatureFlags"})) -- throws : False -- Skip return : False foreign import ccall "ggit_get_features" ggit_get_features :: IO CUInt {- | Gets the features of the library. -} getFeatures :: (B.CallStack.HasCallStack, MonadIO m) => m [Ggit.Flags.FeatureFlags] {- ^ __Returns:__ a 'GI.Ggit.Flags.FeatureFlags'. -} getFeatures = liftIO $ do result <- ggit_get_features let result' = wordToGFlags result return result'