### ----------------------------------------------------
### -- Gnome::Glib
### -- Licenses: Artistic-2.0
### -- Authors: Marcel Timmerman
### -- File: lib/Gnome/Glib/VariantType.rakumod
### ----------------------------------------------------
### -- Chunk 2 of 2
type --> N-GObject )
  is native(&glib-lib)
  { * }

#`{{
#-------------------------------------------------------------------------------
# TM:1:peek-string:
=begin pod
=head2 peek-string

Returns the type string corresponding to the given I<type>.  The result is not nul-terminated; in order to determine its length you must call C<get-string-length()>.  To get a nul-terminated string, see C<g_variant_type_dup_string()>.

Returns: the corresponding type string (not nul-terminated)

  method peek-string ( -->  Str  )


=end pod

method peek-string ( -->  Str  ) {

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

sub g_variant_type_peek_string ( N-GObject $type --> gchar-ptr )
  is native(&glib-lib)
  { * }
}}

#`{{
#-------------------------------------------------------------------------------
# TM:0:g_variant_type_string_scan:
=begin pod
=head2 [g_variant_type_] string_scan

Scan for a single complete and valid Gnome::Glib::VariantType string in I<$string>. The memory pointed to by I<$limit> (or bytes beyond it) is never accessed.

If a valid type string is found, I<$endptr> is updated to point to the first character past the end of the string that was found and C<True> is returned.

If there is no valid type string starting at I<$string>, or if the type string does not end before I<$limit> then C<False> is returned.

For the simple case of checking if a string is a valid type string, see C<g_variant_type_string_is_valid()>.

Returns: C<True> if a valid type string was found

  method g_variant_type_string_scan (
    Str $string, Str $limit, CArray[Str] $endptr --> Int
  )

=item Str $string; a pointer to any string
=item Str $limit; (nullable): the end of I<string>, or C<Any>
=item CArray[Str] $endptr; (out) (optional): location to store the end pointer, or C<Any>

=end pod

sub g_variant_type_string_scan ( Str $string, Str $limit, CArray[Str] $endptr --> int32 )
  is native(&glib-lib)
  { * }
}}

#-------------------------------------------------------------------------------
#TM:1:value:
=begin pod
=head2 value

Determines the value type of a dictionary entry type.  This function may only be used with a dictionary entry type.

Returns: the value type of the dictionary entry

  method value ( --> Gnome::Glib::VariantType )


=end pod

method value ( --> Gnome::Glib::VariantType ) {
  Gnome::Glib::VariantType.new(
    :native-object(g_variant_type_value(self._get-native-object-no-reffing))
  );
}

sub g_variant_type_value ( N-GObject $type --> N-GObject )
  is native(&glib-lib)
  { * }

#-------------------------------------------------------------------------------
#`{{ User must not know about it, they have to use clear-object()
#
#TM:0:g_variant_type_free:
=begin pod
=head2 g_variant_type_free

Frees a B<Gnome::Glib::VariantType> that was allocated with C<g_variant_type_copy()>, C<g_variant_type_new()> or one of the container type constructor functions. In the case that I<type> is C<Any>, this function does nothing.

  method g_variant_type_free ( )

=end pod
}}

#TM:1:_g_variant_type_free:
sub _g_variant_type_free ( N-GObject $type )
  is native(&glib-lib)
  is symbol('g_variant_type_free')
  { * }

#-------------------------------------------------------------------------------
#TM:1:_g_variant_type_new:
#`{{
=begin pod
=head2 g_variant_type_new

Creates a new B<Gnome::Glib::VariantType> corresponding to the type string given
by I<type_string>.  It is appropriate to call C<g_variant_type_free()> on
the return value.

It is a programmer error to call this function with an invalid type
string.  Use C<g_variant_type_string_is_valid()> if you are unsure.

Returns: (transfer full): a new B<Gnome::Glib::VariantType>

  method g_variant_type_new ( Str $type_string --> N-GObject )

=item Str $type_string; a valid Gnome::Glib::Variant type string

=end pod
}}

sub _g_variant_type_new ( Str $type_string --> N-GObject )
  is native(&glib-lib)
  is symbol('g_variant_type_new')
  { * }


#-------------------------------------------------------------------------------
#TM:1:_g_variant_type_new_array:
#`{{
=begin pod
=head2 _g_variant_type_new_array

Constructs the type corresponding to an array of elements of the type I<type>.  It is appropriate to call C<g_variant_type_free()> on the return value.

Returns: (transfer full): a new array B<GVariantType>

  method _g_variant_type_new_array ( --> N-GObject )


