{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)

/No description available in the introspection data./
-}

#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
       && !defined(__HADDOCK_VERSION__))

module GI.Vte.Structs.Regex
    (

-- * Exported types
    Regex(..)                               ,
    noRegex                                 ,


 -- * Methods
-- ** jit #method:jit#

#if ENABLE_OVERLOADING
    RegexJitMethodInfo                      ,
#endif
    regexJit                                ,


-- ** newForMatch #method:newForMatch#

    regexNewForMatch                        ,


-- ** newForSearch #method:newForSearch#

    regexNewForSearch                       ,


-- ** ref #method:ref#

#if ENABLE_OVERLOADING
    RegexRefMethodInfo                      ,
#endif
    regexRef                                ,


-- ** unref #method:unref#

#if 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.ManagedPtr as B.ManagedPtr
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.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP


-- | Memory-managed wrapper type.
newtype Regex = Regex (ManagedPtr Regex)
foreign import ccall "vte_regex_get_type" c_vte_regex_get_type ::
    IO GType

instance BoxedObject Regex where
    boxedType _ = c_vte_regex_get_type

-- | A convenience alias for `Nothing` :: `Maybe` `Regex`.
noRegex :: Maybe Regex
noRegex = Nothing


#if ENABLE_OVERLOADING
instance O.HasAttributeList Regex
type instance O.AttributeList Regex = RegexAttributeList
type RegexAttributeList = ('[ ] :: [(Symbol, *)])
#endif

-- method Regex::new_for_match
-- method type : Constructor
-- Args : [Arg {argCName = "pattern", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "pattern_length", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Vte", name = "Regex"}))
-- throws : True
-- Skip return : False

foreign import ccall "vte_regex_new_for_match" vte_regex_new_for_match ::
    CString ->                              -- pattern : TBasicType TUTF8
    Int64 ->                                -- pattern_length : TBasicType TInt64
    Word32 ->                               -- flags : TBasicType TUInt32
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Regex)

{- |
/No description available in the introspection data./
-}
regexNewForMatch ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -> Int64
    -> Word32
    -> m Regex
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
regexNewForMatch pattern patternLength flags = liftIO $ do
    pattern' <- textToCString pattern
    onException (do
        result <- propagateGError $ vte_regex_new_for_match pattern' patternLength flags
        checkUnexpectedReturnNULL "regexNewForMatch" result
        result' <- (wrapBoxed Regex) result
        freeMem pattern'
        return result'
     ) (do
        freeMem pattern'
     )

#if ENABLE_OVERLOADING
#endif

-- method Regex::new_for_search
-- method type : Constructor
-- Args : [Arg {argCName = "pattern", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "pattern_length", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Vte", name = "Regex"}))
-- throws : True
-- Skip return : False

foreign import ccall "vte_regex_new_for_search" vte_regex_new_for_search ::
    CString ->                              -- pattern : TBasicType TUTF8
    Int64 ->                                -- pattern_length : TBasicType TInt64
    Word32 ->                               -- flags : TBasicType TUInt32
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Regex)

{- |
/No description available in the introspection data./
-}
regexNewForSearch ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -> Int64
    -> Word32
    -> m Regex
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
regexNewForSearch pattern patternLength flags = liftIO $ do
    pattern' <- textToCString pattern
    onException (do
        result <- propagateGError $ vte_regex_new_for_search pattern' patternLength flags
        checkUnexpectedReturnNULL "regexNewForSearch" result
        result' <- (wrapBoxed Regex) result
        freeMem pattern'
        return result'
     ) (do
        freeMem pattern'
     )

#if ENABLE_OVERLOADING
#endif

-- method Regex::jit
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "regex", argType = TInterface (Name {namespace = "Vte", name = "Regex"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "vte_regex_jit" vte_regex_jit ::
    Ptr Regex ->                            -- regex : TInterface (Name {namespace = "Vte", name = "Regex"})
    Word32 ->                               -- flags : TBasicType TUInt32
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
/No description available in the introspection data./
-}
regexJit ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Regex
    -> Word32
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
regexJit regex flags = liftIO $ do
    regex' <- unsafeManagedPtrGetPtr regex
    onException (do
        _ <- propagateGError $ vte_regex_jit regex' flags
        touchManagedPtr regex
        return ()
     ) (do
        return ()
     )

#if ENABLE_OVERLOADING
data RegexJitMethodInfo
instance (signature ~ (Word32 -> m ()), MonadIO m) => O.MethodInfo RegexJitMethodInfo Regex signature where
    overloadedMethod _ = regexJit

#endif

-- method Regex::ref
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "regex", argType = TInterface (Name {namespace = "Vte", name = "Regex"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Vte", name = "Regex"}))
-- throws : False
-- Skip return : False

foreign import ccall "vte_regex_ref" vte_regex_ref ::
    Ptr Regex ->                            -- regex : TInterface (Name {namespace = "Vte", name = "Regex"})
    IO (Ptr Regex)

{- |
/No description available in the introspection data./
-}
regexRef ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Regex
    -> m Regex
regexRef regex = liftIO $ do
    regex' <- unsafeManagedPtrGetPtr regex
    result <- vte_regex_ref regex'
    checkUnexpectedReturnNULL "regexRef" result
    result' <- (wrapBoxed Regex) result
    touchManagedPtr regex
    return result'

#if ENABLE_OVERLOADING
data RegexRefMethodInfo
instance (signature ~ (m Regex), MonadIO m) => O.MethodInfo RegexRefMethodInfo Regex signature where
    overloadedMethod _ = regexRef

#endif

-- method Regex::unref
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "regex", argType = TInterface (Name {namespace = "Vte", name = "Regex"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Vte", name = "Regex"}))
-- throws : False
-- Skip return : False

foreign import ccall "vte_regex_unref" vte_regex_unref ::
    Ptr Regex ->                            -- regex : TInterface (Name {namespace = "Vte", name = "Regex"})
    IO (Ptr Regex)

{- |
/No description available in the introspection data./
-}
regexUnref ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Regex
    -> m Regex
regexUnref regex = liftIO $ do
    regex' <- unsafeManagedPtrGetPtr regex
    result <- vte_regex_unref regex'
    checkUnexpectedReturnNULL "regexUnref" result
    result' <- (wrapBoxed Regex) result
    touchManagedPtr regex
    return result'

#if ENABLE_OVERLOADING
data RegexUnrefMethodInfo
instance (signature ~ (m Regex), MonadIO m) => O.MethodInfo RegexUnrefMethodInfo Regex signature where
    overloadedMethod _ = regexUnref

#endif

#if ENABLE_OVERLOADING
type family ResolveRegexMethod (t :: Symbol) (o :: *) :: * where
    ResolveRegexMethod "jit" o = RegexJitMethodInfo
    ResolveRegexMethod "ref" o = RegexRefMethodInfo
    ResolveRegexMethod "unref" o = RegexUnrefMethodInfo
    ResolveRegexMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveRegexMethod t Regex, O.MethodInfo info Regex p) => O.IsLabelProxy t (Regex -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveRegexMethod t Regex, O.MethodInfo info Regex p) => O.IsLabel t (Regex -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#else
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif
#endif

#endif