{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.Vte.Structs.Regex
(
Regex(..) ,
#if defined(ENABLE_OVERLOADING)
ResolveRegexMethod ,
#endif
#if defined(ENABLE_OVERLOADING)
RegexJitMethodInfo ,
#endif
regexJit ,
regexNewForMatch ,
regexNewForSearch ,
#if defined(ENABLE_OVERLOADING)
RegexRefMethodInfo ,
#endif
regexRef ,
#if defined(ENABLE_OVERLOADING)
RegexSubstituteMethodInfo ,
#endif
regexSubstitute ,
#if defined(ENABLE_OVERLOADING)
RegexUnrefMethodInfo ,
#endif
regexUnref ,
) 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.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 Regex = Regex (SP.ManagedPtr Regex)
deriving (Regex -> Regex -> Bool
(Regex -> Regex -> Bool) -> (Regex -> Regex -> Bool) -> Eq Regex
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Regex -> Regex -> Bool
$c/= :: Regex -> Regex -> Bool
== :: Regex -> Regex -> Bool
$c== :: Regex -> Regex -> Bool
Eq)
instance SP.ManagedPtrNewtype Regex where
toManagedPtr :: Regex -> ManagedPtr Regex
toManagedPtr (Regex ManagedPtr Regex
p) = ManagedPtr Regex
p
foreign import ccall "vte_regex_get_type" c_vte_regex_get_type ::
IO GType
type instance O.ParentTypes Regex = '[]
instance O.HasParentTypes Regex
instance B.Types.TypedObject Regex where
glibType :: IO GType
glibType = IO GType
c_vte_regex_get_type
instance B.Types.GBoxed Regex
instance B.GValue.IsGValue (Maybe Regex) where
gvalueGType_ :: IO GType
gvalueGType_ = IO GType
c_vte_regex_get_type
gvalueSet_ :: Ptr GValue -> Maybe Regex -> IO ()
gvalueSet_ Ptr GValue
gv Maybe Regex
P.Nothing = Ptr GValue -> Ptr Regex -> IO ()
forall a. Ptr GValue -> Ptr a -> IO ()
B.GValue.set_boxed Ptr GValue
gv (Ptr Regex
forall a. Ptr a
FP.nullPtr :: FP.Ptr Regex)
gvalueSet_ Ptr GValue
gv (P.Just Regex
obj) = Regex -> (Ptr Regex -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr Regex
obj (Ptr GValue -> Ptr Regex -> IO ()
forall a. Ptr GValue -> Ptr a -> IO ()
B.GValue.set_boxed Ptr GValue
gv)
gvalueGet_ :: Ptr GValue -> IO (Maybe Regex)
gvalueGet_ Ptr GValue
gv = do
Ptr Regex
ptr <- Ptr GValue -> IO (Ptr Regex)
forall b. Ptr GValue -> IO (Ptr b)
B.GValue.get_boxed Ptr GValue
gv :: IO (Ptr Regex)
if Ptr Regex
ptr Ptr Regex -> Ptr Regex -> Bool
forall a. Eq a => a -> a -> Bool
/= Ptr Regex
forall a. Ptr a
FP.nullPtr
then Regex -> Maybe Regex
forall a. a -> Maybe a
P.Just (Regex -> Maybe Regex) -> IO Regex -> IO (Maybe Regex)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ManagedPtr Regex -> Regex) -> Ptr Regex -> IO Regex
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
B.ManagedPtr.newBoxed ManagedPtr Regex -> Regex
Regex Ptr Regex
ptr
else Maybe Regex -> IO (Maybe Regex)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Regex
forall a. Maybe a
P.Nothing
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList Regex
type instance O.AttributeList Regex = RegexAttributeList
type RegexAttributeList = ('[ ] :: [(Symbol, *)])
#endif
foreign import ccall "vte_regex_new_for_match" vte_regex_new_for_match ::
CString ->
Int64 ->
Word32 ->
Ptr (Ptr GError) ->
IO (Ptr Regex)
regexNewForMatch ::
(B.CallStack.HasCallStack, MonadIO m) =>
T.Text
-> Int64
-> Word32
-> m Regex
regexNewForMatch :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Text -> Int64 -> Word32 -> m Regex
regexNewForMatch Text
pattern Int64
patternLength Word32
flags = IO Regex -> m Regex
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Regex -> m Regex) -> IO Regex -> m Regex
forall a b. (a -> b) -> a -> b
$ do
CString
pattern' <- Text -> IO CString
textToCString Text
pattern
IO Regex -> IO () -> IO Regex
forall a b. IO a -> IO b -> IO a
onException (do
Ptr Regex
result <- (Ptr (Ptr GError) -> IO (Ptr Regex)) -> IO (Ptr Regex)
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr Regex)) -> IO (Ptr Regex))
-> (Ptr (Ptr GError) -> IO (Ptr Regex)) -> IO (Ptr Regex)
forall a b. (a -> b) -> a -> b
$ CString -> Int64 -> Word32 -> Ptr (Ptr GError) -> IO (Ptr Regex)
vte_regex_new_for_match CString
pattern' Int64
patternLength Word32
flags
Text -> Ptr Regex -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"regexNewForMatch" Ptr Regex
result
Regex
result' <- ((ManagedPtr Regex -> Regex) -> Ptr Regex -> IO Regex
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Regex -> Regex
Regex) Ptr Regex
result
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
pattern'
Regex -> IO Regex
forall (m :: * -> *) a. Monad m => a -> m a
return Regex
result'
) (do
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
pattern'
)
#if defined(ENABLE_OVERLOADING)
#endif
foreign import ccall "vte_regex_new_for_search" vte_regex_new_for_search ::
CString ->
Int64 ->
Word32 ->
Ptr (Ptr GError) ->
IO (Ptr Regex)
regexNewForSearch ::
(B.CallStack.HasCallStack, MonadIO m) =>
T.Text
-> Int64
-> Word32
-> m Regex
regexNewForSearch :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Text -> Int64 -> Word32 -> m Regex
regexNewForSearch Text
pattern Int64
patternLength Word32
flags = IO Regex -> m Regex
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Regex -> m Regex) -> IO Regex -> m Regex
forall a b. (a -> b) -> a -> b
$ do
CString
pattern' <- Text -> IO CString
textToCString Text
pattern
IO Regex -> IO () -> IO Regex
forall a b. IO a -> IO b -> IO a
onException (do
Ptr Regex
result <- (Ptr (Ptr GError) -> IO (Ptr Regex)) -> IO (Ptr Regex)
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr Regex)) -> IO (Ptr Regex))
-> (Ptr (Ptr GError) -> IO (Ptr Regex)) -> IO (Ptr Regex)
forall a b. (a -> b) -> a -> b
$ CString -> Int64 -> Word32 -> Ptr (Ptr GError) -> IO (Ptr Regex)
vte_regex_new_for_search CString
pattern' Int64
patternLength Word32
flags
Text -> Ptr Regex -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"regexNewForSearch" Ptr Regex
result
Regex
result' <- ((ManagedPtr Regex -> Regex) -> Ptr Regex -> IO Regex
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Regex -> Regex
Regex) Ptr Regex
result
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
pattern'
Regex -> IO Regex
forall (m :: * -> *) a. Monad m => a -> m a
return Regex
result'
) (do
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
pattern'
)
#if defined(ENABLE_OVERLOADING)
#endif
foreign import ccall "vte_regex_jit" vte_regex_jit ::
Ptr Regex ->
Word32 ->
Ptr (Ptr GError) ->
IO CInt
regexJit ::
(B.CallStack.HasCallStack, MonadIO m) =>
Regex
-> Word32
-> m ()
regexJit :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Regex -> Word32 -> m ()
regexJit Regex
regex Word32
flags = 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 Regex
regex' <- Regex -> IO (Ptr Regex)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Regex
regex
IO () -> IO () -> IO ()
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 Regex -> Word32 -> Ptr (Ptr GError) -> IO CInt
vte_regex_jit Ptr Regex
regex' Word32
flags
Regex -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Regex
regex
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
) (do
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
)
#if defined(ENABLE_OVERLOADING)
data RegexJitMethodInfo
instance (signature ~ (Word32 -> m ()), MonadIO m) => O.OverloadedMethod RegexJitMethodInfo Regex signature where
overloadedMethod = regexJit
instance O.OverloadedMethodInfo RegexJitMethodInfo Regex where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Vte.Structs.Regex.regexJit",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-vte-2.91.29/docs/GI-Vte-Structs-Regex.html#v:regexJit"
})
#endif
foreign import ccall "vte_regex_ref" vte_regex_ref ::
Ptr Regex ->
IO (Ptr Regex)
regexRef ::
(B.CallStack.HasCallStack, MonadIO m) =>
Regex
-> m Regex
regexRef :: forall (m :: * -> *). (HasCallStack, MonadIO m) => Regex -> m Regex
regexRef Regex
regex = IO Regex -> m Regex
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Regex -> m Regex) -> IO Regex -> m Regex
forall a b. (a -> b) -> a -> b
$ do
Ptr Regex
regex' <- Regex -> IO (Ptr Regex)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Regex
regex
Ptr Regex
result <- Ptr Regex -> IO (Ptr Regex)
vte_regex_ref Ptr Regex
regex'
Text -> Ptr Regex -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"regexRef" Ptr Regex
result
Regex
result' <- ((ManagedPtr Regex -> Regex) -> Ptr Regex -> IO Regex
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Regex -> Regex
Regex) Ptr Regex
result
Regex -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Regex
regex
Regex -> IO Regex
forall (m :: * -> *) a. Monad m => a -> m a
return Regex
result'
#if defined(ENABLE_OVERLOADING)
data RegexRefMethodInfo
instance (signature ~ (m Regex), MonadIO m) => O.OverloadedMethod RegexRefMethodInfo Regex signature where
overloadedMethod = regexRef
instance O.OverloadedMethodInfo RegexRefMethodInfo Regex where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Vte.Structs.Regex.regexRef",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-vte-2.91.29/docs/GI-Vte-Structs-Regex.html#v:regexRef"
})
#endif
foreign import ccall "vte_regex_substitute" vte_regex_substitute ::
Ptr Regex ->
CString ->
CString ->
Word32 ->
Ptr (Ptr GError) ->
IO CString
regexSubstitute ::
(B.CallStack.HasCallStack, MonadIO m) =>
Regex
-> T.Text
-> T.Text
-> Word32
-> m T.Text
regexSubstitute :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Regex -> Text -> Text -> Word32 -> m Text
regexSubstitute Regex
regex Text
subject Text
replacement Word32
flags = 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 Regex
regex' <- Regex -> IO (Ptr Regex)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Regex
regex
CString
subject' <- Text -> IO CString
textToCString Text
subject
CString
replacement' <- Text -> IO CString
textToCString Text
replacement
IO Text -> IO () -> IO Text
forall a b. IO a -> IO b -> IO a
onException (do
CString
result <- (Ptr (Ptr GError) -> IO CString) -> IO CString
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CString) -> IO CString)
-> (Ptr (Ptr GError) -> IO CString) -> IO CString
forall a b. (a -> b) -> a -> b
$ Ptr Regex
-> CString -> CString -> Word32 -> Ptr (Ptr GError) -> IO CString
vte_regex_substitute Ptr Regex
regex' CString
subject' CString
replacement' Word32
flags
Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"regexSubstitute" CString
result
Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
Regex -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Regex
regex
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
subject'
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
replacement'
Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'
) (do
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
subject'
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
replacement'
)
#if defined(ENABLE_OVERLOADING)
data RegexSubstituteMethodInfo
instance (signature ~ (T.Text -> T.Text -> Word32 -> m T.Text), MonadIO m) => O.OverloadedMethod RegexSubstituteMethodInfo Regex signature where
overloadedMethod = regexSubstitute
instance O.OverloadedMethodInfo RegexSubstituteMethodInfo Regex where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Vte.Structs.Regex.regexSubstitute",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-vte-2.91.29/docs/GI-Vte-Structs-Regex.html#v:regexSubstitute"
})
#endif
foreign import ccall "vte_regex_unref" vte_regex_unref ::
Ptr Regex ->
IO (Ptr Regex)
regexUnref ::
(B.CallStack.HasCallStack, MonadIO m) =>
Regex
-> m Regex
regexUnref :: forall (m :: * -> *). (HasCallStack, MonadIO m) => Regex -> m Regex
regexUnref Regex
regex = IO Regex -> m Regex
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Regex -> m Regex) -> IO Regex -> m Regex
forall a b. (a -> b) -> a -> b
$ do
Ptr Regex
regex' <- Regex -> IO (Ptr Regex)
forall a. (HasCallStack, GBoxed a) => a -> IO (Ptr a)
B.ManagedPtr.disownBoxed Regex
regex
Ptr Regex
result <- Ptr Regex -> IO (Ptr Regex)
vte_regex_unref Ptr Regex
regex'
Text -> Ptr Regex -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"regexUnref" Ptr Regex
result
Regex
result' <- ((ManagedPtr Regex -> Regex) -> Ptr Regex -> IO Regex
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Regex -> Regex
Regex) Ptr Regex
result
Regex -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Regex
regex
Regex -> IO Regex
forall (m :: * -> *) a. Monad m => a -> m a
return Regex
result'
#if defined(ENABLE_OVERLOADING)
data RegexUnrefMethodInfo
instance (signature ~ (m Regex), MonadIO m) => O.OverloadedMethod RegexUnrefMethodInfo Regex signature where
overloadedMethod = regexUnref
instance O.OverloadedMethodInfo RegexUnrefMethodInfo Regex where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Vte.Structs.Regex.regexUnref",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-vte-2.91.29/docs/GI-Vte-Structs-Regex.html#v:regexUnref"
})
#endif
#if defined(ENABLE_OVERLOADING)
type family ResolveRegexMethod (t :: Symbol) (o :: *) :: * where
ResolveRegexMethod "jit" o = RegexJitMethodInfo
ResolveRegexMethod "ref" o = RegexRefMethodInfo
ResolveRegexMethod "substitute" o = RegexSubstituteMethodInfo
ResolveRegexMethod "unref" o = RegexUnrefMethodInfo
ResolveRegexMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveRegexMethod t Regex, O.OverloadedMethod info Regex p) => OL.IsLabel t (Regex -> 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 ~ ResolveRegexMethod t Regex, O.OverloadedMethod info Regex p, R.HasField t Regex p) => R.HasField t Regex p where
getField = O.overloadedMethod @info
#endif
instance (info ~ ResolveRegexMethod t Regex, O.OverloadedMethodInfo info Regex) => OL.IsLabel t (O.MethodProxy info Regex) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.MethodProxy
#else
fromLabel _ = O.MethodProxy
#endif
#endif