### ----------------------------------------------------
### -- Gnome::GObject
### -- Licenses: Artistic-2.0
### -- Authors: Marcel Timmerman
### -- File: lib/Gnome/GObject/Value.rakumod
### ----------------------------------------------------
### -- Chunk 1 of 3
#TL:1:Gnome::GObject::Value:

use v6;
#-------------------------------------------------------------------------------
=begin pod

=head1 Gnome::GObject::Value

Standard Parameter and Value Types

=head1 Description

This class provides an abstract container structure which can be copied, transformed and compared while holding a value of any (derived) type, which is registered as a GType with a GTypeValueTable in its GTypeInfo structure. Parameter specifications for most value types can be created as GParamSpec derived instances, to implement e.g. GObject properties which operate on GValue containers. (note that not everything is implemented in Raku)

Parameter names need to start with a letter (a-z or A-Z). Subsequent characters can be letters, numbers or a '-'. All other characters are replaced by a '-' during construction.

B<N-GValue> is a polymorphic type that can hold values of any other type operations and thus can be used as a type initializer for C<new(:$init)> and are defined by a separate interface. See the standard values API for details

The B<N-GValue> structure is basically a variable container that consists of a type identifier and a specific value of that type. The type identifier within a B<N-GValue> structure always determines the type of the associated value. To create an undefined B<N-GValue> structure, simply create a zero-filled B<N-GValue> structure. To initialize the B<N-GValue>, use the C<new(:$init)> function. A B<N-GValue> cannot be used until it is initialized. The basic type operations (such as freeing and copying) are determined by the B<GTypeValueTable> associated with the type ID stored in the B<N-GValue>. Other B<N-GValue> operations (such as converting values between types) are provided by this interface.

=begin comment
The code in the example program below demonstrates B<N-GValue>'s features.

|[<!-- language="C" -->
B<include> <glib-object.h>

static void
int2string (const GValue *src_value,
            GValue       *dest_value)
{
  if (g_value_get_int (src_value) == 42)
    g_value_set_static_string (dest_value, "An important number");
  else
    g_value_set_static_string (dest_value, "What's that?");
}

int
main (int   argc,
      char *argv[])
{
  // GValues must be initialized
  GValue a = G_VALUE_INIT;
  GValue b = G_VALUE_INIT;
  const gchar *message;

  // The GValue starts empty
  g_assert (!G_VALUE_HOLDS_STRING (&a));

  // Put a string in it
  g_value_init (&a,#notePE_STRING);
  g_assert (G_VALUE_HOLDS_STRING (&a));
  g_value_set_static_string (&a, "Hello, world!");
  g_printf ("C<s>\n", g_value_get_string (&a));

  // Reset it to its pristine state
  g_value_unset (&a);

  // It can then be reused for another type
  g_value_init (&a, G_TYPE_INT);
  g_value_set_int (&a, 42);

  // Attempt to transform it into a GValue of type STRING
  g_value_init (&b, G_TYPE_STRING);

  // An INT is transformable to a STRING
  g_assert (g_value_type_transformable (G_TYPE_INT, G_TYPE_STRING));

  g_value_transform (&a, &b);
  g_printf ("C<s>\n", g_value_get_string (&b));

  // Attempt to transform it again using a custom transform function
  g_value_register_transform_func (G_TYPE_INT, G_TYPE_STRING, int2string);
  g_value_transform (&a, &b);
  g_printf ("C<s>\n", g_value_get_string (&b));
  return 0;
}
]|
=end comment

=head1 Synopsis
=head2 Declaration

  unit class Gnome::GObject::Value;
  also is Gnome::GObject::Boxed;


=head2 Uml Diagram

![](plantuml/Value.svg)


=comment head2 Example

=end pod
#-------------------------------------------------------------------------------
use NativeCall;

use Gnome::N::X:api<1>;
use Gnome::N::NativeLib:api<1>;
#use Gnome::N::N-GValue:api<1>;
use Gnome::N::GlibToRakuTypes:api<1>;

use Gnome::GObject::Type:api<1>;
use Gnome::GObject::Boxed:api<1>;

#-------------------------------------------------------------------------------
# gvalue.h / .c
# gvaluetypes.h / .c
# gobject/genums.h /.c
#
# https://developer.gnome.org/gobject/stable/gobject-Generic-values.html
# https://developer.gnome.org/gobject/stable/gobject-Standard-Parameter-and-Value-Types.html
# https://developer.gnome.org/gobject/stable/gobject-Enumeration-and-Flag-Types.html
unit class Gnome::GObject::Value:auth<github:MARTIMM>:api<1>;
also is Gnome::GObject::Boxed;

#-------------------------------------------------------------------------------
=head1 Types

=begin pod
=head2 N-GValue

A structure to hold a type and a value.
=coment Its type is readable from the structure as a 32 bit integer and holds type values like C<G_TYPE_UCHAR> and C<G_TYPE_LONG>.

Dynamic types from native widgets are also stored. The static type names like C<G_TYPE_UCHAR> and C<G_TYPE_LONG>, are defined in B<Gnome::GObject::Type>.

=end pod

#TS:1:N-GValue:
class N-GValue is repr('CStruct') is export {
  has GType $.g-type;

  # Data is a union. We do not use it but GTK does, so here it is
  # only set to a type with 64 bits for the longest field in the union.
  has gint64 $!g-data;

  # As if it was G_VALUE_INIT macro. g_value_init() must have
  # the $!g-type set to 0.
  submethod TWEAK {
    $!g-type = 0;
    $!g-data = 0;
  }
}

#`{{
#-------------------------------------------------------------------------------
=begin pod
=head2 class N-GEnumValue

A structure which contains a single enum value, its name, and its nickname.

=item Int $.value: the enum value
=item Str $.value-name: the name of the value
=item Str $.value-nick: the nickname of the value

=end pod

#TT:0:N-GEnumValue:
class N-GEnumValue is export is repr('CStruct') {
  has gint $.value;
  has gchar-ptr $.value_name;
  has gchar-ptr $.value_nick;
}

#-------------------------------------------------------------------------------
=begin pod
=head2 class N-GFlagsValue

A structure which contains a single flags value, its name, and its nickname.

=item UInt $.value: the flags value
=item Str $.value-name: the name of the value
=item Str $.value-nick: the nickname of the value

=end pod

#TT:0:N-GFlagsValue:
class N-GFlagsValue is export is repr('CStruct') {
  has guint $.value;
  has gchar-ptr $.value_name;
  has gchar-ptr $.value_nick;
}
}}

