2 ################################################################################
4 # apicheck.pl -- generate C source for automated API check
6 ################################################################################
10 # $Date: 2005/06/25 16:47:31 +0200 $
12 ################################################################################
14 # Version 3.x, Copyright (C) 2004-2005, Marcus Holland-Moritz.
15 # Version 2.x, Copyright (C) 2001, Paul Marquess.
16 # Version 1.x, Copyright (C) 1999, Kenneth Albanowski.
18 # This program is free software; you can redistribute it and/or
19 # modify it under the same terms as Perl itself.
21 ################################################################################
24 require 'parts/ppptools.pl';
27 open OUT, ">$ARGV[0]" or die "$ARGV[0]: $!\n";
33 my @f = parse_embed(qw( parts/embed.fnc parts/apidoc.fnc ));
35 my %todo = %{&parse_todo};
88 ORIGMARK => ['dORIGMARK;'],
89 POPpx => ['STRLEN n_a;'],
90 POPpbytex => ['STRLEN n_a;'],
99 UNDERBAR => ['dUNDERBAR;'],
100 XCPT_TRY_START => ['dXCPT;'],
101 XCPT_TRY_END => ['dXCPT;'],
102 XCPT_CATCH => ['dXCPT;'],
103 XCPT_RETHROW => ['dXCPT;'],
107 dSP => "some_global_var = !sp;",
108 dMARK => "some_global_var = !mark;",
109 dORIGMARK => "some_global_var = !origmark;",
110 dAX => "some_global_var = !ax;",
111 dITEMS => "some_global_var = !items;",
112 dXSARGS => "some_global_var = ax && items;",
113 NEWSV => "some_global_var = !arg1;",
114 New => "some_global_var = !arg1;",
115 Newc => "some_global_var = !arg1;",
116 Newz => "some_global_var = !arg1;",
117 dUNDERBAR => "(void) UNDERBAR;",
121 map { ($_ => 1) } qw(
136 * !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
137 * This file is built by $0.
138 * Any changes made here will be lost!
147 #ifndef DPPP_APICHECK_NO_PPPORT_H
150 #define NEED_grok_bin
151 #define NEED_grok_hex
152 #define NEED_grok_number
153 #define NEED_grok_numeric_radix
154 #define NEED_grok_oct
155 #define NEED_newCONSTSUB
156 #define NEED_newRV_noinc
157 #define NEED_sv_2pv_nolen
158 #define NEED_sv_2pvbyte
159 #define NEED_sv_catpvf_mg
160 #define NEED_sv_catpvf_mg_nocontext
161 #define NEED_sv_setpvf_mg
162 #define NEED_sv_setpvf_mg_nocontext
163 #define NEED_vnewSVpvf
170 static int some_global_var;
173 static char *VARarg2;
174 static double VARarg3;
180 $ignore{$f->{name}} and next;
181 $f->{flags}{A} or next; # only public API members
183 $ignore{$f->{name}} = 1; # ignore duplicates
185 my $Perl_ = $f->{flags}{p} ? 'Perl_' : '';
194 for $ca (@{$f->{args}}) {
198 push @arg, qw(VARarg1 VARarg2 VARarg3);
201 my($n, $p, $d) = $a =~ /^ (\w+(?:\s+\w+)*)\s* # type name => $n
202 (\**) # pointer => $p
203 ((?:\[[^\]]*\])*) # dimension => $d
205 or die "$0 - cannot parse argument: [$a]\n";
206 if (exists $amap{$n}) {
207 push @arg, $amap{$n};
210 $n = $tmap{$n} || $n;
211 my $v = 'arg' . $i++;
213 $stack .= " static $n $p$v$d;\n";
216 unless ($f->{flags}{n} || $f->{flags}{'m'}) {
217 $stack = " dTHX;\n$stack";
218 $aTHX = @arg ? 'aTHX_ ' : 'aTHX';
221 if ($stack{$f->{name}}) {
223 for (@{$stack{$f->{name}}}) {
229 my $args = join ', ', @arg;
230 my $rvt = $f->{ret} || 'void';
233 $ret = $castvoid{$f->{name}} ? '(void) ' : '';
236 $ret = $ignorerv{$f->{name}} ? '(void) ' : "return ";
238 my $aTHX_args = "$aTHX$args";
241 if ($postcode{$f->{name}}) {
242 $post = $postcode{$f->{name}};
247 unless ($f->{flags}{'m'} and @arg == 0) {
249 $aTHX_args = "($aTHX_args)";
253 /******************************************************************************
257 ******************************************************************************/
261 if ($todo{$f->{name}}) {
262 my($ver,$sub) = $todo{$f->{name}} =~ /^5\.(\d{3})(\d{3})$/ or die;
266 if ($ver < 6 && $sub > 0) {
267 $sub =~ s/0$// or die;
269 print OUT "#if PERL_VERSION > $ver || (PERL_VERSION == $ver && PERL_SUBVERSION >= $sub) /* TODO */\n";
273 ? "$Perl_$f->{name}$aTHX_args"
276 $f->{cond} and print OUT "#if $f->{cond}\n";
279 $rvt _DPPP_test_$f->{name} (void)
286 $ret$f->{name}$args;$post
290 some_global_var = items && ax;
296 $ret$Perl_$f->{name}$aTHX_args;$post
302 $f->{cond} and print OUT "#endif\n";
303 $todo{$f->{name}} and print OUT "#endif\n";