Tie::Array::Pointer

Ties a Perl array to a C pointer
Download

Tie::Array::Pointer Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • John BEPPU
  • Publisher web site:
  • http://search.cpan.org/~beppu/

Tie::Array::Pointer Tags


Tie::Array::Pointer Description

Ties a Perl array to a C pointer Tie::Array::Pointer is a Perl module that ties a Perl array to a C pointer. This makes it possible for Perl code and C code to share simple integer arrays.OptionsWhen you tie an array to Tie::Array::Pointer, you need to pass it a hashref that tells it how big the array is and what the simple integer type each of its elements is.length (required) :: The number of elements in the array.type (required) :: This is a very small subset of pack types, which defines whether the array contains 8 bit, 16 bit, or 32 bit integers. The valid values for this option are: c signed char 8 bit C unsigned char 8 bit s signed short 16 bit S unsigned short 16 bit l signed long 32 bit L unsigned long 32 bitaddress (optional) :: If you specify a memory address using this option, the act of tie'ing (tying?) will not allocate any memory. Instead, we'll trust that you know what you're doing and that the system will allow reads and writes to happen to this address.SYNOPSISTie to @buffer; allocate 256 * 4 bytes for me: use Tie::Array::Pointer; my @buffer; tie @buffer, 'Tie::Array::Pointer', { length => 256, type => 'L', };Tie to @buffer; use memory address I've provided: tie @buffer, 'Tie::Array::Pointer', { length => 320 * 200, type => 'c', address => 0x000a0000, };Get the memory address of the C array. my $addr = tied(@buffer)->address(); Requirements: · Perl Limitations: · Don't treat arrays that are tied to this package as normal Perl arrays. When you tie arrays to this package, they really take on the characteristics of a C array. They should therefore be treated with the same carefulness that a C array would. · In future versions of this module, some of these limitations may be lifted, but don't hold your breath.


Tie::Array::Pointer Related Software