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

Safe HaskellNone
LanguageHaskell98

Data.GI.Base.BasicTypes

Contents

Description

Basic types used in the bindings.

Synopsis

GType related

Memory management

data ManagedPtr a #

Thin wrapper over ForeignPtr, supporting the extra notion of disowning, that is, not running the finalizers associated with the foreign ptr.

Constructors

ManagedPtr 

Fields

type ManagedPtrNewtype a = Coercible a (ManagedPtr ()) #

A constraint ensuring that the given type is coercible to a ManagedPtr. It will hold for newtypes of the form

newtype Foo = Foo (ManagedPtr Foo)

which is the typical shape of wrapped GObjects.

class ManagedPtrNewtype a => BoxedObject a where #

Wrapped boxed structures, identified by their GType.

Minimal complete definition

boxedType

Methods

boxedType :: a -> IO GType #

class BoxedEnum a where #

Enums with an associated GType.

Minimal complete definition

boxedEnumType

Methods

boxedEnumType :: a -> IO GType #

class BoxedFlags a where #

Flags with an associated GType.

Minimal complete definition

boxedFlagsType

Methods

boxedFlagsType :: Proxy a -> IO GType #

class ManagedPtrNewtype a => GObject a where #

A wrapped GObject.

Minimal complete definition

gobjectType

Methods

gobjectType :: a -> IO GType #

The GType for this object.

Instances

(TypeError Constraint ((:<>:) ((:<>:) (Text "Type \8216") (ShowType * a)) (Text "\8217 does not descend from GObject.")), ManagedPtrNewtype a) => GObject a # 

Methods

gobjectType :: a -> IO GType #

class ManagedPtrNewtype a => WrappedPtr a where #

Pointers to structs/unions without an associated GType.

Minimal complete definition

wrappedPtrCalloc, wrappedPtrCopy, wrappedPtrFree

Methods

wrappedPtrCalloc :: IO (Ptr a) #

Allocate a zero-initialized block of memory for the given type.

wrappedPtrCopy :: a -> IO a #

Make a copy of the given WrappedPtr.

wrappedPtrFree :: Maybe (FunPtr (Ptr a -> IO ())) #

A pointer to a function for freeing the given pointer, or Nothing is the memory associated to the pointer does not need to be freed.

data UnexpectedNullPointerReturn #

A common omission in the introspection data is missing (nullable) annotations for return types, when they clearly are nullable. (A common idiom is "Returns: valid value, or %NULL if something went wrong.")

Haskell wrappers will raise this exception if the return value is an unexpected nullPtr.

class NullToNothing a where #

Minimal complete definition

nullToNothing

Methods

nullToNothing :: MonadIO m => IO a -> m (Maybe (UnMaybe a)) #

Deprecated: This will be removed in future versions of haskell-gi.If you know of wrong introspection data in a binding please report it as an issue athttp:/github.comhaskell-gi/haskell-giso that it can be fixed.

Some functions are not marked as having a nullable return type in the introspection data. The result is that they currently do not return a Maybe type. This functions lets you work around this in a way that will not break when the introspection data is fixed.

When you want to call a someHaskellGIFunction that may return null wrap the call like this.

nullToNothing (someHaskellGIFunction x y)

The result will be a Maybe type even if the introspection data has not been fixed for someHaskellGIFunction yet.

Instances

(~) * a (UnMaybe a) => NullToNothing a # 

Methods

nullToNothing :: MonadIO m => IO a -> m (Maybe (UnMaybe a)) #

NullToNothing (Maybe a) # 

Methods

nullToNothing :: MonadIO m => IO (Maybe a) -> m (Maybe (UnMaybe (Maybe a))) #

Basic GLib / GObject types

newtype GParamSpec #

A GParamSpec. See Data.GI.Base.GParamSpec for further methods.

data GArray a #

A GArray. Marshalling for this type is done in Data.GI.Base.BasicConversions, it is mapped to a list on the Haskell side.

Constructors

GArray (Ptr (GArray a)) 

data GPtrArray a #

A GPtrArray. Marshalling for this type is done in Data.GI.Base.BasicConversions, it is mapped to a list on the Haskell side.

Constructors

GPtrArray (Ptr (GPtrArray a)) 

data GByteArray #

A GByteArray. Marshalling for this type is done in Data.GI.Base.BasicConversions, it is packed to a ByteString on the Haskell side.

Constructors

GByteArray (Ptr GByteArray) 

data GHashTable a b #

A GHashTable. It is mapped to a Map on the Haskell side.

Constructors

GHashTable (Ptr (GHashTable a b)) 

data GList a #

A GList, mapped to a list on the Haskell side. Marshalling is done in Data.GI.Base.BasicConversions.

Constructors

GList (Ptr (GList a)) 

g_list_free :: Ptr (GList a) -> IO () #

Free the given GList.

data GSList a #

A GSList, mapped to a list on the Haskell side. Marshalling is done in Data.GI.Base.BasicConversions.

Constructors

GSList (Ptr (GSList a)) 

g_slist_free :: Ptr (GSList a) -> IO () #

Free the given GSList.

class Enum a => IsGFlag a #

An enum usable as a flag for a function.

newtype PtrWrapped a #

Some APIs, such as GHashTable, pass around scalar types wrapped into a pointer. We encode such a type as follows.

Constructors

PtrWrapped 

Fields

type GDestroyNotify a = FunPtr (Ptr a -> IO ()) #

Destroy the memory associated with a given pointer.