Remove CFCHierarchy_ordered_classes

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

Branch: refs/heads/master
Commit: 8971263683dfdf730873ebec50235db5bb895995
Parents: e82ee76
Author: Nick Wellnhofer <wellnho...@aevum.de>
Authored: Mon Feb 27 01:23:14 2017 +0100
Committer: Nick Wellnhofer <wellnho...@aevum.de>
Committed: Thu Mar 2 20:08:03 2017 +0100

----------------------------------------------------------------------
 compiler/perl/lib/Clownfish/CFC.xs | 14 --------------
 compiler/perl/t/401-class.t        |  5 +----
 compiler/src/CFCClass.c            | 29 -----------------------------
 compiler/src/CFCClass.h            |  6 ------
 compiler/src/CFCHierarchy.c        | 23 -----------------------
 compiler/src/CFCHierarchy.h        |  6 ------
 compiler/src/CFCTestClass.c        | 11 +----------
 7 files changed, 2 insertions(+), 92 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/89712636/compiler/perl/lib/Clownfish/CFC.xs
----------------------------------------------------------------------
diff --git a/compiler/perl/lib/Clownfish/CFC.xs 
b/compiler/perl/lib/Clownfish/CFC.xs
index d174ecd..1153bfd 100644
--- a/compiler/perl/lib/Clownfish/CFC.xs
+++ b/compiler/perl/lib/Clownfish/CFC.xs
@@ -297,7 +297,6 @@ ALIAS:
     methods               = 36
     member_vars           = 38
     inert_vars            = 40
-    tree_to_ladder        = 42
     fresh_methods         = 44
     fresh_member_vars     = 46
     privacy_symbol        = 48
@@ -398,12 +397,6 @@ PPCODE:
         case 40:
             retval = 
S_array_of_cfcbase_to_av((CFCBase**)CFCClass_inert_vars(self));
             break;