#-------------------------------------------------------------------------------
has Hash $.map-type-to-method = %(
  G_TYPE_BOOLEAN.Str => 'get-boolean',
  G_TYPE_DOUBLE.Str => 'get-double',
  G_TYPE_ENUM.Str => 'get-enum',
  G_TYPE_FLAGS.Str => 'get-flags',
  G_TYPE_FLOAT.Str => 'get-float',
#   => get-gtype,
  G_TYPE_INT.Str => 'get-int',
  G_TYPE_INT64.Str => 'get-int64',
  G_TYPE_LONG.Str => 'get-long',
#   => get-pointer,
#   => get-schar,
  G_TYPE_STRING.Str => 'get-string',
  G_TYPE_UCHAR.Str => 'get-uchar',
  G_TYPE_UINT.Str => 'get-uint',
  G_TYPE_UINT64.Str => 'get-uint64',
  G_TYPE_ULONG.Str => 'get-ulong',
#   => get-variant,
);

#-------------------------------------------------------------------------------
#TODO add $!value-is-valid flag
#-------------------------------------------------------------------------------
=begin pod
=head1 Methods
=head2 new

=head3 :init

Create a value object and initialize to type. Exampes of a type is G_TYPE_INT or G_TYPE_BOOLEAN.

  multi method new ( Int :$init! )


=head3 :type, :value

Create a value object and initialize to type and set a value.

  multi method new ( Int :$type!, Any :$value! )


=head3 :gvalue

Create an object using a native object from elsewhere.

  multi method new ( N-GValue :$gvalue! )


=head3 :native-object

Create an object using a native object from elsewhere. See also B<Gnome::N::TopLevelSupportClass>.

  multi method new ( N-GValue :$native-object! )

=end pod

