{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson and Iñaki García Etxebarria
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- Data type for holding variation data. Registered OpenType
-- variation-axis tags are listed in
-- <https://docs.microsoft.com/en-us/typography/opentype/spec/dvaraxisreg OpenType Axis Tag Registry>.
-- 
-- /Since: 1.4.2/

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

module GI.HarfBuzz.Structs.VariationT
    ( 

-- * Exported types
    VariationT(..)                          ,
    newZeroVariationT                       ,


 -- * Methods

#if defined(ENABLE_OVERLOADING)
    ResolveVariationTMethod                 ,
#endif



 -- * Properties


-- ** tag #attr:tag#
-- | The @/hb_tag_t/@ tag of the variation-axis name

    getVariationTTag                        ,
    setVariationTTag                        ,
#if defined(ENABLE_OVERLOADING)
    variationT_tag                          ,
#endif


-- ** value #attr:value#
-- | The value of the variation axis

    getVariationTValue                      ,
    setVariationTValue                      ,
#if defined(ENABLE_OVERLOADING)
    variationT_value                        ,
#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.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.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


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

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

instance BoxedPtr VariationT where
    boxedPtrCopy :: VariationT -> IO VariationT
boxedPtrCopy = \VariationT
p -> VariationT -> (Ptr VariationT -> IO VariationT) -> IO VariationT
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr VariationT
p (Int -> Ptr VariationT -> IO (Ptr VariationT)
forall a. (HasCallStack, CallocPtr a) => Int -> Ptr a -> IO (Ptr a)
copyBytes Int
8 (Ptr VariationT -> IO (Ptr VariationT))
-> (Ptr VariationT -> IO VariationT)
-> Ptr VariationT
-> IO VariationT
forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> (ManagedPtr VariationT -> VariationT)
-> Ptr VariationT -> IO VariationT
forall a.
(HasCallStack, BoxedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
B.ManagedPtr.wrapPtr ManagedPtr VariationT -> VariationT
VariationT)
    boxedPtrFree :: VariationT -> IO ()
boxedPtrFree = \VariationT
x -> VariationT -> (Ptr VariationT -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
SP.withManagedPtr VariationT
x Ptr VariationT -> IO ()
forall a. Ptr a -> IO ()
SP.freeMem
instance CallocPtr VariationT where
    boxedPtrCalloc :: IO (Ptr VariationT)
boxedPtrCalloc = Int -> IO (Ptr VariationT)
forall a. Int -> IO (Ptr a)
callocBytes Int
8


-- | Construct a `VariationT` struct initialized to zero.
newZeroVariationT :: MonadIO m => m VariationT
newZeroVariationT :: forall (m :: * -> *). MonadIO m => m VariationT
newZeroVariationT = IO VariationT -> m VariationT
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO VariationT -> m VariationT) -> IO VariationT -> m VariationT
forall a b. (a -> b) -> a -> b
$ IO (Ptr VariationT)
forall a. CallocPtr a => IO (Ptr a)
boxedPtrCalloc IO (Ptr VariationT)
-> (Ptr VariationT -> IO VariationT) -> IO VariationT
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (ManagedPtr VariationT -> VariationT)
-> Ptr VariationT -> IO VariationT
forall a.
(HasCallStack, BoxedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapPtr ManagedPtr VariationT -> VariationT
VariationT

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


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

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

#if defined(ENABLE_OVERLOADING)
data VariationTTagFieldInfo
instance AttrInfo VariationTTagFieldInfo where
    type AttrBaseTypeConstraint VariationTTagFieldInfo = (~) VariationT
    type AttrAllowedOps VariationTTagFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint VariationTTagFieldInfo = (~) Word32
    type AttrTransferTypeConstraint VariationTTagFieldInfo = (~)Word32
    type AttrTransferType VariationTTagFieldInfo = Word32
    type AttrGetType VariationTTagFieldInfo = Word32
    type AttrLabel VariationTTagFieldInfo = "tag"
    type AttrOrigin VariationTTagFieldInfo = VariationT
    attrGet = getVariationTTag
    attrSet = setVariationTTag
    attrConstruct = undefined
    attrClear = undefined
    attrTransfer _ v = do
        return v
    dbgAttrInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.HarfBuzz.Structs.VariationT.tag"
        , O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-harfbuzz-0.0.6/docs/GI-HarfBuzz-Structs-VariationT.html#g:attr:tag"
        })

variationT_tag :: AttrLabelProxy "tag"
variationT_tag = AttrLabelProxy

#endif


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

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

#if defined(ENABLE_OVERLOADING)
data VariationTValueFieldInfo
instance AttrInfo VariationTValueFieldInfo where
    type AttrBaseTypeConstraint VariationTValueFieldInfo = (~) VariationT
    type AttrAllowedOps VariationTValueFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint VariationTValueFieldInfo = (~) Float
    type AttrTransferTypeConstraint VariationTValueFieldInfo = (~)Float
    type AttrTransferType VariationTValueFieldInfo = Float
    type AttrGetType VariationTValueFieldInfo = Float
    type AttrLabel VariationTValueFieldInfo = "value"
    type AttrOrigin VariationTValueFieldInfo = VariationT
    attrGet = getVariationTValue
    attrSet = setVariationTValue
    attrConstruct = undefined
    attrClear = undefined
    attrTransfer _ v = do
        return v
    dbgAttrInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.HarfBuzz.Structs.VariationT.value"
        , O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-harfbuzz-0.0.6/docs/GI-HarfBuzz-Structs-VariationT.html#g:attr:value"
        })

variationT_value :: AttrLabelProxy "value"
variationT_value = AttrLabelProxy

#endif



#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList VariationT
type instance O.AttributeList VariationT = VariationTAttributeList
type VariationTAttributeList = ('[ '("tag", VariationTTagFieldInfo), '("value", VariationTValueFieldInfo)] :: [(Symbol, *)])
#endif

#if defined(ENABLE_OVERLOADING)
type family ResolveVariationTMethod (t :: Symbol) (o :: *) :: * where
    ResolveVariationTMethod l o = O.MethodResolutionFailed l o

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

#endif

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

#endif