About my projects, examples and tutorials
Gnome::N::TopLevelClassSupport

Gnome::N::TopLevelClassSupport

Description

Top most class providing internally used methods and subroutines.

The class Gnome::N::TopLevelClassSupport, is the class at the top of the food chain. Most classes, if not all, are inheriting from this class. Its purpose is to provide convenience methods, processing and storing native objects, etcetera.

Most of the time, if not ever, you will not use any of this and can be read by interested souls only. Some exceptions:

  • .is-valid(); Check if an object is valid.

  • .clear-object(); Destroy an object, i.e. its native object within the Raku object.

  • .new(:$native-object); Instanciation of a Raku object using a native object from elsewhere.

Declaration

Its declaration is a bit different than normally done in Raku. It is done this way to prevent clashes from the Any class.

unit class Gnome::N::TopLevelClassSupport;
also is Mu;

Methods

new

Please note that this class is never instantiated directly but is used indirectly when child classes are instantiated.

:native-object

Create a Raku object using a native object from elsewhere. $native-object can be a N-Object or a Raku object like Gnome::Gtk3::Button.

method new ( :$native-object! )

N-Object

Method to get the native object wrapped in the Raku objects.

Example where the native object is retrieved from a Gnome::Gtk3::Window object.

  my Gnome::Gtk3::Window $w;
  my N-Object() $no = $w;
method N-Object ( --> N-Object )

COERCE

Method to wrap a native object into a Raku object

Example;

my N-Object $no = …;  # native object from somewhere
my Gnome::Gtk3::Window() $w = $no;
method COERCE( $no --> Mu )

get-class-gtype

Get glib type code of this native object which is set when the native object was created.

method get-class-gtype ( --> GType )

get-class-name

Return native class name.

method get-class-name ( --> Str )

native-object-ref

Absolute method needed to be defined in all child classes to do reference count administration.

  method native-object-ref ( $n-native-object ) { !!! }

native-object-unref

Absolute method needed to be defined in all child classes to do reference count administration.

method native-object-unref ( $n-native-object ) { !!! }

is-valid

Returns True if native object is valid. When False, the native object is undefined and errors will occur when this instance is used.

method is-valid ( --> Bool )

clear-object

Clear the error and return data to memory pool. The error object is not valid after this call and is-valid() will return False.

method clear-object ()