#TM:1:new(:init):
#TM:1:new(:type,:value):
#TM:4:new(:native-object):
submethod BUILD ( *%options ) {

  # prevent creating wrong widgets
  return unless self.^name eq 'Gnome::GObject::Value';

  my N-GValue $new-object;

  # check if native object is set by a parent class
  if self.is-valid { }

  # process all options

  # check if common options are handled by some parent
  elsif %options<native-object>:exists { }

  elsif ? %options<init> {
    $new-object = _g_value_init( N-GValue.new, %options<init>);
  }

  elsif %options<type>.defined and %options<value>.defined {
    my GType $type = %options<type>;
    $new-object = _g_value_init( N-GValue.new, $type);

    given $type {
      when G_TYPE_BOOLEAN {
        g_value_set_boolean( $new-object, %options<value>);
      }
      when G_TYPE_CHAR { g_value_set_schar( $new-object, %options<value>); }
      when G_TYPE_UCHAR { g_value_set_uchar( $new-object, %options<value>); }
      when G_TYPE_INT { g_value_set_int( $new-object, %options<value>); }
      when G_TYPE_UINT { g_value_set_uint( $new-object, %options<value>); }
      when G_TYPE_LONG { g_value_set_long( $new-object, %options<value>); }
      when G_TYPE_ULONG { g_value_set_ulong( $new-object, %options<value>); }
      when G_TYPE_INT64 { g_value_set_int64( $new-object, %options<value>); }
      when G_TYPE_UINT64 { g_value_set_uint64( $new-object, %options<value>); }
      when G_TYPE_FLOAT { g_value_set_float( $new-object, %options<value>); }
      when G_TYPE_DOUBLE { g_value_set_double( $new-object, %options<value>); }
      when G_TYPE_STRING { g_value_set_string( $new-object, %options<value>); }

      when G_TYPE_ENUM { g_value_set_enum( $new-object, %options<value>); }
      when G_TYPE_FLAGS { g_value_set_flags( $new-object, %options<value>); }

      when G_TYPE_OBJECT {note "Type object for %options<value> not yet available";}# { g_value_set_( $new-object, %options<value>); }
      when G_TYPE_POINTER {note "Type pointer for %options<value> not yet available";}# { g_value_set_( $new-object, %options<value>); }
      when G_TYPE_BOXED {note "Type boxed for %options<value> not yet available";}# { g_value_set_( $new-object, %options<value>); }
      when G_TYPE_PARAM {note "Type param for %options<value> not yet available";}# { g_value_set_( $new-object, %options<value>); }
      when G_TYPE_VARIANT {note "Type variant for %options<value> not yet available";}# { g_value_set_( $new-object, %options<value>); }
    }
  }

  elsif %options<gvalue> ~~ N-GValue {
    Gnome::N::deprecate(
      '.new(:gvalue)', '.new(:native-object)', '0.15.11', '0.18.0'
    );

    $new-object = %options<gvalue>;
  }
#`{{
  elsif ?%options<native-object> {
    $new-object = %options<native-object>;
    $new-object .= _get-native-object if $new-object ~~ Gnome::GObject::Value;
  }
}}

  elsif %options.keys.elems {
    die X::Gnome.new(
      :message('Unsupported options for ' ~ self.^name ~
               ': ' ~ %options.keys.join(', ')
              )
    );
  }

  if $new-object.defined {
#`{{
    if self.is-valid {
      g_value_unset(self._get-native-object);
#      self.set-valid(False);
    }
}}
    self._set-native-object($new-object);
  }

#note"Value: ", self._get-native-object.perl(), ', ', self.is-valid;

  # only after creating the native-object, the gtype is known
  self._set-class-info('GValue');
}

#-------------------------------------------------------------------------------
# no pod. user does not have to know about it.
method _fallback ( $native-sub is copy --> Callable ) {

  my Callable $s;
  try { $s = &::("g_value_$native-sub"); };
  try { $s = &::("g_$native-sub"); } unless ?$s;
  try { $s = &::($native-sub); } if !$s and $native-sub ~~ m/^ 'g_' /;

  self._set-class-name-of-sub('GValue');
  $s = callsame unless ?$s;

  $s;
}

#-------------------------------------------------------------------------------
# no ref/unref
method native-object-ref ( $n-native-object --> Any ) {
  $n-native-object
}

