codekingpro/portable-devtools
114k
1#!/usr/bin/perl2 eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'3 if 0; # ^ Run only under a shell4#!perl5use 5.006;6BEGIN { pop @INC if $INC[-1] eq '.' }7use strict;8eval {9 require ExtUtils::ParseXS;10 1;11}12or do {13 my $err = $@ || 'Zombie error';14 my $v = $ExtUtils::ParseXS::VERSION;15 $v = '<undef>' if not defined $v;16 die "Failed to load or import from ExtUtils::ParseXS (version $v). Please check that ExtUtils::ParseXS is installed correctly and that the newest version will be found in your \@INC path: $err";17};18 19use Getopt::Long;20 21my %args = ();22 23my $usage = "Usage: xsubpp [-v] [-csuffix csuffix] [-except] [-prototypes] [-noversioncheck] [-nolinenumbers] [-nooptimize] [-noinout] [-noargtypes] [-strip|s pattern] [-typemap typemap]... file.xs\n";24 25Getopt::Long::Configure qw(no_auto_abbrev no_ignore_case);26 27@ARGV = grep {$_ ne '-C++'} @ARGV; # Allow -C++ for backward compatibility28GetOptions(\%args, qw(hiertype!29 prototypes!30 versioncheck!31 linenumbers!32 optimize!33 inout!34 argtypes!35 object_capi!36 except!37 v38 typemap=s@39 output=s40 s|strip=s41 csuffix=s42 ))43 or die $usage;44 45if ($args{v}) {46 print "xsubpp version $ExtUtils::ParseXS::VERSION\n";47 exit;48}49 50@ARGV == 1 or die $usage;51 52$args{filename} = shift @ARGV;53 54my $pxs = ExtUtils::ParseXS->new;55$pxs->process_file(%args);56exit( $pxs->report_error_count() ? 1 : 0 );57 58__END__59 60=head1 NAME61 62xsubpp - compiler to convert Perl XS code into C code63 64=head1 SYNOPSIS65 66B<xsubpp> [B<-v>] [B<-except>] [B<-s pattern>] [B<-prototypes>] [B<-noversioncheck>] [B<-nolinenumbers>] [B<-nooptimize>] [B<-typemap typemap>] [B<-output filename>]... file.xs67 68=head1 DESCRIPTION69 70This compiler is typically run by the makefiles created by L<ExtUtils::MakeMaker>71or by L<Module::Build> or other Perl module build tools.72 73I<xsubpp> will compile XS code into C code by embedding the constructs74necessary to let C functions manipulate Perl values and creates the glue75necessary to let Perl access those functions. The compiler uses typemaps to76determine how to map C function parameters and variables to Perl values.77 78The compiler will search for typemap files called I<typemap>. It will use79the following search path to find default typemaps, with the rightmost80typemap taking precedence.81 82 ../../../typemap:../../typemap:../typemap:typemap83 84It will also use a default typemap installed as C<ExtUtils::typemap>.85 86=head1 OPTIONS87 88Note that the C<XSOPT> MakeMaker option may be used to add these options to89any makefiles generated by MakeMaker.90 91=over 592 93=item B<-hiertype>94 95Retains '::' in type names so that C++ hierarchical types can be mapped.96 97=item B<-except>98 99Adds exception handling stubs to the C code.100 101=item B<-typemap typemap>102 103Indicates that a user-supplied typemap should take precedence over the104default typemaps. This option may be used multiple times, with the last105typemap having the highest precedence.106 107=item B<-output filename>108 109Specifies the name of the output file to generate. If no file is110specified, output will be written to standard output.111 112=item B<-v>113 114Prints the I<xsubpp> version number to standard output, then exits.115 116=item B<-prototypes>117 118By default I<xsubpp> will not automatically generate prototype code for119all xsubs. This flag will enable prototypes.120 121=item B<-noversioncheck>122 123Disables the run time test that determines if the object file (derived124from the C<.xs> file) and the C<.pm> files have the same version125number.126 127=item B<-nolinenumbers>128 129Prevents the inclusion of '#line' directives in the output.130 131=item B<-nooptimize>132 133Disables certain optimizations. The only optimization that is currently134affected is the use of I<target>s by the output C code (see L<perlguts>).135This may significantly slow down the generated code, but this is the way136B<xsubpp> of 5.005 and earlier operated.137 138=item B<-noinout>139 140Disable recognition of C<IN>, C<OUT_LIST> and C<INOUT_LIST> declarations.141 142=item B<-noargtypes>143 144Disable recognition of ANSI-like descriptions of function signature.145 146=item B<-C++>147 148Currently doesn't do anything at all. This flag has been a no-op for149many versions of perl, at least as far back as perl5.003_07. It's150allowed here for backwards compatibility.151 152=item B<-s=...> or B<-strip=...>153 154I<This option is obscure and discouraged.>155 156If specified, the given string will be stripped off from the beginning157of the C function name in the generated XS functions (if it starts with that prefix).158This only applies to XSUBs without C<CODE> or C<PPCODE> blocks.159For example, the XS:160 161 void foo_bar(int i);162 163when C<xsubpp> is invoked with C<-s foo_> will install a C<foo_bar>164function in Perl, but really call C<bar(i)> in C. Most of the time,165this is the opposite of what you want and failure modes are somewhat166obscure, so please avoid this option where possible.167 168=back169 170=head1 ENVIRONMENT171 172No environment variables are used.173 174=head1 AUTHOR175 176Originally by Larry Wall. Turned into the C<ExtUtils::ParseXS> module177by Ken Williams.178 179=head1 MODIFICATION HISTORY180 181See the file F<Changes>.182 183=head1 SEE ALSO184 185perl(1), perlxs(1), perlxstut(1), ExtUtils::ParseXS186 187=cut188 189 