From: <chr...@us...> - 2006-05-18 22:32:15
|
Revision: 879 Author: chromatic Date: 2006-05-18 15:31:43 -0700 (Thu, 18 May 2006) ViewCVS: http://svn.sourceforge.net/everydevel/?rev=879&view=rev Log Message: ----------- r17179@windwheel: chromatic | 2006-05-18 15:31:29 -0700 Removed SUPER() and AUTOLOAD() from Everything::Node. Modified Paths: -------------- trunk/ebase/lib/Everything/Node/Test/container.pm trunk/ebase/lib/Everything/Node/Test/dbtable.pm trunk/ebase/lib/Everything/Node/Test/document.pm trunk/ebase/lib/Everything/Node/Test/htmlcode.pm trunk/ebase/lib/Everything/Node/Test/htmlpage.pm trunk/ebase/lib/Everything/Node/Test/htmlsnippet.pm trunk/ebase/lib/Everything/Node/Test/image.pm trunk/ebase/lib/Everything/Node/Test/location.pm trunk/ebase/lib/Everything/Node/Test/mail.pm trunk/ebase/lib/Everything/Node/Test/node.pm trunk/ebase/lib/Everything/Node/Test/nodeball.pm trunk/ebase/lib/Everything/Node/Test/nodegroup.pm trunk/ebase/lib/Everything/Node/Test/nodelet.pm trunk/ebase/lib/Everything/Node/Test/nodemethod.pm trunk/ebase/lib/Everything/Node/Test/nodetype.pm trunk/ebase/lib/Everything/Node/Test/opcode.pm trunk/ebase/lib/Everything/Node/Test/setting.pm trunk/ebase/lib/Everything/Node/Test/superdoc.pm trunk/ebase/lib/Everything/Node/Test/theme.pm trunk/ebase/lib/Everything/Node/Test/themesetting.pm trunk/ebase/lib/Everything/Node/Test/user.pm trunk/ebase/lib/Everything/Node/Test/usergroup.pm trunk/ebase/lib/Everything/Node/Test/workspace.pm trunk/ebase/lib/Everything/Node.pm trunk/ebase/t/Node.t Property Changed: ---------------- trunk/ebase/ Property changes on: trunk/ebase ___________________________________________________________________ Name: svk:merge - a6810612-c0f9-0310-9d3e-a9e4af8c5745:/ebase/offline:17177 + a6810612-c0f9-0310-9d3e-a9e4af8c5745:/ebase/offline:17179 Modified: trunk/ebase/lib/Everything/Node/Test/container.pm =================================================================== --- trunk/ebase/lib/Everything/Node/Test/container.pm 2006-05-18 22:12:07 UTC (rev 878) +++ trunk/ebase/lib/Everything/Node/Test/container.pm 2006-05-18 22:31:43 UTC (rev 879) @@ -4,6 +4,7 @@ use warnings; use base 'Everything::Node::Test::node'; + use Test::More; sub test_dbtables :Test( 2 ) Modified: trunk/ebase/lib/Everything/Node/Test/dbtable.pm =================================================================== --- trunk/ebase/lib/Everything/Node/Test/dbtable.pm 2006-05-18 22:12:07 UTC (rev 878) +++ trunk/ebase/lib/Everything/Node/Test/dbtable.pm 2006-05-18 22:31:43 UTC (rev 879) @@ -5,11 +5,8 @@ use base 'Everything::Node::Test::node'; -use SUPER; use Test::More; -*Everything::Node::dbtable::SUPER = \&UNIVERSAL::SUPER; - sub test_insert :Test( 8 ) { my $self = shift; Modified: trunk/ebase/lib/Everything/Node/Test/document.pm =================================================================== --- trunk/ebase/lib/Everything/Node/Test/document.pm 2006-05-18 22:12:07 UTC (rev 878) +++ trunk/ebase/lib/Everything/Node/Test/document.pm 2006-05-18 22:31:43 UTC (rev 879) @@ -5,11 +5,8 @@ use base 'Everything::Node::Test::node'; -use SUPER; use Test::More; -*Everything::Node::document::SUPER = \&UNIVERSAL::SUPER; - sub test_dbtables :Test( 2 ) { my $self = shift; Modified: trunk/ebase/lib/Everything/Node/Test/htmlcode.pm =================================================================== --- trunk/ebase/lib/Everything/Node/Test/htmlcode.pm 2006-05-18 22:12:07 UTC (rev 878) +++ trunk/ebase/lib/Everything/Node/Test/htmlcode.pm 2006-05-18 22:31:43 UTC (rev 879) @@ -6,10 +6,7 @@ use base 'Everything::Node::Test::node'; use Test::More; -use SUPER; -*Everything::Node::htmlcode::SUPER = \&UNIVERSAL::SUPER; - sub test_dbtables :Test( 2 ) { my $self = shift; Modified: trunk/ebase/lib/Everything/Node/Test/htmlpage.pm =================================================================== --- trunk/ebase/lib/Everything/Node/Test/htmlpage.pm 2006-05-18 22:12:07 UTC (rev 878) +++ trunk/ebase/lib/Everything/Node/Test/htmlpage.pm 2006-05-18 22:31:43 UTC (rev 879) @@ -4,11 +4,9 @@ use warnings; use base 'Everything::Node::Test::node'; + use Test::More; -use SUPER; -*Everything::Node::htmlpage::SUPER = \&UNIVERSAL::SUPER; - sub test_dbtables { my $self = shift; Modified: trunk/ebase/lib/Everything/Node/Test/htmlsnippet.pm =================================================================== --- trunk/ebase/lib/Everything/Node/Test/htmlsnippet.pm 2006-05-18 22:12:07 UTC (rev 878) +++ trunk/ebase/lib/Everything/Node/Test/htmlsnippet.pm 2006-05-18 22:31:43 UTC (rev 879) @@ -4,6 +4,7 @@ use warnings; use base 'Everything::Node::Test::htmlcode'; + use Test::More; sub test_extends :Test( +1 ) Modified: trunk/ebase/lib/Everything/Node/Test/image.pm =================================================================== --- trunk/ebase/lib/Everything/Node/Test/image.pm 2006-05-18 22:12:07 UTC (rev 878) +++ trunk/ebase/lib/Everything/Node/Test/image.pm 2006-05-18 22:31:43 UTC (rev 879) @@ -6,10 +6,7 @@ use base 'Everything::Node::Test::node'; use Test::More; -use SUPER; -*Everything::Node::image::SUPER = \&UNIVERSAL::SUPER; - sub test_dbtables { my $self = shift; Modified: trunk/ebase/lib/Everything/Node/Test/location.pm =================================================================== --- trunk/ebase/lib/Everything/Node/Test/location.pm 2006-05-18 22:12:07 UTC (rev 878) +++ trunk/ebase/lib/Everything/Node/Test/location.pm 2006-05-18 22:31:43 UTC (rev 879) @@ -4,9 +4,8 @@ use warnings; use base 'Everything::Node::Test::node'; + use Test::More; -use SUPER; -*Everything::Node::location::SUPER = \&UNIVERSAL::SUPER; sub test_nuke :Test( +8 ) { Modified: trunk/ebase/lib/Everything/Node/Test/mail.pm =================================================================== --- trunk/ebase/lib/Everything/Node/Test/mail.pm 2006-05-18 22:12:07 UTC (rev 878) +++ trunk/ebase/lib/Everything/Node/Test/mail.pm 2006-05-18 22:31:43 UTC (rev 879) @@ -5,11 +5,8 @@ use base 'Everything::Node::Test::document'; -use SUPER; use Test::More; -*Everything::Node::document::SUPER = \&UNIVERSAL::SUPER; - sub test_dbtables :Test( 2 ) { my $self = shift; Modified: trunk/ebase/lib/Everything/Node/Test/node.pm =================================================================== --- trunk/ebase/lib/Everything/Node/Test/node.pm 2006-05-18 22:12:07 UTC (rev 878) +++ trunk/ebase/lib/Everything/Node/Test/node.pm 2006-05-18 22:31:43 UTC (rev 879) @@ -11,8 +11,6 @@ use Scalar::Util qw( reftype blessed ); -local *Everything::Node::SUPER = \&UNIVERSAL::SUPER; - sub node_class { my $self = shift; Modified: trunk/ebase/lib/Everything/Node/Test/nodeball.pm =================================================================== --- trunk/ebase/lib/Everything/Node/Test/nodeball.pm 2006-05-18 22:12:07 UTC (rev 878) +++ trunk/ebase/lib/Everything/Node/Test/nodeball.pm 2006-05-18 22:31:43 UTC (rev 879) @@ -5,11 +5,8 @@ use base 'Everything::Node::Test::nodegroup'; -use SUPER; use Test::More; -*Everything::Node::nodeball::SUPER = \&UNIVERSAL::SUPER; - sub test_dbtables :Test( 2 ) { my $self = shift; Modified: trunk/ebase/lib/Everything/Node/Test/nodegroup.pm =================================================================== --- trunk/ebase/lib/Everything/Node/Test/nodegroup.pm 2006-05-18 22:12:07 UTC (rev 878) +++ trunk/ebase/lib/Everything/Node/Test/nodegroup.pm 2006-05-18 22:31:43 UTC (rev 879) @@ -5,11 +5,8 @@ use base 'Everything::Node::Test::node'; -use SUPER; use Test::More; -*Everything::Node::nodegroup::SUPER = \&UNIVERSAL::SUPER; - sub test_construct :Test( 1 ) { my $self = shift; @@ -780,3 +777,5 @@ is( $result, 11, '... returning the result' ); } + +1; Modified: trunk/ebase/lib/Everything/Node/Test/nodelet.pm =================================================================== --- trunk/ebase/lib/Everything/Node/Test/nodelet.pm 2006-05-18 22:12:07 UTC (rev 878) +++ trunk/ebase/lib/Everything/Node/Test/nodelet.pm 2006-05-18 22:31:43 UTC (rev 879) @@ -5,11 +5,8 @@ use base 'Everything::Node::Test::node'; -use SUPER; use Test::More; -*Everything::Node::nodelet::SUPER = \&UNIVERSAL::SUPER; - sub test_dbtables :Test( 2 ) { my $self = shift; Modified: trunk/ebase/lib/Everything/Node/Test/nodemethod.pm =================================================================== --- trunk/ebase/lib/Everything/Node/Test/nodemethod.pm 2006-05-18 22:12:07 UTC (rev 878) +++ trunk/ebase/lib/Everything/Node/Test/nodemethod.pm 2006-05-18 22:31:43 UTC (rev 879) @@ -4,6 +4,7 @@ use warnings; use base 'Everything::Node::Test::node'; + use Test::More; sub test_dbtables :Test( 2 ) Modified: trunk/ebase/lib/Everything/Node/Test/nodetype.pm =================================================================== --- trunk/ebase/lib/Everything/Node/Test/nodetype.pm 2006-05-18 22:12:07 UTC (rev 878) +++ trunk/ebase/lib/Everything/Node/Test/nodetype.pm 2006-05-18 22:31:43 UTC (rev 879) @@ -4,12 +4,9 @@ use warnings; use base 'Everything::Node::Test::node'; + use Test::More; -use SUPER; -# XXX - hack for now -*Everything::Node::nodetype::SUPER = \&UNIVERSAL::SUPER; - sub startup :Test( +1 ) { my $self = shift; Modified: trunk/ebase/lib/Everything/Node/Test/opcode.pm =================================================================== --- trunk/ebase/lib/Everything/Node/Test/opcode.pm 2006-05-18 22:12:07 UTC (rev 878) +++ trunk/ebase/lib/Everything/Node/Test/opcode.pm 2006-05-18 22:31:43 UTC (rev 879) @@ -4,6 +4,7 @@ use warnings; use base 'Everything::Node::Test::htmlcode'; + use Test::More; sub test_extends :Test( +1 ) Modified: trunk/ebase/lib/Everything/Node/Test/setting.pm =================================================================== --- trunk/ebase/lib/Everything/Node/Test/setting.pm 2006-05-18 22:12:07 UTC (rev 878) +++ trunk/ebase/lib/Everything/Node/Test/setting.pm 2006-05-18 22:31:43 UTC (rev 879) @@ -5,11 +5,8 @@ use base 'Everything::Node::Test::node'; -use SUPER; use Test::More; -*Everything::Node::setting::SUPER = \&UNIVERSAL::SUPER; - sub test_extends :Test( +1 ) { my $self = shift; Modified: trunk/ebase/lib/Everything/Node/Test/superdoc.pm =================================================================== --- trunk/ebase/lib/Everything/Node/Test/superdoc.pm 2006-05-18 22:12:07 UTC (rev 878) +++ trunk/ebase/lib/Everything/Node/Test/superdoc.pm 2006-05-18 22:31:43 UTC (rev 879) @@ -5,11 +5,8 @@ use base 'Everything::Node::Test::document'; -use SUPER; use Test::More; -*Everything::Node::document::SUPER = \&UNIVERSAL::SUPER; - sub test_dbtables :Test( 2 ) { my $self = shift; Modified: trunk/ebase/lib/Everything/Node/Test/theme.pm =================================================================== --- trunk/ebase/lib/Everything/Node/Test/theme.pm 2006-05-18 22:12:07 UTC (rev 878) +++ trunk/ebase/lib/Everything/Node/Test/theme.pm 2006-05-18 22:31:43 UTC (rev 879) @@ -4,6 +4,7 @@ use warnings; use base 'Everything::Node::Test::nodeball'; + use Test::More; sub test_extends :Test( +1 ) Modified: trunk/ebase/lib/Everything/Node/Test/themesetting.pm =================================================================== --- trunk/ebase/lib/Everything/Node/Test/themesetting.pm 2006-05-18 22:12:07 UTC (rev 878) +++ trunk/ebase/lib/Everything/Node/Test/themesetting.pm 2006-05-18 22:31:43 UTC (rev 879) @@ -5,9 +5,7 @@ use base 'Everything::Node::Test::setting'; -use SUPER; use Test::More; -*Everything::Node::themesetting::SUPER = \&UNIVERSAL::SUPER; sub test_extends :Test( +1 ) { @@ -30,3 +28,5 @@ is_deeply( \@tables, [qw( themesetting setting node )], 'dbtables() should return node tables' ); } + +1; Modified: trunk/ebase/lib/Everything/Node/Test/user.pm =================================================================== --- trunk/ebase/lib/Everything/Node/Test/user.pm 2006-05-18 22:12:07 UTC (rev 878) +++ trunk/ebase/lib/Everything/Node/Test/user.pm 2006-05-18 22:31:43 UTC (rev 879) @@ -3,15 +3,11 @@ use strict; use warnings; -use SUPER; -use Scalar::Util 'reftype'; +use base 'Everything::Node::Test::setting'; use Test::More; +use Scalar::Util 'reftype'; -*Everything::Node::user::SUPER = \&UNIVERSAL::SUPER; - -use base 'Everything::Node::Test::setting'; - sub test_extends :Test( +1 ) { my $self = shift; Modified: trunk/ebase/lib/Everything/Node/Test/usergroup.pm =================================================================== --- trunk/ebase/lib/Everything/Node/Test/usergroup.pm 2006-05-18 22:12:07 UTC (rev 878) +++ trunk/ebase/lib/Everything/Node/Test/usergroup.pm 2006-05-18 22:31:43 UTC (rev 879) @@ -4,6 +4,7 @@ use warnings; use base 'Everything::Node::Test::nodegroup'; + use Test::More; sub test_extends :Test( +1 ) Modified: trunk/ebase/lib/Everything/Node/Test/workspace.pm =================================================================== --- trunk/ebase/lib/Everything/Node/Test/workspace.pm 2006-05-18 22:12:07 UTC (rev 878) +++ trunk/ebase/lib/Everything/Node/Test/workspace.pm 2006-05-18 22:31:43 UTC (rev 879) @@ -4,11 +4,9 @@ use warnings; use base 'Everything::Node::Test::setting'; + use Test::More; -use SUPER; -*Everything::Node::workspace::SUPER = \&UNIVERSAL::SUPER; - sub test_extends :Test( +1 ) { my $self = shift; Modified: trunk/ebase/lib/Everything/Node.pm =================================================================== --- trunk/ebase/lib/Everything/Node.pm 2006-05-18 22:12:07 UTC (rev 878) +++ trunk/ebase/lib/Everything/Node.pm 2006-05-18 22:31:43 UTC (rev 879) @@ -22,6 +22,7 @@ use Everything (); use Everything::Util; use XML::DOM; +use SUPER; =cut @@ -131,175 +132,6 @@ return $$this{node_id}; } -=cut - - -=head2 C<AUTOLOAD> - -This allows us to call functions like $NODE-E<gt>someFunc(), while implementing -them in either a .pm or a nodemethod node. This is the magic behind how -Everything implements its method inheritance. MAKE SURE YOU UNDERSTAND HOW -THIS WORKS before changing anything in here. You could break the whole system -if this is wrong. - -Returns whatever the function you are calling returns - -=cut - -sub AUTOLOAD -{ - my $this = shift; - - # We just want the function name, not all the package info. - my ($func) = $Everything::Node::AUTOLOAD =~ /::(\w+)$/; - - my $TYPE = $this->{DB}->getType( $$this{SUPERtype} ); - my $origType = $this->{SUPERtype}; - my $origFunc = $this->{SUPERfunc}; - my $origParams = $this->{SUPERparams}; - my $result; - - if ( ( defined( $this->{SUPERfunc} ) ) && ( $func ne $this->{SUPERfunc} ) ) - { - - # If the function being called is different from what we have - # as a SUPERfunc, that means the implementation has called - # another function on this same object. We don't want to have - # this call the function on the SUPERtype - $TYPE = $this->{type}; - } - else - { - $TYPE ||= $this->{type}; - } - - $this->{SUPERtype} = $TYPE->{node_id}; - $this->{SUPERfunc} = $func; - - # Make a copy of the parameters in case they modify the default array. - $this->{SUPERparams} = [@_]; - - my $METHOD = $this->getNodeMethod( $func, $TYPE ); - - if ( defined $METHOD ) - { - my ( $warn, $code, $N ); - my $error = ''; - - # When we search for a method, on type X, we may find it on - # one of its parent types. So, we want to make sure we set - # the current type appropriately otherwise we may end up - # executing the same function 2 or more times (bad). - $this->{SUPERtype} = $METHOD->{SUPERtype}; - - local $SIG{__WARN__} = sub { - $warn .= $_[0] unless $_[0] =~ /^Use of uninitialized value/; - }; - - if ( $METHOD->{type} eq 'nodemethod' ) - { - - # This a method that is in a node. Eval it. - unshift @_, $this; - $N = $this->{DB}->getNode( $METHOD->{node} ); - $code = $N->{code}; - $code =~ tr/\015//d; - $result = eval($code); - $error = $@; - } - - if ( $error or $METHOD->{type} eq 'pm' ) - { - - # We didn't find a method in node form. Execute the default in - # the corresponding .pm. - $code = $METHOD->{name} . "(\@_);"; - my $meth = $METHOD->{name}; - $result = eval { $this->$meth(@_) }; - } - - Everything::logErrors( $warn, $@, $code, $N ) if $warn or $@; - } - else - { - - # A function of the given name was not found for us! Throw an error! - die -"Error! No function '$func' for nodetype $this->{type}{title}.\n($TYPE->{node_id},$this->{title},$this->{node_id})"; - } - - # Set these back to what they were. - $this->{SUPERtype} = $origType; - $this->{SUPERfunc} = $origFunc; - $this->{SUPERparams} = $origParams; - - return $result; -} - -=cut - - -=head2 C<SUPER> - -This implements the idea of calling a parent (inherited) implementation from a -overrided function. This allows you to call $this-E<gt>SUPER(); from a -function implementation and it will call the parent's implementation of that -function. This is similar to the concept in Java. - -Returns the result of calling the parent implementation - -=cut - -sub SUPER -{ - my $this = shift @_; - my $TYPE = $$this{DB}->getType( $$this{SUPERtype} ); - my $PARENT = $$this{DB}->getType( $$TYPE{extends_nodetype} ); - - if ($PARENT) - { - my $origType = $$this{SUPERtype}; - my $origParams = $$this{SUPERparams}; - my $origFunc = $$this{SUPERfunc}; - my $result; - - $$this{SUPERtype} = $PARENT->getId(); - - # If no parameters were passed, we will use the parameters passed - # to the original call to this function. - unless (@_) - { - my $params = $$this{SUPERparams}; - push @_, @$params; - } - - # We use the object reference here to call the function. - my $exec = "\$this->$$this{SUPERfunc}(\@_);"; - my $warn; - - local $SIG{__WARN__} = sub { - $warn .= $_[0]; - }; - - $result = eval($exec); - - local $SIG{__WARN__} = sub { }; - - Everything::logErrors( $warn, $@, $exec ); - - $$this{SUPERtype} = $origType; - $$this{SUPERparams} = $origParams; - $$this{SUPERfunc} = $origFunc; - - return $result; - } - - die "No SUPER for function $$this{SUPERfunc} for type $$TYPE{title}\n"; -} - -=cut - - =head2 C<getNodeMethod> This is a utility function that finds the method of the given name for the Modified: trunk/ebase/t/Node.t =================================================================== --- trunk/ebase/t/Node.t 2006-05-18 22:12:07 UTC (rev 878) +++ trunk/ebase/t/Node.t 2006-05-18 22:31:43 UTC (rev 879) @@ -1,16 +1,10 @@ -#!/usr/bin/perl -w +#! perl use strict; +use warnings; -BEGIN -{ - chdir 't' if -d 't'; - unshift @INC, '../blib/lib', 'lib/', '..'; -} +use vars '$AUTOLOAD'; -use strict; -use vars qw( $AUTOLOAD ); - use Test::More tests => 42; use Test::MockObject; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |