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/01 18:50:40 UTC

[lucy-commits] [3/3] git commit: refs/heads/separate-clownfish-wip2 - Perl bindings for dependent parcels

Perl bindings for dependent parcels


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

Branch: refs/heads/separate-clownfish-wip2
Commit: 393c79b3a40ddca0872fe68060a77dd1c29a7871
Parents: 15e32cc
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sat Jun 1 18:20:44 2013 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat Jun 1 18:48:24 2013 +0200

----------------------------------------------------------------------
 clownfish/compiler/perl/lib/Clownfish/CFC.xs |   28 +++++++++++++++++++++
 clownfish/compiler/perl/t/403-parcel.t       |   16 +++++++++++-
 2 files changed, 43 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/393c79b3/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 152af8f..9c1b385 100644
--- a/clownfish/compiler/perl/lib/Clownfish/CFC.xs
+++ b/clownfish/compiler/perl/lib/Clownfish/CFC.xs
@@ -1175,6 +1175,20 @@ CODE:
 OUTPUT: RETVAL
 
 void
+add_dependent_parcel(self, dependent)
+    CFCParcel *self;
+    CFCParcel *dependent;
+PPCODE:
+    CFCParcel_add_dependent_parcel(self, dependent);
+
+void
+add_inherited_parcel(self, inherited)
+    CFCParcel *self;
+    CFCParcel *inherited;
+PPCODE:
+    CFCParcel_add_inherited_parcel(self, inherited);
+
+void
 reap_singletons(...)
 PPCODE:
     CHY_UNUSED_VAR(items);
@@ -1191,6 +1205,8 @@ ALIAS:
     get_PREFIX = 10
     get_version = 12
     included    = 14
+    dependent_parcels = 16
+    inherited_parcels = 18
 PPCODE:
 {
     START_SET_OR_GET_SWITCH
@@ -1227,6 +1243,18 @@ PPCODE:
         case 14:
             retval = newSViv(CFCParcel_included(self));
             break;
+        case 16: {
+                CFCParcel **parcels = CFCParcel_dependent_parcels(self);
+                retval = S_array_of_cfcbase_to_av((CFCBase**)parcels);
+                FREEMEM(parcels);
+            }
+            break;
+        case 18: {
+                CFCParcel **parcels = CFCParcel_inherited_parcels(self);
+                retval = S_array_of_cfcbase_to_av((CFCBase**)parcels);
+                FREEMEM(parcels);
+            }
+            break;
     END_SET_OR_GET_SWITCH
 }
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/393c79b3/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 20aebdb..f78e81d 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 => 15;
+use Test::More tests => 17;
 use File::Spec::Functions qw( catfile );
 
 BEGIN { use_ok('Clownfish::CFC::Model::Parcel') }
@@ -37,6 +37,20 @@ 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 $dependent_foo = Clownfish::CFC::Model::Parcel->new(
+    name        => "DependentFoo",
+    is_included => 1,
+);
+$dependent_foo->register;
+
+$foo->add_inherited_parcel($included_foo);
+$foo->add_dependent_parcel($dependent_foo);
+my @dep_names = sort(map { $_->get_name } @{ $foo->dependent_parcels });
+is_deeply( \@dep_names, [ "DependentFoo", "IncludedFoo" ],
+           "dependent_parcels" );
+my @inh_names = sort(map { $_->get_name } @{ $foo->inherited_parcels });
+is_deeply( \@inh_names, [ "IncludedFoo" ], "inherited_parcels" );
+
 my $json = qq|
         {
             "name": "Crustacean",