lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nwelln...@apache.org
Subject [lucy-commits] [2/3] git commit: refs/heads/master - Inherit from Clownfish::Obj by default
Date Sat, 06 Jul 2013 14:32:44 GMT
Inherit from Clownfish::Obj by default


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

Branch: refs/heads/master
Commit: 2b523ca72d3baf21e2db32ac3771ad062bba0735
Parents: d339697
Author: Nick Wellnhofer <wellnhofer@aevum.de>
Authored: Tue Jul 2 19:43:54 2013 +0200
Committer: Nick Wellnhofer <wellnhofer@aevum.de>
Committed: Sat Jul 6 13:01:50 2013 +0200

----------------------------------------------------------------------
 clownfish/compiler/c/t/cfbase/Animal.cfh    |  2 ++
 clownfish/compiler/perl/t/401-class.t       |  5 ++++-
 clownfish/compiler/perl/t/500-hierarchy.t   | 11 ++++++-----
 clownfish/compiler/perl/t/501-include_dir.t |  8 ++++----
 clownfish/compiler/perl/t/502-clash.t       |  4 +++-
 clownfish/compiler/perl/t/cfbase/Animal.cfh |  2 ++
 clownfish/compiler/src/CFCClass.c           |  6 ++++++
 clownfish/compiler/src/CFCTestHierarchy.c   |  9 +++++----
 clownfish/runtime/perl/lib/Clownfish.pod    |  4 ++--
 9 files changed, 34 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/2b523ca7/clownfish/compiler/c/t/cfbase/Animal.cfh
----------------------------------------------------------------------
diff --git a/clownfish/compiler/c/t/cfbase/Animal.cfh b/clownfish/compiler/c/t/cfbase/Animal.cfh
index a4d689a..46130b7 100644
--- a/clownfish/compiler/c/t/cfbase/Animal.cfh
+++ b/clownfish/compiler/c/t/cfbase/Animal.cfh
@@ -16,4 +16,6 @@
 
 parcel Animal;
 
+class Clownfish::Obj { }
+
 abstract class Animal { }

http://git-wip-us.apache.org/repos/asf/lucy/blob/2b523ca7/clownfish/compiler/perl/t/401-class.t
----------------------------------------------------------------------
diff --git a/clownfish/compiler/perl/t/401-class.t b/clownfish/compiler/perl/t/401-class.t
index b45f024..6cf51a2 100644
--- a/clownfish/compiler/perl/t/401-class.t
+++ b/clownfish/compiler/perl/t/401-class.t
@@ -16,7 +16,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 56;
+use Test::More tests => 57;
 use Clownfish::CFC::Model::Class;
 use Clownfish::CFC::Parser;
 
@@ -167,6 +167,9 @@ is( $parser->parse("class Fu::$_ inherits $_ { }")->get_parent_class_name,
     $_, "class_inheritance: $_" )
     for ( 'Fooble', 'Foo::FooJr::FooIII' );
 
+is( $parser->parse("class MissingInherits { }")->get_parent_class_name,
+    "Clownfish::Obj", "class inherits from Clownfish::Obj by default" );
+
 my $class_content
     = 'public class Foo::Foodie cnick Foodie inherits Foo { int num; }';
 my $class = $parser->parse($class_content);

http://git-wip-us.apache.org/repos/asf/lucy/blob/2b523ca7/clownfish/compiler/perl/t/500-hierarchy.t
----------------------------------------------------------------------
diff --git a/clownfish/compiler/perl/t/500-hierarchy.t b/clownfish/compiler/perl/t/500-hierarchy.t
index 4866731..6c2a10c 100644
--- a/clownfish/compiler/perl/t/500-hierarchy.t
+++ b/clownfish/compiler/perl/t/500-hierarchy.t
@@ -16,7 +16,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 20;
+use Test::More tests => 21;
 
 use Clownfish::CFC::Model::Hierarchy;
 use Clownfish::CFC::Util qw( a_isa_b );
@@ -59,9 +59,10 @@ my %files;
 for my $file (@files) {
     die "not a File" unless isa_ok( $file, "Clownfish::CFC::Model::File" );
     ok( !$file->get_modified, "start off not modified" );
-    my ($class)
-        = grep { a_isa_b( $_, "Clownfish::CFC::Model::Class" ) }
-        @{ $file->blocks };
+    my ($class) = grep {
+        a_isa_b( $_, "Clownfish::CFC::Model::Class" )
+        && $_->get_class_name ne 'Clownfish::Obj'
+    } @{ $file->blocks };
     die "no class" unless $class;
     $files{ $class->get_class_name } = $file;
 }