-        case 42: {
-                CFCClass **ladder = CFCClass_tree_to_ladder(self);
-                retval = S_array_of_cfcbase_to_av((CFCBase**)ladder);
-                FREEMEM(ladder);
-                break;
-            }
         case 44: {
                 CFCMethod **fresh = CFCClass_fresh_methods(self);
                 retval = S_array_of_cfcbase_to_av((CFCBase**)fresh);
@@ -792,7 +785,6 @@ ALIAS:
     get_include_dest  = 4
     get_source_dest   = 6
     files             = 8
-    ordered_classes   = 10
     get_source_dirs   = 12
     get_include_dirs  = 14
 PPCODE:
@@ -817,12 +809,6 @@ PPCODE:
             retval = S_array_of_cfcbase_to_av(
                 (CFCBase**)CFCHierarchy_files(self));
             break;
-        case 10: {
-                CFCClass **ladder = CFCHierarchy_ordered_classes(self);
-                retval = S_array_of_cfcbase_to_av((CFCBase**)ladder);
-                FREEMEM(ladder);
-            }
-            break;
         case 12: {
                 const char **source_dirs = CFCHierarchy_get_source_dirs(self);
                 retval = S_string_array_to_av(source_dirs);

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/89712636/compiler/perl/t/401-class.t
----------------------------------------------------------------------
diff --git a/compiler/perl/t/401-class.t b/compiler/perl/t/401-class.t
index b7e4af8..c51cd33 100644
--- a/compiler/perl/t/401-class.t
+++ b/compiler/perl/t/401-class.t
@@ -16,7 +16,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 54;
+use Test::More tests => 53;
 use Clownfish::CFC::Model::Class;
 use Clownfish::CFC::Parser;
 
@@ -150,9 +150,6 @@ is_deeply( $foo_jr->fresh_member_vars, [], 
"fresh_member_vars" );
 is_deeply( $foo_jr->inert_vars,        [], "don't inherit inert vars" );
 is_deeply( $final_foo->fresh_methods,  [], "fresh_methods" );
 
-is_deeply( $foo->tree_to_ladder, [ $foo, $foo_jr, $final_foo ],
-    'tree_to_ladder' );
-
 ok( $parser->parse("$_ class Iam$_ { }")->$_, "class_modifier: $_" )
     for (qw( final inert ));
 

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/89712636/compiler/src/CFCClass.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCClass.c b/compiler/src/CFCClass.c
index 685582e..cdfe096 100644
--- a/compiler/src/CFCClass.c
+++ b/compiler/src/CFCClass.c
@@ -655,15 +655,6 @@ S_establish_ancestry(CFCClass *self) {
     }
 }
 
-static size_t
-S_family_tree_size(CFCClass *self) {
-    size_t count = 1; // self
-    for (size_t i = 0; i < self->num_kids; i++) {
-        count += S_family_tree_size(self->children[i]);
-    }
-    return count;
-}
-
 static CFCBase**
 S_copy_cfcbase_array(CFCBase **array, size_t num_elems) {
     CFCBase **copy = (CFCBase**)MALLOCATE((num_elems + 1) * sizeof(CFCBase*));
@@ -700,26 +691,6 @@ CFCClass_grow_tree(CFCClass *self) {
     self->tree_grown = 1;
 }
 
-// Return value is valid only so long as object persists (elements are not
-// refcounted).
-CFCClass**
-CFCClass_tree_to_ladder(CFCClass *self) {
-    size_t ladder_len = S_family_tree_size(self);
-    CFCClass **ladder = (CFCClass**)MALLOCATE((ladder_len + 1) * 
sizeof(CFCClass*));
-    ladder[ladder_len] = NULL;
-    size_t step = 0;
-    ladder[step++] = self;
-    for (size_t i = 0; i < self->num_kids; i++) {
-        CFCClass *child = self->children[i];
-        CFCClass **child_ladder = CFCClass_tree_to_ladder(child);
-        for (size_t j = 0; child_ladder[j] != NULL; j++) {
-            ladder[step++] = child_ladder[j];
-        }
-        FREEMEM(child_ladder);
-    }
-    return ladder;
-}
-
 void
 CFCClass_read_host_data_json(CFCClass *self, CFCJson *hash, const char *path) {
     CFCJson *method_hash = CFCJson_find_hash_elem(hash, "methods");

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/89712636/compiler/src/CFCClass.h
----------------------------------------------------------------------
diff --git a/compiler/src/CFCClass.h b/compiler/src/CFCClass.h
index fe8b40b..072b71c 100644
--- a/compiler/src/CFCClass.h
+++ b/compiler/src/CFCClass.h
@@ -162,12 +162,6 @@ CFCClass_resolve_types(CFCClass *self);
 void
 CFCClass_grow_tree(CFCClass *self);
 
-/** Return this class and all its child classes as an array, where all
- * children appear after their parent nodes.
- */
-CFCClass**
-CFCClass_tree_to_ladder(CFCClass *self);
-
 /** Read host-specific data for the class from a JSON hash.
  */
 void

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/89712636/compiler/src/CFCHierarchy.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCHierarchy.c b/compiler/src/CFCHierarchy.c
index 86ad2cc..0bc1b5f 100644
--- a/compiler/src/CFCHierarchy.c
+++ b/compiler/src/CFCHierarchy.c
@@ -644,29 +644,6 @@ S_add_tree(CFCHierarchy *self, CFCClass *klass) {
     self->trees[self->num_trees] = NULL;
 }
 
-CFCClass**
-CFCHierarchy_ordered_classes(CFCHierarchy *self) {
-    size_t num_classes = 0;
-    size_t max_classes = 10;
-    CFCClass **ladder = (CFCClass**)MALLOCATE(
-                            (max_classes + 1) * sizeof(CFCClass*));
-    for (size_t i = 0; self->trees[i] != NULL; i++) {
-        CFCClass *tree = self->trees[i];
-        CFCClass **child_ladder = CFCClass_tree_to_ladder(tree);
-        for (size_t j = 0; child_ladder[j] != NULL; j++) {
-            if (num_classes == max_classes) {
-                max_classes += 10;
-                ladder = (CFCClass**)REALLOCATE(
-                             ladder, (max_classes + 1) * sizeof(CFCClass*));
-            }
-            ladder[num_classes++] = child_ladder[j];
-        }
-        FREEMEM(child_ladder);
-    }
-    ladder[num_classes] = NULL;
-    return ladder;
-}
-
 void
 CFCHierarchy_write_log(CFCHierarchy *self) {
     // For now, we only write an empty file that can be used as a Makefile

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/89712636/compiler/src/CFCHierarchy.h
----------------------------------------------------------------------
diff --git a/compiler/src/CFCHierarchy.h b/compiler/src/CFCHierarchy.h
index 4177cc4..2694af3 100644
--- a/compiler/src/CFCHierarchy.h
+++ b/compiler/src/CFCHierarchy.h
@@ -89,12 +89,6 @@ CFCHierarchy_propagate_modified(CFCHierarchy *self, int 
modified);
 void
 CFCHierarchy_write_log(CFCHierarchy *self);
 
-/** Return all Classes as an array with the property that every parent class
- * will precede all of its children.
- */
-struct CFCClass**
-CFCHierarchy_ordered_classes(CFCHierarchy *self);
-
 struct CFCFile**
 CFCHierarchy_files(CFCHierarchy *self);
 

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/89712636/compiler/src/CFCTestClass.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCTestClass.c b/compiler/src/CFCTestClass.c
index 009bdfb..499e0cb 100644
--- a/compiler/src/CFCTestClass.c
+++ b/compiler/src/CFCTestClass.c
@@ -44,7 +44,7 @@ S_has_symbol(CFCSymbol **symbols, const char *name);
 
 const CFCTestBatch CFCTEST_BATCH_CLASS = {
     "Clownfish::CFC::Model::Class",
-    97,
+    93,
     S_run_tests
 };
 
@@ -311,15 +311,6 @@ S_run_tests(CFCTest *test) {
     }
 
     {
-        CFCClass **ladder = CFCClass_tree_to_ladder(foo);
-        OK(test, ladder[0] == foo, "ladder[0]");
-        OK(test, ladder[1] == foo_jr, "ladder[1]");
-        OK(test, ladder[2] == final_foo, "ladder[2]");
-        OK(test, ladder[3] == NULL, "ladder[3]");
-        FREEMEM(ladder);
-    }
-
-    {
         CFCClass *final_class
             = CFCTest_parse_class(test, parser, "final class Iamfinal { }");
         OK(test, CFCClass_final(final_class), "class modifer: final");

Reply via email to