{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !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.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
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 PatternSpec
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 PatternSpec
ptr Ptr PatternSpec -> Ptr PatternSpec -> Bool
forall a. Eq a => a -> a -> Bool
/= Ptr PatternSpec
forall a. Ptr a
FP.nullPtr
then PatternSpec -> Maybe PatternSpec
forall a. a -> Maybe a
P.Just (PatternSpec -> Maybe PatternSpec)
-> IO PatternSpec -> IO (Maybe PatternSpec)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ManagedPtr PatternSpec -> PatternSpec)
-> Ptr PatternSpec -> IO PatternSpec
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
B.ManagedPtr.newBoxed ManagedPtr PatternSpec -> PatternSpec
PatternSpec Ptr PatternSpec
ptr
else Maybe PatternSpec -> IO (Maybe PatternSpec)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe PatternSpec
forall a. Maybe a
P.Nothing
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList PatternSpec
type instance O.AttributeList PatternSpec = PatternSpecAttributeList
type PatternSpecAttributeList = ('[ ] :: [(Symbol, *)])
#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
CString
pattern' <- Text -> IO CString
textToCString Text
pattern
Ptr PatternSpec
result <- CString -> IO (Ptr PatternSpec)
g_pattern_spec_new CString
pattern'
Text -> Ptr PatternSpec -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"patternSpecNew" Ptr PatternSpec
result
PatternSpec
result' <- ((ManagedPtr PatternSpec -> PatternSpec)
-> Ptr PatternSpec -> IO PatternSpec
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr PatternSpec -> PatternSpec
PatternSpec) Ptr PatternSpec
result
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
pattern'
PatternSpec -> IO PatternSpec
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return PatternSpec
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
Ptr PatternSpec
pspec' <- PatternSpec -> IO (Ptr PatternSpec)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr PatternSpec
pspec
Ptr PatternSpec
result <- Ptr PatternSpec -> IO (Ptr PatternSpec)
g_pattern_spec_copy Ptr PatternSpec
pspec'
Text -> Ptr PatternSpec -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"patternSpecCopy" Ptr PatternSpec
result
PatternSpec
result' <- ((ManagedPtr PatternSpec -> PatternSpec)
-> Ptr PatternSpec -> IO PatternSpec
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr PatternSpec -> PatternSpec
PatternSpec) Ptr PatternSpec
result
PatternSpec -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr PatternSpec
pspec
PatternSpec -> IO PatternSpec
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return PatternSpec
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.27/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
Ptr PatternSpec
pspec1' <- PatternSpec -> IO (Ptr PatternSpec)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr PatternSpec
pspec1
Ptr PatternSpec
pspec2' <- PatternSpec -> IO (Ptr PatternSpec)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr PatternSpec
pspec2
CInt
result <- Ptr PatternSpec -> Ptr PatternSpec -> IO CInt
g_pattern_spec_equal Ptr PatternSpec
pspec1' Ptr PatternSpec
pspec2'
let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
PatternSpec -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr PatternSpec
pspec1
PatternSpec -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr PatternSpec
pspec2
Bool -> IO Bool
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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.27/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
Ptr PatternSpec
pspec' <- PatternSpec -> IO (Ptr PatternSpec)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr PatternSpec
pspec
Ptr PatternSpec -> IO ()
g_pattern_spec_free Ptr PatternSpec
pspec'
PatternSpec -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr PatternSpec
pspec
() -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
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.27/docs/GI-GLib-Structs-PatternSpec.html#v:patternSpecFree"
})
#endif
foreign import ccall "g_pattern_spec_match" g_pattern_spec_match ::
Ptr PatternSpec ->
Word64 ->
CString ->
CString ->
IO CInt
patternSpecMatch ::
(B.CallStack.HasCallStack, MonadIO m) =>
PatternSpec
-> Word64
-> T.Text
-> Maybe (T.Text)
-> m Bool
patternSpecMatch :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
PatternSpec -> Word64 -> Text -> Maybe Text -> m Bool
patternSpecMatch PatternSpec
pspec Word64
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
Ptr PatternSpec
pspec' <- PatternSpec -> IO (Ptr PatternSpec)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr PatternSpec
pspec
CString
string' <- Text -> IO CString
textToCString Text
string
CString
maybeStringReversed <- case Maybe Text
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
nullPtr
Just Text
jStringReversed -> do
CString
jStringReversed' <- Text -> IO CString
textToCString Text
jStringReversed
CString -> IO CString
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jStringReversed'
CInt
result <- Ptr PatternSpec -> Word64 -> CString -> CString -> IO CInt
g_pattern_spec_match Ptr PatternSpec
pspec' Word64
stringLength CString
string' CString
maybeStringReversed
let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
PatternSpec -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr PatternSpec
pspec
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
string'
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeStringReversed
Bool -> IO Bool
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'
#if defined(ENABLE_OVERLOADING)
data PatternSpecMatchMethodInfo
instance (signature ~ (Word64 -> 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.27/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
Ptr PatternSpec
pspec' <- PatternSpec -> IO (Ptr PatternSpec)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr PatternSpec
pspec
CString
string' <- Text -> IO CString
textToCString Text
string
CInt
result <- Ptr PatternSpec -> CString -> IO CInt
g_pattern_spec_match_string Ptr PatternSpec
pspec' CString
string'
let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
PatternSpec -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr PatternSpec
pspec
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
string'
Bool -> IO Bool
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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.27/docs/GI-GLib-Structs-PatternSpec.html#v:patternSpecMatchString"
})
#endif
#if defined(ENABLE_OVERLOADING)
type family ResolvePatternSpecMethod (t :: Symbol) (o :: *) :: * 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