Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

chromatic (983)

  (email not shown publicly)

Blog Information [] Profile for chr0matic []

Journal of chromatic (983)

Wednesday August 18, 2004
10:57 PM

Throw Away Your C Compiler (after building Perl)

[ #20462 ]


    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( '../' );
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.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • It's like syscall() but for library routines, right? And without having to pack() everything yourself. Nice work!
  • I can't wait until this is usable smoothly. Great job!
  • Is it something like Win32::API [] for Unix?

    Maybe you could coordinate the interfaces if it seems appropriate?
    • 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.