Data.GI.CodeGen.Conversions

Synopsis

# Documentation

genConversion :: Text -> Converter -> CodeGen Text Source #

Given an array, together with its type, return the code for reading its length.

Whether the callable has closure arguments (i.e. "user_data" style arguments).

hToF :: Type -> Transfer -> ExcCodeGen Converter Source #

fToH :: Type -> Transfer -> ExcCodeGen Converter Source #

transientToH :: Type -> Transfer -> ExcCodeGen Converter Source #

Somewhat like fToH, but with slightly different borrowing semantics: in the case of TransferNothing we wrap incoming pointers to boxed structs into transient ManagedPtrs (every other case behaves as fToH). These are ManagedPtrs for which we do not make a copy, and which will be disowned when the function exists, instead of making a copy that the GC will collect eventually.

This is necessary in order to get the semantics of callbacks and signals right: in some cases making a copy of the object does not simply increase the refcount, but rather makes a full copy. In this cases modification of the original object is not possible, but this is sometimes useful, see for example

Another situation where making a copy of incoming arguments is problematic is when the underlying library is not thread-safe. When running under the threaded GHC runtime it can happen that the GC runs on a different OS thread than the thread where the object was created, and this leads to rather mysterious bugs, see for example

This case is particularly nasty, since it affects onWidgetDraw, which is very common.

This translates GI types to the types used for generated Haskell code.

Basically like haskellType, but for types which admit a "isomorphic" version of the Haskell type distinct from the usual Haskell type. Generally the Haskell type we expose is isomorphic to the foreign type, but in some cases, such as callbacks with closure arguments, this does not hold, as we omit the closure arguments. This function returns a type which is actually isomorphic. There is another case this function deals with: for convenience untyped TGClosure types have a type variable on the Haskell side when they are arguments to functions, but we do not want this when they appear as arguments to callbacks/signals, or return types of properties, as it would force the type synonym/type family to depend on the type variable.

Given a type find the typeclasses the type belongs to, and return the representation of the type in the function signature and the list of typeclass constraints for the type.

Whether to expose closures and the associated destroy notify handlers in the Haskell wrapper.

Constructors

 WithClosures WithoutClosures

#### Instances

Instances details
 Source # Instance detailsDefined in Data.GI.CodeGen.Conversions Methods

If the given type maps to a list in Haskell, return the type of the elements, and the function that maps over them.

Returns whether the given type corresponds to a ManagedPtr instance (a thin wrapper over a ForeignPtr).

Returns whether the given type should be represented by a Maybe type on the Haskell side. This applies to all properties which have a C representation in terms of pointers, except for G(S)Lists, for which NULL is a valid G(S)List, and raw pointers, which we just pass through to the Haskell side. Notice that introspection annotations can override this.

Returns whether the given type is represented by a pointer on the C side.

Check whether the given type corresponds to a callback.

If the passed in type is nullable, return the conversion function between the FFI pointer type (may be a Ptr or a FunPtr) and the corresponding Maybe type.

An appropriate NULL value for the given type, for types which are represented by pointers on the C side.

Information on how to allocate the given type, if known.

Information on how to allocate a type.

Constructors

 TypeAllocInfo FieldstypeAllocInfoIsBoxed :: Bool typeAllocInfoSize :: IntIn bytes.

apply :: Constructor -> Converter Source #

mapC :: Constructor -> Converter Source #

literal :: Constructor -> Converter Source #

Constructors

 P Text M Text Id

#### Instances

Instances details
 Source # Instance detailsDefined in Data.GI.CodeGen.Conversions Methods Source # Instance detailsDefined in Data.GI.CodeGen.Conversions MethodsshowList :: [Constructor] -> ShowS # Source # Instance detailsDefined in Data.GI.CodeGen.Conversions Methods