gi-glib-0.2.46.13: GI/GLib/Unions/DoubleIEEE754.hs
{- |
Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)
-}
module GI.GLib.Unions.DoubleIEEE754
(
-- * Exported types
DoubleIEEE754(..) ,
newZeroDoubleIEEE754 ,
noDoubleIEEE754 ,
-- * Properties
-- ** VDouble
doubleIEEE754ReadVDouble ,
) where
import Prelude ()
import Data.GI.Base.ShortPrelude
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import GI.GLib.Types
import GI.GLib.Callbacks
newtype DoubleIEEE754 = DoubleIEEE754 (ForeignPtr DoubleIEEE754)
-- | Construct a `DoubleIEEE754` struct initialized to zero.
newZeroDoubleIEEE754 :: MonadIO m => m DoubleIEEE754
newZeroDoubleIEEE754 = liftIO $ callocBytes 8 >>= wrapPtr DoubleIEEE754
noDoubleIEEE754 :: Maybe DoubleIEEE754
noDoubleIEEE754 = Nothing
doubleIEEE754ReadVDouble :: DoubleIEEE754 -> IO Double
doubleIEEE754ReadVDouble s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 0) :: IO CDouble
let val' = realToFrac val
return val'
type family ResolveDoubleIEEE754Method (t :: Symbol) (o :: *) :: * where
ResolveDoubleIEEE754Method l o = MethodResolutionFailed l o
instance (info ~ ResolveDoubleIEEE754Method t DoubleIEEE754, MethodInfo info DoubleIEEE754 p) => IsLabelProxy t (DoubleIEEE754 -> p) where
fromLabelProxy _ = overloadedMethod (MethodProxy :: MethodProxy info)
#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveDoubleIEEE754Method t DoubleIEEE754, MethodInfo info DoubleIEEE754 p) => IsLabel t (DoubleIEEE754 -> p) where
fromLabel _ = overloadedMethod (MethodProxy :: MethodProxy info)
#endif