NAME
Devel::XSCover::XS - the map from the generated C back to the XS
SYNOPSIS
use Devel::XSCover::XS;
my $xs = Devel::XSCover::XS->new(dir => '.');
my @map = $xs->read;
DESCRIPTION
xsubpp writes the wrapper of every XSUB into the generated C file, with #line directives that switch between the .xs and the .c. gcov credits the .xs for the body and the .c for the wrapper. This map turns the wrapper's name and count into the XSUB's Perl name and declaration line, and keeps the map from each generated line to the source line it stands for.
METHODS
new
my $xs = Devel::XSCover::XS->new(dir => '.', skip => [...]);
generated_files
The pairs of .xs and generated .c, relative to the directory: those the XS entry of Makefile.PL names, and every .c beside an .xs under the directory. Only pairs whose .c exists are returned.
line_map
my $map = $xs->line_map('Op.c');
An array indexed by generated line, each entry the file and line it stands for. Lines before the first #line and the directives themselves map to the .c.
xsubpp drops a comment line (one starting with # that is not a preprocessor directive) from an XSUB's body without a #line to say so, which puts every line after it one short in the compiler's eyes and in gcov's. The map reads the .xs and counts those lines, so a # uncoverable line in a body lands where it was written, and map carries an inverse table, per XS file, from the line gcov reports to the line meant.
xsubs
my @xsubs = $xs->xsubs('Op.c');
Every wrapper definition in the file, with c_name, c_line and, when the wrapper holds a #line into the XS, file and body_line. The boot function is left out.
perl_names
my $names = $xs->perl_names('Op.c');
From the boot function's newXS calls, the Perl names of each wrapper. An ALIAS gives a wrapper more than one.
declaration_line
my $line = $xs->declaration_line('Op.xs', 1191, 'is_op');
Scans upward from the body's first line past blank lines, keyword lines and indented parameter lines to the declaration, and returns its line number when it names the sub.
find_declaration
my ($file, $line) = $xs->find_declaration(\@files, 'Spike::More::triple');
Finds the declaration by name in the files, within the matching PACKAGE section, for a wrapper without a #line of its own.
map
my $map = $xs->map('Op.c');
Joins the rest: c, files (the XS files the C was generated from), lines, inverse (see line_map) and xsubs, each with names, file and line.
subroutines
my @subs = $xs->subroutines($map);
The XSUBs with a declaration line and a Perl name, for the subroutine criterion.
read
A map for every pair of generated_files.