#-------------------------------------------------------------------------------
method native-object-unref ( $n-native-object ) {
#note'value cleared';
  _g_value_unset($n-native-object)
}



#-------------------------------------------------------------------------------
# TM:0:copy:
# TM:0:copy-rk:
=begin pod
=head2 copy, copy-rk

Copies the value of this Value object.

  method copy ( --> N-GValue )
  method copy-rk ( --> Gnome::GObject::Value )

=item N-GValue $dest_value; An initialized B<Gnome::GObject::Value> structure of the same type as I<src-value>.
=end pod

method copy ( --> N-GValue ) {
  my N-GValue $src_value = self._get-native-object-no-reffing;
  my N-GValue $dest_value .= new(:init($src_value.g-type));
  g_value_copy( $src_value, $dest_value);
  $dest_value
}

method copy-rk ( --> Gnome::GObject::Value ) {
  my N-GValue $src_value = self._get-native-object-no-reffing;
  my N-GValue $dest_value .= new(:init($src_value.g-type));
  g_value_copy( $src_value, $dest_value);
  Gnome::GObject::Value.new(:native-object($dest_value))
}

sub g_value_copy (
  N-GValue $src_value, N-GValue $dest_value
) is native(&gobject-lib)
  { * }

#`{{
#-------------------------------------------------------------------------------
# TM:0:dup-string:
=begin pod
=head2 dup-string

Get a copy the contents of a C<G-TYPE-STRING> B<Gnome::GObject::Value>.

Returns: a newly allocated copy of the string content of I<value>

  method dup-string ( --> Str )

=end pod

method dup-string ( --> Str ) {

  g_value_dup_string(
    self._get-native-object-no-reffing,
  )
}

sub g_value_dup_string (
  N-GValue $value --> gchar-ptr
) is native(&gobject-lib)
  { * }

#-------------------------------------------------------------------------------
# TM:0:dup-variant:
=begin pod
=head2 dup-variant

Get the contents of a variant B<Gnome::GObject::Value>, increasing its refcount. The returned B<Gnome::GObject::Variant> is never floating.

Returns: variant contents of I<value> (may be C<undefined>); should be unreffed using C<g-variant-unref()> when no longer needed

  method dup-variant ( --> N-GValue )

=end pod

method dup-variant ( --> N-GValue ) {

  g_value_dup_variant(
    self._get-native-object-no-reffing,
  )
}

sub g_value_dup_variant (
  N-GValue $value --> N-GValue
) is native(&gobject-lib)
  { * }
}}

#`{{
#-------------------------------------------------------------------------------
# TM:0:enum-complete-type-info:
=begin pod
=head2 enum-complete-type-info

This function is meant to be called from the `complete-type-info` function of a B<Gnome::GObject::TypePlugin> implementation, as in the following example:

|[<!-- language="C" --> static void my-enum-complete-type-info (GTypePlugin *plugin, GType g-type, GTypeInfo *info, GTypeValueTable *value-table) { static const GEnumValue values[] = { { MY-ENUM-FOO, "MY-ENUM-FOO", "foo" }, { MY-ENUM-BAR, "MY-ENUM-BAR", "bar" }, { 0, NULL, NULL } };

enum-complete-type-info (type, info, values); } ]|

  method enum-complete-type-info ( N-GValue $g_enum_type, GTypeInfo $info, GEnumValue $const_values )

=item N-GValue $g_enum_type; the type identifier of the type being completed
=item GTypeInfo $info; (out callee-allocates): the B<Gnome::GObject::TypeInfo> struct to be filled in
=item GEnumValue $const_values; An array of B<Gnome::GObject::EnumValue> structs for the possible enumeration values. The array is terminated by a struct with all members being 0.
=end pod

method enum-complete-type-info ( $g_enum_type is copy, GTypeInfo $info, GEnumValue $const_values ) {
  $g_enum_type .= _get-native-object-no-reffing unless $g_enum_type ~~ N-GValue;

  g_enum_complete_type_info(
    self._get-native-object-no-reffing, $g_enum_type, $info, $const_values
  );
}

sub g_enum_complete_type_info (
  N-GValue $g_enum_type, GTypeInfo $info, GEnumValue $const_values
) is native(&gobject-lib)
  { * }

