On Mon, 2002-10-07 at 10:29, Doug MacEachern wrote: > excellent work Philippe!! thanks, i've applied your patch. > one change i made was to remove the dependency on Devel::Symdump by simply > making a copy of it into ModPerl::Symdump. would happily apply patches > that prune away the things we don't need there for Apache::PerlSection, > such as inh_tree, etc.
Here it is, stripped down of Devel::Symdump, and it actually makes the
main loop a bit clearer.
Index: lib/Apache/PerlSection.pm
===================================================================
RCS file: /home/cvspublic/modperl-2.0/lib/Apache/PerlSection.pm,v
retrieving revision 1.1
diff -u -I'$Id' -I'$Revision' -r1.1 PerlSection.pm
--- lib/Apache/PerlSection.pm 7 Oct 2002 02:35:18 -0000 1.1
+++ lib/Apache/PerlSection.pm 7 Oct 2002 04:04:29 -0000
@@ -5,7 +5,6 @@
our $VERSION = '0.01';
-use ModPerl::Symdump ();
use Apache::CmdParms ();
use Apache::Directive ();
@@ -19,6 +18,7 @@
sub server { return shift->{'parms'}->server() }
sub directives { return shift->{'directives'} ||= [] }
+sub package { return shift->{'args'}->get('package') }
sub handler : method {
my($self, $parms, $args) = @_;
@@ -27,25 +27,17 @@
$self = $self->new('parms' => $parms, 'args' => $args);
}
- my $package = $args->get('package');
my $special = $self->SPECIAL_NAME;
- my $root = ModPerl::Symdump->new($package);
-
- my %convert = (
- 'scalars' => sub { no strict 'refs'; return ${ $_[0] } },
- 'arrays' => sub { no strict 'refs'; return \@{ $_[0] } },
- 'hashes' => sub { no strict 'refs'; return \%{ $_[0] } },
- );
-
- for my $type (sort keys %convert) {
- for my $entry (grep { !/$special/ } $root->$type()) {
- (my $name = $entry) =~ s/${package}:://;
- $self->dump($name, $convert{$type}->($entry));
+ for my $entry ($self->symdump())
+ {
+ if ($entry->[0] !~ /$special/) {
+ $self->dump(@$entry);
}
}
{
+ my $package = $self->package;
no strict 'refs';
$self->dump_special(${"${package}::$special"},
@{"${package}::$special"} );
@@ -54,6 +46,42 @@
$self->post_config();
Apache::OK;
+}
+
+sub symdump
+{
+ my ($self) = @_;
+ return if $self->{_symdump}++;
+
+ my $pack = $self->package;
+
+ if (!$self->{symbols})
+ {
+ $self->{symbols} ||= [];
+
+ no strict;
+
+ #XXX: Shamelessly borrowed from Devel::Symdump;
+ while (my ($key, $val) = each(%{*{"$pack\::"}}))
+ {
+ local (*ENTRY) = $val;
+ if (defined $val && defined *ENTRY{SCALAR})
+ {
+ push @{$self->{symbols}}, [$key, $ENTRY];
+ }
+ if (defined $val && defined *ENTRY{ARRAY})
+ {
+ push @{$self->{symbols}}, [$key, \@ENTRY];
+ }
+ if (defined $val && defined *ENTRY{HASH} && $key !~ /::/)
+ {
+ push @{$self->{symbols}}, [$key, \%ENTRY];
+ }
+ }
+ }
+
+ return @{$self->{symbols}};
+
}
sub dump_special {
signature.asc
Description: This is a digitally signed message part
