{-# LANGUAGE TypeApplications #-}
#if !defined(__HADDOCK_VERSION__)
#define ENABLE_OVERLOADING
#endif
module GI.GLib.Structs.PatternSpec
(
PatternSpec(..) ,
#if defined(ENABLE_OVERLOADING)
ResolvePatternSpecMethod ,
#endif
#if defined(ENABLE_OVERLOADING)
PatternSpecCopyMethodInfo ,
#endif
patternSpecCopy ,
#if defined(ENABLE_OVERLOADING)
PatternSpecEqualMethodInfo ,
#endif
patternSpecEqual ,
#if defined(ENABLE_OVERLOADING)
PatternSpecFreeMethodInfo ,
#endif
patternSpecFree ,
#if defined(ENABLE_OVERLOADING)
PatternSpecMatchMethodInfo ,
#endif
patternSpecMatch ,
#if defined(ENABLE_OVERLOADING)
PatternSpecMatchStringMethodInfo ,
#endif
patternSpecMatchString ,
patternSpecNew ,
) 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.BasicTypes as B.Types
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GArray as B.GArray
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GHashTable as B.GHT
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 Control.Monad.IO.Class as MIO
import qualified Data.Coerce as Coerce
import qualified Data.Text as T
import qualified Data.Kind as DK
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 GHC.Records as R
import qualified Data.Word as DW
import qualified Data.Int as DI
import qualified System.Posix.Types as SPT
import qualified Foreign.C.Types as FCT
#if MIN_VERSION_base(4,18,0)
#else
#endif
newtype PatternSpec = PatternSpec (SP.ManagedPtr PatternSpec)
deriving (PatternSpec -> PatternSpec -> Bool
(PatternSpec -> PatternSpec -> Bool)
-> (PatternSpec -> PatternSpec -> Bool) -> Eq PatternSpec
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PatternSpec -> PatternSpec -> Bool
== :: PatternSpec -> PatternSpec -> Bool
$c/= :: PatternSpec -> PatternSpec -> Bool
/= :: PatternSpec -> PatternSpec -> Bool
Eq)
instance SP.ManagedPtrNewtype PatternSpec where
toManagedPtr :: PatternSpec -> ManagedPtr PatternSpec
toManagedPtr (PatternSpec ManagedPtr PatternSpec
p) = ManagedPtr PatternSpec
p
foreign import ccall "g_pattern_spec_get_type" c_g_pattern_spec_get_type ::
IO GType
type instance O.ParentTypes PatternSpec = '[]
instance O.HasParentTypes PatternSpec
instance B.Types.TypedObject PatternSpec where
glibType :: IO GType
glibType = IO GType
c_g_pattern_spec_get_type
instance B.Types.GBoxed PatternSpec
instance B.GValue.IsGValue (Maybe PatternSpec) where
gvalueGType_ :: IO GType
gvalueGType_ = IO GType
c_g_pattern_spec_get_type
gvalueSet_ :: Ptr GValue -> Maybe PatternSpec -> IO ()
gvalueSet_ Ptr GValue
gv Maybe PatternSpec
P.Nothing = Ptr GValue -> Ptr PatternSpec -> IO ()
forall a. Ptr GValue -> Ptr a -> IO ()
B.GValue.set_boxed Ptr GValue
gv (Ptr PatternSpec
forall a. Ptr a
FP.nullPtr :: FP.Ptr PatternSpec)
gvalueSet_ Ptr GValue
gv (P.Just PatternSpec
obj) = PatternSpec -> (Ptr PatternSpec -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr PatternSpec
obj (Ptr GValue -> Ptr PatternSpec -> IO ()
forall a. Ptr GValue -> Ptr a -> IO ()
B.GValue.set_boxed Ptr GValue
gv)
gvalueGet_ :: Ptr GValue -> IO (Maybe PatternSpec)
gvalueGet_ Ptr GValue
gv = do
ptr <- Ptr GValue -> IO (Ptr PatternSpec)
forall b. Ptr GValue -> IO (Ptr b)
B.GValue.get_boxed Ptr GValue
gv :: IO (Ptr PatternSpec)
if ptr /= FP.nullPtr
then P.Just <$> B.ManagedPtr.newBoxed PatternSpec ptr
else return P.Nothing
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList PatternSpec
type instance O.AttributeList PatternSpec = PatternSpecAttributeList
type PatternSpecAttributeList = ('[ ] :: [(Symbol, DK.Type)])
#endif
foreign import ccall "g_pattern_spec_new" g_pattern_spec_new ::
CString ->
IO (Ptr PatternSpec)
patternSpecNew ::
(B.CallStack.HasCallStack, MonadIO m) =>
T.Text
-> m PatternSpec
patternSpecNew :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Text -> m PatternSpec
patternSpecNew Text
pattern = IO PatternSpec -> m PatternSpec
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO PatternSpec -> m PatternSpec)
-> IO PatternSpec -> m PatternSpec
forall a b. (a -> b) -> a -> b
$ do
pattern' <- Text -> IO CString
textToCString Text
pattern
result <- g_pattern_spec_new pattern'
checkUnexpectedReturnNULL "patternSpecNew" result
result' <- (wrapBoxed PatternSpec) result
freeMem pattern'
return result'
#if defined(ENABLE_OVERLOADING)
#endif
foreign import ccall "g_pattern_spec_copy" g_pattern_spec_copy ::
Ptr PatternSpec ->
IO (Ptr PatternSpec)
patternSpecCopy ::
(B.CallStack.HasCallStack, MonadIO m) =>
PatternSpec
-> m PatternSpec
patternSpecCopy :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
PatternSpec -> m PatternSpec
patternSpecCopy PatternSpec
pspec = IO PatternSpec -> m PatternSpec
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO PatternSpec -> m PatternSpec)
-> IO PatternSpec -> m PatternSpec
forall a b. (a -> b) -> a -> b
$ do
pspec' <- PatternSpec -> IO (Ptr PatternSpec)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr PatternSpec
pspec
result <- g_pattern_spec_copy pspec'
checkUnexpectedReturnNULL "patternSpecCopy" result
result' <- (wrapBoxed PatternSpec) result
touchManagedPtr pspec
return result'
#if defined(ENABLE_OVERLOADING)
data PatternSpecCopyMethodInfo
instance (signature ~ (m PatternSpec), MonadIO m) => O.OverloadedMethod PatternSpecCopyMethodInfo PatternSpec signature where
overloadedMethod = patternSpecCopy
instance O.OverloadedMethodInfo PatternSpecCopyMethodInfo PatternSpec where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.GLib.Structs.PatternSpec.patternSpecCopy",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.30/docs/GI-GLib-Structs-PatternSpec.html#v:patternSpecCopy"
})
#endif
foreign import ccall "g_pattern_spec_equal" g_pattern_spec_equal ::
Ptr PatternSpec ->
Ptr PatternSpec ->
IO CInt
patternSpecEqual ::
(B.CallStack.HasCallStack, MonadIO m) =>
PatternSpec
-> PatternSpec
-> m Bool
patternSpecEqual :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
PatternSpec -> PatternSpec -> m Bool
patternSpecEqual PatternSpec
pspec1 PatternSpec
pspec2 = IO Bool -> m Bool
forall a. IO a -> m a
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
pspec1' <- PatternSpec -> IO (Ptr PatternSpec)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr PatternSpec
pspec1
pspec2' <- unsafeManagedPtrGetPtr pspec2
result <- g_pattern_spec_equal pspec1' pspec2'
let result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
touchManagedPtr pspec1
touchManagedPtr pspec2
return result'
#if defined(ENABLE_OVERLOADING)
data PatternSpecEqualMethodInfo
instance (signature ~ (PatternSpec -> m Bool), MonadIO m) => O.OverloadedMethod PatternSpecEqualMethodInfo PatternSpec signature where
overloadedMethod = patternSpecEqual
instance O.OverloadedMethodInfo PatternSpecEqualMethodInfo PatternSpec where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.GLib.Structs.PatternSpec.patternSpecEqual",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.30/docs/GI-GLib-Structs-PatternSpec.html#v:patternSpecEqual"
})
#endif
foreign import ccall "g_pattern_spec_free" g_pattern_spec_free ::
Ptr PatternSpec ->
IO ()
patternSpecFree ::
(B.CallStack.HasCallStack, MonadIO m) =>
PatternSpec
-> m ()
patternSpecFree :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
PatternSpec -> m ()
patternSpecFree PatternSpec
pspec = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
pspec' <- PatternSpec -> IO (Ptr PatternSpec)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr PatternSpec
pspec
g_pattern_spec_free pspec'
touchManagedPtr pspec
return ()
#if defined(ENABLE_OVERLOADING)
data PatternSpecFreeMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.OverloadedMethod PatternSpecFreeMethodInfo PatternSpec signature where
overloadedMethod = patternSpecFree
instance O.OverloadedMethodInfo PatternSpecFreeMethodInfo PatternSpec where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.GLib.Structs.PatternSpec.patternSpecFree",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.30/docs/GI-GLib-Structs-PatternSpec.html#v:patternSpecFree"
})
#endif
foreign import ccall "g_pattern_spec_match" g_pattern_spec_match ::
Ptr PatternSpec ->
FCT.CSize ->
CString ->
CString ->
IO CInt
patternSpecMatch ::
(B.CallStack.HasCallStack, MonadIO m) =>
PatternSpec
-> FCT.CSize
-> T.Text
-> Maybe (T.Text)
-> m Bool
patternSpecMatch :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
PatternSpec -> CSize -> Text -> Maybe Text -> m Bool
patternSpecMatch PatternSpec
pspec CSize
stringLength Text
string Maybe Text
stringReversed = IO Bool -> m Bool
forall a. IO a -> m a
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
pspec' <- PatternSpec -> IO (Ptr PatternSpec)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr PatternSpec
pspec
string' <- textToCString string
maybeStringReversed <- case stringReversed of
Maybe Text
Nothing -> CString -> IO CString
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
FP.nullPtr
Just Text
jStringReversed -> do
jStringReversed' <- Text -> IO CString
textToCString Text
jStringReversed
return jStringReversed'
result <- g_pattern_spec_match pspec' stringLength string' maybeStringReversed
let result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
touchManagedPtr pspec
freeMem string'
freeMem maybeStringReversed
return result'
#if defined(ENABLE_OVERLOADING)
data PatternSpecMatchMethodInfo
instance (signature ~ (FCT.CSize -> T.Text -> Maybe (T.Text) -> m Bool), MonadIO m) => O.OverloadedMethod PatternSpecMatchMethodInfo PatternSpec signature where
overloadedMethod = patternSpecMatch
instance O.OverloadedMethodInfo PatternSpecMatchMethodInfo PatternSpec where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.GLib.Structs.PatternSpec.patternSpecMatch",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.30/docs/GI-GLib-Structs-PatternSpec.html#v:patternSpecMatch"
})
#endif
foreign import ccall "g_pattern_spec_match_string" g_pattern_spec_match_string ::
Ptr PatternSpec ->
CString ->
IO CInt
patternSpecMatchString ::
(B.CallStack.HasCallStack, MonadIO m) =>
PatternSpec
-> T.Text
-> m Bool
patternSpecMatchString :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
PatternSpec -> Text -> m Bool
patternSpecMatchString PatternSpec
pspec Text
string = IO Bool -> m Bool
forall a. IO a -> m a
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
pspec' <- PatternSpec -> IO (Ptr PatternSpec)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr PatternSpec
pspec
string' <- textToCString string
result <- g_pattern_spec_match_string pspec' string'
let result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
touchManagedPtr pspec
freeMem string'
return result'
#if defined(ENABLE_OVERLOADING)
data PatternSpecMatchStringMethodInfo
instance (signature ~ (T.Text -> m Bool), MonadIO m) => O.OverloadedMethod PatternSpecMatchStringMethodInfo PatternSpec signature where
overloadedMethod = patternSpecMatchString
instance O.OverloadedMethodInfo PatternSpecMatchStringMethodInfo PatternSpec where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.GLib.Structs.PatternSpec.patternSpecMatchString",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.30/docs/GI-GLib-Structs-PatternSpec.html#v:patternSpecMatchString"
})
#endif
#if defined(ENABLE_OVERLOADING)
type family ResolvePatternSpecMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
ResolvePatternSpecMethod "copy" o = PatternSpecCopyMethodInfo
ResolvePatternSpecMethod "equal" o = PatternSpecEqualMethodInfo
ResolvePatternSpecMethod "free" o = PatternSpecFreeMethodInfo
ResolvePatternSpecMethod "match" o = PatternSpecMatchMethodInfo
ResolvePatternSpecMethod "matchString" o = PatternSpecMatchStringMethodInfo
ResolvePatternSpecMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolvePatternSpecMethod t PatternSpec, O.OverloadedMethod info PatternSpec p) => OL.IsLabel t (PatternSpec -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod @info
#else
fromLabel _ = O.overloadedMethod @info
#endif
#if MIN_VERSION_base(4,13,0)
instance (info ~ ResolvePatternSpecMethod t PatternSpec, O.OverloadedMethod info PatternSpec p, R.HasField t PatternSpec p) => R.HasField t PatternSpec p where
getField = O.overloadedMethod @info
#endif
instance (info ~ ResolvePatternSpecMethod t PatternSpec, O.OverloadedMethodInfo info PatternSpec) => OL.IsLabel t (O.MethodProxy info PatternSpec) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.MethodProxy
#else
fromLabel _ = O.MethodProxy
#endif
#endif