{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson and Iñaki García Etxebarria
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- /No description available in the introspection data./

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

module GI.Cairo.Structs.TextCluster
    ( 

-- * Exported types
    TextCluster(..)                         ,
    newZeroTextCluster                      ,


 -- * Methods

#if defined(ENABLE_OVERLOADING)
    ResolveTextClusterMethod                ,
#endif



 -- * Properties


-- ** numBytes #attr:numBytes#
-- | /No description available in the introspection data./

    getTextClusterNumBytes                  ,
    setTextClusterNumBytes                  ,
#if defined(ENABLE_OVERLOADING)
    textCluster_numBytes                    ,
#endif


-- ** numGlyphs #attr:numGlyphs#
-- | /No description available in the introspection data./

    getTextClusterNumGlyphs                 ,
    setTextClusterNumGlyphs                 ,
#if defined(ENABLE_OVERLOADING)
    textCluster_numGlyphs                   ,
#endif




    ) 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.Kind as DK
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
import qualified Data.Word as DW
import qualified Data.Int as DI
import qualified System.Posix.Types as SPT
import qualified Foreign.C.Types as FCT

-- Workaround for https://gitlab.haskell.org/ghc/ghc/-/issues/23392
#if MIN_VERSION_base(4,18,0)

#else

#endif

-- | Memory-managed wrapper type.
newtype TextCluster = TextCluster (SP.ManagedPtr TextCluster)
    deriving (TextCluster -> TextCluster -> Bool
(TextCluster -> TextCluster -> Bool)
-> (TextCluster -> TextCluster -> Bool) -> Eq TextCluster
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TextCluster -> TextCluster -> Bool
== :: TextCluster -> TextCluster -> Bool
$c/= :: TextCluster -> TextCluster -> Bool
/= :: TextCluster -> TextCluster -> Bool
Eq)

instance SP.ManagedPtrNewtype TextCluster where
    toManagedPtr :: TextCluster -> ManagedPtr TextCluster
toManagedPtr (TextCluster ManagedPtr TextCluster
p) = ManagedPtr TextCluster
p

foreign import ccall "cairo_gobject_text_cluster_get_type" c_cairo_gobject_text_cluster_get_type :: 
    IO GType

type instance O.ParentTypes TextCluster = '[]
instance O.HasParentTypes TextCluster

instance B.Types.TypedObject TextCluster where
    glibType :: IO GType
glibType = IO GType
c_cairo_gobject_text_cluster_get_type

instance B.Types.GBoxed TextCluster

-- | Convert t'TextCluster' to and from 'Data.GI.Base.GValue.GValue'. See 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'.
instance B.GValue.IsGValue (Maybe TextCluster) where
    gvalueGType_ :: IO GType
gvalueGType_ = IO GType
c_cairo_gobject_text_cluster_get_type
    gvalueSet_ :: Ptr GValue -> Maybe TextCluster -> IO ()
gvalueSet_ Ptr GValue
gv Maybe TextCluster
P.Nothing = Ptr GValue -> Ptr TextCluster -> IO ()
forall a. Ptr GValue -> Ptr a -> IO ()
B.GValue.set_boxed Ptr GValue
gv (Ptr TextCluster
forall a. Ptr a
FP.nullPtr :: FP.Ptr TextCluster)
    gvalueSet_ Ptr GValue
gv (P.Just TextCluster
obj) = TextCluster -> (Ptr TextCluster -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr TextCluster
obj (Ptr GValue -> Ptr TextCluster -> IO ()
forall a. Ptr GValue -> Ptr a -> IO ()
B.GValue.set_boxed Ptr GValue
gv)
    gvalueGet_ :: Ptr GValue -> IO (Maybe TextCluster)
gvalueGet_ Ptr GValue
gv = do
        Ptr TextCluster
ptr <- Ptr GValue -> IO (Ptr TextCluster)
forall b. Ptr GValue -> IO (Ptr b)
B.GValue.get_boxed Ptr GValue
gv :: IO (Ptr TextCluster)
        if Ptr TextCluster
ptr Ptr TextCluster -> Ptr TextCluster -> Bool
forall a. Eq a => a -> a -> Bool
/= Ptr TextCluster
forall a. Ptr a
FP.nullPtr
        then TextCluster -> Maybe TextCluster
forall a. a -> Maybe a
P.Just (TextCluster -> Maybe TextCluster)
-> IO TextCluster -> IO (Maybe TextCluster)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ManagedPtr TextCluster -> TextCluster)
-> Ptr TextCluster -> IO TextCluster
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
B.ManagedPtr.newBoxed ManagedPtr TextCluster -> TextCluster
TextCluster Ptr TextCluster
ptr
        else Maybe TextCluster -> IO (Maybe TextCluster)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe TextCluster
forall a. Maybe a
P.Nothing
        
    

-- | Construct a t'TextCluster' struct initialized to zero.
newZeroTextCluster :: MonadIO m => m TextCluster
newZeroTextCluster :: forall (m :: * -> *). MonadIO m => m TextCluster
newZeroTextCluster = IO TextCluster -> m TextCluster
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO TextCluster -> m TextCluster)
-> IO TextCluster -> m TextCluster
forall a b. (a -> b) -> a -> b
$ Int -> IO (Ptr TextCluster)
forall a. GBoxed a => Int -> IO (Ptr a)
callocBoxedBytes Int
8 IO (Ptr TextCluster)
-> (Ptr TextCluster -> IO TextCluster) -> IO TextCluster
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (ManagedPtr TextCluster -> TextCluster)
-> Ptr TextCluster -> IO TextCluster
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr TextCluster -> TextCluster
TextCluster

