Commit | Line | Data |
---|---|---|
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 | ||
22 | use strict; | |
23 | $^W = 1; | |
24 | require "parts/ppptools.pl"; | |
25 | ||
26 | my %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 | ##---------------------------------------------------------------------- | |
35 | ENDHEADER | |
adfe19db MHM |
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 | ||
1d088ed8 | 47 | for $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 | ||
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 | ||
78b4ff79 | 75 | open FH, ">RealPPPort.xs" or die "RealPPPort.xs: $!\n"; |
adfe19db MHM |
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 | * | |
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 | ||
135 | MODULE = Devel::PPPort PACKAGE = Devel::PPPort | |
136 | ||
137 | BOOT: | |
138 | __XSBOOT__ | |
139 | ||
140 | __XSUBS__ |