You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2013/06/15 23:42:34 UTC

[lucy-commits] [11/14] git commit: refs/heads/master - Generate headers for included parcels

Generate headers for included parcels

The C headers of included parcels must be generated, too.

TODO: Skip parcels the source parcels don't depend on.


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

Branch: refs/heads/master
Commit: 1f57e4ab41fe69bdea9a3e0dab0a8264f171c1a6
Parents: 90d4d4f
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Thu Jun 6 21:55:15 2013 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat Jun 15 23:34:20 2013 +0200

----------------------------------------------------------------------
 clownfish/compiler/perl/lib/Clownfish/CFC.xs |  8 ++++----
 clownfish/compiler/perl/t/403-parcel.t       |  8 ++++----
 clownfish/compiler/src/CFCBindCore.c         |  7 +++++--
 clownfish/compiler/src/CFCParcel.c           |  6 +++---
 clownfish/compiler/src/CFCParcel.h           |  6 +++---
 clownfish/compiler/src/CFCPerl.c             | 10 ++++++----
 6 files changed, 25 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/1f57e4ab/clownfish/compiler/perl/lib/Clownfish/CFC.xs
----------------------------------------------------------------------
diff --git a/clownfish/compiler/perl/lib/Clownfish/CFC.xs b/clownfish/compiler/perl/lib/Clownfish/CFC.xs
index bddcce9..01aaf3e 100644
--- a/clownfish/compiler/perl/lib/Clownfish/CFC.xs
+++ b/clownfish/compiler/perl/lib/Clownfish/CFC.xs
@@ -1166,12 +1166,12 @@ CODE:
 OUTPUT: RETVAL
 
 SV*
-source_parcels(...)
+all_parcels(...)
 CODE:
     CHY_UNUSED_VAR(items);
-    CFCParcel **source_parcels = CFCParcel_source_parcels();
-    RETVAL = S_array_of_cfcbase_to_av((CFCBase**)source_parcels);
-    FREEMEM(source_parcels);
+    CFCParcel **all_parcels = CFCParcel_all_parcels();
+    RETVAL = S_array_of_cfcbase_to_av((CFCBase**)all_parcels);
+    FREEMEM(all_parcels);
 OUTPUT: RETVAL
 
 void

http://git-wip-us.apache.org/repos/asf/lucy/blob/1f57e4ab/clownfish/compiler/perl/t/403-parcel.t
----------------------------------------------------------------------
diff --git a/clownfish/compiler/perl/t/403-parcel.t b/clownfish/compiler/perl/t/403-parcel.t
index f78e81d..462f7c3 100644
--- a/clownfish/compiler/perl/t/403-parcel.t
+++ b/clownfish/compiler/perl/t/403-parcel.t
@@ -16,7 +16,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 17;
+use Test::More tests => 16;
 use File::Spec::Functions qw( catfile );
 
 BEGIN { use_ok('Clownfish::CFC::Model::Parcel') }
