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/12 01:03:49 UTC

[lucy-commits] svn commit: r1069993 - in /incubator/lucy/trunk/clownfish: lib/Clownfish.xs lib/Clownfish/Type.pm src/CFCType.c src/CFCType.h

Author: marvin
Date: Sat Feb 12 00:03:48 2011
New Revision: 1069993

URL: http://svn.apache.org/viewvc?rev=1069993&view=rev
Log:
Port remaining functionality in Clownfish::Type to C.

Modified:
    incubator/lucy/trunk/clownfish/lib/Clownfish.xs
    incubator/lucy/trunk/clownfish/lib/Clownfish/Type.pm
    incubator/lucy/trunk/clownfish/src/CFCType.c
    incubator/lucy/trunk/clownfish/src/CFCType.h

Modified: incubator/lucy/trunk/clownfish/lib/Clownfish.xs
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/lib/Clownfish.xs?rev=1069993&r1=1069992&r2=1069993&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/lib/Clownfish.xs (original)
+++ incubator/lucy/trunk/clownfish/lib/Clownfish.xs Sat Feb 12 00:03:48 2011
@@ -547,19 +547,27 @@ CODE:
 OUTPUT: RETVAL
 
 void
-_destroy(self)
+DESTROY(self)
     CFCType *self;
 PPCODE:
     CFCType_destroy(self);
 
 int
-_equals(self, other)
+equals(self, other)
     CFCType *self;
     CFCType *other;
 CODE:
     RETVAL = CFCType_equals(self, other);
 OUTPUT: RETVAL
 
+int
+similar(self, other)
+    CFCType *self;
+    CFCType *other;
+CODE:
+    RETVAL = CFCType_similar(self, other);
+OUTPUT: RETVAL
+
 unsigned
 CONST(...)
 CODE:

Modified: incubator/lucy/trunk/clownfish/lib/Clownfish/Type.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/lib/Clownfish/Type.pm?rev=1069993&r1=1069992&r2=1069993&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/lib/Clownfish/Type.pm (original)
+++ incubator/lucy/trunk/clownfish/lib/Clownfish/Type.pm Sat Feb 12 00:03:48 2011
@@ -58,14 +58,10 @@ sub new {
     $flags |= ARBITRARY   if $args{arbitrary};
     $flags |= COMPOSITE   if $args{composite};
 
-    my $parcel = $args{parcel};
-    if ( defined $parcel ) {
-        if ( !blessed($parcel) ) {
-            $parcel = Clownfish::Parcel->singleton( name => $parcel );
-        }
-        confess("Not a Clownfish::Parcel")
-            unless $parcel->isa('Clownfish::Parcel');
-    }
+    my $parcel
+        = $args{parcel}
+        ? Clownfish::Parcel->acquire( $args{parcel} )
+        : $args{parcel};
 
     my $indirection = $args{indirection} || 0;
     my $specifier   = $args{specifier}   || '';
@@ -180,25 +176,6 @@ sub new_arbitrary {
     return $package->_new_arbitrary( $parcel, $args{specifier} );
 }
 
-sub DESTROY {
-    my $self = shift;
-    $self->_destroy;
-}
-
-sub similar {
-    my ( $self, $other ) = @_;
-    confess("Not an object type") unless $self->is_object;
-    for (qw( is_object const incremented decremented nullable )) {
-        return 0 if ( $self->$_ xor $other->$_ );
-    }
-    return 1;
-}
-
-sub equals {
-    my ( $self, $other ) = @_;
-    return $self->_equals($other);
-}
-
 1;
 
 __END__

Modified: incubator/lucy/trunk/clownfish/src/CFCType.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/src/CFCType.c?rev=1069993&r1=1069992&r2=1069993&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/src/CFCType.c (original)
+++ incubator/lucy/trunk/clownfish/src/CFCType.c Sat Feb 12 00:03:48 2011
@@ -339,6 +339,23 @@ CFCType_equals(CFCType *self, CFCType *o
     return true;
 }
 
+int
+CFCType_similar(CFCType *self, CFCType *other)
+{
+    if (!CFCType_is_object(self)) {
+        croak("Attempt to call 'similar' on a non-object type");
+    }
+    if (   (CFCType_const(self)        ^ CFCType_const(other))
+        || (CFCType_nullable(self)     ^ CFCType_nullable(other))
+        || (CFCType_incremented(self)  ^ CFCType_incremented(other))
+        || (CFCType_decremented(self)  ^ CFCType_decremented(other))
+        || (CFCType_is_object(self)    ^ CFCType_is_object(other))
+    ) {
+        return false;
+    }
+    return true;
+}
+
 void
 CFCType_set_specifier(CFCType *self, const char *specifier)
 {

Modified: incubator/lucy/trunk/clownfish/src/CFCType.h
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/src/CFCType.h?rev=1069993&r1=1069992&r2=1069993&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/src/CFCType.h (original)
+++ incubator/lucy/trunk/clownfish/src/CFCType.h Sat Feb 12 00:03:48 2011
@@ -68,6 +68,9 @@ CFCType_destroy(CFCType *self);
 int
 CFCType_equals(CFCType *self, CFCType *other);
 
+int
+CFCType_similar(CFCType *self, CFCType *other);
+
 void
 CFCType_set_specifier(CFCType *self, const char *specifier);