@@ -70,7 +71,7 @@ my $dog    = $files{'Animal::Dog'}  or die "No Dog";
 my $util   = $files{'Animal::Util'} or die "No Util";
 
 my $classes = $hierarchy->ordered_classes;
-is( scalar @$classes, 3, "all classes" );
+is( scalar @$classes, 4, "all classes" );
 for my $class (@$classes) {
     die "not a Class" unless isa_ok( $class, "Clownfish::CFC::Model::Class" );
 }

http://git-wip-us.apache.org/repos/asf/lucy/blob/2b523ca7/clownfish/compiler/perl/t/501-include_dir.t
----------------------------------------------------------------------
diff --git a/clownfish/compiler/perl/t/501-include_dir.t b/clownfish/compiler/perl/t/501-include_dir.t
index 00b735c..8f16f4a 100644
--- a/clownfish/compiler/perl/t/501-include_dir.t
+++ b/clownfish/compiler/perl/t/501-include_dir.t
@@ -16,7 +16,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 21;
+use Test::More tests => 24;
 
 use Clownfish::CFC::Model::Hierarchy;
 use File::Spec::Functions qw( catdir catfile splitpath );
@@ -41,7 +41,7 @@ my $dest_dir = catdir(qw( t cfdest ));
     $hierarchy->build;
 
     my $classes = $hierarchy->ordered_classes;
-    is( scalar @$classes, 4, "all classes" );
+    is( scalar @$classes, 5, "all classes" );
     my $num_included = 0;
     for my $class (@$classes) {
         die "not a Class"
@@ -63,7 +63,7 @@ my $dest_dir = catdir(qw( t cfdest ));
 
         is( $included, $expect, "included" );
     }
-    is( $num_included, 3, "included class count" );
+    is( $num_included, 4, "included class count" );
 
     Clownfish::CFC::Model::Class->_clear_registry();
     Clownfish::CFC::Model::Parcel->reap_singletons();
@@ -83,7 +83,7 @@ my $dest_dir = catdir(qw( t cfdest ));
     $hierarchy->build;
 
     my $classes = $hierarchy->ordered_classes;