#-------------------------------------------------------------------------------
# TM:0:enum-get-value:
=begin pod
=head2 enum-get-value

Returns the B<Gnome::GObject::EnumValue> for a value.

Returns: the B<Gnome::GObject::EnumValue> for I<value>, or C<undefined> if I<value> is not a member of the enumeration

  method enum-get-value ( GEnumClass $enum_class, Int() $value --> GEnumValue )

=item GEnumClass $enum_class; a B<Gnome::GObject::EnumClass>
=item Int() $value; the value to look up
=end pod

method enum-get-value ( GEnumClass $enum_class, Int() $value --> GEnumValue ) {

  g_enum_get_value(
    self._get-native-object-no-reffing, $enum_class, $value
  )
}

sub g_enum_get_value (
  GEnumClass $enum_class, gint $value --> GEnumValue
) is native(&gobject-lib)
  { * }

#-------------------------------------------------------------------------------
# TM:0:enum-get-value-by-name:
=begin pod
=head2 enum-get-value-by-name

Looks up a B<Gnome::GObject::EnumValue> by name.

Returns: the B<Gnome::GObject::EnumValue> with name I<name>, or C<undefined> if the enumeration doesn't have a member with that name

  method enum-get-value-by-name ( GEnumClass $enum_class, Str $name --> GEnumValue )

=item GEnumClass $enum_class; a B<Gnome::GObject::EnumClass>
=item Str $name; the name to look up
=end pod

method enum-get-value-by-name ( GEnumClass $enum_class, Str $name --> GEnumValue ) {

  g_enum_get_value_by_name(
    self._get-native-object-no-reffing, $enum_class, $name
  )
}

sub g_enum_get_value_by_name (
  GEnumClass $enum_class, gchar-ptr $name --> GEnumValue
) is native(&gobject-lib)
  { * }

#-------------------------------------------------------------------------------
# TM:0:enum-get-value-by-nick:
=begin pod
=head2 enum-get-value-by-nick

Looks up a B<Gnome::GObject::EnumValue> by nickname.

Returns: the B<Gnome::GObject::EnumValue> with nickname I<nick>, or C<undefined> if the enumeration doesn't have a member with that nickname

  method enum-get-value-by-nick ( GEnumClass $enum_class, Str $nick --> GEnumValue )

=item GEnumClass $enum_class; a B<Gnome::GObject::EnumClass>
=item Str $nick; the nickname to look up
=end pod

method enum-get-value-by-nick ( GEnumClass $enum_class, Str $nick --> GEnumValue ) {

  g_enum_get_value_by_nick(
    self._get-native-object-no-reffing, $enum_class, $nick
  )
}

sub g_enum_get_value_by_nick (
  GEnumClass $enum_class, gchar-ptr $nick --> GEnumValue
) is native(&gobject-lib)
  { * }

#-------------------------------------------------------------------------------
# TM:0:enum-register-static:
=begin pod
=head2 enum-register-static

Registers a new static enumeration type with the name I<name>.

It is normally more convenient to let [glib-mkenums][glib-mkenums], generate a C<my-enum-get-type()> function from a usual C enumeration definition than to write one yourself using C<enum-register-static()>.

Returns: The new type identifier.

  method enum-register-static ( Str $name, GEnumValue $const_static_values --> N-GValue )

=item Str $name; A nul-terminated string used as the name of the new type.
=item GEnumValue $const_static_values; An array of B<Gnome::GObject::EnumValue> structs for the possible enumeration values. The array is terminated by a struct with all members being 0. GObject keeps a reference to the data, so it cannot be stack-allocated.
=end pod

method enum-register-static ( Str $name, GEnumValue $const_static_values --> N-GValue ) {

  g_enum_register_static(
    self._get-native-object-no-reffing, $name, $const_static_values
  )
}

sub g_enum_register_static (
  gchar-ptr $name, GEnumValue $const_static_values --> N-GValue
) is native(&gobject-lib)
  { * }

#-------------------------------------------------------------------------------
# TM:0:enum-to-string:
=begin pod
=head2 enum-to-string

Pretty-prints I<value> in the form of the enum’s name.

This is intended to be used for debugging purposes. The format of the output may change in the future.

