{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.Pango.Structs.AttrFloat
(
AttrFloat(..) ,
newZeroAttrFloat ,
noAttrFloat ,
#if defined(ENABLE_OVERLOADING)
ResolveAttrFloatMethod ,
#endif
#if defined(ENABLE_OVERLOADING)
attrFloat_attr ,
#endif
getAttrFloatAttr ,
#if defined(ENABLE_OVERLOADING)
attrFloat_value ,
#endif
getAttrFloatValue ,
setAttrFloatValue ,
) 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.GI.Base.Signals as B.Signals
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.Structs.Attribute as Pango.Attribute
newtype AttrFloat = AttrFloat (ManagedPtr AttrFloat)
deriving (AttrFloat -> AttrFloat -> Bool
(AttrFloat -> AttrFloat -> Bool)
-> (AttrFloat -> AttrFloat -> Bool) -> Eq AttrFloat
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AttrFloat -> AttrFloat -> Bool
$c/= :: AttrFloat -> AttrFloat -> Bool
== :: AttrFloat -> AttrFloat -> Bool
$c== :: AttrFloat -> AttrFloat -> Bool
Eq)
instance WrappedPtr AttrFloat where
wrappedPtrCalloc :: IO (Ptr AttrFloat)
wrappedPtrCalloc = Int -> IO (Ptr AttrFloat)
forall a. Int -> IO (Ptr a)
callocBytes 24
wrappedPtrCopy :: AttrFloat -> IO AttrFloat
wrappedPtrCopy = \p :: AttrFloat
p -> AttrFloat -> (Ptr AttrFloat -> IO AttrFloat) -> IO AttrFloat
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr AttrFloat
p (Int -> Ptr AttrFloat -> IO (Ptr AttrFloat)
forall a. WrappedPtr a => Int -> Ptr a -> IO (Ptr a)
copyBytes 24 (Ptr AttrFloat -> IO (Ptr AttrFloat))
-> (Ptr AttrFloat -> IO AttrFloat) -> Ptr AttrFloat -> IO AttrFloat
forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> (ManagedPtr AttrFloat -> AttrFloat)
-> Ptr AttrFloat -> IO AttrFloat
forall a.
(HasCallStack, WrappedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapPtr ManagedPtr AttrFloat -> AttrFloat
AttrFloat)
wrappedPtrFree :: Maybe (GDestroyNotify AttrFloat)
wrappedPtrFree = GDestroyNotify AttrFloat -> Maybe (GDestroyNotify AttrFloat)
forall a. a -> Maybe a
Just GDestroyNotify AttrFloat
forall a. FunPtr (Ptr a -> IO ())
ptr_to_g_free
newZeroAttrFloat :: MonadIO m => m AttrFloat
newZeroAttrFloat :: m AttrFloat
newZeroAttrFloat = IO AttrFloat -> m AttrFloat
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO AttrFloat -> m AttrFloat) -> IO AttrFloat -> m AttrFloat
forall a b. (a -> b) -> a -> b
$ IO (Ptr AttrFloat)
forall a. WrappedPtr a => IO (Ptr a)
wrappedPtrCalloc IO (Ptr AttrFloat)
-> (Ptr AttrFloat -> IO AttrFloat) -> IO AttrFloat
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (ManagedPtr AttrFloat -> AttrFloat)
-> Ptr AttrFloat -> IO AttrFloat
forall a.
(HasCallStack, WrappedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapPtr ManagedPtr AttrFloat -> AttrFloat
AttrFloat
instance tag ~ 'AttrSet => Constructible AttrFloat tag where
new :: (ManagedPtr AttrFloat -> AttrFloat)
-> [AttrOp AttrFloat tag] -> m AttrFloat
new _ attrs :: [AttrOp AttrFloat tag]
attrs = do
AttrFloat
o <- m AttrFloat
forall (m :: * -> *). MonadIO m => m AttrFloat
newZeroAttrFloat
AttrFloat -> [AttrOp AttrFloat 'AttrSet] -> m ()
forall o (m :: * -> *).
MonadIO m =>
o -> [AttrOp o 'AttrSet] -> m ()
GI.Attributes.set AttrFloat
o [AttrOp AttrFloat tag]
[AttrOp AttrFloat 'AttrSet]
attrs
AttrFloat -> m AttrFloat
forall (m :: * -> *) a. Monad m => a -> m a
return AttrFloat
o
noAttrFloat :: Maybe AttrFloat
noAttrFloat :: Maybe AttrFloat
noAttrFloat = Maybe AttrFloat
forall a. Maybe a
Nothing
getAttrFloatAttr :: MonadIO m => AttrFloat -> m Pango.Attribute.Attribute
getAttrFloatAttr :: AttrFloat -> m Attribute
getAttrFloatAttr s :: AttrFloat
s = IO Attribute -> m Attribute
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Attribute -> m Attribute) -> IO Attribute -> m Attribute
forall a b. (a -> b) -> a -> b
$ AttrFloat -> (Ptr AttrFloat -> IO Attribute) -> IO Attribute
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr AttrFloat
s ((Ptr AttrFloat -> IO Attribute) -> IO Attribute)
-> (Ptr AttrFloat -> IO Attribute) -> IO Attribute
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr AttrFloat
ptr -> do
let val :: Ptr Attribute
val = Ptr AttrFloat
ptr Ptr AttrFloat -> Int -> Ptr Attribute
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: (Ptr Pango.Attribute.Attribute)
Attribute
val' <- ((ManagedPtr Attribute -> Attribute)
-> Ptr Attribute -> IO Attribute
forall a.
(HasCallStack, WrappedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newPtr ManagedPtr Attribute -> Attribute
Pango.Attribute.Attribute) Ptr Attribute
val
Attribute -> IO Attribute
forall (m :: * -> *) a. Monad m => a -> m a
return Attribute
val'
#if defined(ENABLE_OVERLOADING)
data AttrFloatAttrFieldInfo
instance AttrInfo AttrFloatAttrFieldInfo where
type AttrBaseTypeConstraint AttrFloatAttrFieldInfo = (~) AttrFloat
type AttrAllowedOps AttrFloatAttrFieldInfo = '[ 'AttrGet]
type AttrSetTypeConstraint AttrFloatAttrFieldInfo = (~) (Ptr Pango.Attribute.Attribute)
type AttrTransferTypeConstraint AttrFloatAttrFieldInfo = (~)(Ptr Pango.Attribute.Attribute)
type AttrTransferType AttrFloatAttrFieldInfo = (Ptr Pango.Attribute.Attribute)
type AttrGetType AttrFloatAttrFieldInfo = Pango.Attribute.Attribute
type AttrLabel AttrFloatAttrFieldInfo = "attr"
type AttrOrigin AttrFloatAttrFieldInfo = AttrFloat
attrGet = getAttrFloatAttr
attrSet = undefined
attrConstruct = undefined
attrClear = undefined
attrTransfer = undefined
attrFloat_attr :: AttrLabelProxy "attr"
attrFloat_attr = AttrLabelProxy
#endif
getAttrFloatValue :: MonadIO m => AttrFloat -> m Double
getAttrFloatValue :: AttrFloat -> m Double
getAttrFloatValue s :: AttrFloat
s = IO Double -> m Double
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
$ AttrFloat -> (Ptr AttrFloat -> IO Double) -> IO Double
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr AttrFloat
s ((Ptr AttrFloat -> IO Double) -> IO Double)
-> (Ptr AttrFloat -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr AttrFloat
ptr -> do
CDouble
val <- Ptr CDouble -> IO CDouble
forall a. Storable a => Ptr a -> IO a
peek (Ptr AttrFloat
ptr Ptr AttrFloat -> Int -> Ptr CDouble
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16) :: IO CDouble
let val' :: Double
val' = CDouble -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac CDouble
val
Double -> IO Double
forall (m :: * -> *) a. Monad m => a -> m a
return Double
val'
setAttrFloatValue :: MonadIO m => AttrFloat -> Double -> m ()
setAttrFloatValue :: AttrFloat -> Double -> m ()
setAttrFloatValue s :: AttrFloat
s val :: Double
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ AttrFloat -> (Ptr AttrFloat -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr AttrFloat
s ((Ptr AttrFloat -> IO ()) -> IO ())
-> (Ptr AttrFloat -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr AttrFloat
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 AttrFloat
ptr Ptr AttrFloat -> Int -> Ptr CDouble
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16) (CDouble
val' :: CDouble)
#if defined(ENABLE_OVERLOADING)
data AttrFloatValueFieldInfo
instance AttrInfo AttrFloatValueFieldInfo where
type AttrBaseTypeConstraint AttrFloatValueFieldInfo = (~) AttrFloat
type AttrAllowedOps AttrFloatValueFieldInfo = '[ 'AttrSet, 'AttrGet]
type AttrSetTypeConstraint AttrFloatValueFieldInfo = (~) Double
type AttrTransferTypeConstraint AttrFloatValueFieldInfo = (~)Double
type AttrTransferType AttrFloatValueFieldInfo = Double
type AttrGetType AttrFloatValueFieldInfo = Double
type AttrLabel AttrFloatValueFieldInfo = "value"
type AttrOrigin AttrFloatValueFieldInfo = AttrFloat
attrGet = getAttrFloatValue
attrSet = setAttrFloatValue
attrConstruct = undefined
attrClear = undefined
attrTransfer _ v = do
return v
attrFloat_value :: AttrLabelProxy "value"
attrFloat_value = AttrLabelProxy
#endif
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList AttrFloat
type instance O.AttributeList AttrFloat = AttrFloatAttributeList
type AttrFloatAttributeList = ('[ '("attr", AttrFloatAttrFieldInfo), '("value", AttrFloatValueFieldInfo)] :: [(Symbol, *)])
#endif
#if defined(ENABLE_OVERLOADING)
type family ResolveAttrFloatMethod (t :: Symbol) (o :: *) :: * where
ResolveAttrFloatMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveAttrFloatMethod t AttrFloat, O.MethodInfo info AttrFloat p) => OL.IsLabel t (AttrFloat -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod @info
#else
fromLabel _ = O.overloadedMethod @info
#endif
#endif