This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Refactor die_exit.t to loop over a list, rather than iterate on an hash.
[perl5.git] / cpan / Devel-PPPort / PPPort_xs.PL
CommitLineData
adfe19db
MHM
1################################################################################
2#
78b4ff79 3# PPPort_xs.PL -- generate RealPPPort.xs
adfe19db
MHM
4#
5################################################################################
6#
3f0c6e0c 7# $Revision: 15 $
adfe19db 8# $Author: mhx $
3f0c6e0c 9# $Date: 2009/01/18 14:10:48 +0100 $
adfe19db
MHM
10#
11################################################################################
12#
3f0c6e0c 13# Version 3.x, Copyright (C) 2004-2009, Marcus Holland-Moritz.
adfe19db
MHM
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
22use strict;
23$^W = 1;
24require "parts/ppptools.pl";
25
26my %SECTION = (
cac25305
MHM
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##----------------------------------------------------------------------
35ENDHEADER
adfe19db
MHM
36);
37
38if (exists $ENV{PERL_NO_GET_CONTEXT} && $ENV{PERL_NO_GET_CONTEXT}) {
39$SECTION{xshead}{code} .= <<END;
40#define PERL_NO_GET_CONTEXT
41END
42}
43
44my $file;
45my $sec;
46
1d088ed8 47for $file (all_files_in_dir('parts/inc')) {
adfe19db
MHM
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
64my $data = do { local $/; <DATA> };
65
66for $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
78b4ff79 75open FH, ">RealPPPort.xs" or die "RealPPPort.xs: $!\n";
adfe19db
MHM
76print FH $data;
77close FH;
78
79exit 0;
80
81__DATA__
82/*******************************************************************************
83*
84* !!!!! Do NOT edit this file directly! -- Edit PPPort_xs.PL instead. !!!!!
85*
cac25305
MHM
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*
adfe19db
MHM
90********************************************************************************
91*
92* Perl/Pollution/Portability
93*
94********************************************************************************
95*
3f0c6e0c 96* $Revision: 15 $
adfe19db 97* $Author: mhx $
3f0c6e0c 98* $Date: 2009/01/18 14:10:48 +0100 $
adfe19db
MHM
99*
100********************************************************************************
101*
3f0c6e0c 102* Version 3.x, Copyright (C) 2004-2009, Marcus Holland-Moritz.
adfe19db
MHM
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
135MODULE = Devel::PPPort PACKAGE = Devel::PPPort
136
137BOOT:
138__XSBOOT__
139
140__XSUBS__