-    is( scalar @$classes, 4, "all classes" );
+    is( scalar @$classes, 5, "all classes" );
     for my $class (@$classes) {
         die "not a Class" unless isa_ok( $class, "Clownfish::CFC::Model::Class" );
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/2b523ca7/clownfish/compiler/perl/t/502-clash.t
----------------------------------------------------------------------
diff --git a/clownfish/compiler/perl/t/502-clash.t b/clownfish/compiler/perl/t/502-clash.t
index 85df4d0..ae64da1 100644
--- a/clownfish/compiler/perl/t/502-clash.t
+++ b/clownfish/compiler/perl/t/502-clash.t
@@ -67,7 +67,7 @@ my $file_clash_dir  = catdir(qw( t cfclash file ));
     $hierarchy->build;
 
     my $classes = $hierarchy->ordered_classes;
-    is( scalar @$classes, 3, "source/include filename clash" );
+    is( scalar @$classes, 4, "source/include filename clash" );
 
     Clownfish::CFC::Model::Class->_clear_registry();
     Clownfish::CFC::Model::Parcel->reap_singletons();
@@ -83,6 +83,7 @@ my $bar_dir = catdir(qw( t cfclash bar ));
 
     $hierarchy->add_source_dir($foo_dir);
     $hierarchy->add_include_dir($bar_dir);
+    $hierarchy->add_include_dir($base_dir);
 
     eval { $hierarchy->build; };
 
@@ -98,6 +99,7 @@ my $bar_dir = catdir(qw( t cfclash bar ));
 
     $hierarchy->add_source_dir($bar_dir);
     $hierarchy->add_include_dir($foo_dir);
+    $hierarchy->add_include_dir($base_dir);
 
     eval { $hierarchy->build; };
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/2b523ca7/clownfish/compiler/perl/t/cfbase/Animal.cfh
----------------------------------------------------------------------
diff --git a/clownfish/compiler/perl/t/cfbase/Animal.cfh b/clownfish/compiler/perl/t/cfbase/Animal.cfh
index a4d689a..46130b7 100644
--- a/clownfish/compiler/perl/t/cfbase/Animal.cfh
+++ b/clownfish/compiler/perl/t/cfbase/Animal.cfh
@@ -16,4 +16,6 @@
 
 parcel Animal;
 
+class Clownfish::Obj { }
+
 abstract class Animal { }

http://git-wip-us.apache.org/repos/asf/lucy/blob/2b523ca7/clownfish/compiler/src/CFCClass.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCClass.c b/clownfish/compiler/src/CFCClass.c
index 7e6767b..9c90f68 100644
--- a/clownfish/compiler/src/CFCClass.c
+++ b/clownfish/compiler/src/CFCClass.c
@@ -134,6 +134,12 @@ CFCClass_do_create(CFCClass *self, struct CFCParcel *parcel,
     parcel    = parcel    ? parcel    : CFCParcel_default_parcel();
     CFCSymbol_init((CFCSymbol*)self, parcel, exposure, class_name, cnick,
                    micro_sym);
+    if (!is_inert
+        && !parent_class_name
+        && strcmp(class_name, "Clownfish::Obj") != 0
+       ) {
+        parent_class_name = "Clownfish::Obj";
+    }
     self->parent     = NULL;
     self->tree_grown = false;
     self->autocode   = (char*)CALLOCATE(1, sizeof(char));

http://git-wip-us.apache.org/repos/asf/lucy/blob/2b523ca7/clownfish/compiler/src/CFCTestHierarchy.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCTestHierarchy.c b/clownfish/compiler/src/CFCTestHierarchy.c
index c84c836..8941fe2 100644
--- a/clownfish/compiler/src/CFCTestHierarchy.c
+++ b/clownfish/compiler/src/CFCTestHierarchy.c
@@ -53,7 +53,7 @@ S_run_include_tests(CFCTest *test);
 
 const CFCTestBatch CFCTEST_BATCH_HIERARCHY = {
     "Clownfish::CFC::Model::Hierarchy",
-    36,
+    39,
     S_run_tests
 };
 
@@ -114,7 +114,8 @@ S_run_basic_tests(CFCTest *test) {
         OK(test, ordered_classes[0] != NULL, "ordered_classes[0]");
         OK(test, ordered_classes[1] != NULL, "ordered_classes[1]");
         OK(test, ordered_classes[2] != NULL, "ordered_classes[2]");
-        OK(test, ordered_classes[3] == NULL, "all classes");
+        OK(test, ordered_classes[3] != NULL, "ordered_classes[3]");
+        OK(test, ordered_classes[4] == NULL, "all classes");
         FREEMEM(ordered_classes);
     }
 
@@ -188,7 +189,7 @@ S_run_include_tests(CFCTest *test) {
             INT_EQ(test, CFCClass_included(klass), expect_included,
                    "included");
         }
-        INT_EQ(test, num_classes, 4, "class count");
+        INT_EQ(test, num_classes, 5, "class count");
         INT_EQ(test, num_source_classes, 1, "source class count");
         STR_EQ(test, CFCClass_get_class_name(CFCClass_get_parent(rottweiler)),
                "Animal::Dog", "parent of included class");
@@ -217,7 +218,7 @@ S_run_include_tests(CFCTest *test) {
             }
             OK(test, !CFCClass_included(klass), "not included");
         }
-        INT_EQ(test, num_classes, 4, "class count");
+        INT_EQ(test, num_classes, 5, "class count");
         OK(test, rottweiler != NULL, "found rottweiler");
         STR_EQ(test, CFCClass_get_class_name(CFCClass_get_parent(rottweiler)),
                "Animal::Dog", "parent of class from second source");

http://git-wip-us.apache.org/repos/asf/lucy/blob/2b523ca7/clownfish/runtime/perl/lib/Clownfish.pod
----------------------------------------------------------------------
diff --git a/clownfish/runtime/perl/lib/Clownfish.pod b/clownfish/runtime/perl/lib/Clownfish.pod
index d7d9874..49031c7 100644
--- a/clownfish/runtime/perl/lib/Clownfish.pod
+++ b/clownfish/runtime/perl/lib/Clownfish.pod
@@ -231,8 +231,8 @@ outside of the parcel and must not contain public variables or functions.
 
 Inert classes must contain only inert variables or inert methods, that is,
 neither instance variables nor methods. They must not inherit from another
-class or be inherited from. All other classes (except Clownfish::Obj) must
-inherit from Clownfish::Obj or another class.
+class or be inherited from. Non-inert classes inherit from Clownfish::Obj by
+default.
 
 =head3 Final classes
 


Mime
View raw message