lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nwelln...@apache.org
Subject [lucy-commits] [4/6] git commit: Eliminate default parcel
Date Tue, 18 Mar 2014 16:38:01 GMT
Eliminate default parcel


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

Branch: refs/heads/single-parcel-per-file
Commit: 5ec0912d2ff2d4ad826dccdc44e282cf59d55663
Parents: 221f5c4
Author: Nick Wellnhofer <wellnhofer@aevum.de>
Authored: Tue Mar 18 15:17:15 2014 +0100
Committer: Nick Wellnhofer <wellnhofer@aevum.de>
Committed: Tue Mar 18 16:57:41 2014 +0100

----------------------------------------------------------------------
 compiler/perl/lib/Clownfish/CFC.pm |  6 ++---
 compiler/perl/lib/Clownfish/CFC.xs |  9 -------
 compiler/perl/t/403-parcel.t       | 10 +-------
 compiler/src/CFCBindCore.c         |  1 -
 compiler/src/CFCHierarchy.c        |  2 --
 compiler/src/CFCParcel.c           | 43 +--------------------------------
 compiler/src/CFCParcel.h           |  8 +-----
 compiler/src/CFCPerl.c             |  1 -
 compiler/src/CFCTestParcel.c       | 14 +----------
 9 files changed, 7 insertions(+), 87 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/5ec0912d/compiler/perl/lib/Clownfish/CFC.pm
----------------------------------------------------------------------
diff --git a/compiler/perl/lib/Clownfish/CFC.pm b/compiler/perl/lib/Clownfish/CFC.pm
index d60ef1e..2f8c200 100644
--- a/compiler/perl/lib/Clownfish/CFC.pm
+++ b/compiler/perl/lib/Clownfish/CFC.pm
@@ -358,12 +358,12 @@ BEGIN { XSLoader::load( 'Clownfish::CFC', '0.01' ) }
 #    $parcel = Clownfish::CFC::Model::Parcel->acquire($parcel_name_or_parcel_object);
 #
 # Aquire a parcel one way or another.  If the supplied argument is a
-# Parcel, return it.  If it's not defined, return the default Parcel.  If
-# it's a name, fetch an existing Parcel or register a new one.
+# Parcel, return it.  If it's a name, fetch an existing Parcel or register
+# a new one.
     sub acquire {
         my ( undef, $thing ) = @_;
         if ( !defined $thing ) {
-            return Clownfish::CFC::Model::Parcel->default_parcel;
+            confess("Missing required param 'parcel'");
         }
         elsif ( blessed($thing) ) {
             confess("Not a Clownfish::CFC::Model::Parcel")

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/5ec0912d/compiler/perl/lib/Clownfish/CFC.xs
----------------------------------------------------------------------
diff --git a/compiler/perl/lib/Clownfish/CFC.xs b/compiler/perl/lib/Clownfish/CFC.xs
index dfc33af..2725f79 100644
--- a/compiler/perl/lib/Clownfish/CFC.xs
+++ b/compiler/perl/lib/Clownfish/CFC.xs
@@ -1118,20 +1118,11 @@ CODE:
 OUTPUT: RETVAL
 
 SV*
-default_parcel(...)
-CODE:
-    CHY_UNUSED_VAR(items);
-    CFCParcel *default_parcel = CFCParcel_default_parcel();
-    RETVAL = S_cfcbase_to_perlref(default_parcel);
-OUTPUT: RETVAL
-
-SV*
 all_parcels(...)
 CODE:
     CHY_UNUSED_VAR(items);
     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-clownfish/blob/5ec0912d/compiler/perl/t/403-parcel.t
----------------------------------------------------------------------
diff --git a/compiler/perl/t/403-parcel.t b/compiler/perl/t/403-parcel.t
index de93c21..4b8f973 100644
--- a/compiler/perl/t/403-parcel.t
+++ b/compiler/perl/t/403-parcel.t
@@ -16,7 +16,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 41;
+use Test::More tests => 38;
 use File::Spec::Functions qw( catfile );
 
 BEGIN { use_ok('Clownfish::CFC::Model::Prereq') }
@@ -98,14 +98,6 @@ is( $parcel->get_version->get_vstring, 'v0', "get_version" );
 
 my $thing = Clownfish::CFC::Model::Symbol->new(
     micro_sym => 'sym',
-    exposure  => 'parcel',
-);
-is( $thing->get_prefix, '', 'get_prefix with no parcel' );
-is( $thing->get_Prefix, '', 'get_Prefix with no parcel' );
-is( $thing->get_PREFIX, '', 'get_PREFIx with no parcel' );
-
-$thing = Clownfish::CFC::Model::Symbol->new(
-    micro_sym => 'sym',
     parcel    => 'Crustacean',
     exposure  => 'parcel'
 );

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/5ec0912d/compiler/src/CFCBindCore.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCBindCore.c b/compiler/src/CFCBindCore.c
index e8d49e6..754e558 100644
--- a/compiler/src/CFCBindCore.c
+++ b/compiler/src/CFCBindCore.c
@@ -138,7 +138,6 @@ CFCBindCore_write_all_modified(CFCBindCore *self, int modified) {
                 S_write_parcel_c(self, parcel);
             }
         }
-        FREEMEM(parcels);
     }
 
     return modified;

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/5ec0912d/compiler/src/CFCHierarchy.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCHierarchy.c b/compiler/src/CFCHierarchy.c
index f7e9520..116e172 100644
--- a/compiler/src/CFCHierarchy.c
+++ b/compiler/src/CFCHierarchy.c
@@ -270,8 +270,6 @@ S_check_prereqs() {
             CFCParcel_check_prereqs(parcel);
         }
     }