@@ -33,9 +33,9 @@ my $included_foo = Clownfish::CFC::Model::Parcel->new(
 ok( $included_foo->included, "included" );
 $included_foo->register;
 
-my $source_parcels = Clownfish::CFC::Model::Parcel->source_parcels;
-is( @$source_parcels, 1, "number of source parcels" );
-is( $source_parcels->[0]->get_name, "Foo", "name of source parcel" );
+my $parcels = Clownfish::CFC::Model::Parcel->all_parcels;
+my @names = sort(map { $_->get_name } @$parcels);
+is_deeply( \@names, [ "Foo", "IncludedFoo" ], "all_parcels" );
 
 my $dependent_foo = Clownfish::CFC::Model::Parcel->new(
     name        => "DependentFoo",

http://git-wip-us.apache.org/repos/asf/lucy/blob/1f57e4ab/clownfish/compiler/src/CFCBindCore.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCBindCore.c b/clownfish/compiler/src/CFCBindCore.c
index c1f200e..91721a2 100644
--- a/clownfish/compiler/src/CFCBindCore.c
+++ b/clownfish/compiler/src/CFCBindCore.c
@@ -115,11 +115,14 @@ CFCBindCore_write_all_modified(CFCBindCore *self, int modified) {
     // If any class definition has changed, rewrite the parcel.h and parcel.c
     // files.
     if (modified) {
-        CFCParcel **parcels = CFCParcel_source_parcels();
+        CFCParcel **parcels = CFCParcel_all_parcels();
         for (size_t i = 0; parcels[i]; ++i) {
             CFCParcel *parcel = parcels[i];
+            // TODO: Skip parcels the source parcels don't depend on.
             S_write_parcel_h(self, parcel);
-            S_write_parcel_c(self, parcel);
+            if (!CFCParcel_included(parcel)) {
+                S_write_parcel_c(self, parcel);
+            }
         }
         FREEMEM(parcels);
     }

http://git-wip-us.apache.org/repos/asf/lucy/blob/1f57e4ab/clownfish/compiler/src/CFCParcel.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCParcel.c b/clownfish/compiler/src/CFCParcel.c
index fe4f27a..6e72f2e 100644
--- a/clownfish/compiler/src/CFCParcel.c
+++ b/clownfish/compiler/src/CFCParcel.c
@@ -112,7 +112,7 @@ CFCParcel_register(CFCParcel *self) {
 }
 
 CFCParcel**
-CFCParcel_source_parcels(void) {
+CFCParcel_all_parcels(void) {
     size_t size = (num_registered + 1) * sizeof(CFCParcel*);
     CFCParcel **parcels = (CFCParcel**)MALLOCATE(size);
     size_t n = 0;
@@ -121,8 +121,8 @@ CFCParcel_source_parcels(void) {
         CFCParcel  *parcel = registry[i];
         const char *prefix = CFCParcel_get_prefix(parcel);
 
-        // Skip default and included parcels.
-        if (*prefix && !CFCParcel_included(parcel)) {
+        // Skip default parcel.
+        if (*prefix) {
             parcels[n++] = parcel;
         }
     }

http://git-wip-us.apache.org/repos/asf/lucy/blob/1f57e4ab/clownfish/compiler/src/CFCParcel.h
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCParcel.h b/clownfish/compiler/src/CFCParcel.h
index d937297..d5cdb5f 100644
--- a/clownfish/compiler/src/CFCParcel.h
+++ b/clownfish/compiler/src/CFCParcel.h
@@ -50,11 +50,11 @@ CFCParcel_fetch(const char *name);
 void
 CFCParcel_register(CFCParcel *self);
 
-/** Return a NULL-terminated list of all registered parcels that are not
- * included. Must be freed by the caller.
+/** Return a NULL-terminated list of all registered parcels. Must be freed by
+ * the caller.
  */
 CFCParcel**
-CFCParcel_source_parcels(void);
+CFCParcel_all_parcels(void);
 
 /** Decref all singletons at shutdown.
  */

http://git-wip-us.apache.org/repos/asf/lucy/blob/1f57e4ab/clownfish/compiler/src/CFCPerl.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCPerl.c b/clownfish/compiler/src/CFCPerl.c
index 37f8b19..7c171cf 100644
--- a/clownfish/compiler/src/CFCPerl.c
+++ b/clownfish/compiler/src/CFCPerl.c
@@ -203,16 +203,18 @@ S_write_boot_h(CFCPerl *self) {
 static void
 S_write_boot_c(CFCPerl *self) {
     CFCClass  **ordered   = CFCHierarchy_ordered_classes(self->hierarchy);
-    CFCParcel **parcels   = CFCParcel_source_parcels();
+    CFCParcel **parcels   = CFCParcel_all_parcels();
     char *pound_includes  = CFCUtil_strdup("");
     char *bootstrap_code  = CFCUtil_strdup("");
     char *alias_adds      = CFCUtil_strdup("");
     char *isa_pushes      = CFCUtil_strdup("");
 
     for (size_t i = 0; parcels[i]; ++i) {
-        const char *prefix = CFCParcel_get_prefix(parcels[i]);
-        bootstrap_code = CFCUtil_cat(bootstrap_code, "    ", prefix,
-                                     "bootstrap_parcel();\n", NULL);
+        if (!CFCParcel_included(parcels[i])) {
+            const char *prefix = CFCParcel_get_prefix(parcels[i]);
+            bootstrap_code = CFCUtil_cat(bootstrap_code, "    ", prefix,
+                                         "bootstrap_parcel();\n", NULL);
+        }
     }
 
     for (size_t i = 0; ordered[i] != NULL; i++) {