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