This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Upgrade to Devel::PPPort 3.19_02
[perl5.git] / cpan / Devel-PPPort / PPPort_xs.PL
1 ################################################################################
2 #
3 #  PPPort_xs.PL -- generate RealPPPort.xs
4 #
5 ################################################################################
6 #
7 #  $Revision: 16 $
8 #  $Author: mhx $
9 #  $Date: 2010/03/07 13:15:41 +0100 $
10 #
11 ################################################################################
12 #
13 #  Version 3.x, Copyright (C) 2004-2010, Marcus Holland-Moritz.
14 #  Version 2.x, Copyright (C) 2001, Paul Marquess.
15 #  Version 1.x, Copyright (C) 1999, Kenneth Albanowski.
16 #
17 #  This program is free software; you can redistribute it and/or
18 #  modify it under the same terms as Perl itself.
19 #
20 ################################################################################
21
22 use strict;
23 $^W = 1;
24 require "parts/ppptools.pl";
25
26 my %SECTION = (
27   xshead => { code => '', header => "/* ---- code from __FILE__ ---- */" },
28   xsinit => { code => '', header => "/* ---- code from __FILE__ ---- */" },
29   xsmisc => { code => '', header => "/* ---- code from __FILE__ ---- */" },
30   xsboot => { code => '', header => "/* ---- code from __FILE__ ---- */", indent => "\t" },
31   xsubs  => { code => '', header => <<ENDHEADER },
32 ##----------------------------------------------------------------------
33 ##  XSUBs for testing the implementation in __FILE__
34 ##----------------------------------------------------------------------
35 ENDHEADER
36 );
37
38 if (exists $ENV{PERL_NO_GET_CONTEXT} && $ENV{PERL_NO_GET_CONTEXT}) {
39 $SECTION{xshead}{code} .= <<END;
40 #define PERL_NO_GET_CONTEXT
41 END
42 }
43
44 my $file;
45 my $sec;
46
47 for $file (all_files_in_dir('parts/inc')) {
48   my $spec = parse_partspec($file);
49
50   my $msg = 0;
51   for $sec (keys %SECTION) {
52     if (exists $spec->{$sec}) {
53       $msg++ or print "adding XS code from $file\n";
54       if (exists $SECTION{$sec}{header}) {
55         my $header = $SECTION{$sec}{header};
56         $header =~ s/__FILE__/$file/g;
57         $SECTION{$sec}{code} .= $header . "\n";
58       }
59       $SECTION{$sec}{code} .= $spec->{$sec} . "\n";
60     }
61   }
62 }
63
64 my $data = do { local $/; <DATA> };
65
66 for $sec (keys %SECTION) {
67   my $code = $SECTION{$sec}{code};
68   if (exists $SECTION{$sec}{indent}) {
69     $code =~ s/^/$SECTION{$sec}{indent}/gm;
70   }
71   $code =~ s/[\r\n]+$//;
72   $data =~ s/^__\U$sec\E__$/$code/m;
73 }
74
75 open FH, ">RealPPPort.xs" or die "RealPPPort.xs: $!\n";
76 print FH $data;
77 close FH;
78
79 exit 0;
80
81 __DATA__
82 /*******************************************************************************
83 *
84 *  !!!!! Do NOT edit this file directly! -- Edit PPPort_xs.PL instead. !!!!!
85 *
86 *  This file was automatically generated from the definition files in the
87 *  parts/inc/ subdirectory by PPPort_xs.PL. To learn more about how all this
88 *  works, please read the F<HACKERS> file that came with this distribution.
89 *
90 ********************************************************************************
91 *
92 *  Perl/Pollution/Portability
93 *
94 ********************************************************************************
95 *
96 *  $Revision: 16 $
97 *  $Author: mhx $
98 *  $Date: 2010/03/07 13:15:41 +0100 $
99 *
100 ********************************************************************************
101 *
102 *  Version 3.x, Copyright (C) 2004-2010, Marcus Holland-Moritz.
103 *  Version 2.x, Copyright (C) 2001, Paul Marquess.
104 *  Version 1.x, Copyright (C) 1999, Kenneth Albanowski.
105 *
106 *  This program is free software; you can redistribute it and/or
107 *  modify it under the same terms as Perl itself.
108 *
109 *******************************************************************************/
110
111 /* ========== BEGIN XSHEAD ================================================== */
112
113 __XSHEAD__
114
115 /* =========== END XSHEAD =================================================== */
116
117 #include "EXTERN.h"
118 #include "perl.h"
119 #include "XSUB.h"
120
121 /* ========== BEGIN XSINIT ================================================== */
122
123 __XSINIT__
124
125 /* =========== END XSINIT =================================================== */
126
127 #include "ppport.h"
128
129 /* ========== BEGIN XSMISC ================================================== */
130
131 __XSMISC__
132
133 /* =========== END XSMISC =================================================== */
134
135 MODULE = Devel::PPPort          PACKAGE = Devel::PPPort
136
137 BOOT:
138 __XSBOOT__
139
140 __XSUBS__