You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2011/02/02 00:17:00 UTC

[lucy-commits] svn commit: r1066265 - in /incubator/lucy/trunk/clownfish: lib/Clownfish/Function.pm lib/Clownfish/Method.pm t/400-class.t

Author: marvin
Date: Tue Feb  1 23:17:00 2011
New Revision: 1066265

URL: http://svn.apache.org/viewvc?rev=1066265&view=rev
Log:
Change Clownfish::Function to inside-out implementation.

Modified:
    incubator/lucy/trunk/clownfish/lib/Clownfish/Function.pm
    incubator/lucy/trunk/clownfish/lib/Clownfish/Method.pm
    incubator/lucy/trunk/clownfish/t/400-class.t

Modified: incubator/lucy/trunk/clownfish/lib/Clownfish/Function.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/lib/Clownfish/Function.pm?rev=1066265&r1=1066264&r2=1066265&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/lib/Clownfish/Function.pm (original)
+++ incubator/lucy/trunk/clownfish/lib/Clownfish/Function.pm Tue Feb  1 23:17:00 2011
@@ -23,6 +23,11 @@ use Clownfish::Util qw( verify_args a_is
 use Clownfish::Type;
 use Clownfish::ParamList;
 
+our %return_type;
+our %param_list;
+our %docucomment;
+our %inline;
+
 my %new_PARAMS = (
     return_type => undef,
     class_name  => undef,
@@ -36,28 +41,45 @@ my %new_PARAMS = (
 );
 
 sub new {
-    my $either = shift;
-    verify_args( \%new_PARAMS, @_ ) or confess $@;
-    my $self = $either->SUPER::new( %new_PARAMS, @_ );
+    my ( $either, %args ) = @_;
+    verify_args( \%new_PARAMS, %args ) or confess $@;
+    my $return_type = delete $args{return_type};
+    my $param_list  = delete $args{param_list};
+    my $docucomment = delete $args{docucomment};
+    my $inline      = delete $args{inline} || 0;
+    my $self        = $either->SUPER::new( %new_PARAMS, %args );
+    $return_type{$self} = $return_type;
+    $param_list{$self}  = $param_list;
+    $docucomment{$self} = $docucomment;
+    $inline{$self}      = $inline;
 
     # Validate.
     for (qw( return_type class_name param_list )) {
-        confess("$_ is mandatory") unless defined $self->{$_};
+        my $meth_name = "get_$_";
+        confess("$_ is mandatory") unless defined $self->$meth_name;
     }
     confess( "Invalid micro_sym: '" . $self->micro_sym . "'" )
         unless $self->micro_sym =~ /^[a-z0-9_]+$/;
     confess 'param_list must be a ParamList object'
-        unless a_isa_b( $self->get_param_list, "Clownfish::ParamList" );
+        unless a_isa_b( $param_list, "Clownfish::ParamList" );
     confess 'return_type must be a Type object'
-        unless a_isa_b( $self->get_return_type, "Clownfish::Type" );
+        unless a_isa_b( $return_type, "Clownfish::Type" );
 
     return $self;
 }
 
-sub get_return_type { shift->{return_type} }
-sub get_param_list  { shift->{param_list} }
-sub get_docucomment { shift->{docucomment} }
-sub inline          { shift->{inline} }
+sub DESTROY {
+    my $self = shift;
+    delete $return_type{$self};
+    delete $param_list{$self};
+    delete $docucomment{$self};
+    delete $inline{$self};
+}
+
+sub get_return_type { $return_type{ +shift } }
+sub get_param_list  { $param_list{ +shift } }
+sub get_docucomment { $docucomment{ +shift } }
+sub inline          { $inline{ +shift } }
 
 sub void { shift->get_return_type->is_void }
 

Modified: incubator/lucy/trunk/clownfish/lib/Clownfish/Method.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/lib/Clownfish/Method.pm?rev=1066265&r1=1066264&r2=1066265&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/lib/Clownfish/Method.pm (original)
+++ incubator/lucy/trunk/clownfish/lib/Clownfish/Method.pm Tue Feb  1 23:17:00 2011
@@ -91,6 +91,7 @@ sub DESTROY {
     delete $final{$self};
     delete $novel{$self};
     delete $short_typedef{$self};
+    $self->SUPER::DESTROY;
 }
 
 sub abstract      { $abstract{ +shift } }

Modified: incubator/lucy/trunk/clownfish/t/400-class.t
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/t/400-class.t?rev=1066265&r1=1066264&r2=1066265&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/t/400-class.t (original)
+++ incubator/lucy/trunk/clownfish/t/400-class.t Tue Feb  1 23:17:00 2011
@@ -204,7 +204,7 @@ ok( ( scalar grep { $_->micro_sym eq 'sc
 
 for my $method ( @{ $class->methods } ) {
     if ( $method->micro_sym eq 'scratch' ) {
-        ok( $method->{return_type}->nullable,
+        ok( $method->get_return_type->nullable,
             "public abstract incremented nullable flagged as nullable" );
     }
 }