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:39 UTC
[lucy-commits] [2/3] git commit: refs/heads/separate-clownfish-wip2 - Perl bindings
for is_included member of CFCParcel
Perl bindings for is_included member of CFCParcel
Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/15e32cc2
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/15e32cc2
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/15e32cc2
Branch: refs/heads/separate-clownfish-wip2
Commit: 15e32cc26ec9e1b2af62fcd58f6649bec56d8f1f
Parents: fcf9f89
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sat Jun 1 17:59:22 2013 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat Jun 1 18:48:24 2013 +0200
----------------------------------------------------------------------
clownfish/compiler/perl/lib/Clownfish/CFC.pm | 19 ++++++++------
clownfish/compiler/perl/lib/Clownfish/CFC.xs | 28 ++++++++++++++++----
clownfish/compiler/perl/t/403-parcel.t | 20 +++++++++++---
3 files changed, 48 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy/blob/15e32cc2/clownfish/compiler/perl/lib/Clownfish/CFC.pm
----------------------------------------------------------------------
diff --git a/clownfish/compiler/perl/lib/Clownfish/CFC.pm b/clownfish/compiler/perl/lib/Clownfish/CFC.pm
index cbd28ee..8a7572f 100644
--- a/clownfish/compiler/perl/lib/Clownfish/CFC.pm
+++ b/clownfish/compiler/perl/lib/Clownfish/CFC.pm
@@ -320,38 +320,41 @@ BEGIN { XSLoader::load( 'Clownfish::CFC', '0.01' ) }
use Carp;
our %new_PARAMS = (
- name => undef,
- cnick => undef,
- version => undef,
+ name => undef,
+ cnick => undef,
+ version => undef,
+ is_included => undef,
);
sub new {
my ( $either, %args ) = @_;
verify_args( \%new_PARAMS, %args ) or confess $@;
confess "no subclassing allowed" unless $either eq __PACKAGE__;
- return _new( @args{qw( name cnick version )} );
+ return _new( @args{qw( name cnick version is_included )} );
}
our %new_from_json_PARAMS = (
- json => undef,
+ json => undef,
+ is_included => undef,
);
sub new_from_json {
my ( $either, %args ) = @_;
verify_args( \%new_from_json_PARAMS, %args ) or confess $@;
confess "no subclassing allowed" unless $either eq __PACKAGE__;
- return _new_from_json( $args{json} );
+ return _new_from_json( @args{qw( json is_included )} );
}
our %new_from_file_PARAMS = (
- path => undef,
+ path => undef,
+ is_included => undef,
);
sub new_from_file {
my ( $either, %args ) = @_;
verify_args( \%new_from_file_PARAMS, %args ) or confess $@;
confess "no subclassing allowed" unless $either eq __PACKAGE__;
- return _new_from_file( $args{path} );
+ return _new_from_file( @args{qw( path is_included )} );
}
# $parcel = Clownfish::CFC::Model::Parcel->acquire($parcel_name_or_parcel_object);
http://git-wip-us.apache.org/repos/asf/lucy/blob/15e32cc2/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 00fb54c..152af8f 100644
--- a/clownfish/compiler/perl/lib/Clownfish/CFC.xs
+++ b/clownfish/compiler/perl/lib/Clownfish/CFC.xs
@@ -1098,32 +1098,35 @@ PPCODE:
MODULE = Clownfish::CFC PACKAGE = Clownfish::CFC::Model::Parcel
SV*
-_new(name_sv, cnick_sv, version)
+_new(name_sv, cnick_sv, version, is_included)
SV *name_sv;
SV *cnick_sv;
CFCVersion *version;
+ bool is_included;
CODE:
const char *name = SvOK(name_sv) ? SvPV_nolen(name_sv) : NULL;
const char *cnick = SvOK(cnick_sv) ? SvPV_nolen(cnick_sv) : NULL;
- CFCParcel *self = CFCParcel_new(name, cnick, version, false);
+ CFCParcel *self = CFCParcel_new(name, cnick, version, is_included);
RETVAL = S_cfcbase_to_perlref(self);
CFCBase_decref((CFCBase*)self);
OUTPUT: RETVAL
SV*
-_new_from_file(path)
+_new_from_file(path, is_included)
const char *path;
+ bool is_included;
CODE:
- CFCParcel *self = CFCParcel_new_from_file(path, false);
+ CFCParcel *self = CFCParcel_new_from_file(path, is_included);
RETVAL = S_cfcbase_to_perlref(self);
CFCBase_decref((CFCBase*)self);
OUTPUT: RETVAL
SV*
-_new_from_json(json)
+_new_from_json(json, is_included)
const char *json;
+ bool is_included;
CODE:
- CFCParcel *self = CFCParcel_new_from_json(json, false);
+ CFCParcel *self = CFCParcel_new_from_json(json, is_included);
RETVAL = S_cfcbase_to_perlref(self);
CFCBase_decref((CFCBase*)self);
OUTPUT: RETVAL
@@ -1162,6 +1165,15 @@ CODE:
RETVAL = S_cfcbase_to_perlref(default_parcel);
OUTPUT: RETVAL
+SV*
+source_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);
+OUTPUT: RETVAL
+
void
reap_singletons(...)
PPCODE:
@@ -1178,6 +1190,7 @@ ALIAS:
get_Prefix = 8
get_PREFIX = 10
get_version = 12
+ included = 14
PPCODE:
{
START_SET_OR_GET_SWITCH
@@ -1211,6 +1224,9 @@ PPCODE:
retval = S_cfcbase_to_perlref(value);
}
break;
+ case 14:
+ retval = newSViv(CFCParcel_included(self));
+ break;
END_SET_OR_GET_SWITCH
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/15e32cc2/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 7e5c6d7..20aebdb 100644
--- a/clownfish/compiler/perl/t/403-parcel.t
+++ b/clownfish/compiler/perl/t/403-parcel.t
@@ -16,16 +16,26 @@
use strict;
use warnings;
-use Test::More tests => 11;
+use Test::More tests => 15;
use File::Spec::Functions qw( catfile );
BEGIN { use_ok('Clownfish::CFC::Model::Parcel') }
-isa_ok(
- Clownfish::CFC::Model::Parcel->new( name => "Foo" ),
- "Clownfish::CFC::Model::Parcel",
- "new"
+my $foo = Clownfish::CFC::Model::Parcel->new( name => "Foo" );
+isa_ok( $foo, "Clownfish::CFC::Model::Parcel", "new" );
+ok( !$foo->included, "not included" );
+$foo->register;
+
+my $included_foo = Clownfish::CFC::Model::Parcel->new(
+ name => "IncludedFoo",
+ is_included => 1,
);
+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 $json = qq|
{