Returns: a newly-allocated text string

  method enum-to-string ( N-GValue $g_enum_type, Int() $value --> Str )

=item N-GValue $g_enum_type; the type identifier of a B<Gnome::GObject::EnumClass> type
=item Int() $value; the value
=end pod

method enum-to-string ( $g_enum_type is copy, Int() $value --> Str ) {
  $g_enum_type .= _get-native-object-no-reffing unless $g_enum_type ~~ N-GValue;

  g_enum_to_string(
    self._get-native-object-no-reffing, $g_enum_type, $value
  )
}

sub g_enum_to_string (
  N-GValue $g_enum_type, gint $value --> gchar-ptr
) is native(&gobject-lib)
  { * }
}}

#`{{
#-------------------------------------------------------------------------------
# TM:0:fits-pointer:
=begin pod
=head2 fits-pointer

Determines if I<value> will fit inside the size of a pointer value. This is an internal function introduced mainly for C marshallers.

Returns: C<True> if I<value> will fit inside a pointer value.

  method fits-pointer ( --> Bool )

=end pod

method fits-pointer ( --> Bool ) {

  g_value_fits_pointer(
    self._get-native-object-no-reffing,
  ).Bool
}

sub g_value_fits_pointer (
  N-GValue $value --> gboolean
) is native(&gobject-lib)
  { * }
}}

#`{{
#-------------------------------------------------------------------------------
# TM:0:flags-complete-type-info:
=begin pod
=head2 flags-complete-type-info

This function is meant to be called from the C<complete-type-info()> function of a B<Gnome::GObject::TypePlugin> implementation, see the example for C<enum-complete-type-info()> above.

  method flags-complete-type-info ( N-GValue $g_flags_type, GTypeInfo $info, GFlagsValue $const_values )

=item N-GValue $g_flags_type; the type identifier of the type being completed
=item GTypeInfo $info; (out callee-allocates): the B<Gnome::GObject::TypeInfo> struct to be filled in
=item GFlagsValue $const_values; An array of B<Gnome::GObject::FlagsValue> structs for the possible enumeration values. The array is terminated by a struct with all members being 0.
=end pod

method flags-complete-type-info ( $g_flags_type is copy, GTypeInfo $info, GFlagsValue $const_values ) {
  $g_flags_type .= _get-native-object-no-reffing unless $g_flags_type ~~ N-GValue;

  g_flags_complete_type_info(
    self._get-native-object-no-reffing, $g_flags_type, $info, $const_values
  );
}

sub g_flags_complete_type_info (
  N-GValue $g_flags_type, GTypeInfo $info, GFlagsValue $const_values
) is native(&gobject-lib)
  { * }

#-------------------------------------------------------------------------------
# TM:0:flags-get-first-value:
=begin pod
=head2 flags-get-first-value

Returns the first B<Gnome::GObject::FlagsValue> which is set in I<value>.

Returns: the first B<Gnome::GObject::FlagsValue> which is set in I<value>, or C<undefined> if none is set

  method flags-get-first-value ( GFlagsClass $flags_class, UInt $value --> GFlagsValue )

=item GFlagsClass $flags_class; a B<Gnome::GObject::FlagsClass>
=item UInt $value; the value
=end pod

method flags-get-first-value ( GFlagsClass $flags_class, UInt $value --> GFlagsValue ) {

  g_flags_get_first_value(
    self._get-native-object-no-reffing, $flags_class, $value
  )
}

sub g_flags_get_first_value (
  GFlagsClass $flags_class, guint $value --> GFlagsValue
) is native(&gobject-lib)
  { * }

#-------------------------------------------------------------------------------
# TM:0:flags-get-value-by-name:
=begin pod
=head2 flags-get-value-by-name

Looks up a B<Gnome::GObject::FlagsValue> by name.

Returns: the B<Gnome::GObject::FlagsValue> with name I<name>, or C<undefined> if there is no flag with that name

  method flags-get-value-by-name ( GFlagsClass $flags_class, Str $name --> GFlagsValue )

=item GFlagsClass $flags_class; a B<Gnome::GObject::FlagsClass>
=item Str $name; the name to look up
=end pod

