David Mertens > C-TinyCompiler > C::TinyCompiler::Perl

Download:
C-TinyCompiler-0.04.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Source  

NAME ^

C::TinyCompiler::Perl - Enabling Perl's full C-API in your C::TinyCompiler context

SYNOPSIS ^

 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);

DESCRIPTION ^

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:

 #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.

ERROR MESSAGES ^

This module may lead to some interesting error messages. Here's a reference.

Unable to locate Perl CORE directory!

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.

whatever comes after C::TinyCompiler::Perl

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.

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

You can also look for information at:

LICENSE AND COPYRIGHT ^

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.

syntax highlighting: