{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.GLib.Structs.OptionContext
(
OptionContext(..) ,
noOptionContext ,
#if defined(ENABLE_OVERLOADING)
ResolveOptionContextMethod ,
#endif
#if defined(ENABLE_OVERLOADING)
OptionContextAddGroupMethodInfo ,
#endif
optionContextAddGroup ,
#if defined(ENABLE_OVERLOADING)
OptionContextAddMainEntriesMethodInfo ,
#endif
optionContextAddMainEntries ,
#if defined(ENABLE_OVERLOADING)
OptionContextFreeMethodInfo ,
#endif
optionContextFree ,
#if defined(ENABLE_OVERLOADING)
OptionContextGetDescriptionMethodInfo ,
#endif
optionContextGetDescription ,
#if defined(ENABLE_OVERLOADING)
OptionContextGetHelpMethodInfo ,
#endif
optionContextGetHelp ,
#if defined(ENABLE_OVERLOADING)
OptionContextGetHelpEnabledMethodInfo ,
#endif
optionContextGetHelpEnabled ,
#if defined(ENABLE_OVERLOADING)
OptionContextGetIgnoreUnknownOptionsMethodInfo,
#endif
optionContextGetIgnoreUnknownOptions ,
#if defined(ENABLE_OVERLOADING)
OptionContextGetMainGroupMethodInfo ,
#endif
optionContextGetMainGroup ,
#if defined(ENABLE_OVERLOADING)
OptionContextGetStrictPosixMethodInfo ,
#endif
optionContextGetStrictPosix ,
#if defined(ENABLE_OVERLOADING)
OptionContextGetSummaryMethodInfo ,
#endif
optionContextGetSummary ,
#if defined(ENABLE_OVERLOADING)
OptionContextParseMethodInfo ,
#endif
optionContextParse ,
#if defined(ENABLE_OVERLOADING)
OptionContextParseStrvMethodInfo ,
#endif
optionContextParseStrv ,
#if defined(ENABLE_OVERLOADING)
OptionContextSetDescriptionMethodInfo ,
#endif
optionContextSetDescription ,
#if defined(ENABLE_OVERLOADING)
OptionContextSetHelpEnabledMethodInfo ,
#endif
optionContextSetHelpEnabled ,
#if defined(ENABLE_OVERLOADING)
OptionContextSetIgnoreUnknownOptionsMethodInfo,
#endif
optionContextSetIgnoreUnknownOptions ,
#if defined(ENABLE_OVERLOADING)
OptionContextSetMainGroupMethodInfo ,
#endif
optionContextSetMainGroup ,
#if defined(ENABLE_OVERLOADING)
OptionContextSetStrictPosixMethodInfo ,
#endif
optionContextSetStrictPosix ,
#if defined(ENABLE_OVERLOADING)
OptionContextSetSummaryMethodInfo ,
#endif
optionContextSetSummary ,
#if defined(ENABLE_OVERLOADING)
OptionContextSetTranslateFuncMethodInfo ,
#endif
optionContextSetTranslateFunc ,
#if defined(ENABLE_OVERLOADING)
OptionContextSetTranslationDomainMethodInfo,
#endif
optionContextSetTranslationDomain ,
) 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
import qualified GI.GLib.Callbacks as GLib.Callbacks
import {-# SOURCE #-} qualified GI.GLib.Structs.OptionEntry as GLib.OptionEntry
import {-# SOURCE #-} qualified GI.GLib.Structs.OptionGroup as GLib.OptionGroup
newtype OptionContext = OptionContext (ManagedPtr OptionContext)
deriving (OptionContext -> OptionContext -> Bool
(OptionContext -> OptionContext -> Bool)
-> (OptionContext -> OptionContext -> Bool) -> Eq OptionContext
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OptionContext -> OptionContext -> Bool
$c/= :: OptionContext -> OptionContext -> Bool
== :: OptionContext -> OptionContext -> Bool
$c== :: OptionContext -> OptionContext -> Bool
Eq)
instance WrappedPtr OptionContext where
wrappedPtrCalloc :: IO (Ptr OptionContext)
wrappedPtrCalloc = Ptr OptionContext -> IO (Ptr OptionContext)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr OptionContext
forall a. Ptr a
nullPtr
wrappedPtrCopy :: OptionContext -> IO OptionContext
wrappedPtrCopy = OptionContext -> IO OptionContext
forall (m :: * -> *) a. Monad m => a -> m a
return
wrappedPtrFree :: Maybe (GDestroyNotify OptionContext)
wrappedPtrFree = Maybe (GDestroyNotify OptionContext)
forall a. Maybe a
Nothing
noOptionContext :: Maybe OptionContext
noOptionContext :: Maybe OptionContext
noOptionContext = Maybe OptionContext
forall a. Maybe a
Nothing
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList OptionContext
type instance O.AttributeList OptionContext = OptionContextAttributeList
type OptionContextAttributeList = ('[ ] :: [(Symbol, *)])
#endif
foreign import ccall "g_option_context_add_group" g_option_context_add_group ::
Ptr OptionContext ->
Ptr GLib.OptionGroup.OptionGroup ->
IO ()
optionContextAddGroup ::
(B.CallStack.HasCallStack, MonadIO m) =>
OptionContext
-> GLib.OptionGroup.OptionGroup
-> m ()
optionContextAddGroup :: OptionContext -> OptionGroup -> m ()
optionContextAddGroup context :: OptionContext
context group :: OptionGroup
group = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
Ptr OptionContext
context' <- OptionContext -> IO (Ptr OptionContext)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OptionContext
context
Ptr OptionGroup
group' <- OptionGroup -> IO (Ptr OptionGroup)
forall a. (HasCallStack, BoxedObject a) => a -> IO (Ptr a)
B.ManagedPtr.disownBoxed OptionGroup
group
Ptr OptionContext -> Ptr OptionGroup -> IO ()
g_option_context_add_group Ptr OptionContext
context' Ptr OptionGroup
group'
OptionContext -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionContext
context
OptionGroup -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionGroup
group
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data OptionContextAddGroupMethodInfo
instance (signature ~ (GLib.OptionGroup.OptionGroup -> m ()), MonadIO m) => O.MethodInfo OptionContextAddGroupMethodInfo OptionContext signature where
overloadedMethod = optionContextAddGroup
#endif
foreign import ccall "g_option_context_add_main_entries" g_option_context_add_main_entries ::
Ptr OptionContext ->
Ptr GLib.OptionEntry.OptionEntry ->
CString ->
IO ()
optionContextAddMainEntries ::
(B.CallStack.HasCallStack, MonadIO m) =>
OptionContext
-> GLib.OptionEntry.OptionEntry
-> Maybe (T.Text)
-> m ()
optionContextAddMainEntries :: OptionContext -> OptionEntry -> Maybe Text -> m ()
optionContextAddMainEntries context :: OptionContext
context entries :: OptionEntry
entries translationDomain :: Maybe Text
translationDomain = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
Ptr OptionContext
context' <- OptionContext -> IO (Ptr OptionContext)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OptionContext
context
Ptr OptionEntry
entries' <- OptionEntry -> IO (Ptr OptionEntry)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OptionEntry
entries
Ptr CChar
maybeTranslationDomain <- case Maybe Text
translationDomain of
Nothing -> Ptr CChar -> IO (Ptr CChar)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CChar
forall a. Ptr a
nullPtr
Just jTranslationDomain :: Text
jTranslationDomain -> do
Ptr CChar
jTranslationDomain' <- Text -> IO (Ptr CChar)
textToCString Text
jTranslationDomain
Ptr CChar -> IO (Ptr CChar)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CChar
jTranslationDomain'
Ptr OptionContext -> Ptr OptionEntry -> Ptr CChar -> IO ()
g_option_context_add_main_entries Ptr OptionContext
context' Ptr OptionEntry
entries' Ptr CChar
maybeTranslationDomain
OptionContext -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionContext
context
OptionEntry -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionEntry
entries
Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CChar
maybeTranslationDomain
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data OptionContextAddMainEntriesMethodInfo
instance (signature ~ (GLib.OptionEntry.OptionEntry -> Maybe (T.Text) -> m ()), MonadIO m) => O.MethodInfo OptionContextAddMainEntriesMethodInfo OptionContext signature where
overloadedMethod = optionContextAddMainEntries
#endif
foreign import ccall "g_option_context_free" g_option_context_free ::
Ptr OptionContext ->
IO ()
optionContextFree ::
(B.CallStack.HasCallStack, MonadIO m) =>
OptionContext
-> m ()
optionContextFree :: OptionContext -> m ()
optionContextFree context :: OptionContext
context = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
Ptr OptionContext
context' <- OptionContext -> IO (Ptr OptionContext)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OptionContext
context
Ptr OptionContext -> IO ()
g_option_context_free Ptr OptionContext
context'
OptionContext -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionContext
context
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data OptionContextFreeMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo OptionContextFreeMethodInfo OptionContext signature where
overloadedMethod = optionContextFree
#endif
foreign import ccall "g_option_context_get_description" g_option_context_get_description ::
Ptr OptionContext ->
IO CString
optionContextGetDescription ::
(B.CallStack.HasCallStack, MonadIO m) =>
OptionContext
-> m T.Text
optionContextGetDescription :: OptionContext -> m Text
optionContextGetDescription context :: OptionContext
context = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
Ptr OptionContext
context' <- OptionContext -> IO (Ptr OptionContext)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OptionContext
context
Ptr CChar
result <- Ptr OptionContext -> IO (Ptr CChar)
g_option_context_get_description Ptr OptionContext
context'
Text -> Ptr CChar -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "optionContextGetDescription" Ptr CChar
result
Text
result' <- HasCallStack => Ptr CChar -> IO Text
Ptr CChar -> IO Text
cstringToText Ptr CChar
result
OptionContext -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionContext
context
Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'
#if defined(ENABLE_OVERLOADING)
data OptionContextGetDescriptionMethodInfo
instance (signature ~ (m T.Text), MonadIO m) => O.MethodInfo OptionContextGetDescriptionMethodInfo OptionContext signature where
overloadedMethod = optionContextGetDescription
#endif
foreign import ccall "g_option_context_get_help" g_option_context_get_help ::
Ptr OptionContext ->
CInt ->
Ptr GLib.OptionGroup.OptionGroup ->
IO CString
optionContextGetHelp ::
(B.CallStack.HasCallStack, MonadIO m) =>
OptionContext
-> Bool
-> Maybe (GLib.OptionGroup.OptionGroup)
-> m T.Text
optionContextGetHelp :: OptionContext -> Bool -> Maybe OptionGroup -> m Text
optionContextGetHelp context :: OptionContext
context mainHelp :: Bool
mainHelp group :: Maybe OptionGroup
group = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
Ptr OptionContext
context' <- OptionContext -> IO (Ptr OptionContext)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OptionContext
context
let mainHelp' :: CInt
mainHelp' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Bool -> Int) -> Bool -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Int
forall a. Enum a => a -> Int
fromEnum) Bool
mainHelp
Ptr OptionGroup
maybeGroup <- case Maybe OptionGroup
group of
Nothing -> Ptr OptionGroup -> IO (Ptr OptionGroup)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr OptionGroup
forall a. Ptr a
nullPtr
Just jGroup :: OptionGroup
jGroup -> do
Ptr OptionGroup
jGroup' <- OptionGroup -> IO (Ptr OptionGroup)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OptionGroup
jGroup
Ptr OptionGroup -> IO (Ptr OptionGroup)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr OptionGroup
jGroup'
Ptr CChar
result <- Ptr OptionContext -> CInt -> Ptr OptionGroup -> IO (Ptr CChar)
g_option_context_get_help Ptr OptionContext
context' CInt
mainHelp' Ptr OptionGroup
maybeGroup
Text -> Ptr CChar -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "optionContextGetHelp" Ptr CChar
result
Text
result' <- HasCallStack => Ptr CChar -> IO Text
Ptr CChar -> IO Text
cstringToText Ptr CChar
result
Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CChar
result
OptionContext -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionContext
context
Maybe OptionGroup -> (OptionGroup -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe OptionGroup
group OptionGroup -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'
#if defined(ENABLE_OVERLOADING)
data OptionContextGetHelpMethodInfo
instance (signature ~ (Bool -> Maybe (GLib.OptionGroup.OptionGroup) -> m T.Text), MonadIO m) => O.MethodInfo OptionContextGetHelpMethodInfo OptionContext signature where
overloadedMethod = optionContextGetHelp
#endif
foreign import ccall "g_option_context_get_help_enabled" g_option_context_get_help_enabled ::
Ptr OptionContext ->
IO CInt
optionContextGetHelpEnabled ::
(B.CallStack.HasCallStack, MonadIO m) =>
OptionContext
-> m Bool
optionContextGetHelpEnabled :: OptionContext -> m Bool
optionContextGetHelpEnabled context :: OptionContext
context = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
Ptr OptionContext
context' <- OptionContext -> IO (Ptr OptionContext)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OptionContext
context
CInt
result <- Ptr OptionContext -> IO CInt
g_option_context_get_help_enabled Ptr OptionContext
context'
let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
OptionContext -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionContext
context
Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'
#if defined(ENABLE_OVERLOADING)
data OptionContextGetHelpEnabledMethodInfo
instance (signature ~ (m Bool), MonadIO m) => O.MethodInfo OptionContextGetHelpEnabledMethodInfo OptionContext signature where
overloadedMethod = optionContextGetHelpEnabled
#endif
foreign import ccall "g_option_context_get_ignore_unknown_options" g_option_context_get_ignore_unknown_options ::
Ptr OptionContext ->
IO CInt
optionContextGetIgnoreUnknownOptions ::
(B.CallStack.HasCallStack, MonadIO m) =>
OptionContext
-> m Bool
optionContextGetIgnoreUnknownOptions :: OptionContext -> m Bool
optionContextGetIgnoreUnknownOptions context :: OptionContext
context = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
Ptr OptionContext
context' <- OptionContext -> IO (Ptr OptionContext)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OptionContext
context
CInt
result <- Ptr OptionContext -> IO CInt
g_option_context_get_ignore_unknown_options Ptr OptionContext
context'
let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
OptionContext -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionContext
context
Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'
#if defined(ENABLE_OVERLOADING)
data OptionContextGetIgnoreUnknownOptionsMethodInfo
instance (signature ~ (m Bool), MonadIO m) => O.MethodInfo OptionContextGetIgnoreUnknownOptionsMethodInfo OptionContext signature where
overloadedMethod = optionContextGetIgnoreUnknownOptions
#endif
foreign import ccall "g_option_context_get_main_group" g_option_context_get_main_group ::
Ptr OptionContext ->
IO (Ptr GLib.OptionGroup.OptionGroup)
optionContextGetMainGroup ::
(B.CallStack.HasCallStack, MonadIO m) =>
OptionContext
-> m GLib.OptionGroup.OptionGroup
optionContextGetMainGroup :: OptionContext -> m OptionGroup
optionContextGetMainGroup context :: OptionContext
context = IO OptionGroup -> m OptionGroup
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO OptionGroup -> m OptionGroup)
-> IO OptionGroup -> m OptionGroup
forall a b. (a -> b) -> a -> b
$ do
Ptr OptionContext
context' <- OptionContext -> IO (Ptr OptionContext)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OptionContext
context
Ptr OptionGroup
result <- Ptr OptionContext -> IO (Ptr OptionGroup)
g_option_context_get_main_group Ptr OptionContext
context'
Text -> Ptr OptionGroup -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "optionContextGetMainGroup" Ptr OptionGroup
result
OptionGroup
result' <- ((ManagedPtr OptionGroup -> OptionGroup)
-> Ptr OptionGroup -> IO OptionGroup
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr OptionGroup -> OptionGroup
GLib.OptionGroup.OptionGroup) Ptr OptionGroup
result
OptionContext -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionContext
context
OptionGroup -> IO OptionGroup
forall (m :: * -> *) a. Monad m => a -> m a
return OptionGroup
result'
#if defined(ENABLE_OVERLOADING)
data OptionContextGetMainGroupMethodInfo
instance (signature ~ (m GLib.OptionGroup.OptionGroup), MonadIO m) => O.MethodInfo OptionContextGetMainGroupMethodInfo OptionContext signature where
overloadedMethod = optionContextGetMainGroup
#endif
foreign import ccall "g_option_context_get_strict_posix" g_option_context_get_strict_posix ::
Ptr OptionContext ->
IO CInt
optionContextGetStrictPosix ::
(B.CallStack.HasCallStack, MonadIO m) =>
OptionContext
-> m Bool
optionContextGetStrictPosix :: OptionContext -> m Bool
optionContextGetStrictPosix context :: OptionContext
context = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
Ptr OptionContext
context' <- OptionContext -> IO (Ptr OptionContext)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OptionContext
context
CInt
result <- Ptr OptionContext -> IO CInt
g_option_context_get_strict_posix Ptr OptionContext
context'
let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
OptionContext -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionContext
context
Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'
#if defined(ENABLE_OVERLOADING)
data OptionContextGetStrictPosixMethodInfo
instance (signature ~ (m Bool), MonadIO m) => O.MethodInfo OptionContextGetStrictPosixMethodInfo OptionContext signature where
overloadedMethod = optionContextGetStrictPosix
#endif
foreign import ccall "g_option_context_get_summary" g_option_context_get_summary ::
Ptr OptionContext ->
IO CString
optionContextGetSummary ::
(B.CallStack.HasCallStack, MonadIO m) =>
OptionContext
-> m T.Text
optionContextGetSummary :: OptionContext -> m Text
optionContextGetSummary context :: OptionContext
context = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
Ptr OptionContext
context' <- OptionContext -> IO (Ptr OptionContext)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OptionContext
context
Ptr CChar
result <- Ptr OptionContext -> IO (Ptr CChar)
g_option_context_get_summary Ptr OptionContext
context'
Text -> Ptr CChar -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "optionContextGetSummary" Ptr CChar
result
Text
result' <- HasCallStack => Ptr CChar -> IO Text
Ptr CChar -> IO Text
cstringToText Ptr CChar
result
OptionContext -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionContext
context
Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'
#if defined(ENABLE_OVERLOADING)
data OptionContextGetSummaryMethodInfo
instance (signature ~ (m T.Text), MonadIO m) => O.MethodInfo OptionContextGetSummaryMethodInfo OptionContext signature where
overloadedMethod = optionContextGetSummary
#endif
foreign import ccall "g_option_context_parse" g_option_context_parse ::
Ptr OptionContext ->
Ptr Int32 ->
Ptr (Ptr CString) ->
Ptr (Ptr GError) ->
IO CInt
optionContextParse ::
(B.CallStack.HasCallStack, MonadIO m) =>
OptionContext
-> Maybe ([T.Text])
-> m ((Maybe [T.Text]))
optionContextParse :: OptionContext -> Maybe [Text] -> m (Maybe [Text])
optionContextParse context :: OptionContext
context argv :: Maybe [Text]
argv = IO (Maybe [Text]) -> m (Maybe [Text])
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe [Text]) -> m (Maybe [Text]))
-> IO (Maybe [Text]) -> m (Maybe [Text])
forall a b. (a -> b) -> a -> b
$ do
let argc :: Int32
argc = case Maybe [Text]
argv of
Nothing -> 0
Just jArgv :: [Text]
jArgv -> Int -> Int32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Int32) -> Int -> Int32
forall a b. (a -> b) -> a -> b
$ [Text] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Text]
jArgv
Ptr OptionContext
context' <- OptionContext -> IO (Ptr OptionContext)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OptionContext
context
Ptr Int32
argc' <- IO (Ptr Int32)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Int32)
Ptr Int32 -> Int32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr Int32
argc' Int32
argc
Ptr (Ptr CChar)
maybeArgv <- case Maybe [Text]
argv of
Nothing -> Ptr (Ptr CChar) -> IO (Ptr (Ptr CChar))
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr (Ptr CChar)
forall a. Ptr a
nullPtr
Just jArgv :: [Text]
jArgv -> do
Ptr (Ptr CChar)
jArgv' <- [Text] -> IO (Ptr (Ptr CChar))
packUTF8CArray [Text]
jArgv
Ptr (Ptr CChar) -> IO (Ptr (Ptr CChar))
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr (Ptr CChar)
jArgv'
Ptr (Ptr (Ptr CChar))
maybeArgv' <- IO (Ptr (Ptr (Ptr CChar)))
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr (Ptr CString))
Ptr (Ptr (Ptr CChar)) -> Ptr (Ptr CChar) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (Ptr (Ptr CChar))
maybeArgv' Ptr (Ptr CChar)
maybeArgv
IO (Maybe [Text]) -> IO () -> IO (Maybe [Text])
forall a b. IO a -> IO b -> IO a
onException (do
CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr OptionContext
-> Ptr Int32
-> Ptr (Ptr (Ptr CChar))
-> Ptr (Ptr GError)
-> IO CInt
g_option_context_parse Ptr OptionContext
context' Ptr Int32
argc' Ptr (Ptr (Ptr CChar))
maybeArgv'
Int32
argc'' <- Ptr Int32 -> IO Int32
forall a. Storable a => Ptr a -> IO a
peek Ptr Int32
argc'
Ptr (Ptr CChar)
maybeArgv'' <- Ptr (Ptr (Ptr CChar)) -> IO (Ptr (Ptr CChar))
forall a. Storable a => Ptr a -> IO a
peek Ptr (Ptr (Ptr CChar))
maybeArgv'
Maybe [Text]
maybeMaybeArgv'' <- Ptr (Ptr CChar)
-> (Ptr (Ptr CChar) -> IO [Text]) -> IO (Maybe [Text])
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr (Ptr CChar)
maybeArgv'' ((Ptr (Ptr CChar) -> IO [Text]) -> IO (Maybe [Text]))
-> (Ptr (Ptr CChar) -> IO [Text]) -> IO (Maybe [Text])
forall a b. (a -> b) -> a -> b
$ \maybeArgv''' :: Ptr (Ptr CChar)
maybeArgv''' -> do
[Text]
maybeArgv'''' <- (Int32 -> Ptr (Ptr CChar) -> IO [Text]
forall a.
(HasCallStack, Integral a) =>
a -> Ptr (Ptr CChar) -> IO [Text]
unpackUTF8CArrayWithLength Int32
argc'') Ptr (Ptr CChar)
maybeArgv'''
(Int32 -> (Ptr CChar -> IO ()) -> Ptr (Ptr CChar) -> IO ()
forall a b c.
(Storable a, Integral b) =>
b -> (a -> IO c) -> Ptr a -> IO ()
mapCArrayWithLength Int32
argc'') Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr CChar)
maybeArgv'''
Ptr (Ptr CChar) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr CChar)
maybeArgv'''
[Text] -> IO [Text]
forall (m :: * -> *) a. Monad m => a -> m a
return [Text]
maybeArgv''''
OptionContext -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionContext
context
Ptr Int32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Int32
argc'
Ptr (Ptr (Ptr CChar)) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr (Ptr CChar))
maybeArgv'
Maybe [Text] -> IO (Maybe [Text])
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe [Text]
maybeMaybeArgv''
) (do
Ptr Int32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Int32
argc'
Ptr (Ptr (Ptr CChar)) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr (Ptr CChar))
maybeArgv'
)
#if defined(ENABLE_OVERLOADING)
data OptionContextParseMethodInfo
instance (signature ~ (Maybe ([T.Text]) -> m ((Maybe [T.Text]))), MonadIO m) => O.MethodInfo OptionContextParseMethodInfo OptionContext signature where
overloadedMethod = optionContextParse
#endif
foreign import ccall "g_option_context_parse_strv" g_option_context_parse_strv ::
Ptr OptionContext ->
Ptr (Ptr CString) ->
Ptr (Ptr GError) ->
IO CInt
optionContextParseStrv ::
(B.CallStack.HasCallStack, MonadIO m) =>
OptionContext
-> [T.Text]
-> m ([T.Text])
optionContextParseStrv :: OptionContext -> [Text] -> m [Text]
optionContextParseStrv context :: OptionContext
context arguments :: [Text]
arguments = IO [Text] -> m [Text]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Text] -> m [Text]) -> IO [Text] -> m [Text]
forall a b. (a -> b) -> a -> b
$ do
Ptr OptionContext
context' <- OptionContext -> IO (Ptr OptionContext)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OptionContext
context
Ptr (Ptr CChar)
arguments' <- [Text] -> IO (Ptr (Ptr CChar))
packZeroTerminatedUTF8CArray [Text]
arguments
Ptr (Ptr (Ptr CChar))
arguments'' <- IO (Ptr (Ptr (Ptr CChar)))
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr (Ptr CString))
Ptr (Ptr (Ptr CChar)) -> Ptr (Ptr CChar) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (Ptr (Ptr CChar))
arguments'' Ptr (Ptr CChar)
arguments'
IO [Text] -> IO () -> IO [Text]
forall a b. IO a -> IO b -> IO a
onException (do
CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr OptionContext
-> Ptr (Ptr (Ptr CChar)) -> Ptr (Ptr GError) -> IO CInt
g_option_context_parse_strv Ptr OptionContext
context' Ptr (Ptr (Ptr CChar))
arguments''
Ptr (Ptr CChar)
arguments''' <- Ptr (Ptr (Ptr CChar)) -> IO (Ptr (Ptr CChar))
forall a. Storable a => Ptr a -> IO a
peek Ptr (Ptr (Ptr CChar))
arguments''
[Text]
arguments'''' <- HasCallStack => Ptr (Ptr CChar) -> IO [Text]
Ptr (Ptr CChar) -> IO [Text]
unpackZeroTerminatedUTF8CArray Ptr (Ptr CChar)
arguments'''
(Ptr CChar -> IO ()) -> Ptr (Ptr CChar) -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr CChar)
arguments'''
Ptr (Ptr CChar) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr CChar)
arguments'''
OptionContext -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionContext
context
Ptr (Ptr (Ptr CChar)) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr (Ptr CChar))
arguments''
[Text] -> IO [Text]
forall (m :: * -> *) a. Monad m => a -> m a
return [Text]
arguments''''
) (do
Ptr (Ptr (Ptr CChar)) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr (Ptr CChar))
arguments''
)
#if defined(ENABLE_OVERLOADING)
data OptionContextParseStrvMethodInfo
instance (signature ~ ([T.Text] -> m ([T.Text])), MonadIO m) => O.MethodInfo OptionContextParseStrvMethodInfo OptionContext signature where
overloadedMethod = optionContextParseStrv
#endif
foreign import ccall "g_option_context_set_description" g_option_context_set_description ::
Ptr OptionContext ->
CString ->
IO ()
optionContextSetDescription ::
(B.CallStack.HasCallStack, MonadIO m) =>
OptionContext
-> Maybe (T.Text)
-> m ()
optionContextSetDescription :: OptionContext -> Maybe Text -> m ()
optionContextSetDescription context :: OptionContext
context description :: Maybe Text
description = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
Ptr OptionContext
context' <- OptionContext -> IO (Ptr OptionContext)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OptionContext
context
Ptr CChar
maybeDescription <- case Maybe Text
description of
Nothing -> Ptr CChar -> IO (Ptr CChar)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CChar
forall a. Ptr a
nullPtr
Just jDescription :: Text
jDescription -> do
Ptr CChar
jDescription' <- Text -> IO (Ptr CChar)
textToCString Text
jDescription
Ptr CChar -> IO (Ptr CChar)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CChar
jDescription'
Ptr OptionContext -> Ptr CChar -> IO ()
g_option_context_set_description Ptr OptionContext
context' Ptr CChar
maybeDescription
OptionContext -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionContext
context
Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CChar
maybeDescription
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data OptionContextSetDescriptionMethodInfo
instance (signature ~ (Maybe (T.Text) -> m ()), MonadIO m) => O.MethodInfo OptionContextSetDescriptionMethodInfo OptionContext signature where
overloadedMethod = optionContextSetDescription
#endif
foreign import ccall "g_option_context_set_help_enabled" g_option_context_set_help_enabled ::
Ptr OptionContext ->
CInt ->
IO ()
optionContextSetHelpEnabled ::
(B.CallStack.HasCallStack, MonadIO m) =>
OptionContext
-> Bool
-> m ()
optionContextSetHelpEnabled :: OptionContext -> Bool -> m ()
optionContextSetHelpEnabled context :: OptionContext
context helpEnabled :: Bool
helpEnabled = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
Ptr OptionContext
context' <- OptionContext -> IO (Ptr OptionContext)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OptionContext
context
let helpEnabled' :: CInt
helpEnabled' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Bool -> Int) -> Bool -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Int
forall a. Enum a => a -> Int
fromEnum) Bool
helpEnabled
Ptr OptionContext -> CInt -> IO ()
g_option_context_set_help_enabled Ptr OptionContext
context' CInt
helpEnabled'
OptionContext -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionContext
context
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data OptionContextSetHelpEnabledMethodInfo
instance (signature ~ (Bool -> m ()), MonadIO m) => O.MethodInfo OptionContextSetHelpEnabledMethodInfo OptionContext signature where
overloadedMethod = optionContextSetHelpEnabled
#endif
foreign import ccall "g_option_context_set_ignore_unknown_options" g_option_context_set_ignore_unknown_options ::
Ptr OptionContext ->
CInt ->
IO ()
optionContextSetIgnoreUnknownOptions ::
(B.CallStack.HasCallStack, MonadIO m) =>
OptionContext
-> Bool
-> m ()
optionContextSetIgnoreUnknownOptions :: OptionContext -> Bool -> m ()
optionContextSetIgnoreUnknownOptions context :: OptionContext
context ignoreUnknown :: Bool
ignoreUnknown = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
Ptr OptionContext
context' <- OptionContext -> IO (Ptr OptionContext)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OptionContext
context
let ignoreUnknown' :: CInt
ignoreUnknown' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Bool -> Int) -> Bool -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Int
forall a. Enum a => a -> Int
fromEnum) Bool
ignoreUnknown
Ptr OptionContext -> CInt -> IO ()
g_option_context_set_ignore_unknown_options Ptr OptionContext
context' CInt
ignoreUnknown'
OptionContext -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionContext
context
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data OptionContextSetIgnoreUnknownOptionsMethodInfo
instance (signature ~ (Bool -> m ()), MonadIO m) => O.MethodInfo OptionContextSetIgnoreUnknownOptionsMethodInfo OptionContext signature where
overloadedMethod = optionContextSetIgnoreUnknownOptions
#endif
foreign import ccall "g_option_context_set_main_group" g_option_context_set_main_group ::
Ptr OptionContext ->
Ptr GLib.OptionGroup.OptionGroup ->
IO ()
optionContextSetMainGroup ::
(B.CallStack.HasCallStack, MonadIO m) =>
OptionContext
-> GLib.OptionGroup.OptionGroup
-> m ()
optionContextSetMainGroup :: OptionContext -> OptionGroup -> m ()
optionContextSetMainGroup context :: OptionContext
context group :: OptionGroup
group = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
Ptr OptionContext
context' <- OptionContext -> IO (Ptr OptionContext)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OptionContext
context
Ptr OptionGroup
group' <- OptionGroup -> IO (Ptr OptionGroup)
forall a. (HasCallStack, BoxedObject a) => a -> IO (Ptr a)
B.ManagedPtr.disownBoxed OptionGroup
group
Ptr OptionContext -> Ptr OptionGroup -> IO ()
g_option_context_set_main_group Ptr OptionContext
context' Ptr OptionGroup
group'
OptionContext -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionContext
context
OptionGroup -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionGroup
group
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data OptionContextSetMainGroupMethodInfo
instance (signature ~ (GLib.OptionGroup.OptionGroup -> m ()), MonadIO m) => O.MethodInfo OptionContextSetMainGroupMethodInfo OptionContext signature where
overloadedMethod = optionContextSetMainGroup
#endif
foreign import ccall "g_option_context_set_strict_posix" g_option_context_set_strict_posix ::
Ptr OptionContext ->
CInt ->
IO ()
optionContextSetStrictPosix ::
(B.CallStack.HasCallStack, MonadIO m) =>
OptionContext
-> Bool
-> m ()
optionContextSetStrictPosix :: OptionContext -> Bool -> m ()
optionContextSetStrictPosix context :: OptionContext
context strictPosix :: Bool
strictPosix = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
Ptr OptionContext
context' <- OptionContext -> IO (Ptr OptionContext)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OptionContext
context
let strictPosix' :: CInt
strictPosix' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Bool -> Int) -> Bool -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Int
forall a. Enum a => a -> Int
fromEnum) Bool
strictPosix
Ptr OptionContext -> CInt -> IO ()
g_option_context_set_strict_posix Ptr OptionContext
context' CInt
strictPosix'
OptionContext -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionContext
context
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data OptionContextSetStrictPosixMethodInfo
instance (signature ~ (Bool -> m ()), MonadIO m) => O.MethodInfo OptionContextSetStrictPosixMethodInfo OptionContext signature where
overloadedMethod = optionContextSetStrictPosix
#endif
foreign import ccall "g_option_context_set_summary" g_option_context_set_summary ::
Ptr OptionContext ->
CString ->
IO ()
optionContextSetSummary ::
(B.CallStack.HasCallStack, MonadIO m) =>
OptionContext
-> Maybe (T.Text)
-> m ()
optionContextSetSummary :: OptionContext -> Maybe Text -> m ()
optionContextSetSummary context :: OptionContext
context summary :: Maybe Text
summary = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
Ptr OptionContext
context' <- OptionContext -> IO (Ptr OptionContext)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OptionContext
context
Ptr CChar
maybeSummary <- case Maybe Text
summary of
Nothing -> Ptr CChar -> IO (Ptr CChar)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CChar
forall a. Ptr a
nullPtr
Just jSummary :: Text
jSummary -> do
Ptr CChar
jSummary' <- Text -> IO (Ptr CChar)
textToCString Text
jSummary
Ptr CChar -> IO (Ptr CChar)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CChar
jSummary'
Ptr OptionContext -> Ptr CChar -> IO ()
g_option_context_set_summary Ptr OptionContext
context' Ptr CChar
maybeSummary
OptionContext -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionContext
context
Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CChar
maybeSummary
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data OptionContextSetSummaryMethodInfo
instance (signature ~ (Maybe (T.Text) -> m ()), MonadIO m) => O.MethodInfo OptionContextSetSummaryMethodInfo OptionContext signature where
overloadedMethod = optionContextSetSummary
#endif
foreign import ccall "g_option_context_set_translate_func" g_option_context_set_translate_func ::
Ptr OptionContext ->
FunPtr GLib.Callbacks.C_TranslateFunc ->
Ptr () ->
FunPtr GLib.Callbacks.C_DestroyNotify ->
IO ()
optionContextSetTranslateFunc ::
(B.CallStack.HasCallStack, MonadIO m) =>
OptionContext
-> Maybe (GLib.Callbacks.TranslateFunc)
-> m ()
optionContextSetTranslateFunc :: OptionContext -> Maybe TranslateFunc -> m ()
optionContextSetTranslateFunc context :: OptionContext
context func :: Maybe TranslateFunc
func = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
Ptr OptionContext
context' <- OptionContext -> IO (Ptr OptionContext)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OptionContext
context
FunPtr C_TranslateFunc
maybeFunc <- case Maybe TranslateFunc
func of
Nothing -> FunPtr C_TranslateFunc -> IO (FunPtr C_TranslateFunc)
forall (m :: * -> *) a. Monad m => a -> m a
return (Ptr Any -> FunPtr C_TranslateFunc
forall a b. Ptr a -> FunPtr b
castPtrToFunPtr Ptr Any
forall a. Ptr a
nullPtr)
Just jFunc :: TranslateFunc
jFunc -> do
FunPtr C_TranslateFunc
jFunc' <- C_TranslateFunc -> IO (FunPtr C_TranslateFunc)
GLib.Callbacks.mk_TranslateFunc (Maybe (Ptr (FunPtr C_TranslateFunc))
-> TranslateFunc -> C_TranslateFunc
GLib.Callbacks.wrap_TranslateFunc Maybe (Ptr (FunPtr C_TranslateFunc))
forall a. Maybe a
Nothing TranslateFunc
jFunc)
FunPtr C_TranslateFunc -> IO (FunPtr C_TranslateFunc)
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_TranslateFunc
jFunc'
let data_ :: Ptr ()
data_ = FunPtr C_TranslateFunc -> Ptr ()
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr FunPtr C_TranslateFunc
maybeFunc
let destroyNotify :: FunPtr (Ptr a -> IO ())
destroyNotify = FunPtr (Ptr a -> IO ())
forall a. FunPtr (Ptr a -> IO ())
safeFreeFunPtrPtr
Ptr OptionContext
-> FunPtr C_TranslateFunc
-> Ptr ()
-> FunPtr C_DestroyNotify
-> IO ()
g_option_context_set_translate_func Ptr OptionContext
context' FunPtr C_TranslateFunc
maybeFunc Ptr ()
data_ FunPtr C_DestroyNotify
forall a. FunPtr (Ptr a -> IO ())
destroyNotify
OptionContext -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionContext
context
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data OptionContextSetTranslateFuncMethodInfo
instance (signature ~ (Maybe (GLib.Callbacks.TranslateFunc) -> m ()), MonadIO m) => O.MethodInfo OptionContextSetTranslateFuncMethodInfo OptionContext signature where
overloadedMethod = optionContextSetTranslateFunc
#endif
foreign import ccall "g_option_context_set_translation_domain" g_option_context_set_translation_domain ::
Ptr OptionContext ->
CString ->
IO ()
optionContextSetTranslationDomain ::
(B.CallStack.HasCallStack, MonadIO m) =>
OptionContext
-> T.Text
-> m ()
optionContextSetTranslationDomain :: OptionContext -> Text -> m ()
optionContextSetTranslationDomain context :: OptionContext
context domain :: Text
domain = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
Ptr OptionContext
context' <- OptionContext -> IO (Ptr OptionContext)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OptionContext
context
Ptr CChar
domain' <- Text -> IO (Ptr CChar)
textToCString Text
domain
Ptr OptionContext -> Ptr CChar -> IO ()
g_option_context_set_translation_domain Ptr OptionContext
context' Ptr CChar
domain'
OptionContext -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionContext
context
Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CChar
domain'
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data OptionContextSetTranslationDomainMethodInfo
instance (signature ~ (T.Text -> m ()), MonadIO m) => O.MethodInfo OptionContextSetTranslationDomainMethodInfo OptionContext signature where
overloadedMethod = optionContextSetTranslationDomain
#endif
#if defined(ENABLE_OVERLOADING)
type family ResolveOptionContextMethod (t :: Symbol) (o :: *) :: * where
ResolveOptionContextMethod "addGroup" o = OptionContextAddGroupMethodInfo
ResolveOptionContextMethod "addMainEntries" o = OptionContextAddMainEntriesMethodInfo
ResolveOptionContextMethod "free" o = OptionContextFreeMethodInfo
ResolveOptionContextMethod "parse" o = OptionContextParseMethodInfo
ResolveOptionContextMethod "parseStrv" o = OptionContextParseStrvMethodInfo
ResolveOptionContextMethod "getDescription" o = OptionContextGetDescriptionMethodInfo
ResolveOptionContextMethod "getHelp" o = OptionContextGetHelpMethodInfo
ResolveOptionContextMethod "getHelpEnabled" o = OptionContextGetHelpEnabledMethodInfo
ResolveOptionContextMethod "getIgnoreUnknownOptions" o = OptionContextGetIgnoreUnknownOptionsMethodInfo
ResolveOptionContextMethod "getMainGroup" o = OptionContextGetMainGroupMethodInfo
ResolveOptionContextMethod "getStrictPosix" o = OptionContextGetStrictPosixMethodInfo
ResolveOptionContextMethod "getSummary" o = OptionContextGetSummaryMethodInfo
ResolveOptionContextMethod "setDescription" o = OptionContextSetDescriptionMethodInfo
ResolveOptionContextMethod "setHelpEnabled" o = OptionContextSetHelpEnabledMethodInfo
ResolveOptionContextMethod "setIgnoreUnknownOptions" o = OptionContextSetIgnoreUnknownOptionsMethodInfo
ResolveOptionContextMethod "setMainGroup" o = OptionContextSetMainGroupMethodInfo
ResolveOptionContextMethod "setStrictPosix" o = OptionContextSetStrictPosixMethodInfo
ResolveOptionContextMethod "setSummary" o = OptionContextSetSummaryMethodInfo
ResolveOptionContextMethod "setTranslateFunc" o = OptionContextSetTranslateFuncMethodInfo
ResolveOptionContextMethod "setTranslationDomain" o = OptionContextSetTranslationDomainMethodInfo
ResolveOptionContextMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveOptionContextMethod t OptionContext, O.MethodInfo info OptionContext p) => OL.IsLabel t (OptionContext -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod @info
#else
fromLabel _ = O.overloadedMethod @info
#endif
#endif