#!/usr/bin/perl
BEGIN
{
	chdir 't' if -d 't';
	use blib;
}
use strict;
use warnings;
use Test::More tests => 9;
use_ok('P5NCI') or exit;
my $double_lib     = P5NCI::load_lib( '../nci_demo.so' );
my  $double_double = P5NCI::load_nci_func( $double_lib, 'double_double', 'dd' );
is( $double_double->( 1.0 ),  2.0  );
is( $double_double->( 3.14 ), 6.28 );
my  $double_int = P5NCI::load_nci_func( $double_lib, 'double_int', 'ii' );
is( $double_int->( 1 ), 2 );
is( $double_int->( 3 ), 6 );
my  $double_float = P5NCI::load_nci_func( $double_lib, 'double_float', 'ff' );
is( $double_float->( 1.0 ),   2.0   );
ok( abs( $double_float->( 0.314 ) - 0.628) < 0.00001 );
my  $multiply_ints = P5NCI::load_nci_func( $double_lib, 'multiply_ints', 'iii' );
is( $multiply_ints->( 10, 20 ), 200 );
is( $multiply_ints->(  5,  5 ),  25 );
The interface is a bit grotty, the documentation is spotty, the build system needs some help, and it only handles really simple functions right now, but it works.
Re:Other work
chromatic on 2004-08-20T05:10:03
It's a lot like Win32::API actually, except it should work on other platforms as well.
I don't particularly like the interface to Win32::API (which looks a lot like the Win32 API, so it's clearly appropriate and just a matter of personal taste), but there are some good ideas there I can use -- especially in handling structs and alignments.