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 2010/02/08 20:26:35 UTC
svn commit: r907765 - in /lucene/lucy/trunk:
clownfish/lib/Clownfish/Method.pm clownfish/lib/Clownfish/Type/Object.pm
core/Lucy/Object/CharBuf.bp core/Lucy/Store/CompoundFileReader.bp
Author: marvin
Date: Mon Feb 8 19:26:34 2010
New Revision: 907765
URL: http://svn.apache.org/viewvc?rev=907765&view=rev
Log:
Improve checking of method return types in Clownfish. Fix a couple incorrect
return types that were revealed by the new check.
Modified:
lucene/lucy/trunk/clownfish/lib/Clownfish/Method.pm
lucene/lucy/trunk/clownfish/lib/Clownfish/Type/Object.pm
lucene/lucy/trunk/core/Lucy/Object/CharBuf.bp
lucene/lucy/trunk/core/Lucy/Store/CompoundFileReader.bp
Modified: lucene/lucy/trunk/clownfish/lib/Clownfish/Method.pm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/clownfish/lib/Clownfish/Method.pm?rev=907765&r1=907764&r2=907765&view=diff
==============================================================================
--- lucene/lucy/trunk/clownfish/lib/Clownfish/Method.pm (original)
+++ lucene/lucy/trunk/clownfish/lib/Clownfish/Method.pm Mon Feb 8 19:26:34 2010
@@ -143,6 +143,16 @@
}
}
+ # Weak validation of return type to allow covariant object return types.
+ my $return_type = $self->{return_type};
+ my $other_return_type = $other->{return_type};
+ if ( $return_type->is_object ) {
+ return 0 unless $return_type->similar($other_return_type);
+ }
+ else {
+ return 0 unless $return_type->equals($other_return_type);
+ }
+
return 1;
}
Modified: lucene/lucy/trunk/clownfish/lib/Clownfish/Type/Object.pm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/clownfish/lib/Clownfish/Type/Object.pm?rev=907765&r1=907764&r2=907765&view=diff
==============================================================================
--- lucene/lucy/trunk/clownfish/lib/Clownfish/Type/Object.pm (original)
+++ lucene/lucy/trunk/clownfish/lib/Clownfish/Type/Object.pm Mon Feb 8 19:26:34 2010
@@ -65,15 +65,21 @@
sub set_nullable { $_[0]->{nullable} = $_[1] }
-sub equals {
+sub similar {
my ( $self, $other ) = @_;
- return 0 unless $self->{specifier} eq $other->{specifier};
for (qw( const incremented decremented nullable )) {
return 0 if ( $self->{$_} xor $other->{$_} );
}
return 1;
}
+sub equals {
+ my ( $self, $other ) = @_;
+ return 0 unless $self->similar($other);
+ return 0 unless $self->{specifier} eq $other->{specifier};
+ return 1;
+}
+
1;
__END__
@@ -135,6 +141,12 @@
Returns true if the Type is decremented.
+=head2 similar
+
+ do_stuff() if $type->similar($other_type);
+
+Weak checking of type which allows for covariant return types.
+
=head1 COPYRIGHT AND LICENSE
/**
Modified: lucene/lucy/trunk/core/Lucy/Object/CharBuf.bp
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/core/Lucy/Object/CharBuf.bp?rev=907765&r1=907764&r2=907765&view=diff
==============================================================================
--- lucene/lucy/trunk/core/Lucy/Object/CharBuf.bp (original)
+++ lucene/lucy/trunk/core/Lucy/Object/CharBuf.bp Mon Feb 8 19:26:34 2010
@@ -320,7 +320,7 @@
Nip_One(ViewCharBuf *self);
/** Throws an error. */
- void
+ char*
Grow(ViewCharBuf *self, size_t size);
public void
Modified: lucene/lucy/trunk/core/Lucy/Store/CompoundFileReader.bp
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/core/Lucy/Store/CompoundFileReader.bp?rev=907765&r1=907764&r2=907765&view=diff
==============================================================================
--- lucene/lucy/trunk/core/Lucy/Store/CompoundFileReader.bp (original)
+++ lucene/lucy/trunk/core/Lucy/Store/CompoundFileReader.bp Mon Feb 8 19:26:34 2010
@@ -66,7 +66,7 @@
nullable Folder*
Local_Find_Folder(CompoundFileReader *self, const CharBuf *name);
- nullable DirHandle*
+ incremented nullable DirHandle*
Local_Open_Dir(CompoundFileReader *self);
}