method flags-get-value-by-name ( GFlagsClass $flags_class, Str $name --> GFlagsValue ) {

  g_flags_get_value_by_name(
    self._get-native-object-no-reffing, $flags_class, $name
  )
}

sub g_flags_get_value_by_name (
  GFlagsClass $flags_class, gchar-ptr $name --> GFlagsValue
) is native(&gobject-lib)
  { * }

#-------------------------------------------------------------------------------
# TM:0:flags-get-value-by-nick:
=begin pod
=head2 flags-get-value-by-nick

Looks up a B<Gnome::GObject::FlagsValue> by nickname.

Returns: the B<Gnome::GObject::FlagsValue> with nickname I<nick>, or C<undefined> if there is no flag with that nickname

  method flags-get-value-by-nick ( GFlagsClass $flags_class, Str $nick --> GFlagsValue )

=item GFlagsClass $flags_class; a B<Gnome::GObject::FlagsClass>
=item Str $nick; the nickname to look up
=end pod

method flags-get-value-by-nick ( GFlagsClass $flags_class, Str $nick --> GFlagsValue ) {

  g_flags_get_value_by_nick(
    self._get-native-object-no-reffing, $flags_class, $nick
  )
}

sub g_flags_get_value_by_nick (
  GFlagsClass $flags_class, gchar-ptr $nick --> GFlagsValue
) is native(&gobject-lib)
  { * }

#-------------------------------------------------------------------------------
# TM:0:flags-register-static:
=begin pod
=head2 flags-register-static

Registers a new static flags type with the name I<name>.

It is normally more convenient to let [glib-mkenums][glib-mkenums] generate a C<my-flags-get-type()> function from a usual C enumeration definition than to write one yourself using C<flags-register-static()>.

Returns: The new type identifier.

  method flags-register-static ( Str $name, GFlagsValue $const_static_values --> N-GValue )

=item Str $name; A nul-terminated string used as the name of the new type.
=item GFlagsValue $const_static_values; An array of B<Gnome::GObject::FlagsValue> structs for the possible flags values. The array is terminated by a struct with all members being 0. GObject keeps a reference to the data, so it cannot be stack-allocated.
=end pod

method flags-register-static ( Str $name, GFlagsValue $const_static_values --> N-GValue ) {

  g_flags_register_static(
    self._get-native-object-no-reffing, $name, $const_static_values
  )
}

sub g_flags_register_static (
  gchar-ptr $name, GFlagsValue $const_static_values --> N-GValue
) is native(&gobject-lib)
  { * }

#-------------------------------------------------------------------------------
# TM:0:flags-to-string:
=begin pod
=head2 flags-to-string

Pretty-prints I<value> in the form of the flag names separated by ` | ` and sorted. Any extra bits will be shown at the end as a hexadecimal number.

This is intended to be used for debugging purposes. The format of the output may change in the future.

Returns: a newly-allocated text string

  method flags-to-string ( N-GValue $flags_type, UInt $value --> Str )

=item N-GValue $flags_type; the type identifier of a B<Gnome::GObject::FlagsClass> type
=item UInt $value; the value
=end pod

method flags-to-string ( $flags_type is copy, UInt $value --> Str ) {
  $flags_type .= _get-native-object-no-reffing unless $flags_type ~~ N-GValue;

  g_flags_to_string(
    self._get-native-object-no-reffing, $flags_type, $value
  )
}

sub g_flags_to_string (
  N-GValue $flags_type, guint $value --> gchar-ptr
) is native(&gobject-lib)
  { * }
}}

#-------------------------------------------------------------------------------
# TM:0:get-boolean:
=begin pod
=head2 get-boolean

Get the contents of a C<G-TYPE-BOOLEAN> B<Gnome::GObject::Value>.

Returns: boolean contents of I<value>

  method get-boolean ( --> Bool )

=end pod

method get-boolean ( --> Bool ) {

  g_value_get_boolean(
    self._get-native-object-no-reffing,
  ).Bool
}

sub g_value_get_boolean (
  N-GValue $value --> gboolean
) is native(&gobject-lib)
  { * }

#-------------------------------------------------------------------------------
# TM:0:get-double:
=begin pod
=head2 get-double

Get the contents of a C<G-TYPE-DOUBLE> B<Gnome::GObject::Value>.

Returns: double contents of I<value>

  method get-double ( --> Num )

