summaryrefslogtreecommitdiffstats
path: root/fake_packages
diff options
context:
space:
mode:
authorThierry Vignaud <tv@mageia.org>2012-01-30 17:48:03 +0000
committerThierry Vignaud <tv@mageia.org>2012-01-30 17:48:03 +0000
commitc84e02b58babf893d1c63eae4a090a75902293ea (patch)
tree738cb55d5bf2ed5d71287c8fd4586f8afd7fe90b /fake_packages
parentc9eb5a44c2022318d0ee927b8098ce251504fef8 (diff)
downloadperl_checker-c84e02b58babf893d1c63eae4a090a75902293ea.tar
perl_checker-c84e02b58babf893d1c63eae4a090a75902293ea.tar.gz
perl_checker-c84e02b58babf893d1c63eae4a090a75902293ea.tar.bz2
perl_checker-c84e02b58babf893d1c63eae4a090a75902293ea.tar.xz
perl_checker-c84e02b58babf893d1c63eae4a090a75902293ea.zip
(parse_pm) parse .pm files too when generating fake packages
eg: URPM (or some Gtk2*) implement methods in both perl & XS
Diffstat (limited to 'fake_packages')
-rwxr-xr-xfake_packages/gen.pl36
1 files changed, 36 insertions, 0 deletions
diff --git a/fake_packages/gen.pl b/fake_packages/gen.pl
index f5e336f..f65c3e6 100755
--- a/fake_packages/gen.pl
+++ b/fake_packages/gen.pl
@@ -85,12 +85,48 @@ sub parse_xs {
}
}
+sub parse_pm {
+ my ($file) = @_;
+ warn "parse_pm $file\n";
+ my $state = 'waiting_for_type';
+ my $name;
+ $current_package = '';
+ my $c;
+ foreach (cat_($file)) {
+ $c++;
+ next if /^=/ ... /^=cut/;
+ chomp;
+ my $orig_line = $_;
+
+ if (/^\s*#/ || (m!^\s*/\*! .. m!\*/!)) {
+ # forget it
+ } elsif (/^package\s*(\S+)\s*;/) {
+ $current_package = $1;
+ } elsif (!$current_package) {
+ # waiting for the package line
+ } elsif (/^sub\s*(\S*)/) {
+ $name = $1;
+ $l{$current_package}{$name} = [] if !defined($l{$current_package}{$name});
+ $state = 'waiting_for_param';
+ } elsif ($state eq 'waiting_for_param' && /=\s*\@_/) {
+ get_paras($name, $_);
+ $state = 'waiting_for_end';
+ } else {
+ warn "bad line2 #$c $orig_line (state: $state)\n" if 0 &&
+ !(($state eq 'waiting_for_end' || $state eq 'waiting_for_type') &&
+ (/^\s/ || /^[{}]\s*$/ || /^(CODE|OUTPUT):\s*$/));
+ }
+ }
+}
my ($pkg_name, $dir) = @ARGV;
my @xs_files = chomp_(`find $dir -name "*.xs"`);
+# ignore test suites, inc/ and ext/ :
+my @pm_files = chomp_(`find $dir -name "*.pm" | egrep -v '/(ext|inc|t)/'`);
@ARGV == 2 && @xs_files or die "usage: gen.pl <Gtk2 or Glib> <dir where Gtk2's or Glib's *.xs are>\n";
parse_xs($_) foreach @xs_files;
+parse_pm($_) foreach @pm_files;
print "package $pkg_name;\nuse Glib;\n" if $pkg_name eq 'Gtk2';