{- | Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte License : LGPL-2.1 Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc) 'GI.GtkSource.Structs.RegionIter.RegionIter' is an opaque datatype; ignore all its fields. Initialize the iter with 'GI.GtkSource.Objects.Region.regionGetStartRegionIter'. /Since: 3.22/ -} #define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \ && !defined(__HADDOCK_VERSION__)) module GI.GtkSource.Structs.RegionIter ( -- * Exported types RegionIter(..) , newZeroRegionIter , noRegionIter , -- * Methods -- ** getSubregion #method:getSubregion# #if ENABLE_OVERLOADING RegionIterGetSubregionMethodInfo , #endif regionIterGetSubregion , -- ** isEnd #method:isEnd# #if ENABLE_OVERLOADING RegionIterIsEndMethodInfo , #endif regionIterIsEnd , -- ** next #method:next# #if ENABLE_OVERLOADING RegionIterNextMethodInfo , #endif regionIterNext , ) 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.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.Gtk.Structs.TextIter as Gtk.TextIter -- | Memory-managed wrapper type. newtype RegionIter = RegionIter (ManagedPtr RegionIter) instance WrappedPtr RegionIter where wrappedPtrCalloc = callocBytes 24 wrappedPtrCopy = \p -> withManagedPtr p (copyBytes 24 >=> wrapPtr RegionIter) wrappedPtrFree = Just ptr_to_g_free -- | Construct a `RegionIter` struct initialized to zero. newZeroRegionIter :: MonadIO m => m RegionIter newZeroRegionIter = liftIO $ wrappedPtrCalloc >>= wrapPtr RegionIter instance tag ~ 'AttrSet => Constructible RegionIter tag where new _ attrs = do o <- newZeroRegionIter GI.Attributes.set o attrs return o -- | A convenience alias for `Nothing` :: `Maybe` `RegionIter`. noRegionIter :: Maybe RegionIter noRegionIter = Nothing #if ENABLE_OVERLOADING instance O.HasAttributeList RegionIter type instance O.AttributeList RegionIter = RegionIterAttributeList type RegionIterAttributeList = ('[ ] :: [(Symbol, *)]) #endif -- method RegionIter::get_subregion -- method type : OrdinaryMethod -- Args : [Arg {argCName = "iter", argType = TInterface (Name {namespace = "GtkSource", name = "RegionIter"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkSourceRegionIter.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "start", argType = TInterface (Name {namespace = "Gtk", name = "TextIter"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "iterator to initialize with the subregion start, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = True, transfer = TransferNothing},Arg {argCName = "end", argType = TInterface (Name {namespace = "Gtk", name = "TextIter"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "iterator to initialize with the subregion end, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = True, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "gtk_source_region_iter_get_subregion" gtk_source_region_iter_get_subregion :: Ptr RegionIter -> -- iter : TInterface (Name {namespace = "GtkSource", name = "RegionIter"}) Ptr Gtk.TextIter.TextIter -> -- start : TInterface (Name {namespace = "Gtk", name = "TextIter"}) Ptr Gtk.TextIter.TextIter -> -- end : TInterface (Name {namespace = "Gtk", name = "TextIter"}) IO CInt {- | Gets the subregion at this iterator. /Since: 3.22/ -} regionIterGetSubregion :: (B.CallStack.HasCallStack, MonadIO m) => RegionIter {- ^ /@iter@/: a 'GI.GtkSource.Structs.RegionIter.RegionIter'. -} -> m ((Bool, Gtk.TextIter.TextIter, Gtk.TextIter.TextIter)) {- ^ __Returns:__ 'True' if /@start@/ and /@end@/ have been set successfully (if non-'Nothing'), or 'False' if /@iter@/ is the end iterator or if the region is empty. -} regionIterGetSubregion iter = liftIO $ do iter' <- unsafeManagedPtrGetPtr iter start <- callocBoxedBytes 80 :: IO (Ptr Gtk.TextIter.TextIter) end <- callocBoxedBytes 80 :: IO (Ptr Gtk.TextIter.TextIter) result <- gtk_source_region_iter_get_subregion iter' start end let result' = (/= 0) result start' <- (wrapBoxed Gtk.TextIter.TextIter) start end' <- (wrapBoxed Gtk.TextIter.TextIter) end touchManagedPtr iter return (result', start', end') #if ENABLE_OVERLOADING data RegionIterGetSubregionMethodInfo instance (signature ~ (m ((Bool, Gtk.TextIter.TextIter, Gtk.TextIter.TextIter))), MonadIO m) => O.MethodInfo RegionIterGetSubregionMethodInfo RegionIter signature where overloadedMethod _ = regionIterGetSubregion #endif -- method RegionIter::is_end -- method type : OrdinaryMethod -- Args : [Arg {argCName = "iter", argType = TInterface (Name {namespace = "GtkSource", name = "RegionIter"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkSourceRegionIter.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "gtk_source_region_iter_is_end" gtk_source_region_iter_is_end :: Ptr RegionIter -> -- iter : TInterface (Name {namespace = "GtkSource", name = "RegionIter"}) IO CInt {- | /No description available in the introspection data./ /Since: 3.22/ -} regionIterIsEnd :: (B.CallStack.HasCallStack, MonadIO m) => RegionIter {- ^ /@iter@/: a 'GI.GtkSource.Structs.RegionIter.RegionIter'. -} -> m Bool {- ^ __Returns:__ whether /@iter@/ is the end iterator. -} regionIterIsEnd iter = liftIO $ do iter' <- unsafeManagedPtrGetPtr iter result <- gtk_source_region_iter_is_end iter' let result' = (/= 0) result touchManagedPtr iter return result' #if ENABLE_OVERLOADING data RegionIterIsEndMethodInfo instance (signature ~ (m Bool), MonadIO m) => O.MethodInfo RegionIterIsEndMethodInfo RegionIter signature where overloadedMethod _ = regionIterIsEnd #endif -- method RegionIter::next -- method type : OrdinaryMethod -- Args : [Arg {argCName = "iter", argType = TInterface (Name {namespace = "GtkSource", name = "RegionIter"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkSourceRegionIter.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "gtk_source_region_iter_next" gtk_source_region_iter_next :: Ptr RegionIter -> -- iter : TInterface (Name {namespace = "GtkSource", name = "RegionIter"}) IO CInt {- | Moves /@iter@/ to the next subregion. /Since: 3.22/ -} regionIterNext :: (B.CallStack.HasCallStack, MonadIO m) => RegionIter {- ^ /@iter@/: a 'GI.GtkSource.Structs.RegionIter.RegionIter'. -} -> m Bool {- ^ __Returns:__ 'True' if /@iter@/ moved and is dereferenceable, or 'False' if /@iter@/ has been set to the end iterator. -} regionIterNext iter = liftIO $ do iter' <- unsafeManagedPtrGetPtr iter result <- gtk_source_region_iter_next iter' let result' = (/= 0) result touchManagedPtr iter return result' #if ENABLE_OVERLOADING data RegionIterNextMethodInfo instance (signature ~ (m Bool), MonadIO m) => O.MethodInfo RegionIterNextMethodInfo RegionIter signature where overloadedMethod _ = regionIterNext #endif #if ENABLE_OVERLOADING type family ResolveRegionIterMethod (t :: Symbol) (o :: *) :: * where ResolveRegionIterMethod "isEnd" o = RegionIterIsEndMethodInfo ResolveRegionIterMethod "next" o = RegionIterNextMethodInfo ResolveRegionIterMethod "getSubregion" o = RegionIterGetSubregionMethodInfo ResolveRegionIterMethod l o = O.MethodResolutionFailed l o instance (info ~ ResolveRegionIterMethod t RegionIter, O.MethodInfo info RegionIter p) => OL.IsLabel t (RegionIter -> 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