{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.GLib.Unions.FloatIEEE754
(
FloatIEEE754(..) ,
newZeroFloatIEEE754 ,
noFloatIEEE754 ,
#if defined(ENABLE_OVERLOADING)
ResolveFloatIEEE754Method ,
#endif
#if defined(ENABLE_OVERLOADING)
floatIEEE754_vFloat ,
#endif
getFloatIEEE754VFloat ,
setFloatIEEE754VFloat ,
) 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
newtype FloatIEEE754 = FloatIEEE754 (ManagedPtr FloatIEEE754)
deriving (FloatIEEE754 -> FloatIEEE754 -> Bool
(FloatIEEE754 -> FloatIEEE754 -> Bool)
-> (FloatIEEE754 -> FloatIEEE754 -> Bool) -> Eq FloatIEEE754
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FloatIEEE754 -> FloatIEEE754 -> Bool
$c/= :: FloatIEEE754 -> FloatIEEE754 -> Bool
== :: FloatIEEE754 -> FloatIEEE754 -> Bool
$c== :: FloatIEEE754 -> FloatIEEE754 -> Bool
Eq)
instance WrappedPtr FloatIEEE754 where
wrappedPtrCalloc :: IO (Ptr FloatIEEE754)
wrappedPtrCalloc = Int -> IO (Ptr FloatIEEE754)
forall a. Int -> IO (Ptr a)
callocBytes 4
wrappedPtrCopy :: FloatIEEE754 -> IO FloatIEEE754
wrappedPtrCopy = \p :: FloatIEEE754
p -> FloatIEEE754
-> (Ptr FloatIEEE754 -> IO FloatIEEE754) -> IO FloatIEEE754
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr FloatIEEE754
p (Int -> Ptr FloatIEEE754 -> IO (Ptr FloatIEEE754)
forall a. WrappedPtr a => Int -> Ptr a -> IO (Ptr a)
copyBytes 4 (Ptr FloatIEEE754 -> IO (Ptr FloatIEEE754))
-> (Ptr FloatIEEE754 -> IO FloatIEEE754)
-> Ptr FloatIEEE754
-> IO FloatIEEE754
forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> (ManagedPtr FloatIEEE754 -> FloatIEEE754)
-> Ptr FloatIEEE754 -> IO FloatIEEE754
forall a.
(HasCallStack, WrappedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapPtr ManagedPtr FloatIEEE754 -> FloatIEEE754
FloatIEEE754)
wrappedPtrFree :: Maybe (GDestroyNotify FloatIEEE754)
wrappedPtrFree = GDestroyNotify FloatIEEE754 -> Maybe (GDestroyNotify FloatIEEE754)
forall a. a -> Maybe a
Just GDestroyNotify FloatIEEE754
forall a. FunPtr (Ptr a -> IO ())
ptr_to_g_free
newZeroFloatIEEE754 :: MonadIO m => m FloatIEEE754
newZeroFloatIEEE754 :: m FloatIEEE754
newZeroFloatIEEE754 = IO FloatIEEE754 -> m FloatIEEE754
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO FloatIEEE754 -> m FloatIEEE754)
-> IO FloatIEEE754 -> m FloatIEEE754
forall a b. (a -> b) -> a -> b
$ IO (Ptr FloatIEEE754)
forall a. WrappedPtr a => IO (Ptr a)
wrappedPtrCalloc IO (Ptr FloatIEEE754)
-> (Ptr FloatIEEE754 -> IO FloatIEEE754) -> IO FloatIEEE754
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (ManagedPtr FloatIEEE754 -> FloatIEEE754)
-> Ptr FloatIEEE754 -> IO FloatIEEE754
forall a.
(HasCallStack, WrappedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapPtr ManagedPtr FloatIEEE754 -> FloatIEEE754
FloatIEEE754
instance tag ~ 'AttrSet => Constructible FloatIEEE754 tag where
new :: (ManagedPtr FloatIEEE754 -> FloatIEEE754)
-> [AttrOp FloatIEEE754 tag] -> m FloatIEEE754
new _ attrs :: [AttrOp FloatIEEE754 tag]
attrs = do
FloatIEEE754
o <- m FloatIEEE754
forall (m :: * -> *). MonadIO m => m FloatIEEE754
newZeroFloatIEEE754
FloatIEEE754 -> [AttrOp FloatIEEE754 'AttrSet] -> m ()
forall o (m :: * -> *).
MonadIO m =>
o -> [AttrOp o 'AttrSet] -> m ()
GI.Attributes.set FloatIEEE754
o [AttrOp FloatIEEE754 tag]
[AttrOp FloatIEEE754 'AttrSet]
attrs
FloatIEEE754 -> m FloatIEEE754
forall (m :: * -> *) a. Monad m => a -> m a
return FloatIEEE754
o
noFloatIEEE754 :: Maybe FloatIEEE754
noFloatIEEE754 :: Maybe FloatIEEE754
noFloatIEEE754 = Maybe FloatIEEE754
forall a. Maybe a
Nothing
getFloatIEEE754VFloat :: MonadIO m => FloatIEEE754 -> m Float
getFloatIEEE754VFloat :: FloatIEEE754 -> m Float
getFloatIEEE754VFloat s :: FloatIEEE754
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
$ FloatIEEE754 -> (Ptr FloatIEEE754 -> IO Float) -> IO Float
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr FloatIEEE754
s ((Ptr FloatIEEE754 -> IO Float) -> IO Float)
-> (Ptr FloatIEEE754 -> IO Float) -> IO Float
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr FloatIEEE754
ptr -> do
CFloat
val <- Ptr CFloat -> IO CFloat
forall a. Storable a => Ptr a -> IO a
peek (Ptr FloatIEEE754
ptr Ptr FloatIEEE754 -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0) :: 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'
setFloatIEEE754VFloat :: MonadIO m => FloatIEEE754 -> Float -> m ()
setFloatIEEE754VFloat :: FloatIEEE754 -> Float -> m ()
setFloatIEEE754VFloat s :: FloatIEEE754
s val :: 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
$ FloatIEEE754 -> (Ptr FloatIEEE754 -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr FloatIEEE754
s ((Ptr FloatIEEE754 -> IO ()) -> IO ())
-> (Ptr FloatIEEE754 -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr FloatIEEE754
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 FloatIEEE754
ptr Ptr FloatIEEE754 -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0) (CFloat
val' :: CFloat)
#if defined(ENABLE_OVERLOADING)
data FloatIEEE754VFloatFieldInfo
instance AttrInfo FloatIEEE754VFloatFieldInfo where
type AttrBaseTypeConstraint FloatIEEE754VFloatFieldInfo = (~) FloatIEEE754
type AttrAllowedOps FloatIEEE754VFloatFieldInfo = '[ 'AttrSet, 'AttrGet]
type AttrSetTypeConstraint FloatIEEE754VFloatFieldInfo = (~) Float
type AttrTransferTypeConstraint FloatIEEE754VFloatFieldInfo = (~)Float
type AttrTransferType FloatIEEE754VFloatFieldInfo = Float
type AttrGetType FloatIEEE754VFloatFieldInfo = Float
type AttrLabel FloatIEEE754VFloatFieldInfo = "v_float"
type AttrOrigin FloatIEEE754VFloatFieldInfo = FloatIEEE754
attrGet = getFloatIEEE754VFloat
attrSet = setFloatIEEE754VFloat
attrConstruct = undefined
attrClear = undefined
attrTransfer _ v = do
return v
floatIEEE754_vFloat :: AttrLabelProxy "vFloat"
floatIEEE754_vFloat = AttrLabelProxy
#endif
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList FloatIEEE754
type instance O.AttributeList FloatIEEE754 = FloatIEEE754AttributeList
type FloatIEEE754AttributeList = ('[ '("vFloat", FloatIEEE754VFloatFieldInfo)] :: [(Symbol, *)])
#endif
#if defined(ENABLE_OVERLOADING)
type family ResolveFloatIEEE754Method (t :: Symbol) (o :: *) :: * where
ResolveFloatIEEE754Method l o = O.MethodResolutionFailed l o
instance (info ~ ResolveFloatIEEE754Method t FloatIEEE754, O.MethodInfo info FloatIEEE754 p) => OL.IsLabel t (FloatIEEE754 -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod @info
#else
fromLabel _ = O.overloadedMethod @info
#endif
#endif