haskell-gi-base-0.26.9: Foundation for libraries generated by haskell-gi

Safe Haskell | None
Language | Haskell2010

Data.GI.Base.GValue

Contents

- Constructing GValues
- Packing GValues into arrays
- Packing Haskell values into GValues
- Setters and getters

Synopsis

- newtype GValue = GValue (ManagedPtr GValue)
- class IsGValue a where
  - gvalueGType_ :: IO GType
  - gvalueSet_ :: Ptr GValue -> a -> IO ()
  - gvalueGet_ :: Ptr GValue -> IO a
- toGValue :: (IsGValue a, MonadIO m) => a -> m GValue
- fromGValue :: (IsGValue a, MonadIO m) => GValue -> m a
- data GValueConstruct o = GValueConstruct String GValue
- ptr_to_gvalue_free :: FunPtr (Ptr GValue -> IO ())
- newGValue :: GType -> IO GValue
- buildGValue :: GType -> (Ptr GValue -> a -> IO ()) -> a -> IO GValue
- disownGValue :: GValue -> IO (Ptr GValue)
- noGValue :: Maybe GValue
- newGValueFromPtr :: Ptr GValue -> IO GValue
- wrapGValuePtr :: Ptr GValue -> IO GValue
- unsetGValue :: Ptr GValue -> IO ()
- gvalueType :: GValue -> IO GType
- packGValueArray :: [GValue] -> IO (Ptr GValue)
- unpackGValueArrayWithLength :: Integral a => a -> Ptr GValue -> IO [GValue]
- mapGValueArrayWithLength :: Integral a => a -> (Ptr GValue -> IO c) -> Ptr GValue -> IO ()
- data HValue a
  - = HValue a
  - | NoHValue
- set_object :: GObject a => Ptr GValue -> Ptr a -> IO ()
- get_object :: GObject a => Ptr GValue -> IO (Ptr a)
- set_boxed :: Ptr GValue -> Ptr a -> IO ()
- get_boxed :: Ptr GValue -> IO (Ptr b)
- set_variant :: Ptr GValue -> Ptr GVariant -> IO ()
- get_variant :: Ptr GValue -> IO (Ptr GVariant)
- set_enum :: Ptr GValue -> CUInt -> IO ()
- get_enum :: Ptr GValue -> IO CUInt
- set_flags :: Ptr GValue -> CUInt -> IO ()
- get_flags :: Ptr GValue -> IO CUInt
- set_stablePtr :: Ptr GValue -> StablePtr a -> IO ()
- get_stablePtr :: Ptr GValue -> IO (StablePtr a)
- take_stablePtr :: Ptr GValue -> StablePtr a -> IO ()
- set_param :: Ptr GValue -> Maybe GParamSpec -> IO ()
- get_param :: Ptr GValue -> IO (Maybe GParamSpec)
- set_hvalue :: Typeable a => Ptr GValue -> HValue a -> IO ()
- get_hvalue :: Typeable a => Ptr GValue -> IO (HValue a)

# Constructing GValues

newtype GValue Source #

Haskell-side representation of a `GValue`.

Constructors

GValue (ManagedPtr GValue) |

#### Instances

Instances details

GBoxed GValue Source # | `GValue`s are registered as boxed in the GLib type system.
Instance details Defined in Data.GI.Base.GValue
TypedObject GValue Source # | Find the associated `GType` for `GValue`.
Instance details Defined in Data.GI.Base.GValue Methods glibType :: IO GType Source #
HasParentTypes GValue Source # |
Instance details Defined in Data.GI.Base.GValue
type ParentTypes GValue Source # | There are no types in the bindings that a `GValue` can be safely cast to.
Instance details Defined in Data.GI.Base.GValue type ParentTypes GValue = '[] :: [Type]

class IsGValue a where Source #

Class for types that can be marshaled back and forth between Haskell values and `GValue`s. These are low-level methods, you might want to use `toGValue` and `fromGValue` instead for a higher level interface.

Methods

gvalueGType_ Source #

Arguments

:: IO GType | `GType` for the `GValue` containing values of this type.

gvalueSet_ Source #

Arguments

:: Ptr GValue |
-> a |
-> IO () | Set the `GValue` to the given Haskell value.

gvalueGet_ Source #

Arguments

:: Ptr GValue |
-> IO a | Get the Haskel value inside the `GValue`.

#### Instances

Instances details

