cvsuser 02/03/22 15:15:14 Modified: P5EEx/Blue/P5EEx/Blue P5EE.pm Log: moved some methods around Revision Changes Path 1.11 +100 -60 p5ee/P5EEx/Blue/P5EEx/Blue/P5EE.pm Index: P5EE.pm =================================================================== RCS file: /cvs/public/p5ee/P5EEx/Blue/P5EEx/Blue/P5EE.pm,v retrieving revision 1.10 retrieving revision 1.11 diff -u -w -r1.10 -r1.11 --- P5EE.pm 19 Mar 2002 22:42:30 -0000 1.10 +++ P5EE.pm 22 Mar 2002 23:15:14 -0000 1.11 @@ -1,6 +1,6 @@ ############################################################################# -## $Id: P5EE.pm,v 1.10 2002/03/19 22:42:30 spadkins Exp $ +## $Id: P5EE.pm,v 1.11 2002/03/22 23:15:14 spadkins Exp $ ############################################################################# package P5EEx::Blue::P5EE; @@ -233,6 +233,104 @@ $P5EEx::Blue::DEBUG = 0 if (!defined $P5EEx::Blue::DEBUG); ############################################################################# +# SUPPORT FOR ASPECT-ORIENTED-PROGRAMMING (AOP) +############################################################################# + +=head1 Code Inclusion and Instrumentation + +=cut + +############################################################################# +# use() +############################################################################# + +=head2 use() + +The use() method loads additional perl code and enables aspect-oriented +programming (AOP) features if they are appropriate. + + * Signature: P5EEx::Blue->use($class); + * Param: $class string [in] + * Return: void + * Throws: <none> + * Since: 0.01 + + Sample Usage: + + P5EEx::Blue->use("P5EEx::Blue::Widget::Entity"); + +=cut + +my (%used); +my (%class_aop_enabled, %class_aop_instrumented); +my ($aop_entry, $aop_exit, @advice); + +sub use { + my ($self, $class) = @_; + return if (defined $used{$class}); + eval "use $class;"; + if ($@) { + P5EEx::Blue::Exception->throw( + error => "class $class failed to load: $@\n", + ); + } + $used{$class} = 1; + @advice = (); + #P5EEx::Blue->instrument_aop(); +} + +############################################################################# +# printargs() +############################################################################# + +=head2 printargs() + + * Signature: P5EEx::Blue::P5EE->printargs($depth, $skipatend, @args); + * Param: $depth integer [in] + * Param: $skipatend integer [in] + * Param: @args any [in] + * Return: void + * Throws: none + * Since: 0.01 + +=cut + +sub printargs { + my $depth = shift; + my $skipatend = shift; + my ($narg); + for ($narg = 0; $narg <= $#_ - $skipatend; $narg++) { + print "," if ($narg); + if (ref($_[$narg]) eq "") { + print $_[$narg]; + } + elsif (ref($_[$narg]) eq "ARRAY") { + print "["; + if ($depth <= 1) { + print join(",", @{$_[$narg]}); + } + else { + &printdepth($depth-1, 0, @{$_[$narg]}); + } + print "]"; + } + elsif (ref($_[$narg]) eq "HASH") { + print "{"; + if ($depth <= 1) { + print join(",", %{$_[$narg]}); + } + else { + &printdepth($depth-1, 0, %{$_[$narg]}); + } + print "}"; + } + else { + print $_[$narg]; + } + } +} + +############################################################################# # CONSTRUCTOR METHODS ############################################################################# @@ -272,8 +370,6 @@ =cut -my (%used); - sub new { my $self = shift; return $self->context(@_) if ($#_ == -1); @@ -281,12 +377,7 @@ if ($class =~ /^([A-Za-z0-9:_]+)$/) { $class = $1; # untaint the $class if (! $used{$class}) { - eval("use $class;"); - if ($@) { - print STDERR "Error creating object: $@\n"; - return undef; - } - $used{$class} = 1; + $self->use($class); } my $method = ($#_ > -1) ? shift : "new"; return $class->$method(@_); @@ -431,57 +522,6 @@ } $self->context($args)->config(); -} - -############################################################################# -# printargs() -############################################################################# - -=head2 printargs() - - * Signature: P5EEx::Blue::P5EE->printargs($depth, $skipatend, @args); - * Param: $depth integer [in] - * Param: $skipatend integer [in] - * Param: @args any [in] - * Return: void - * Throws: none - * Since: 0.01 - -=cut - -sub printargs { - my $depth = shift; - my $skipatend = shift; - my ($narg); - for ($narg = 0; $narg <= $#_ - $skipatend; $narg++) { - print "," if ($narg); - if (ref($_[$narg]) eq "") { - print $_[$narg]; - } - elsif (ref($_[$narg]) eq "ARRAY") { - print "["; - if ($depth <= 1) { - print join(",", @{$_[$narg]}); - } - else { - &printdepth($depth-1, 0, @{$_[$narg]}); - } - print "]"; - } - elsif (ref($_[$narg]) eq "HASH") { - print "{"; - if ($depth <= 1) { - print join(",", %{$_[$narg]}); - } - else { - &printdepth($depth-1, 0, %{$_[$narg]}); - } - print "}"; - } - else { - print $_[$narg]; - } - } } =head1 ACKNOWLEDGEMENTS