PageRenderTime 24ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/dist/ExtUtils-ParseXS/lib/ExtUtils/xsubpp

https://github.com/rurban/perl
Perl | 184 lines | 120 code | 63 blank | 1 comment | 7 complexity | b7d871ecde1469598fc73604e331d3f8 MD5 | raw file
Possible License(s): AGPL-1.0
  1. #!perl
  2. use 5.006;
  3. use strict;
  4. eval {
  5. require ExtUtils::ParseXS;
  6. 1;
  7. }
  8. or do {
  9. my $err = $@ || 'Zombie error';
  10. my $v = $ExtUtils::ParseXS::VERSION;
  11. $v = '<undef>' if not defined $v;
  12. 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";
  13. };
  14. use Getopt::Long;
  15. my %args = ();
  16. my $usage = "Usage: xsubpp [-v] [-csuffix csuffix] [-except] [-prototypes] [-noversioncheck] [-nolinenumbers] [-nooptimize] [-noinout] [-noargtypes] [-strip|s pattern] [-typemap typemap]... file.xs\n";
  17. Getopt::Long::Configure qw(no_auto_abbrev no_ignore_case);
  18. @ARGV = grep {$_ ne '-C++'} @ARGV; # Allow -C++ for backward compatibility
  19. GetOptions(\%args, qw(hiertype!
  20. prototypes!
  21. versioncheck!
  22. linenumbers!
  23. optimize!
  24. inout!
  25. argtypes!
  26. object_capi!
  27. except!
  28. v
  29. typemap=s@
  30. output=s
  31. s|strip=s
  32. csuffix=s
  33. ))
  34. or die $usage;
  35. if ($args{v}) {
  36. print "xsubpp version $ExtUtils::ParseXS::VERSION\n";
  37. exit;
  38. }
  39. @ARGV == 1 or die $usage;
  40. $args{filename} = shift @ARGV;
  41. my $pxs = ExtUtils::ParseXS->new;
  42. $pxs->process_file(%args);
  43. exit( $pxs->report_error_count() ? 1 : 0 );
  44. __END__
  45. =head1 NAME
  46. xsubpp - compiler to convert Perl XS code into C code
  47. =head1 SYNOPSIS
  48. B<xsubpp> [B<-v>] [B<-except>] [B<-s pattern>] [B<-prototypes>] [B<-noversioncheck>] [B<-nolinenumbers>] [B<-nooptimize>] [B<-typemap typemap>] [B<-output filename>]... file.xs
  49. =head1 DESCRIPTION
  50. This compiler is typically run by the makefiles created by L<ExtUtils::MakeMaker>
  51. or by L<Module::Build> or other Perl module build tools.
  52. I<xsubpp> will compile XS code into C code by embedding the constructs
  53. necessary to let C functions manipulate Perl values and creates the glue
  54. necessary to let Perl access those functions. The compiler uses typemaps to
  55. determine how to map C function parameters and variables to Perl values.
  56. The compiler will search for typemap files called I<typemap>. It will use
  57. the following search path to find default typemaps, with the rightmost
  58. typemap taking precedence.
  59. ../../../typemap:../../typemap:../typemap:typemap
  60. It will also use a default typemap installed as C<ExtUtils::typemap>.
  61. =head1 OPTIONS
  62. Note that the C<XSOPT> MakeMaker option may be used to add these options to
  63. any makefiles generated by MakeMaker.
  64. =over 5
  65. =item B<-hiertype>
  66. Retains '::' in type names so that C++ hierarchical types can be mapped.
  67. =item B<-except>
  68. Adds exception handling stubs to the C code.
  69. =item B<-typemap typemap>
  70. Indicates that a user-supplied typemap should take precedence over the
  71. default typemaps. This option may be used multiple times, with the last
  72. typemap having the highest precedence.
  73. =item B<-output filename>
  74. Specifies the name of the output file to generate. If no file is
  75. specified, output will be written to standard output.
  76. =item B<-v>
  77. Prints the I<xsubpp> version number to standard output, then exits.
  78. =item B<-prototypes>
  79. By default I<xsubpp> will not automatically generate prototype code for
  80. all xsubs. This flag will enable prototypes.
  81. =item B<-noversioncheck>
  82. Disables the run time test that determines if the object file (derived
  83. from the C<.xs> file) and the C<.pm> files have the same version
  84. number.
  85. =item B<-nolinenumbers>
  86. Prevents the inclusion of '#line' directives in the output.
  87. =item B<-nooptimize>
  88. Disables certain optimizations. The only optimization that is currently
  89. affected is the use of I<target>s by the output C code (see L<perlguts>).
  90. This may significantly slow down the generated code, but this is the way
  91. B<xsubpp> of 5.005 and earlier operated.
  92. =item B<-noinout>
  93. Disable recognition of C<IN>, C<OUT_LIST> and C<INOUT_LIST> declarations.
  94. =item B<-noargtypes>
  95. Disable recognition of ANSI-like descriptions of function signature.
  96. =item B<-C++>
  97. Currently doesn't do anything at all. This flag has been a no-op for
  98. many versions of perl, at least as far back as perl5.003_07. It's
  99. allowed here for backwards compatibility.
  100. =item B<-s=...> or B<-strip=...>
  101. I<This option is obscure and discouraged.>
  102. If specified, the given string will be stripped off from the beginning
  103. of the C function name in the generated XS functions (if it starts with that prefix).
  104. This only applies to XSUBs without C<CODE> or C<PPCODE> blocks.
  105. For example, the XS:
  106. void foo_bar(int i);
  107. when C<xsubpp> is invoked with C<-s foo_> will install a C<foo_bar>
  108. function in Perl, but really call C<bar(i)> in C. Most of the time,
  109. this is the opposite of what you want and failure modes are somewhat
  110. obscure, so please avoid this option where possible.
  111. =back
  112. =head1 ENVIRONMENT
  113. No environment variables are used.
  114. =head1 AUTHOR
  115. Originally by Larry Wall. Turned into the C<ExtUtils::ParseXS> module
  116. by Ken Williams.
  117. =head1 MODIFICATION HISTORY
  118. See the file F<Changes>.
  119. =head1 SEE ALSO
  120. perl(1), perlxs(1), perlxstut(1), ExtUtils::ParseXS
  121. =cut