1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
|
#!/usr/bin/perl -w
#############################################################################
## Name: script/make_exp_list.pl
## Purpose: builds lib/Wx/_Exp.pm (export lists for Wx and Wx::Event)
## Author: Mattia Barbon
## Modified by:
## Created: 29/10/2000
## RCS-ID: $Id: make_exp_list.pl 2057 2007-06-18 23:03:00Z mbarbon $
## Copyright: (c) 2000-2003, 2005 Mattia Barbon
## Licence: This program is free software; you can redistribute it and/or
## modify it under the same terms as Perl itself
#############################################################################
#
# @EXPORT_OK and %EXPORT_TAGS for Wx.pm (constants in Constant.xs)
#
my $ext = shift @ARGV;
my $parser;
my %packages;
my $tag;
my $package;
sub add_to_exports {
my( $values, $tags ) = @_;
foreach my $i ( split '\s+', $values ) {
next if $i =~ /^\s*$/;
foreach my $j ( split '\s+', $tags ) {
next if $_ =~ /^\s*$/;
push @{ $packages{$package}{tags}{$j} }, $i;
}
push @{ $packages{$package}{exp_ok} }, $i;
}
}
foreach my $i ( @ARGV ) {
open IN, '< ' . $i or die "unable to open '$i'";
$tag = '';
$package = '';
$parser = undef;
while( <IN> ) {
m/^\W+?\!(\w+):\s*(.*)$/ && do {
my( $t, $v ) = ( $1, $2 );
if( $t eq 'parser' ) { $parser = eval "$v"; die if $@ }
if( $t eq 'package' ) { $package = $v }
if( $t eq 'tag' ) { $tag = $v }
if( $t eq 'export' ) { add_to_exports( $v, $tag ); next }
next;
};
next unless $parser;
my @values = $parser->( $_ );
( defined( $values[0] ) && length( $values[0] ) ) || next;
$values[1] ||= '';
add_to_exports( $values[0], "$values[1] $tag" );
}
}
close IN;
#
# write export file
#
local $" = "\n";
open OUT, '> '. $ext || die "unable to open file '$ext'";
binmode OUT; # Perl 5.004 on Unix complains for CR
print OUT <<EOT;
#############################################################################
## Name: lib/Wx/Wx_Exp.pm
## Purpose: export lists (AUTOGENERATED, DO NOT EDIT)
## Author: Mattia Barbon
## Modified by:
## Licence: This program is free software; you can redistribute it and/or
## modify it under the same terms as Perl itself
#############################################################################
package Wx::Wx_Exp; # for RPM
EOT
foreach my $package ( sort keys %packages ) {
print OUT <<EOT;
package ${package};
push \@EXPORT_OK, qw(@{$packages{$package}{exp_ok}});
\$EXPORT_TAGS{'everything'} = \\\@EXPORT_OK;
EOT
foreach my $tag ( sort keys %{ $packages{$package}{tags} } ) {
next unless length $tag;
print OUT <<EOT;
\$EXPORT_TAGS{'$tag'} = [ qw(@{ $packages{$package}{tags}{$tag} }) ];
EOT
}
}
print OUT <<EOT;
1;
# Local variables: #
# mode: cperl #
# End: #
EOT
# Local variables: #
# mode: cperl #
# End: #
|