-
-    FREEMEM(parcels);
 }
 
 static void

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/5ec0912d/compiler/src/CFCParcel.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCParcel.c b/compiler/src/CFCParcel.c
index 84b95a8..3050613 100644
--- a/compiler/src/CFCParcel.c
+++ b/compiler/src/CFCParcel.c
@@ -48,8 +48,6 @@ struct CFCParcel {
     size_t num_prereqs;
 };
 
-static CFCParcel *default_parcel = NULL;
-
 #define JSON_STRING 1
 #define JSON_HASH   2
 #define JSON_NULL   3
@@ -87,11 +85,6 @@ static size_t num_registered = 0;
 
 CFCParcel*
 CFCParcel_fetch(const char *name) {
-    // Return the default parcel for either a blank name or a NULL name.
-    if (!name || !strlen(name)) {
-        return CFCParcel_default_parcel();
-    }
-
     for (size_t i = 0; i < num_registered ; i++) {
         CFCParcel *existing = registry[i];
         if (strcmp(existing->name, name) == 0) {
@@ -118,14 +111,6 @@ CFCParcel_register(CFCParcel *self) {
         }
     }
 
-    if (!num_registered) {
-        // Init default parcel as first.
-        registry = (CFCParcel**)CALLOCATE(3, sizeof(CFCParcel*));
-        CFCParcel *def = CFCParcel_default_parcel();
-        registry[0] = (CFCParcel*)CFCBase_incref((CFCBase*)def);
-        num_registered++;
-    }
-
     size_t size = (num_registered + 2) * sizeof(CFCParcel*);
     registry = (CFCParcel**)REALLOCATE(registry, size);
     registry[num_registered++] = (CFCParcel*)CFCBase_incref((CFCBase*)self);
@@ -134,23 +119,7 @@ CFCParcel_register(CFCParcel *self) {
 
 CFCParcel**
 CFCParcel_all_parcels(void) {
-    size_t size = (num_registered + 1) * sizeof(CFCParcel*);
-    CFCParcel **parcels = (CFCParcel**)MALLOCATE(size);
-    size_t n = 0;
-
-    for (size_t i = 0; registry[i]; ++i) {
-        CFCParcel  *parcel = registry[i];
-        const char *prefix = CFCParcel_get_prefix(parcel);
-
-        // Skip default parcel.
-        if (*prefix) {
-            parcels[n++] = parcel;
-        }
-    }
-
-    parcels[n] = NULL;
-
-    return parcels;
+    return registry;
 }
 
 void
@@ -161,8 +130,6 @@ CFCParcel_reap_singletons(void) {
     FREEMEM(registry);
     num_registered = 0;
     registry = NULL;
-    CFCBase_decref((CFCBase*)default_parcel);
-    default_parcel = NULL;
 }
 
 static int
@@ -402,14 +369,6 @@ CFCParcel_destroy(CFCParcel *self) {
     CFCBase_destroy((CFCBase*)self);
 }
 
-CFCParcel*
-CFCParcel_default_parcel(void) {
-    if (default_parcel == NULL) {
-        default_parcel = CFCParcel_new("", "", NULL, false);
-    }
-    return default_parcel;
-}
-
 int
 CFCParcel_equals(CFCParcel *self, CFCParcel *other) {
     if (strcmp(self->name, other->name)) { return false; }

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/5ec0912d/compiler/src/CFCParcel.h
----------------------------------------------------------------------
diff --git a/compiler/src/CFCParcel.h b/compiler/src/CFCParcel.h
index 4bd822d..dcf1dfe 100644
--- a/compiler/src/CFCParcel.h
+++ b/compiler/src/CFCParcel.h
@@ -51,8 +51,7 @@ CFCParcel_fetch(const char *name);
 void
 CFCParcel_register(CFCParcel *self);
 
-/** Return a NULL-terminated list of all registered parcels. Must be freed by
- * the caller.
+/** Return a NULL-terminated list of all registered parcels.
  */
 CFCParcel**
 CFCParcel_all_parcels(void);
@@ -79,11 +78,6 @@ CFCParcel_init(CFCParcel *self, const char *name, const char *cnick,
 void
 CFCParcel_destroy(CFCParcel *self);
 
-/** Return the singleton for default parcel, which has no prefix.
- */
-CFCParcel*
-CFCParcel_default_parcel(void);
-
 int
 CFCParcel_equals(CFCParcel *self, CFCParcel *other);
 

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/5ec0912d/compiler/src/CFCPerl.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPerl.c b/compiler/src/CFCPerl.c
index 2c873f5..c907b57 100644
--- a/compiler/src/CFCPerl.c
+++ b/compiler/src/CFCPerl.c
@@ -305,7 +305,6 @@ S_write_boot_c(CFCPerl *self) {
     FREEMEM(alias_adds);
     FREEMEM(bootstrap_code);
     FREEMEM(pound_includes);
-    FREEMEM(parcels);
     FREEMEM(ordered);
 }
 

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/5ec0912d/compiler/src/CFCTestParcel.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCTestParcel.c b/compiler/src/CFCTestParcel.c
index 504f2a7..46d8f1c 100644
--- a/compiler/src/CFCTestParcel.c
+++ b/compiler/src/CFCTestParcel.c
@@ -40,7 +40,7 @@ S_run_parcel_tests(CFCTest *test);
 
 const CFCTestBatch CFCTEST_BATCH_PARCEL = {
     "Clownfish::CFC::Model::Parcel",
-    35,
+    32,
     S_run_tests
 };
 
@@ -110,18 +110,6 @@ S_run_parcel_tests(CFCTest *test) {
     }
 
     {
-        CFCParcel *parcel = CFCParcel_default_parcel();
-        CFCSymbol *thing = CFCSymbol_new(parcel, "parcel", NULL, NULL, "sym");
-        STR_EQ(test, CFCSymbol_get_prefix(thing), "",
-               "get_prefix with no parcel");
-        STR_EQ(test, CFCSymbol_get_Prefix(thing), "",
-               "get_Prefix with no parcel");
-        STR_EQ(test, CFCSymbol_get_PREFIX(thing), "",
-               "get_PREFIX with no parcel");
-        CFCBase_decref((CFCBase*)thing);
-    }
-
-    {
         CFCParcel *parcel = CFCParcel_new("Crustacean", "Crust", NULL, false);
         CFCParcel_register(parcel);
         STR_EQ(test, CFCVersion_get_vstring(CFCParcel_get_version(parcel)),


Mime
View raw message