IsGValue CInt Source # |
Instance details Defined in Data.GI.Base.GValue Methods gvalueGType_ :: IO GType Source # gvalueSet_ :: Ptr GValue -> CInt -> IO () Source # gvalueGet_ :: Ptr GValue -> IO CInt Source #
IsGValue CLong Source # |
Instance details Defined in Data.GI.Base.GValue Methods gvalueGType_ :: IO GType Source # gvalueSet_ :: Ptr GValue -> CLong -> IO () Source # gvalueGet_ :: Ptr GValue -> IO CLong Source #
IsGValue CUInt Source # |
Instance details Defined in Data.GI.Base.GValue Methods gvalueGType_ :: IO GType Source # gvalueSet_ :: Ptr GValue -> CUInt -> IO () Source # gvalueGet_ :: Ptr GValue -> IO CUInt Source #
IsGValue CULong Source # |
Instance details Defined in Data.GI.Base.GValue Methods gvalueGType_ :: IO GType Source # gvalueSet_ :: Ptr GValue -> CULong -> IO () Source # gvalueGet_ :: Ptr GValue -> IO CULong Source #
IsGValue Int32 Source # |
Instance details Defined in Data.GI.Base.GValue Methods gvalueGType_ :: IO GType Source # gvalueSet_ :: Ptr GValue -> Int32 -> IO () Source # gvalueGet_ :: Ptr GValue -> IO Int32 Source #
IsGValue Int64 Source # |
Instance details Defined in Data.GI.Base.GValue Methods gvalueGType_ :: IO GType Source # gvalueSet_ :: Ptr GValue -> Int64 -> IO () Source # gvalueGet_ :: Ptr GValue -> IO Int64 Source #
IsGValue Word32 Source # |
Instance details Defined in Data.GI.Base.GValue Methods gvalueGType_ :: IO GType Source # gvalueSet_ :: Ptr GValue -> Word32 -> IO () Source # gvalueGet_ :: Ptr GValue -> IO Word32 Source #
IsGValue Word64 Source # |
Instance details Defined in Data.GI.Base.GValue Methods gvalueGType_ :: IO GType Source # gvalueSet_ :: Ptr GValue -> Word64 -> IO () Source # gvalueGet_ :: Ptr GValue -> IO Word64 Source #
IsGValue GType Source # |
Instance details Defined in Data.GI.Base.GValue Methods gvalueGType_ :: IO GType Source # gvalueSet_ :: Ptr GValue -> GType -> IO () Source # gvalueGet_ :: Ptr GValue -> IO GType Source #
IsGValue Bool Source # |
Instance details Defined in Data.GI.Base.GValue Methods gvalueGType_ :: IO GType Source # gvalueSet_ :: Ptr GValue -> Bool -> IO () Source # gvalueGet_ :: Ptr GValue -> IO Bool Source #
IsGValue Double Source # |
Instance details Defined in Data.GI.Base.GValue Methods gvalueGType_ :: IO GType Source # gvalueSet_ :: Ptr GValue -> Double -> IO () Source # gvalueGet_ :: Ptr GValue -> IO Double Source #
IsGValue Float Source # |
Instance details Defined in Data.GI.Base.GValue Methods gvalueGType_ :: IO GType Source # gvalueSet_ :: Ptr GValue -> Float -> IO () Source # gvalueGet_ :: Ptr GValue -> IO Float Source #
IsGValue (Ptr a) Source # |
Instance details Defined in Data.GI.Base.GValue Methods gvalueGType_ :: IO GType Source # gvalueSet_ :: Ptr GValue -> Ptr a -> IO () Source # gvalueGet_ :: Ptr GValue -> IO (Ptr a) Source #
IsGValue (StablePtr a) Source # |
Instance details Defined in Data.GI.Base.GValue Methods gvalueGType_ :: IO GType Source # gvalueSet_ :: Ptr GValue -> StablePtr a -> IO () Source # gvalueGet_ :: Ptr GValue -> IO (StablePtr a) Source #
Typeable a => IsGValue (HValue a) Source # |
Instance details Defined in Data.GI.Base.GValue Methods gvalueGType_ :: IO GType Source # gvalueSet_ :: Ptr GValue -> HValue a -> IO () Source # gvalueGet_ :: Ptr GValue -> IO (HValue a) Source #
IsGValue (Maybe GParamSpec) Source # |
Instance details Defined in Data.GI.Base.GValue Methods gvalueGType_ :: IO GType Source # gvalueSet_ :: Ptr GValue -> Maybe GParamSpec -> IO () Source # gvalueGet_ :: Ptr GValue -> IO (Maybe GParamSpec) Source #
IsGValue (Maybe Text) Source # |
Instance details Defined in Data.GI.Base.GValue Methods gvalueGType_ :: IO GType Source # gvalueSet_ :: Ptr GValue -> Maybe Text -> IO () Source # gvalueGet_ :: Ptr GValue -> IO (Maybe Text) Source #
IsGValue (Maybe String) Source # |
Instance details Defined in Data.GI.Base.GValue Methods gvalueGType_ :: IO GType Source # gvalueSet_ :: Ptr GValue -> Maybe String -> IO () Source # gvalueGet_ :: Ptr GValue -> IO (Maybe String) Source #

toGValue :: (IsGValue a, MonadIO m) => a -> m GValue Source #

Create a `GValue` from the given Haskell value.

fromGValue :: (IsGValue a, MonadIO m) => GValue -> m a Source #

