C::TinyCompiler::Perl - Enabling Perl's full C-API in your C::TinyCompiler context
use C::TinyCompiler; # Declare the compiler context with the Perl bindings: my $context= C::TinyCompiler->new('::Perl'); # Or add them afterwards: my $context = C::TinyCompiler->new; $context->apply_packages('::Perl'); # 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);
This module provides access to the full Perl C API in your compiler context. This is a very blunt tool, but it is guaranteed to always reflect the API of whichever version of Perl you use to run your script. It is equivalent to including the following in your Head code section:
Head
#include "EXTERN.h" #include "perl.h" #include "XSUB.h"
where it determines the path to your Perl's include directory during your script's compile phase. On my machine, the resulting text of this pull-in is equivalent to approximately 8,000 or 10,000 lines of real code, depending on how you define real (as well as many blank lines), which is why I consider it to be quite a blunt tool.
(What follows is what I *hope* happens, though it is not yet the reality.) This weight is the motivation for the C::TinyCompiler::Perl::* sub-modules. They pull in and define only the exact code that you need.
This module may lead to some interesting error messages. Here's a reference.
This compile-time error will indicate that C::TinyCompiler::Perl was not able to find the CORE directory in your Perl libs. This is a big issue because the header files that C::TinyCompiler::Perl wants to include in your compiler context can only be found in this directory. If you run into this problem, it means you do not have your Perl header files stored in a customary place. If you don't know how to fix this, you should reach out to me or to the Perl community (i.e. PerlMonks) for help.
If you see anything with this text in it, you have encountered an error (probably a compile error) in code that you added to your compiler's Head section after you added the C::TinyCompiler::Perl package. Check any and all code that you added. Using "line_numbers" in C::TinyCompiler may help narrow-down the errant line in your code.
David Mertens, <dcmertens.perl at gmail.com>
<dcmertens.perl at gmail.com>
Please report any bugs or feature requests at the project's main github page: http://github.com/run4flat/perl-TCC/issues.
You can find documentation for this module with the perldoc command.
perldoc C::TinyCompiler::Perl
You can also look for information at:
The Github issue tracker (report bugs here)
http://github.com/run4flat/perl-TCC/issues
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/C-TinyCompiler
CPAN Ratings
http://cpanratings.perl.org/d/C-TinyCompiler
Search CPAN
http://p3rl.org/C::TinyCompiler http://search.cpan.org/dist/C-TinyCompiler/
Code copyright 2012 Northwestern University. Documentation copyright 2012-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.
To install C::TinyCompiler, copy and paste the appropriate command in to your terminal.
cpanm
cpanm C::TinyCompiler
CPAN shell
perl -MCPAN -e shell install C::TinyCompiler
For more information on module installation, please visit the detailed CPAN module installation guide.