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


@node Enum
@subsection Enum

G-Golf class, accessors, methods and procedures to deal with C enum
types.


@subheading Classes

@indentedblock
@table @code
@item @ref{<enum>}
@item @ref{<gi-enum>}
@end table
@end indentedblock


@subheading Procedures, Accessors and Methods

@indentedblock
@table @code
@item @ref{!enum-set}
@item @ref{enum->value}
@item @ref{enum->values}
@item @ref{enum->symbol}
@item @ref{enum->symbols}
@item @ref{enum->name}
@item @ref{enum->names}
@item @ref{!g-type_}
@item @ref{!g-name}
@item @ref{!name__}
@end table
@end indentedblock


@subheading Description

G-Golf class, accessors, methods and procedures to deal with C enum
types.


@subheading Classes

@anchor{<enum>}
@deftp Class <enum>

The @code{<enum>} class is for enumerated values. Its (unique) slot is:

@indentedblock
@table @code
@item @emph{enum-set}
#:accessor !enum-set @*
#:init-keyword #:enum-set
@end table
@end indentedblock

Notes:

@itemize
@item the @code{enum-set} can't be empty and so you must use the
@code{#:enum-set} (#:init-keyword) when creating new @code{<enum>}
instances;
@ifhtml
@*@*
@end ifhtml

@item
the @code{#:enum-set} (#:init-keyword) accepts either a list of symbols
or a well-formed @code{enum-set};
@ifhtml
@*@*
@end ifhtml

@item
a well-formed @code{enum-set} is a list of @code{(symbol . id)} pairs,
where @code{id} is a positive integer.
@ifhtml
@*@*
@end ifhtml

@item
each @code{symbol} and each @code{id} of an @code{enum-set} must be
unique.
@end itemize

Instances of the @code{<enum>} class are immutable (to be precise, there
are not meant to be mutated, see @ref{GOOPS Notes and Conventions},
'Slots are not Immutable').
@end deftp


@anchor{<gi-enum>}
@deftp Class <gi-enum>

The @code{<gi-enum>} class is a subclass of @code{<enum>}.  Its
@code{class-direct-slots} are:

@indentedblock
@table @code
@item @emph{g-type}
#:accessor !g-type	   @*
#:init-keyword #:g-type  @*
#:init-value #f

@item @emph{g-name}
#:accessor !g-name @*
#:init-keyword #:g-name

@item @emph{name}
#:accessor !name
@end table
@end indentedblock

The @code{name} slot is automatically initialized.

Instances of the @code{<gi-enum>} class are immutable (to be precise,
there are not meant to be mutated, see @ref{GOOPS Notes and
Conventions}, 'Slots are not Immutable').
@end deftp


@subheading Procedures, Accessors and Methods

@anchor{!enum-set}
@deffn Accessor !enum-set (inst <enum>)

Returns the content of the enum-set slot for @var{inst}.
@end deffn

@anchor{enum->value}
@anchor{enum->values}
@deffn Method enum->value (inst <enum>) symbol
@deffnx Method enum->values (inst <enum>)

Returns the @var{inst} value for @var{symbol} (or @code{#f} if it does
not exists), or the list of all values for @var{inst}, respectively.
@end deffn


@anchor{enum->symbol}
@anchor{enum->symbols}
@deffn Method enum->symbol (inst <enum>) value
@deffnx Method enum->symbols (inst <enum>)

Returns the @var{inst} symbol for @var{value} (or @code{#f} if it does
not exists), or the list of all symbols for @var{inst}, respectively.
@end deffn


@anchor{enum->name}
@anchor{enum->names}
@deffn Method enum->name (inst <enum>) value
@deffnx Method enum->names (inst <enum>)

Returns the @var{inst} name (the string representation of the symbol)
for @var{value} (or @code{#f} if it does not exists), or the list of all
names for @var{inst}, respectively.

@var{value} can either be a @code{symbol} or an @code{id}.
@end deffn


@anchor{!g-type_}
@anchor{!g-name}
@anchor{!name__}
@deffn Accessor !g-type (inst <gi-enum>)
@deffnx Accessor !g-name (inst <gi-enum>)
@deffnx Accessor !name (inst <gi-enum>)

Returns the content of the g-type, g-name or name slot for @var{inst},
respectively.
@end deffn
