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/27 04:22:47 UTC

[lucy-commits] svn commit: r1074980 - in /incubator/lucy/trunk/clownfish: lib/Clownfish.xs lib/Clownfish/Class.pm src/CFCClass.c src/CFCClass.h

Author: marvin
Date: Sun Feb 27 03:22:46 2011
New Revision: 1074980

URL: http://svn.apache.org/viewvc?rev=1074980&view=rev
Log:
Port CFCClass_novel_member_vars() to C.

Modified:
    incubator/lucy/trunk/clownfish/lib/Clownfish.xs
    incubator/lucy/trunk/clownfish/lib/Clownfish/Class.pm
    incubator/lucy/trunk/clownfish/src/CFCClass.c
    incubator/lucy/trunk/clownfish/src/CFCClass.h

Modified: incubator/lucy/trunk/clownfish/lib/Clownfish.xs
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/lib/Clownfish.xs?rev=1074980&r1=1074979&r2=1074980&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/lib/Clownfish.xs (original)
+++ incubator/lucy/trunk/clownfish/lib/Clownfish.xs Sun Feb 27 03:22:46 2011
@@ -222,6 +222,7 @@ ALIAS:
     member_vars           = 38
     inert_vars            = 40
     tree_to_ladder        = 42
+    novel_member_vars     = 44
 PPCODE:
 {
     START_SET_OR_GET_SWITCH
@@ -373,6 +374,19 @@ PPCODE:
             SvREFCNT_dec(av);
             break;
         }
+        case 44: {
+            AV *av = newAV();
+            CFCVariable **novel = CFCClass_novel_member_vars(self);
+            size_t i;
+            for (i = 0; novel[i] != NULL; i++) {
+                SV *val = newRV(CFCBase_get_perl_obj((CFCBase*)novel[i]));
+                av_store(av, i, val);
+            }
+            FREEMEM(novel);
+            retval = newRV((SV*)av);
+            SvREFCNT_dec(av);
+            break;
+        }
     END_SET_OR_GET_SWITCH
 }
 

Modified: incubator/lucy/trunk/clownfish/lib/Clownfish/Class.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/lib/Clownfish/Class.pm?rev=1074980&r1=1074979&r2=1074980&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/lib/Clownfish/Class.pm (original)
+++ incubator/lucy/trunk/clownfish/lib/Clownfish/Class.pm Sun Feb 27 03:22:46 2011
@@ -129,14 +129,6 @@ sub novel_methods {
     return \@methods;
 }
 
-sub novel_member_vars {
-    my $self  = shift;
-    my $cnick = $self->get_cnick;
-    my @novel
-        = grep { $_->get_class_cnick eq $cnick } @{ $self->member_vars };
-    return \@novel;
-}
-
 sub method {
     my ( $self, $micro_sym ) = @_;
     $micro_sym = lc($micro_sym);

Modified: incubator/lucy/trunk/clownfish/src/CFCClass.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/src/CFCClass.c?rev=1074980&r1=1074979&r2=1074980&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/src/CFCClass.c (original)
+++ incubator/lucy/trunk/clownfish/src/CFCClass.c Sun Feb 27 03:22:46 2011
@@ -387,6 +387,25 @@ CFCClass_tree_to_ladder(CFCClass *self)
     return ladder;
 }
 
+CFCVariable**
+CFCClass_novel_member_vars(CFCClass *self)
+{
+    const char *cnick = CFCSymbol_get_class_cnick((CFCSymbol*)self);
+    size_t amount = (self->num_member_vars + 1) * sizeof(CFCVariable*);
+    CFCVariable **novel = (CFCVariable**)MALLOCATE(amount);
+    size_t i;
+    size_t num_novel = 0;
+    for (i = 0; i < self->num_member_vars; i++) {
+        CFCVariable *var = self->member_vars[i];
+        const char *var_cnick = CFCSymbol_get_class_cnick((CFCSymbol*)var);
+        if (strcmp(var_cnick, cnick) == 0) {
+            novel[num_novel++] = var;
+        }
+    }
+    novel[num_novel] = NULL;
+    return novel;
+}
+
 CFCClass**
 CFCClass_children(CFCClass *self)
 {

Modified: incubator/lucy/trunk/clownfish/src/CFCClass.h
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/src/CFCClass.h?rev=1074980&r1=1074979&r2=1074980&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/src/CFCClass.h (original)
+++ incubator/lucy/trunk/clownfish/src/CFCClass.h Sun Feb 27 03:22:46 2011
@@ -73,6 +73,9 @@ CFCClass_establish_ancestry(CFCClass *se
 CFCClass**
 CFCClass_tree_to_ladder(CFCClass *self);
 
+struct CFCVariable**
+CFCClass_novel_member_vars(CFCClass *self);
+
 CFCClass**
 CFCClass_children(CFCClass *self);