Prototype of the native call interface for Rakudo
Perl 6 Perl
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is 8 commits ahead of cxreg:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



This project prototypes native calling interface functionality for
Rakudo.  It should give Rakudo the ability to call out to C libraries
without having to drop to writing PIR).  The Parrot Native Call
Interface gives a similar facility in PIR.

The project name is the Slovak translation of the imperative "call!", to
complement Blizkost, a Rakudo-to-Perl-5 integration project.

The functions that Zavolaj can currently call must have signatures (the
type of the return value and the types of the arguments) that already
exist in a fixed list inside Parrot.  Adding more signatures currently
involves adding entries to the parrot/src/nci/extra_thunks.nci file.

There is a project to enable calling all possible function signatures: is currently a Parrot
extension.  Zavolaj does not use it yet.


Initially the MySQL client library is being used as a test case, because
it is a popular application, is frequently asked about, and because
Parrot does have all the function signatures.  There is a Rakudo project that wraps these functions with a DBI
compatible interface.

The /usr/include/mysql.h file defines the mysql client library functions
and their parameters.

Prepare your system along these lines before trying out the examples:

    $ mysql -u root -p
    CREATE DATABASE zavolaj;
    CREATE USER 'testuser'@'localhost' IDENTIFIED BY 'testpass';
    GRANT CREATE      ON zavolaj.* TO 'testuser'@'localhost';
    GRANT DROP        ON zavolaj.* TO 'testuser'@'localhost';
    GRANT INSERT      ON zavolaj.* TO 'testuser'@'localhost';
    GRANT DELETET     ON zavolaj.* TO 'testuser'@'localhost';
    GRANT SELECT      ON zavolaj.* TO 'testuser'@'localhost';
    GRANT LOCK TABLES ON zavolaj.* TO 'testuser'@'localhost';
    GRANT SELECT      ON   mysql.* TO 'testuser'@'localhost';
    # or maybe otherwise
    GRANT ALL PRIVILEGES ON zavolaj.* TO 'testuser'@'localhost';

You can look at the results via a normal mysql connection:

    $ mysql -utestuser -ptestpass
    USE zavolaj;
    SELECT * FROM nom;


This library cannot be called yet because of missing Parrot NCI
signatures, see the example file for details.

Microsoft Windows

The win32-api-call.p6 script shows the beginning of a GUI application
written in Perl 6.


Before running 'make test', you *must* perform this:

    sudo apt-get install libmysqlclient-dev
    sudo apt-get install libtest-harness-perl
    export PERL6LIB=lib