@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 rt


@node Registered Type Info
@subsection Registered Type Info

G-Golf Registered Type Info low level API.@*
GIRegisteredTypeInfo — Struct representing a struct with a @code{GType}. 


@subheading Procedures

@indentedblock
@table @code
@item @ref{gi-registered-type-info-name}
@item @ref{g-registered-type-info-get-type-name}
@item @ref{g-registered-type-info-get-type-init}
@item @ref{g-registered-type-info-get-g-type}
@end table
@end indentedblock


@c @subheading Types and Values

@c @indentedblock
@c @table @code
@c @ref{...}
@c @end table
@c @end indentedblock


@subheading Struct Hierarchy

@indentedblock
GIBaseInfo					@*
@ @ +----GIRegisteredTypeInfo			@*
@ @ @ @ @ @ @ @ @ @ @ +----GIEnumInfo		@*
@ @ @ @ @ @ @ @ @ @ @ +----GIInterfaceInfo	@*
@ @ @ @ @ @ @ @ @ @ @ +----GIObjectInfo		@*
@ @ @ @ @ @ @ @ @ @ @ +----GIStructInfo		@*
@ @ @ @ @ @ @ @ @ @ @ +----GIUnionInfo
@end indentedblock


@subheading Description

@code{GIRegisteredTypeInfo} represents an entity with a @code{GType}
associated. Could be either a @code{GIEnumInfo}, @code{GIInterfaceInfo},
@code{GIObjectInfo}, @code{GIStructInfo} or a @code{GIUnionInfo}.

A registered type info struct has a name and a type function.


@subheading Procedures

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


@anchor{gi-registered-type-info-name}
@deffn Procedure gi-registered-type-info-name info

Returns a type name.

Some registered type are not @samp{registered}, and calling
@ref{g-registered-type-info-get-type-name} returns
@code{#f}@footnote{Another symptom for those is that if if you call
@code{(@ref{g-type-name} g-type)}, it returns @code{"void"}.}.

Even though they are @samp{unnamed}, some are present in their typelib,
like @code{"GLib" "SpawnFlags"}, or @code{"GObject" "ParamFlags"}, and
may be imported - sometimes manually, sometimes automatically.

In G-Golf, imported @code{GIRegisteredTypeInfo} must have a unique name,
since it is used as the secondary key in its cache @samp{mechanism} (See
@ref{Cache Park}).

Obtains and returns a unique name for @var{info}. If
@ref{g-registered-type-info-get-type-name} returns a name, that name is
returned. Otherwise, it returns a name composed of the @code{namespace}
and @code{name} for @var{info}.

Here is an example, to illustrate:

@lisp
(g-irepository-find-by-name "GObject" "ParamFlags")
@result{} $2 = #<pointer 0x5654c59ee4f0>

(g-registered-type-info-get-type-name $2)
@result{} $3 = #f

(gi-registered-type-info-name $2)
@result{} $4 = "GObjectParamFlags"

(g-name->name $4)
@result{} $5 = g-object-param-flags
@end lisp
@end deffn


@anchor{g-registered-type-info-get-type-name}
@deffn Procedure g-registered-type-info-get-type-name info

Returns the type name.

Obtain the type name of the struct within the GObject type system. This
name can be passed to g_type_from_name to get a GType.
@end deffn


@anchor{g-registered-type-info-get-type-init}
@deffn Procedure g-registered-type-info-get-type-init info

Returns the name of the type init function.

Obtain the type init function for @var{info}. The type init function is
the function which will register the @code{GType} within the
@code{GObject} type system. Usually this is not called by langauge
bindings or applications.
@end deffn


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

Returns the @code{GType} for @var{info}.

Obtain the @code{GType} for this registered type or @code{G_TYPE_NONE}
which has a special meaning.  It means that either there is no type
information associated with this info or that the shared library which
provides the type_init function for this info cannot be called.
@end deffn


@c @subheading Types and Values
