#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
&& !defined(__HADDOCK_VERSION__))
module GI.Pango.Structs.ScriptIter
(
ScriptIter(..) ,
noScriptIter ,
#if ENABLE_OVERLOADING
ScriptIterFreeMethodInfo ,
#endif
scriptIterFree ,
#if ENABLE_OVERLOADING
ScriptIterGetRangeMethodInfo ,
#endif
scriptIterGetRange ,
#if ENABLE_OVERLOADING
ScriptIterNextMethodInfo ,
#endif
scriptIterNext ,
) 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 {-# SOURCE #-} qualified GI.Pango.Enums as Pango.Enums
newtype ScriptIter = ScriptIter (ManagedPtr ScriptIter)
instance WrappedPtr ScriptIter where
wrappedPtrCalloc = return nullPtr
wrappedPtrCopy = return
wrappedPtrFree = Nothing
noScriptIter :: Maybe ScriptIter
noScriptIter = Nothing
#if ENABLE_OVERLOADING
instance O.HasAttributeList ScriptIter
type instance O.AttributeList ScriptIter = ScriptIterAttributeList
type ScriptIterAttributeList = ('[ ] :: [(Symbol, *)])
#endif
foreign import ccall "pango_script_iter_free" pango_script_iter_free ::
Ptr ScriptIter ->
IO ()
scriptIterFree ::
(B.CallStack.HasCallStack, MonadIO m) =>
ScriptIter
-> m ()
scriptIterFree iter = liftIO $ do
iter' <- unsafeManagedPtrGetPtr iter
pango_script_iter_free iter'
touchManagedPtr iter
return ()
#if ENABLE_OVERLOADING
data ScriptIterFreeMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo ScriptIterFreeMethodInfo ScriptIter signature where
overloadedMethod _ = scriptIterFree
#endif
foreign import ccall "pango_script_iter_get_range" pango_script_iter_get_range ::
Ptr ScriptIter ->
Ptr CString ->
Ptr CString ->
Ptr CInt ->
IO ()
scriptIterGetRange ::
(B.CallStack.HasCallStack, MonadIO m) =>
ScriptIter
-> m ((T.Text, T.Text, Pango.Enums.Script))
scriptIterGetRange iter = liftIO $ do
iter' <- unsafeManagedPtrGetPtr iter
start <- allocMem :: IO (Ptr CString)
end <- allocMem :: IO (Ptr CString)
script <- allocMem :: IO (Ptr CInt)
pango_script_iter_get_range iter' start end script
start' <- peek start
start'' <- cstringToText start'
freeMem start'
end' <- peek end
end'' <- cstringToText end'
freeMem end'
script' <- peek script
let script'' = (toEnum . fromIntegral) script'
touchManagedPtr iter
freeMem start
freeMem end
freeMem script
return (start'', end'', script'')
#if ENABLE_OVERLOADING
data ScriptIterGetRangeMethodInfo
instance (signature ~ (m ((T.Text, T.Text, Pango.Enums.Script))), MonadIO m) => O.MethodInfo ScriptIterGetRangeMethodInfo ScriptIter signature where
overloadedMethod _ = scriptIterGetRange
#endif
foreign import ccall "pango_script_iter_next" pango_script_iter_next ::
Ptr ScriptIter ->
IO CInt
scriptIterNext ::
(B.CallStack.HasCallStack, MonadIO m) =>
ScriptIter
-> m Bool
scriptIterNext iter = liftIO $ do
iter' <- unsafeManagedPtrGetPtr iter
result <- pango_script_iter_next iter'
let result' = (/= 0) result
touchManagedPtr iter
return result'
#if ENABLE_OVERLOADING
data ScriptIterNextMethodInfo
instance (signature ~ (m Bool), MonadIO m) => O.MethodInfo ScriptIterNextMethodInfo ScriptIter signature where
overloadedMethod _ = scriptIterNext
#endif
#if ENABLE_OVERLOADING
type family ResolveScriptIterMethod (t :: Symbol) (o :: *) :: * where
ResolveScriptIterMethod "free" o = ScriptIterFreeMethodInfo
ResolveScriptIterMethod "next" o = ScriptIterNextMethodInfo
ResolveScriptIterMethod "getRange" o = ScriptIterGetRangeMethodInfo
ResolveScriptIterMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveScriptIterMethod t ScriptIter, O.MethodInfo info ScriptIter p) => OL.IsLabel t (ScriptIter -> 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