Callable Info

G-Golf Callable Info low level API.
GICallableInfo — Struct representing a callable.

Procedures

g-callable-info-can-throw-gerror
g-callable-info-get-n-args
g-callable-info-get-arg
g-callable-info-get-caller-owns
g-callable-info-get-instance-ownership-transfer
g-callable-info-get-return-type
g-callable-info-invoke
g-callable-info-is-method
g-callable-info-may-return-null
g-callable-info-create-closure
g-callable-info-get-closure-native-address

Struct Hierarchy

GIBaseInfoInfo
  +— GICallableInfo
           +— GIFunctionInfo
           +— GICallbackInfo
           +— GISignalInfo
           +— GIVFuncInfo

Description

GICallableInfo represents an entity which is callable. Examples of callable are: functions (GIFunctionInfo), virtual functions, (GIVFuncInfo), callbacks (GICallbackInfo).

A callable has a list of arguments (GIArgInfo), a return type, direction and a flag which decides if it returns null.

Procedures

Note: in this section, the info argument is [must be] a pointer to a GICallableInfo.

Procedure: g-callable-info-can-throw-gerror info

Returns #t if the callable info can throw a GError, otherwise it returns #f.

Procedure: g-callable-info-get-n-args info

Returns the number of arguments this info expects.

Obtain the number of arguments (both IN and OUT) for this info.

Procedure: g-callable-info-get-arg info n

Returns a pointer to the nth GIArgInfo of info.

It must be freed by calling g-base-info-unref when done accessing the data.

Procedure: g-callable-info-get-caller-owns info

Returns a GITransfer enumerated value.

See whether the caller owns the return value of this callable. See %gi-transfer for the list of possible values.

Procedure: g-callable-info-get-instance-ownership-transfer info

Returns a GITransfer enumerated value.

Obtains the ownership transfer for the instance argument. See %gi-transfer for the list of possible values.

Procedure: g-callable-info-get-return-type info

Returns a pointer to the GITypeInfo.

It must be freed by calling g-base-info-unref when done accessing the data.

Procedure: g-callable-info-invoke info function in-args n-in out-args n-out r-val is-method throws g-error

Returns #t if the function has been invoked, #f if an error occured.

Invokes the function described in info with the given arguments. Note that inout parameters must appear in both argument lists. The arguments are:

info

a pointer to a GIFunctionInfo describing the function to invoke.

function

a pointer to the function to invoke.

in-args

a pointer to an array of GIArguments, one for each in and inout parameter of info. If there are no in parameter, in-args must be the %null-pointer.

n-in

the length of the in-args array.

out-args

a pointer to an array of GIArguments, one for each out and inout parameter of info. If there are no out parameter, out-args must be the %null-pointer.

n-out

the length of the out-args array.

r-val

a pointer to a GIArguments, the return location for the return value of the function. If the function returns void, r-val must be the %null-pointer.

is-method

is the callable info is a method.

throws

can the callable throw a GError.

g-error

a pointer to a newly allocated (and ‘empty’) GError (the recommended way for procedure calls that need such a pointer is to ‘surround’ the call using with-gerror).

Procedure: g-callable-info-is-method info

Returns #t if the callable info is a method, otherwise it return #f.

Determines if the callable info is a method. For GIVFuncInfo and GISignalInfo, this is always true. Otherwise, this looks at the GI_FUNCTION_IS_METHOD flag on the GIFunctionInfo.

Concretely, this function returns whether g-callable-info-get-n-args matches the number of arguments in the raw C method. For methods, there is one more C argument than is exposed by introspection: the ‘self’ or ‘this’ object.

Procedure: g-callable-info-may-return-null info

Returns #t if the callable info could return NULL.

See if a callable could return NULL.

Procedure: g-callable-info-create-closure info ffi-cif ffi-closure-callback user-data

Returns the ffi-closure or #f on error.

The return value should be freed by calling g-callable-info-destroy-closure.

Procedure: g-callable-info-get-closure-native-address info ffi-closure

Returns a pointer.

Obtain and return the callable code from ffi-closure prepared by g-callable-info-create-closure. The return value should be freed by calling g-callable-info-destroy-closure.