Create a Haskell object out of the given `GValue`.

data GValueConstruct o Source #

A type holding a `GValue` with an associated label. It is parameterized by a phantom type encoding the target type for the `GValue` (useful when constructing properties).

Constructors

GValueConstruct String GValue |

ptr_to_gvalue_free :: FunPtr (Ptr GValue -> IO ()) Source #

A pointer to a function freeing GValues.

newGValue :: GType -> IO GValue Source #

Build a new, empty, `GValue` of the given type.

buildGValue :: GType -> (Ptr GValue -> a -> IO ()) -> a -> IO GValue Source #

A convenience function for building a new GValue and setting the initial value.

disownGValue :: GValue -> IO (Ptr GValue) Source #

Disown a `GValue`, i.e. do not unref the underlying object when the Haskell object is garbage collected.

noGValue :: Maybe GValue Source #

A convenient alias for `Nothing :: Maybe GValue`.

newGValueFromPtr :: Ptr GValue -> IO GValue Source #

Construct a Haskell wrapper for the given `GValue`, making a copy.

wrapGValuePtr :: Ptr GValue -> IO GValue Source #

Take ownership of a passed in `Ptr`.

unsetGValue :: Ptr GValue -> IO () Source #

Unset the `GValue`, freeing all resources associated to it.

gvalueType :: GValue -> IO GType Source #

Return the `GType` contained by a `GValue`.

# Packing GValues into arrays

packGValueArray :: [GValue] -> IO (Ptr GValue) Source #

Pack the given list of GValues contiguously into a C array

unpackGValueArrayWithLength :: Integral a => a -> Ptr GValue -> IO [GValue] Source #

Unpack an array of contiguous GValues into a list of GValues.

mapGValueArrayWithLength :: Integral a => a -> (Ptr GValue -> IO c) -> Ptr GValue -> IO () Source #

Map over the `GValue`s inside a C array.

# Packing Haskell values into GValues

data HValue a Source #

A type isomorphic to `Maybe a`, used to indicate to `fromGValue`/`toGValue` that we are packing a native Haskell value, without attempting to marshall it to the corresponding C type.

Constructors

HValue a | A packed value of type `a`
NoHValue | An empty `HValue`

#### Instances

Instances details

Show a => Show (HValue a) Source # |
Instance details Defined in Data.GI.Base.GValue Methods showsPrec :: Int -> HValue a -> ShowS Source # show :: HValue a -> String Source # showList :: [HValue a] -> ShowS Source #
Eq a => Eq (HValue a) Source # |
Instance details Defined in Data.GI.Base.GValue Methods (==) :: HValue a -> HValue a -> Bool Source # (/=) :: HValue a -> HValue a -> Bool Source #
Typeable a => IsGValue (HValue a) Source # |
Instance details Defined in Data.GI.Base.GValue Methods gvalueGType_ :: IO GType Source # gvalueSet_ :: Ptr GValue -> HValue a -> IO () Source # gvalueGet_ :: Ptr GValue -> IO (HValue a) Source #

# Setters and getters

set_object :: GObject a => Ptr GValue -> Ptr a -> IO () Source #

get_object :: GObject a => Ptr GValue -> IO (Ptr a) Source #

set_boxed :: Ptr GValue -> Ptr a -> IO () Source #

get_boxed :: Ptr GValue -> IO (Ptr b) Source #

set_variant :: Ptr GValue -> Ptr GVariant -> IO () Source #

get_variant :: Ptr GValue -> IO (Ptr GVariant) Source #

set_enum :: Ptr GValue -> CUInt -> IO () Source #

get_enum :: Ptr GValue -> IO CUInt Source #

set_flags :: Ptr GValue -> CUInt -> IO () Source #

get_flags :: Ptr GValue -> IO CUInt Source #

set_stablePtr :: Ptr GValue -> StablePtr a -> IO () Source #

Set the value of `GValue` containing a `StablePtr`

get_stablePtr :: Ptr GValue -> IO (StablePtr a) Source #

Get (a freshly allocated copy of) the value of a `GValue` containing a `StablePtr`

take_stablePtr :: Ptr GValue -> StablePtr a -> IO () Source #

Like `set_stablePtr`, but the `GValue` takes ownership of the `StablePtr`

set_param :: Ptr GValue -> Maybe GParamSpec -> IO () Source #

Set the value of `GValue` containing a `GParamSpec`

get_param :: Ptr GValue -> IO (Maybe GParamSpec) Source #

Get the value of a `GValue` containing a `GParamSpec`

set_hvalue :: Typeable a => Ptr GValue -> HValue a -> IO () Source #

Set the `GValue` to the given Haskell value.

get_hvalue :: Typeable a => Ptr GValue -> IO (HValue a) Source #

Read the Haskell value of the given type from the `GValue`. If the `GValue` contains no value of the expected type, `NoHValue` will be returned instead, and an error will be printed to stderr.