C::DynaLib 0.55 review

Download
by rbytes.net on

C::DynaLib is a Perl interface to C compiled code. SYNOPSIS use C::DynaLib; use sigtrap; # recommended $lib = new C:

License: Perl Artistic License
File size: 35K
Developer: John Tobey
0 stars award from rbytes.net

C::DynaLib is a Perl interface to C compiled code.

SYNOPSIS

use C::DynaLib;
use sigtrap; # recommended

$lib = new C::DynaLib( $linker_arg );

$func = $lib->DeclareSub( $symbol_name
[, $return_type [, @arg_types] ] );
# or
$func = $lib->DeclareSub( { "name" => $symbol_name,
[param => $value,] ... } );
# or
use C::DynaLib qw(DeclareSub);
$func = DeclareSub( $function_pointer,
[, $return_type [, @arg_types] ] );
# or
$func = DeclareSub( { "ptr" => $function_pointer,
[param => $value,] ... } );

$result = $func->( @args );

$callback = new C::DynaLib::Callback( &my_sub,
$return_type, @arg_types );
$callback_pointer = $callback->Ptr();

PLUG FOR PERL XS

If you have a C compiler that Perl supports, you will get better results by writing XSubs than by using this module. I GUARANTEE IT! It may take you longer to do what you want, but your code will be much more solid and portable. See perlxs.

This module brings "pointers" to Perl. Perl's non-use of pointers is one of its great strengths. If you don't know what I mean, then maybe you ought to practice up a bit on C or C++ before using this module. If anything, pointers are more dangerous in Perl than in C, due to Perl's dynamic, interpretive nature.

The XSub interface and Perl objects provide a means of calling C and C++ code while preserving Perl's abstraction from pointers. Once again, I urge you to check out perlxs! It's really cool!!!

This module allows Perl programs to call C functions in dynamic libraries. It is useful for testing library functions, writing simple programs without the bother of XS, and generating C function pointers that call Perl code.

Your Perl must be of the dynamic variety and have a working DynaLoader to use the dynamic loading capabilities of this module. Be sure you answered "y" when Configure (from the Perl source kit) asked, "Do you wish to use dynamic loading?".
The mechanics of passing arguments to and returning values from C functions vary greatly among machines, operating systems, and compilers. Therefore, Makefile.PL checks the Perl configuration and may even compile and run a test program before the module is built.

This module is divided into two packages, C::DynaLib and C::DynaLib::Callback. Each makes use of Perl objects (see perlobj) and provides its own constructor.
A C::DynaLib object corresponds to a dynamic library whose functions are available to Perl. A C::DynaLib::Callback object corresponds to a Perl sub which may be accessed from C.

Requirements:
Perl

C::DynaLib 0.55 search tags