@c -*-texinfo-*-
@c This is part of the GNU G-Golf Reference Manual.
@c Copyright (C) 2016 - 2022 Free Software Foundation, Inc.
@c See the file g-golf.texi for copying conditions.


@defindex ti


@node Type Info
@subsection Type Info

G-Golf Type Info low level API.@*
GITypeInfo — Struct representing a type.


@subheading Procedures

@indentedblock
@table @code
@item @ref{g-info-type-to-string}
@item @ref{g-type-info-is-pointer}
@item @ref{g-type-info-get-tag}
@item @ref{g-type-info-get-param-type}
@item @ref{g-type-info-get-interface}
@item @ref{g-type-info-get-array-length}
@item @ref{g-type-info-get-array-fixed-size}
@item @ref{g-type-info-is-zero-terminated}
@item @ref{g-type-info-get-array-type}
@end table
@end indentedblock


@subheading Struct Hierarchy

@indentedblock
GIBaseInfoInfo         	                     @*
@ @ +--- GITypeInfo
@end indentedblock


@subheading Description

@code{GITypeInfo} represents a type. You can retrieve a type info from
an argument (see @ref{Arg Info}), a functions return value (see
@ref{Function Info}), a field (see @code{GIFieldInfo}), a property (see
@ref{Property Info}), a constant (see @code{GIConstantInfo}) or for a
union discriminator (see @code{GIUnionInfo}).

A type can either be a of a basic type which is a standard C primitive
type or an interface type. For interface types you need to call
@code{g-type-info-get-interface} to get a reference to the base info for
that interface.


@subheading Procedures

Note: in this section, the @var{info} argument is [must be] a pointer to
a @code{GITypeInfo}.


@anchor{g-info-type-to-string}
@deffn Procedure g-info-type-to-string info-type

Returns a string or @code{#f}.

Obtains the string representation for @var{info-type} or @code{#f} if it
does not exists.

@var{info-type} can either be a @code{symbol} or an @code{id}, a member
of the @code{enum-set} of @ref{%gi-info-type} (otherwise, @code{#f} is
returned).
@end deffn


@anchor{g-type-info-is-pointer}
@deffn Procedure g-type-info-is-pointer info

Returns @code{#t} or @code{#f}.

Obtains if the @var{info} type is passed as a reference.

Note that the types of @code{out} and @code{inout} parameters (see
@ref{%gi-direction}) will only be pointers if the underlying type being
transferred is a pointer (i.e. only if the type of the C function’s
formal parameter is a pointer to a pointer).
@end deffn


@anchor{g-type-info-get-tag}
@deffn Procedure g-type-info-get-tag info

Returns a symbol.

Obtains the type tag for @var{info} (see @ref{%gi-type-tag} for the list
of type tags).
@end deffn


@anchor{g-type-info-get-param-type}
@deffn Procedure g-type-info-get-param-type info n

Returns a pointer or @code{#f}.

Obtains the parameter type @var{n} (the index of the parameter).  When
there is no such @var{n} parameter, the procedure returns @code{#f}.
@end deffn


@anchor{g-type-info-get-interface}
@deffn Procedure g-type-info-get-interface info

Returns a pointer or @code{#f}.

For @code{interface} types (see @ref{%gi-type-tag}) such as GObjects and
boxed values, this procedure returns a (pointer to a) @code{GIBaseInfo},
holding full information about the referenced type.  You can then
inspect the type of the returned @code{GIBaseInfo} to further query
whether it is a concrete GObject, a GInterface, a structure, etc. using
@ref{g-base-info-get-type}.
@end deffn


@anchor{g-type-info-get-array-length}
@deffn Procedure g-type-info-get-array-length info

Returns an interger.

Obtain the array length of the type. The type tag must be a @code{array}
(see @ref{%gi-type-tag}), or -1 will returned.
@end deffn


@anchor{g-type-info-get-array-fixed-size}
@deffn Procedure g-type-info-get-array-fixed-size info

Returns an interger.

Obtain the fixed array syze of the type. The type tag must be a
@code{array} (see @ref{%gi-type-tag}), or -1 will returned.
@end deffn


@anchor{g-type-info-is-zero-terminated}
@deffn Procedure g-type-info-is-zero-terminated info

Returns @code{#t} or @code{#f}.

Obtains if the last element of the array is @code{NULL}.  The type tag
must be a @code{array} (see @ref{%gi-type-tag}), or @code{#f} will
returned.
@end deffn


@anchor{g-type-info-get-array-type}
@deffn Procedure g-type-info-get-array-type info

Returns a symbol or @code{#f}.

Obtain the array type for this type (see @ref{%gi-array-type}).  If the
type tag of this type is not array, @code{#f} will be returned.
@end deffn