instance tag ~ 'AttrSet => Constructible TextCluster tag where
    new :: forall (m :: * -> *).
MonadIO m =>
(ManagedPtr TextCluster -> TextCluster)
-> [AttrOp TextCluster tag] -> m TextCluster
new ManagedPtr TextCluster -> TextCluster
_ [AttrOp TextCluster tag]
attrs = do
        TextCluster
o <- m TextCluster
forall (m :: * -> *). MonadIO m => m TextCluster
newZeroTextCluster
        TextCluster -> [AttrOp TextCluster 'AttrSet] -> m ()
forall o (m :: * -> *).
MonadIO m =>
o -> [AttrOp o 'AttrSet] -> m ()
GI.Attributes.set TextCluster
o [AttrOp TextCluster tag]
[AttrOp TextCluster 'AttrSet]
attrs
        TextCluster -> m TextCluster
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return TextCluster
o


-- | Get the value of the “@num_bytes@” field.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.get' textCluster #numBytes
-- @
getTextClusterNumBytes :: MonadIO m => TextCluster -> m Int32
getTextClusterNumBytes :: forall (m :: * -> *). MonadIO m => TextCluster -> m Int32
getTextClusterNumBytes TextCluster
s = IO Int32 -> m Int32
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ TextCluster -> (Ptr TextCluster -> IO Int32) -> IO Int32
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr TextCluster
s ((Ptr TextCluster -> IO Int32) -> IO Int32)
-> (Ptr TextCluster -> IO Int32) -> IO Int32
forall a b. (a -> b) -> a -> b
$ \Ptr TextCluster
ptr -> do
    Int32
val <- Ptr Int32 -> IO Int32
forall a. Storable a => Ptr a -> IO a
peek (Ptr TextCluster
ptr Ptr TextCluster -> Int -> Ptr Int32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0) :: IO Int32
    Int32 -> IO Int32
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
val

-- | Set the value of the “@num_bytes@” field.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.set' textCluster [ #numBytes 'Data.GI.Base.Attributes.:=' value ]
-- @
setTextClusterNumBytes :: MonadIO m => TextCluster -> Int32 -> m ()
setTextClusterNumBytes :: forall (m :: * -> *). MonadIO m => TextCluster -> Int32 -> m ()
setTextClusterNumBytes TextCluster
s Int32
val = 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
$ TextCluster -> (Ptr TextCluster -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr TextCluster
s ((Ptr TextCluster -> IO ()) -> IO ())
-> (Ptr TextCluster -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr TextCluster
ptr -> do
    Ptr Int32 -> Int32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr TextCluster
ptr Ptr TextCluster -> Int -> Ptr Int32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0) (Int32
val :: Int32)

#if defined(ENABLE_OVERLOADING)
data TextClusterNumBytesFieldInfo
instance AttrInfo TextClusterNumBytesFieldInfo where
    type AttrBaseTypeConstraint TextClusterNumBytesFieldInfo = (~) TextCluster
    type AttrAllowedOps TextClusterNumBytesFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint TextClusterNumBytesFieldInfo = (~) Int32
    type AttrTransferTypeConstraint TextClusterNumBytesFieldInfo = (~)Int32
    type AttrTransferType TextClusterNumBytesFieldInfo = Int32
    type AttrGetType TextClusterNumBytesFieldInfo = Int32
    type AttrLabel TextClusterNumBytesFieldInfo = "num_bytes"
    type AttrOrigin TextClusterNumBytesFieldInfo = TextCluster
    attrGet = getTextClusterNumBytes
    attrSet = setTextClusterNumBytes
    attrConstruct = undefined
    attrClear = undefined
    attrTransfer _ v = do
        return v
    dbgAttrInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Cairo.Structs.TextCluster.numBytes"
        , O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-cairo-1.0.30/docs/GI-Cairo-Structs-TextCluster.html#g:attr:numBytes"
        })

textCluster_numBytes :: AttrLabelProxy "numBytes"
textCluster_numBytes = AttrLabelProxy

#endif


-- | Get the value of the “@num_glyphs@” field.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.get' textCluster #numGlyphs
-- @
getTextClusterNumGlyphs :: MonadIO m => TextCluster -> m Int32
getTextClusterNumGlyphs :: forall (m :: * -> *). MonadIO m => TextCluster -> m Int32
getTextClusterNumGlyphs TextCluster
s = IO Int32 -> m Int32
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ TextCluster -> (Ptr TextCluster -> IO Int32) -> IO Int32
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr TextCluster
s ((Ptr TextCluster -> IO Int32) -> IO Int32)
-> (Ptr TextCluster -> IO Int32) -> IO Int32
forall a b. (a -> b) -> a -> b
$ \Ptr TextCluster
ptr -> do
    Int32
val <- Ptr Int32 -> IO Int32
forall a. Storable a => Ptr a -> IO a
peek (Ptr TextCluster
ptr Ptr TextCluster -> Int -> Ptr Int32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
4) :: IO Int32
    Int32 -> IO Int32
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
val

-- | Set the value of the “@num_glyphs@” field.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.set' textCluster [ #numGlyphs 'Data.GI.Base.Attributes.:=' value ]
-- @
setTextClusterNumGlyphs :: MonadIO m => TextCluster -> Int32 -> m ()
setTextClusterNumGlyphs :: forall (m :: * -> *). MonadIO m => TextCluster -> Int32 -> m ()
setTextClusterNumGlyphs TextCluster
s Int32
val = 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
$ TextCluster -> (Ptr TextCluster -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr TextCluster
s ((Ptr TextCluster -> IO ()) -> IO ())
-> (Ptr TextCluster -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr TextCluster
ptr -> do
    Ptr Int32 -> Int32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr TextCluster
ptr Ptr TextCluster -> Int -> Ptr Int32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
4) (Int32
val :: Int32)

#if defined(ENABLE_OVERLOADING)
data TextClusterNumGlyphsFieldInfo
instance AttrInfo TextClusterNumGlyphsFieldInfo where
    type AttrBaseTypeConstraint TextClusterNumGlyphsFieldInfo = (~) TextCluster
    type AttrAllowedOps TextClusterNumGlyphsFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint TextClusterNumGlyphsFieldInfo = (~) Int32
    type AttrTransferTypeConstraint TextClusterNumGlyphsFieldInfo = (~)Int32
    type AttrTransferType TextClusterNumGlyphsFieldInfo = Int32
    type AttrGetType TextClusterNumGlyphsFieldInfo = Int32
    type AttrLabel TextClusterNumGlyphsFieldInfo = "num_glyphs"
    type AttrOrigin TextClusterNumGlyphsFieldInfo = TextCluster
    attrGet = getTextClusterNumGlyphs
    attrSet = setTextClusterNumGlyphs
    attrConstruct = undefined
    attrClear = undefined
    attrTransfer _ v = do
        return v
    dbgAttrInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Cairo.Structs.TextCluster.numGlyphs"
        , O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-cairo-1.0.30/docs/GI-Cairo-Structs-TextCluster.html#g:attr:numGlyphs"
        })

textCluster_numGlyphs :: AttrLabelProxy "numGlyphs"
textCluster_numGlyphs = AttrLabelProxy

#endif



#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList TextCluster
type instance O.AttributeList TextCluster = TextClusterAttributeList
type TextClusterAttributeList = ('[ '("numBytes", TextClusterNumBytesFieldInfo), '("numGlyphs", TextClusterNumGlyphsFieldInfo)] :: [(Symbol, DK.Type)])
#endif

#if defined(ENABLE_OVERLOADING)
type family ResolveTextClusterMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
    ResolveTextClusterMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveTextClusterMethod t TextCluster, O.OverloadedMethod info TextCluster p) => OL.IsLabel t (TextCluster -> 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 ~ ResolveTextClusterMethod t TextCluster, O.OverloadedMethod info TextCluster p, R.HasField t TextCluster p) => R.HasField t TextCluster p where
    getField = O.overloadedMethod @info

#endif

instance (info ~ ResolveTextClusterMethod t TextCluster, O.OverloadedMethodInfo info TextCluster) => OL.IsLabel t (O.MethodProxy info TextCluster) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.MethodProxy
#else
    fromLabel _ = O.MethodProxy
#endif

#endif