{-# 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.Glyph
    ( 

-- * Exported types
    Glyph(..)                               ,
    newZeroGlyph                            ,


 -- * Methods

#if defined(ENABLE_OVERLOADING)
    ResolveGlyphMethod                      ,
#endif



 -- * Properties


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

    getGlyphIndex                           ,
#if defined(ENABLE_OVERLOADING)
    glyph_index                             ,
#endif
    setGlyphIndex                           ,


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

    getGlyphX                               ,
#if defined(ENABLE_OVERLOADING)
    glyph_x                                 ,
#endif
    setGlyphX                               ,


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

    getGlyphY                               ,
#if defined(ENABLE_OVERLOADING)
    glyph_y                                 ,
#endif
    setGlyphY                               ,




    ) 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 Glyph = Glyph (SP.ManagedPtr Glyph)
    deriving (Glyph -> Glyph -> Bool
(Glyph -> Glyph -> Bool) -> (Glyph -> Glyph -> Bool) -> Eq Glyph
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Glyph -> Glyph -> Bool
== :: Glyph -> Glyph -> Bool
$c/= :: Glyph -> Glyph -> Bool
/= :: Glyph -> Glyph -> Bool
Eq)

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

foreign import ccall "cairo_gobject_glyph_get_type" c_cairo_gobject_glyph_get_type :: 
    IO GType

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

instance B.Types.TypedObject Glyph where
    glibType :: IO GType
glibType = IO GType
c_cairo_gobject_glyph_get_type

instance B.Types.GBoxed Glyph

-- | Convert t'Glyph' 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 Glyph) where
    gvalueGType_ :: IO GType
gvalueGType_ = IO GType
c_cairo_gobject_glyph_get_type
    gvalueSet_ :: Ptr GValue -> Maybe Glyph -> IO ()
gvalueSet_ Ptr GValue
gv Maybe Glyph
P.Nothing = Ptr GValue -> Ptr Glyph -> IO ()
forall a. Ptr GValue -> Ptr a -> IO ()
B.GValue.set_boxed Ptr GValue
gv (Ptr Glyph
forall a. Ptr a
FP.nullPtr :: FP.Ptr Glyph)
    gvalueSet_ Ptr GValue
gv (P.Just Glyph
obj) = Glyph -> (Ptr Glyph -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr Glyph
obj (Ptr GValue -> Ptr Glyph -> IO ()
forall a. Ptr GValue -> Ptr a -> IO ()
B.GValue.set_boxed Ptr GValue
gv)
    gvalueGet_ :: Ptr GValue -> IO (Maybe Glyph)
gvalueGet_ Ptr GValue
gv = do
        Ptr Glyph
ptr <- Ptr GValue -> IO (Ptr Glyph)
forall b. Ptr GValue -> IO (Ptr b)
B.GValue.get_boxed Ptr GValue
gv :: IO (Ptr Glyph)
        if Ptr Glyph
ptr Ptr Glyph -> Ptr Glyph -> Bool
forall a. Eq a => a -> a -> Bool
/= Ptr Glyph
forall a. Ptr a
FP.nullPtr
        then Glyph -> Maybe Glyph
forall a. a -> Maybe a
P.Just (Glyph -> Maybe Glyph) -> IO Glyph -> IO (Maybe Glyph)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ManagedPtr Glyph -> Glyph) -> Ptr Glyph -> IO Glyph
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
B.ManagedPtr.newBoxed ManagedPtr Glyph -> Glyph
Glyph Ptr Glyph
ptr
        else Maybe Glyph -> IO (Maybe Glyph)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Glyph
forall a. Maybe a
P.Nothing
        
    

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

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


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

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

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

glyph_index :: AttrLabelProxy "index"
glyph_index = AttrLabelProxy

#endif


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

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

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

glyph_x :: AttrLabelProxy "x"
glyph_x = AttrLabelProxy

#endif


-- | Get the value of the “@y@” field.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.get' glyph #y
-- @
getGlyphY :: MonadIO m => Glyph -> m Double
getGlyphY :: forall (m :: * -> *). MonadIO m => Glyph -> m Double
getGlyphY Glyph
s = IO Double -> m Double
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Double -> m Double) -> IO Double -> m Double
forall a b. (a -> b) -> a -> b
$ Glyph -> (Ptr Glyph -> IO Double) -> IO Double
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr Glyph
s ((Ptr Glyph -> IO Double) -> IO Double)
-> (Ptr Glyph -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr Glyph
ptr -> do
    CDouble
val <- Ptr CDouble -> IO CDouble
forall a. Storable a => Ptr a -> IO a
peek (Ptr Glyph
ptr Ptr Glyph -> Int -> Ptr CDouble
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
12) :: IO CDouble
    let val' :: Double
val' = CDouble -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac CDouble
val
    Double -> IO Double
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Double
val'

-- | Set the value of the “@y@” field.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.set' glyph [ #y 'Data.GI.Base.Attributes.:=' value ]
-- @
setGlyphY :: MonadIO m => Glyph -> Double -> m ()
setGlyphY :: forall (m :: * -> *). MonadIO m => Glyph -> Double -> m ()
setGlyphY Glyph
s Double
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
$ Glyph -> (Ptr Glyph -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr Glyph
s ((Ptr Glyph -> IO ()) -> IO ()) -> (Ptr Glyph -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Glyph
ptr -> do
    let val' :: CDouble
val' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
val
    Ptr CDouble -> CDouble -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr Glyph
ptr Ptr Glyph -> Int -> Ptr CDouble
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
12) (CDouble
val' :: CDouble)

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

glyph_y :: AttrLabelProxy "y"
glyph_y = AttrLabelProxy

#endif



#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList Glyph
type instance O.AttributeList Glyph = GlyphAttributeList
type GlyphAttributeList = ('[ '("index", GlyphIndexFieldInfo), '("x", GlyphXFieldInfo), '("y", GlyphYFieldInfo)] :: [(Symbol, DK.Type)])
#endif

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

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

#endif

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

#endif