{- |
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.GObject.Unions.TypeCValue
    ( 

-- * Exported types
    TypeCValue(..)                          ,
    noTypeCValue                            ,


 -- * Properties
-- ** VDouble
    typeCValueReadVDouble                   ,


-- ** VInt
    typeCValueReadVInt                      ,


-- ** VInt64
    typeCValueReadVInt64                    ,


-- ** VLong
    typeCValueReadVLong                     ,


-- ** VPointer
    typeCValueReadVPointer                  ,




    ) 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.GObject.Types
import GI.GObject.Callbacks

newtype TypeCValue = TypeCValue (ForeignPtr TypeCValue)
noTypeCValue :: Maybe TypeCValue
noTypeCValue = Nothing

typeCValueReadVInt :: TypeCValue -> IO Int32
typeCValueReadVInt s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 0) :: IO Int32
    return val

typeCValueReadVLong :: TypeCValue -> IO Int64
typeCValueReadVLong s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 0) :: IO Int64
    return val

typeCValueReadVInt64 :: TypeCValue -> IO Int64
typeCValueReadVInt64 s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 0) :: IO Int64
    return val

typeCValueReadVDouble :: TypeCValue -> IO Double
typeCValueReadVDouble s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 0) :: IO CDouble
    let val' = realToFrac val
    return val'

typeCValueReadVPointer :: TypeCValue -> IO (Ptr ())
typeCValueReadVPointer s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 0) :: IO (Ptr ())
    return val