Stop tracking parcels that are inherited from

This code was unused. The original idea was to allow circular
dependencies between parcels as long as they don't inherit classes
from each other. This is an unimportant feature that had to be solved
differently, now that we specify prereqs in .cfp files.


Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/859f5b88
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/859f5b88
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/859f5b88

Branch: refs/heads/master
Commit: 859f5b88cde34e65e563d8a5d7b48a5586230eaa
Parents: a3231bc
Author: Nick Wellnhofer <wellnho...@aevum.de>
Authored: Tue Feb 28 14:49:02 2017 +0100
Committer: Nick Wellnhofer <wellnho...@aevum.de>
Committed: Thu Mar 2 20:08:05 2017 +0100

----------------------------------------------------------------------
 compiler/perl/lib/Clownfish/CFC.xs | 14 ------------
 compiler/perl/t/403-parcel.t       |  6 +----
 compiler/src/CFCClass.c            |  5 -----
 compiler/src/CFCParcel.c           | 39 ---------------------------------
 compiler/src/CFCParcel.h           | 12 ----------
 compiler/src/CFCTestParcel.c       | 12 +---------
 6 files changed, 2 insertions(+), 86 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/859f5b88/compiler/perl/lib/Clownfish/CFC.xs
----------------------------------------------------------------------
diff --git a/compiler/perl/lib/Clownfish/CFC.xs 
b/compiler/perl/lib/Clownfish/CFC.xs
index b0205d9..d46a1a0 100644
--- a/compiler/perl/lib/Clownfish/CFC.xs
+++ b/compiler/perl/lib/Clownfish/CFC.xs
@@ -1097,13 +1097,6 @@ CODE:
     RETVAL = S_array_of_cfcbase_to_av((CFCBase**)all_parcels);
 OUTPUT: RETVAL
 
-void
-add_inherited_parcel(self, inherited)
-    CFCParcel *self;
-    CFCParcel *inherited;
-PPCODE:
-    CFCParcel_add_inherited_parcel(self, inherited);
-
 int
 has_prereq(self, parcel)
     CFCParcel *self;
@@ -1162,7 +1155,6 @@ ALIAS:
     get_prereqs       = 14
     included          = 16
     prereq_parcels    = 20
-    inherited_parcels = 22
     get_xs_module     = 24
     get_classes       = 26
 PPCODE:
@@ -1212,12 +1204,6 @@ PPCODE:
                 FREEMEM(parcels);
             }
             break;
