Haiku API Bindings
KernelKit
Not logged in

Documentation | KernelKit

SYNOPSIS

Perl

use HaikuR1::KernelKit;

Python

from HaikuR1.KernelKit import *

DESCRIPTION

Contains several constants.

CLASSES AND SUBMODULES

KernelKit contains no classes or submodules

FUNCTIONS

snooze

This function snoozes a thread. Calling snooze on a thread is like calling sleep, with one important difference: snooze allows the thread to switch.

Ordinarily, the system will handle thread switching by itself, with no input from you. But if your thread is waiting on another thread, snooze tells the system that our thread isn't going to do anything for a while, so it can give your time to another thread.

Perl

snooze($amount);

Python

snooze(amount)

rewrap

This utility function is not part of the Haiku R1 API; it is for convenience.

Sometimes function return objects of a certain class, but the underlying C++ object may be a subclass. For example, Looper.HandlerAt returns a Handler, Window.FindView returns a View object, but the object might actually be a Button or a StringView or a Menu.

The glue code does not know what the underlying C++ class is. And since it may be an object created by the system, the glue code cannot simply assume that a target language wrapper object already exists. So instead, the glue code creates a new wrapper object for the C++ object.

Usually, this is not a problem, since calling a hook method on the passed instance will result in the proper hook method for the underlying C++ class. However, if you want to call a non-hook method, you will either get the base class version (if it exists) or crash due to calling a non-existent function.

In C++, the solution is simple: you simply cast the object into the class you want. Unfortunately, this is not possible in most interpreted languages.

The rewrap function allows you to get around this shortcoming. If you know the real class of the object in question, you can can create a brand new wrapper object for the the C++ object, and you will then be able to call the proper versions of non-hook methods.

Perl

my $copy = rewrap($object, $new_class, $transfer);

Python

copy = rewrap(object, new_class, transfer)

Perl

Unless you actually need two wrappers, it's easier to simply rebless the object into the desired class:

bless($object, $new_class);

If ownership is transferred, the old object can safely go out of scope, allowing code like this:

Perl

$object = rewrap($object, $new_class);

Python

object = rewrap(object, new_class)

CONSTANTS

System constants

Perl

use HaikuR1::KernelKit qw(:system)

Python

Python does not support export tags.

Team constants

Perl

use HaikuR1::KernelKit qw(:team)

Python

Python does not support export tags.

Thread priority constants

Perl

use HaikuR1::KernelKit qw(:thread_priority)

Python

Python does not support export tags.

Timeout constants

Perl

use HaikuR1::KernelKit qw(:timeout)

Python

Python does not support export tags.