NAME
C::TinyCompiler::Perl::AV - Perl's array C-API
STILL UNDER CONSTRUCTION
This code has not seen much attention and has neither been carefully reviewed nor tested. It may not even be use
able. You have been warned.
SYNOPSIS
use C::TinyCompiler;
# Declare the compiler context with the AV bindings:
my $context= C::TinyCompiler->new(packages => '::Perl::AV');
# Or add them afterwards:
my $context = C::TinyCompiler->new;
$context->add_packages('::Perl::AV');
# Create a function that tells us how many arguments we sent:
$context->code('Body') = q{
void test_func(AV * inputs, AV * outputs) {
printf("You sent %d arguments\n", av_len(inputs));
}
};
# Compile and call:
$context->compile;
$context->call_function('test_func', 1, 2, 3);
DESCRIPTION
This module provides various Perl array manipulate functions to the compiler context. Eventually it will contain options so that you can specify which parts of the API you want, but for now it comes in one big bunch (or as much of it as I have packaged thus far).
Like other C::TinyCompiler packages, you never use this module directly. Rather, you add it to your compiler context in the constructor or with the function "apply_packages" in C::TinyCompiler.
Documentation for all of these functions can be found at perlapi, so I will only give their names and signatures here for reference (and possibly a few notes if I deem them to be helpful).
- av_clear
-
void av_clear (AV * array)
- av_len
-
int av_len (AV * array)
- av_fetch
-
SV ** av_fetch (AV * array, int key, int lval)
Fetches the requested item from the array, creating it if necessary. The usage is descriped in perlapi. I simply wish to point out that in my experience, the only time the returned pointer to the SV is only null is when I try to retrieve a non-existent array element not in lvalue context. (I suspect that it may also return null in lvalue context if Perl is unable to allocate the contiguous memory for
key
elements, but I have not confirmed that.) The point is that you ought to check that the returned pointer is non-null before dereferencing it.
AUTHOR
David Mertens, <dcmertens.perl at gmail.com>
BUGS
Please report any bugs or feature requests at the project's main github page: http://github.com/run4flat/perl-TCC/issues.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc C::TinyCompiler::Perl::AV
You can also look for information at:
The Github issue tracker (report bugs here)
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
http://p3rl.org/C::TinyCompiler http://search.cpan.org/dist/C-TinyCompiler/
LICENSE AND COPYRIGHT
Code Copyright 2011-2012 Northwestern University. Documentation copyright 2011-2013 David Mertens.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.