-        case 22: {
-                CFCParcel **parcels = CFCParcel_inherited_parcels(self);
-                retval = S_array_of_cfcbase_to_av((CFCBase**)parcels);
-                FREEMEM(parcels);
-            }
-            break;
         case 24: {
                 const char *xs_module = CFCParcel_get_host_module_name(self);
                 retval = newSVpvn(xs_module, strlen(xs_module));

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/859f5b88/compiler/perl/t/403-parcel.t
----------------------------------------------------------------------
diff --git a/compiler/perl/t/403-parcel.t b/compiler/perl/t/403-parcel.t
index 47023de..9892e4b 100644
--- a/compiler/perl/t/403-parcel.t
+++ b/compiler/perl/t/403-parcel.t
@@ -18,7 +18,7 @@ use warnings;
 use lib 'buildlib';
 
 use Clownfish::CFC::Test::TestUtils qw( test_files_dir );
-use Test::More tests => 32;
+use Test::More tests => 31;
 use File::Spec::Functions qw( catdir );
 
 BEGIN { use_ok('Clownfish::CFC::Model::Prereq') }
@@ -71,10 +71,6 @@ my $parcels = Clownfish::CFC::Model::Parcel->all_parcels;
 my @names = sort(map { $_->get_name } @$parcels);
 is_deeply( \@names, [ "Foo", "IncludedFoo" ], "all_parcels" );
 
-$foo->add_inherited_parcel($included_foo);
-my @inh_names = sort(map { $_->get_name } @{ $foo->inherited_parcels });
-is_deeply( \@inh_names, [ "IncludedFoo" ], "inherited_parcels" );
-
 my $json = qq|
         {
             "name": "Crustacean",

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/859f5b88/compiler/src/CFCClass.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCClass.c b/compiler/src/CFCClass.c
index 0a16a6b..ff4b05c 100644
--- a/compiler/src/CFCClass.c
+++ b/compiler/src/CFCClass.c
@@ -363,11 +363,6 @@ CFCClass_add_child(CFCClass *self, CFCClass *child) {
 
     // Set parent of child.
     CFCWeakPtr_set(&child->parent, (CFCBase*)self);
-
-    // Add parcel dependency.
-    CFCParcel *parcel       = CFCClass_get_parcel(self);
-    CFCParcel *child_parcel = CFCClass_get_parcel(child);
-    CFCParcel_add_inherited_parcel(child_parcel, parcel);
 }
 
 void

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/859f5b88/compiler/src/CFCParcel.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCParcel.c b/compiler/src/CFCParcel.c
index 07c5ce6..0a24478 100644
--- a/compiler/src/CFCParcel.c
+++ b/compiler/src/CFCParcel.c
@@ -44,8 +44,6 @@ struct CFCParcel {
     char *PREFIX;
     char *privacy_sym;
     int is_installed;
-    char **inherited_parcels;
-    size_t num_inherited_parcels;
     CFCClass **classes;
     size_t num_classes;
     CFCPrereq **prereqs;
@@ -215,8 +213,6 @@ CFCParcel_init(CFCParcel *self, const char *name, const 
char *nickname,
     self->is_installed = false;
 
     // Initialize arrays.
-    self->inherited_parcels = (char**)CALLOCATE(1, sizeof(char*));
-    self->num_inherited_parcels = 0;
     self->classes = (CFCClass**)CALLOCATE(1, sizeof(CFCClass*));
     self->num_classes = 0;
     self->prereqs = (CFCPrereq**)CALLOCATE(1, sizeof(CFCPrereq*));
@@ -372,7 +368,6 @@ CFCParcel_destroy(CFCParcel *self) {
     FREEMEM(self->Prefix);
     FREEMEM(self->PREFIX);
     FREEMEM(self->privacy_sym);
-    CFCUtil_free_string_array(self->inherited_parcels);
     for (size_t i = 0; self->classes[i]; ++i) {
         CFCBase_decref((CFCBase*)self->classes[i]);
     }
@@ -484,40 +479,6 @@ CFCParcel_included(CFCParcel *self) {
     return self->file_spec ? CFCFileSpec_included(self->file_spec) : false;
 }
 
-void
-CFCParcel_add_inherited_parcel(CFCParcel *self, CFCParcel *inherited) {
-    const char *name     = CFCParcel_get_name(self);
-    const char *inh_name = CFCParcel_get_name(inherited);
-
-    if (strcmp(name, inh_name) == 0) { return; }
-
-    for (size_t i = 0; self->inherited_parcels[i]; ++i) {
-        const char *other_name = self->inherited_parcels[i];
-        if (strcmp(other_name, inh_name) == 0) { return; }
-    }
-
-    size_t num_parcels = self->num_inherited_parcels;
-    self->inherited_parcels
-        = (char**)REALLOCATE(self->inherited_parcels,
-                             (num_parcels + 2) * sizeof(char*));
-    self->inherited_parcels[num_parcels]   = CFCUtil_strdup(inh_name);
-    self->inherited_parcels[num_parcels+1] = NULL;
-    self->num_inherited_parcels = num_parcels + 1;
-}
-
-CFCParcel**
-CFCParcel_inherited_parcels(CFCParcel *self) {
-    CFCParcel **parcels
-        = (CFCParcel**)CALLOCATE(self->num_inherited_parcels + 1,
-                                 sizeof(CFCParcel*));
-
-    for (size_t i = 0; self->inherited_parcels[i]; ++i) {
-        parcels[i] = CFCParcel_fetch(self->inherited_parcels[i]);
-    }
-
-    return parcels;
-}
-
 CFCPrereq**
 CFCParcel_get_prereqs(CFCParcel *self) {
     return self->prereqs;

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/859f5b88/compiler/src/CFCParcel.h
----------------------------------------------------------------------
diff --git a/compiler/src/CFCParcel.h b/compiler/src/CFCParcel.h
index deaee9f..baf0eb3 100644
--- a/compiler/src/CFCParcel.h
+++ b/compiler/src/CFCParcel.h
@@ -146,18 +146,6 @@ CFCParcel_get_source_dir(CFCParcel *self);
 int
 CFCParcel_included(CFCParcel *self);
 
-/** Add another Parcel containing superclasses that subclasses in the Parcel
- * extend.
- */
-void
-CFCParcel_add_inherited_parcel(CFCParcel *self, CFCParcel *inherited);
-
-/** Return a NULL-terminated array of all Parcels containing superclasses that
- * subclasses in the Parcel extend. Must be freed by the caller.
- */
-CFCParcel**
-CFCParcel_inherited_parcels(CFCParcel *self);
-
 /** Return a NULL-terminated array of all prerequisites.
  */
 CFCPrereq**

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/859f5b88/compiler/src/CFCTestParcel.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCTestParcel.c b/compiler/src/CFCTestParcel.c
index 7ee28ac..5bf6253 100644
--- a/compiler/src/CFCTestParcel.c
+++ b/compiler/src/CFCTestParcel.c
@@ -47,7 +47,7 @@ S_run_extended_tests(CFCTest *test);
 
 const CFCTestBatch CFCTEST_BATCH_PARCEL = {
     "Clownfish::CFC::Model::Parcel",
-    41,
+    39,
     S_run_tests
 };
 
@@ -153,16 +153,6 @@ S_run_basic_tests(CFCTest *test) {
                "all_parcels returns parcel IncludedFoo");
     }
 
-    {
-        CFCParcel_add_inherited_parcel(foo, included_foo);
-        CFCParcel **inh_parcels = CFCParcel_inherited_parcels(foo);
-        OK(test, inh_parcels[0] && !inh_parcels[1],
-           "inherited_parcels returns one parcel");
-        STR_EQ(test, CFCParcel_get_name(inh_parcels[0]), "IncludedFoo",
-               "inh_parcels returns parcel IncludedFoo");
-        FREEMEM(inh_parcels);
-    }
-
     CFCBase_decref((CFCBase*)included_foo);
     CFCBase_decref((CFCBase*)file_spec);
     CFCBase_decref((CFCBase*)foo);

Reply via email to