Inline::C 0.44 review

Download
by rbytes.net on

Inline::C is a Perl module that can Write Perl Subroutines in C. Inline::C is a module that allows you to write Perl subroutines i

License: Perl Artistic License
File size: 89K
Developer: Brian Ingerson
0 stars award from rbytes.net

Inline::C is a Perl module that can Write Perl Subroutines in C.

Inline::C is a module that allows you to write Perl subroutines in C. Since version 0.30 the Inline module supports multiple programming languages and each language has its own support module. This document describes how to use Inline with the C programming language. It also goes a bit into Perl C internals.

If you want to start working with programming examples right away, check out Inline::C-Cookbook. For more information on Inline in general, see Inline.

Usage

You never actually use Inline::C directly. It is just a support module for using Inline.pm with C. So the usage is always:
use Inline C => ...;
or
bind Inline C => ...;

Function Definitions

The Inline grammar for C recognizes certain function definitions (or signatures) in your C code. If a signature is recognized by Inline, then it will be available in Perl-space. That is, Inline will generate the "glue" necessary to call that function as if it were a Perl subroutine. If the signature is not recognized, Inline will simply ignore it, with no complaints. It will not be available from Perl-space, although it will be available from C-space.

Inline looks for ANSI/prototype style function definitions. They must be of the form:

return-type function-name ( type-name-pairs ) { ... }

The most common types are: int, long, double, char*, and SV*. But you can use any type for which Inline can find a typemap. Inline uses the typemap file distributed with Perl as the default. You can specify more typemaps with the TYPEMAPS configuration option.

A return type of void may also be used. The following are examples of valid function definitions.

int Foo(double num, char* str) {
void Foo(double num, char* str) {
SV* Foo() {
void Foo(SV*, ...) {
long Foo(int i, int j, ...) {

The following definitions would not be recognized:

Foo(int i) { # no return type
int Foo(float f) { # no (default) typemap for float
int Foo(num, str) double num; char* str; {
void Foo(void) { # void only valid for return type

Notice that Inline only looks for function definitions, not function prototypes. Definitions are the syntax directly preceeding a function body. Also Inline does not scan external files, like headers. Only the code passed to Inline is used to create bindings; although other libraries can linked in, and called from C-space.

Requirements:
Perl

Inline::C 0.44 search tags