Commit | Line | Data |
---|---|---|
adfe19db MHM |
1 | ################################################################################ |
2 | # | |
3bfe1c68 | 3 | # RealPPPort_xs.PL -- generate RealPPPort.xs |
adfe19db MHM |
4 | # |
5 | ################################################################################ | |
6 | # | |
b2049988 | 7 | # Version 3.x, Copyright (C) 2004-2013, Marcus Holland-Moritz. |
adfe19db MHM |
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 | ||
16 | use strict; | |
17 | $^W = 1; | |
874389ae | 18 | require "./parts/ppptools.pl"; |
adfe19db MHM |
19 | |
20 | my %SECTION = ( | |
cac25305 MHM |
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 | ##---------------------------------------------------------------------- | |
29 | ENDHEADER | |
adfe19db MHM |
30 | ); |
31 | ||
b2049988 | 32 | if (not exists $ENV{PERL_NO_GET_CONTEXT} or $ENV{PERL_NO_GET_CONTEXT}) { |
adfe19db MHM |
33 | $SECTION{xshead}{code} .= <<END; |
34 | #define PERL_NO_GET_CONTEXT | |
35 | END | |
36 | } | |
37 | ||
38 | my $file; | |
39 | my $sec; | |
40 | ||
1d088ed8 | 41 | for $file (all_files_in_dir('parts/inc')) { |
adfe19db MHM |
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 | ||
58 | my $data = do { local $/; <DATA> }; | |
59 | ||
60 | for $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 | ||
78b4ff79 | 69 | open FH, ">RealPPPort.xs" or die "RealPPPort.xs: $!\n"; |
adfe19db MHM |
70 | print FH $data; |
71 | close FH; | |
72 | ||
73 | exit 0; | |
74 | ||
75 | __DATA__ | |
76 | /******************************************************************************* | |
77 | * | |
4fefab01 | 78 | * !!!!! Do NOT edit this file directly! -- Edit RealPPPort_xs.PL instead. !!!!! |
adfe19db | 79 | * |
cac25305 MHM |
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 | * | |
adfe19db MHM |
84 | ******************************************************************************** |
85 | * | |
86 | * Perl/Pollution/Portability | |
87 | * | |
88 | ******************************************************************************** | |
89 | * | |
b2049988 | 90 | * Version 3.x, Copyright (C) 2004-2013, Marcus Holland-Moritz. |
adfe19db MHM |
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 | ||
b2049988 | 123 | MODULE = Devel::PPPort PACKAGE = Devel::PPPort |
adfe19db MHM |
124 | |
125 | BOOT: | |
126 | __XSBOOT__ | |
127 | ||
128 | __XSUBS__ |