ExtUtils::ParseXS::Utilities - Subroutines used with ExtUtils::ParseXS
use ExtUtils::ParseXS::Utilities qw( standard_typemap_locations trim_whitespace tidy_type C_string valid_proto_string process_typemaps make_targetable map_type standard_XS_defs assign_func_args analyze_preprocessor_statements set_cond Warn blurt death check_conditional_preprocessor_statements escape_file_for_line_directive report_typemap_failure );
The following functions are not considered to be part of the public interface. They are documented here for the benefit of future maintainers of this module.
standard_typemap_locations()
Purpose
Provide a list of filepaths where typemap files may be found. The filepaths -- relative paths to files (not just directory paths) -- appear in this list in lowest-to-highest priority.
The highest priority is to look in the current directory.
'typemap'
The second and third highest priorities are to look in the parent of the current directory and a directory called lib/ExtUtils underneath the parent directory.
'../typemap', '../lib/ExtUtils/typemap',
The fourth through ninth highest priorities are to look in the corresponding grandparent, great-grandparent and great-great-grandparent directories.
'../../typemap', '../../lib/ExtUtils/typemap', '../../../typemap', '../../../lib/ExtUtils/typemap', '../../../../typemap', '../../../../lib/ExtUtils/typemap',
The tenth and subsequent priorities are to look in directories named ExtUtils which are subdirectories of directories found in @INC -- provided a file named typemap actually exists in such a directory. Example:
@INC
'/usr/local/lib/perl5/5.10.1/ExtUtils/typemap',
However, these filepaths appear in the list returned by standard_typemap_locations() in reverse order, i.e., lowest-to-highest.
'/usr/local/lib/perl5/5.10.1/ExtUtils/typemap', '../../../../lib/ExtUtils/typemap', '../../../../typemap', '../../../lib/ExtUtils/typemap', '../../../typemap', '../../lib/ExtUtils/typemap', '../../typemap', '../lib/ExtUtils/typemap', '../typemap', 'typemap'
Arguments
my @stl = standard_typemap_locations( \@INC );
Reference to @INC.
Return Value
Array holding list of directories to be searched for typemap files.
trim_whitespace()
Perform an in-place trimming of leading and trailing whitespace from the first argument provided to the function.
Argument
trim_whitespace($arg);
None. Remember: this is an in-place modification of the argument.
tidy_type()
Rationalize any asterisks (*) by joining them into bunches, removing interior whitespace, then trimming leading and trailing whitespace.
*
($ret_type) = tidy_type($_);
String to be cleaned up.
String cleaned up.
C_string()
Escape backslashes (\) in prototype strings.
\
$ProtoThisXSUB = C_string($_);
String needing escaping.
Properly escaped string.
valid_proto_string()
Validate prototype string.
String needing checking.
Upon success, returns the same string passed as argument.
Upon failure, returns 0.
0
process_typemaps()
Process all typemap files.
my $typemaps_object = process_typemaps( $args{typemap}, $pwd );
List of two elements: typemap element from %args; current working directory.
typemap
%args
Upon success, returns an ExtUtils::Typemaps object.
make_targetable()
Populate %targetable. This constitutes a refinement of the output of process_typemaps() with respect to its fourth output, $output_expr_ref.
%targetable
$output_expr_ref
%targetable = make_targetable($output_expr_ref);
Single hash reference: the fourth such ref returned by process_typemaps().
Hash.
map_type()
Performs a mapping at several places inside PARAGRAPH loop.
PARAGRAPH
$type = map_type($self, $type, $varname);
List of three arguments.
String holding augmented version of second argument.
standard_XS_defs()
Writes to the .c output file certain preprocessor directives and function headers needed in all such files.
.c
None.
Returns true.
assign_func_args()
Perform assignment to the func_args attribute.
func_args
$string = assign_func_args($self, $argsref, $class);
List of three elements. Second is an array reference; third is a string.
String.
analyze_preprocessor_statements()
Within each function inside each Xsub, print to the .c output file certain preprocessor statements.
( $self, $XSS_work_idx, $BootCode_ref ) = analyze_preprocessor_statements( $self, $statement, $XSS_work_idx, $BootCode_ref );
List of four elements.
Modifed values of three of the arguments passed to the function. In particular, the XSStack and InitFileCode attributes are modified.
XSStack
InitFileCode
set_cond()
current_line_number()
Figures out the current line number in the XS file.
$self
The current line number.
Warn()
blurt()
death()
check_conditional_preprocessor_statements()
escape_file_for_line_directive()
Escapes a given code source name (typically a file name but can also be a command that was read from) so that double-quotes and backslashes are escaped.
A string.
A string with escapes for double-quotes and backslashes.
report_typemap_failure
Do error reporting for missing typemaps.
The ExtUtils::ParseXS object.
ExtUtils::ParseXS
An ExtUtils::Typemaps object.
ExtUtils::Typemaps
The string that represents the C type that was not found in the typemap.
Optionally, the string death or blurt to choose whether the error is immediately fatal or not. Default: blurt
death
blurt
Returns nothing. Depending on the arguments, this may call death or blurt, the former of which is fatal.
To install ExtUtils::ParseXS, copy and paste the appropriate command in to your terminal.
cpanm
cpanm ExtUtils::ParseXS
CPAN shell
perl -MCPAN -e shell install ExtUtils::ParseXS
For more information on module installation, please visit the detailed CPAN module installation guide.