=end pod

method get-double ( --> Num ) {

  g_value_get_double(
    self._get-native-object-no-reffing,
  )
}

sub g_value_get_double (
  N-GValue $value --> gdouble
) is native(&gobject-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:1:get-enum:
=begin pod
=head2 get-enum

Get the contents of a C<G-TYPE-ENUM> B<Gnome::GObject::Value>.

  method get-enum ( --> Int )

=end pod

method get-enum ( --> Int ) {
  g_value_get_enum(self._get-native-object-no-reffing)
}

sub g_value_get_enum (
  N-GValue $value --> gint
) is native(&gobject-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:1:get-flags:
=begin pod
=head2 get-flags

Get the contents of a C<G-TYPE-FLAGS> B<Gnome::GObject::Value>.

Returns: flags contents of I<value>

  method get-flags ( --> UInt )

=end pod

method get-flags ( --> UInt ) {
  g_value_get_flags(self._get-native-object-no-reffing)
}

sub g_value_get_flags (
  N-GValue $value --> guint
) is native(&gobject-lib)
  { * }

#-------------------------------------------------------------------------------
# TM:0:get-float:
=begin pod
=head2 get-float

Get the contents of a C<G-TYPE-FLOAT> B<Gnome::GObject::Value>.

Returns: float contents of I<value>

  method get-float ( --> Num )

=end pod

method get-float ( --> Num ) {
  g_value_get_float(self._get-native-object-no-reffing)
}

sub g_value_get_float (
  N-GValue $value --> gfloat
) is native(&gobject-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:1:get-gtype:
=begin pod
=head2 get-gtype

Get the contents of a C<G-TYPE-GTYPE> B<Gnome::GObject::Value>.

Returns: the B<Gnome::GObject::Type> stored in I<value>

  method get-gtype ( --> N-GValue )

=end pod

method get-gtype ( --> N-GValue ) {
  g_value_get_gtype(self._get-native-object-no-reffing)
}

sub g_value_get_gtype (
  N-GValue $value --> N-GValue
) is native(&gobject-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:1:get-int:
=begin pod
=head2 get-int

Get the contents of a C<G-TYPE-INT> B<Gnome::GObject::Value>.

Returns: integer contents of I<value>

  method get-int ( --> Int )

=end pod

method get-int ( --> Int ) {

  g_value_get_int(
    self._get-native-object-no-reffing,
  )
}

sub g_value_get_int (
  N-GValue $value --> gint
) is native(&gobject-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:1:get-int64:
=begin pod
=head2 get-int64

Get the contents of a C<G-TYPE-INT64> B<Gnome::GObject::Value>.

Returns: 64bit integer contents of I<value>

  method get-int64 ( --> Int )

=end pod

method get-int64 ( --> Int ) {

  g_value_get_int64(
    self._get-native-object-no-reffing,
  )
}

sub g_value_get_int64 (
  N-GValue $value --> gint64
) is native(&gobject-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:1:get-long:
=begin pod
=head2 get-long

Get the contents of a C<G-TYPE-LONG> B<Gnome::GObject::Value>.

Returns: long integer contents of I<value>

  method get-long ( --> Int )

=end pod

method get-long ( --> Int ) {

  g_value_get_long(
    self._get-native-object-no-reffing,
  )
}

sub g_value_get_long (
  N-GValue $value --> glong
) is native(&gobject-lib)
  { * }

#-------------------------------------------------------------------------------
# TM:0:get-pointer:
=begin pod
=head2 get-pointer

Get the contents of a pointer B<Gnome::GObject::Value>.

Returns: pointer contents of I<value>

  method get-pointer ( --> Pointer )

=end pod

method get-pointer ( --> Pointer ) {

  g_value_get_pointer(
    self._get-native-object-no-reffing,
  )
}

sub g_value_get_pointer (
  N-GValue $value --> gpointer
) is native(&gobject-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:1:get-schar:
=begin pod
=head2 get-schar

Get the contents of a C<G-TYPE-CHAR> B<Gnome::GObject::Value>.

Returns: signed 8 bit integer contents of I<value>

  method get-schar ( --> Int )

=end pod

method get-schar ( --> Int ) {

  g_value_get_schar(
   