=end pod
}}

sub _g_variant_type_new_array ( N-GObject $element --> N-GObject )
  is native(&glib-lib)
  is symbol('g_variant_type_new_array')
  { * }

#-------------------------------------------------------------------------------
#TM:1:_g_variant_type_new_maybe:
#`{{
=begin pod
=head2 _g_variant_type_new_maybe

Constructs the type corresponding to a maybe instance containing type I<type> or Nothing.  It is appropriate to call C<g_variant_type_free()> on the return value.

Returns: (transfer full): a new maybe B<GVariantType>

  method _g_variant_type_new_maybe ( --> N-GObject )


=end pod
}}

sub _g_variant_type_new_maybe ( N-GObject $element --> N-GObject )
  is native(&glib-lib)
  is symbol('g_variant_type_new_maybe')
  { * }

#-------------------------------------------------------------------------------
#TM:0:_g_variant_type_new_tuple:
#`{{
=begin pod
=head2 _g_variant_type_new_tuple

Constructs a new tuple type, from I<items>.  I<length> is the number of items in I<items>, or -1 to indicate that I<items> is C<Any>-terminated.  It is appropriate to call C<g_variant_type_free()> on the return value.

Returns: (transfer full): a new tuple B<GVariantType>

  method _g_variant_type_new_tuple (
    *@items --> N-GObject
  )

=item  $const GVariantType * const *items; (array length=length): an array of B<GVariantTypes>, one for each item
=item Int $length; the length of I<items>, or -1

=end pod
}}

sub _g_variant_type_new_tuple ( @items --> N-GObject ) {
  my $no = CArray[N-GObject].new;
  my $count = 0;
  for @items -> $item is copy {
    $item .= _get-native-object-no-reffing unless $item ~~ N-GObject;
    $no[$count++] = $item;
  }

  my @parameter-list = (
    Parameter.new(:type(CArray[N-GObject])), # GVariantType * const *items
    Parameter.new(:type(gint))
  );

  # create signature
  my Signature $signature .= new(
    :params(|@parameter-list),
    :returns(N-GObject)
  );

  # get a pointer to the sub, then cast it to a sub with the proper
  # signature. after that, the sub can be called, returning a value.
  state $ptr = cglobal( &glib-lib, 'g_variant_type_new_tuple', Pointer);
  my Callable $f = nativecast( $signature, $ptr);

  $f( $no, $count)
}

#  is native(&glib-lib)
#  is symbol('g_variant_type_new_tuple')
#  { * }


#`{{
#-------------------------------------------------------------------------------
#TM:0:_g_variant_type_new_dict_entry:
#`{{
=begin pod
=head2 _g_variant_type_new_dict_entry

Constructs the type corresponding to a dictionary entry with a key of type I<key> and a value of type I<value>.  It is appropriate to call C<g_variant_type_free()> on the return value.

Returns: (transfer full): a new dictionary entry B<GVariantType>

  method _g_variant_type_new_dict_entry ( N-GObject $value --> N-GObject )

=item N-GObject $value; a B<GVariantType>

=end pod
}}

sub _g_variant_type_new_dict_entry ( N-GObject $key, N-GObject $value --> N-GObject )
  is native(&glib-lib)
  is symbol('g_variant_type_new_dict_entry')
  { * }
}}

#`{{
#-------------------------------------------------------------------------------
# TM:0:checked-:
=begin pod
=head2 checked-



  method checked- (  $const gchar * --> N-GObject )

=item  $const gchar *;

=end pod

method checked- (  $const gchar * --> N-GObject ) {

  g_variant_type_checked_(
    self._get-native-object-no-reffing, $const gchar *
  );
}

sub g_variant_type_checked_ (  $const gchar * --> N-GObject )
  is native(&glib-lib)
  { * }
}}

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

Get the maximum depth of the nested types in I<type_string>. A basic type will return depth 1, and a container type will return a greater value. The depth of a tuple is 1 plus the depth of its deepest child type.  If I<type_string> is not a valid B<GVariant> type string, 0 will be returned.

Returns: depth of I<type_string>, or 0 on error

  method string-get-depth- (  Str  $type_string --> UInt )

=item  Str  $type_string; a pointer to any string

=end pod

method string-get-depth- (  Str  $type_string --> UInt ) {

  g_variant_type_string_get_depth_(
    self._get-native-object-no-reffing, $type_string
  );
}

sub g_variant_type_string_get_depth_ ( gchar-ptr $type_string --> gsize )
  is native(&glib-lib)
  { * }
}}


