haskell-gi-0.15: Generate Haskell bindings for GObject Introspection capable libraries

Safe HaskellNone
LanguageHaskell98

Data.GI.CodeGen.Callable

Synopsis

Documentation

callableSignature :: Callable -> Bool -> ExcCodeGen ([Text], [(Text, Text)]) Source

The Haskell signature for the given callable. It returns a tuple ([constraints], [(type, argname)]).

fixupCallerAllocates :: Callable -> Callable Source

caller-allocates arguments are arguments that the caller allocates, and the called function modifies. They are marked as out argumens in the introspection data, we treat them as inout arguments instead. The semantics are somewhat tricky: for memory management purposes they should be treated as "in" arguments, but from the point of view of the exposed API they should be treated as "inout". Unfortunately we cannot always just assume that they are purely "out", so in many cases the generated API is somewhat suboptimal (since the initial values are not important): for example for g_io_channel_read_chars the size of the buffer to read is determined by the caller-allocates argument. As a compromise, we assume that we can allocate anything that is not a TCArray.

wrapMaybe :: Arg -> CodeGen Bool Source

Given an argument to a function, return whether it should be wrapped in a maybe type (useful for nullable types). We do some sanity checking to make sure that the argument is actually nullable (a relatively common annotation mistake is to mix up (optional) with (nullable)).