You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2012/01/26 03:48:40 UTC
[lucy-commits] svn commit: r1236028 [1/2] - in /incubator/lucy/trunk:
clownfish/perl/lib/Clownfish/ clownfish/src/
perl/buildlib/Lucy/Build/Binding/ perl/buildlib/Lucy/Build/Binding/Index/
perl/buildlib/Lucy/Build/Binding/Search/
perl/buildlib/Lucy/Build/Binding/Test...
Author: marvin
Date: Thu Jan 26 02:48:39 2012
New Revision: 1236028
URL: http://svn.apache.org/viewvc?rev=1236028&view=rev
Log:
Break out pod spec.
Break pod spec out of Clownfish::CFC::Binding::Perl::Class#new, and have
individual binding routines build up pod spec objects. This makes the
validation more rational and obvious and the code more grokkable, since the
actions are undertaken as individual method calls rather than embedded in a
big hash of arguments.
Modified:
incubator/lucy/trunk/clownfish/perl/lib/Clownfish/CFC.pm
incubator/lucy/trunk/clownfish/perl/lib/Clownfish/CFC.xs
incubator/lucy/trunk/clownfish/src/CFCPerlClass.c
incubator/lucy/trunk/clownfish/src/CFCPerlClass.h
incubator/lucy/trunk/clownfish/src/CFCPerlPod.c
incubator/lucy/trunk/clownfish/src/CFCPerlPod.h
incubator/lucy/trunk/perl/buildlib/Lucy/Build/Binding/Analysis.pm
incubator/lucy/trunk/perl/buildlib/Lucy/Build/Binding/Docs.pm
incubator/lucy/trunk/perl/buildlib/Lucy/Build/Binding/Document.pm
incubator/lucy/trunk/perl/buildlib/Lucy/Build/Binding/Highlight.pm
incubator/lucy/trunk/perl/buildlib/Lucy/Build/Binding/Index.pm
incubator/lucy/trunk/perl/buildlib/Lucy/Build/Binding/Index/Posting.pm
incubator/lucy/trunk/perl/buildlib/Lucy/Build/Binding/Lucy.pm
incubator/lucy/trunk/perl/buildlib/Lucy/Build/Binding/Object.pm
incubator/lucy/trunk/perl/buildlib/Lucy/Build/Binding/Plan.pm
incubator/lucy/trunk/perl/buildlib/Lucy/Build/Binding/Search.pm
incubator/lucy/trunk/perl/buildlib/Lucy/Build/Binding/Search/Collector.pm
incubator/lucy/trunk/perl/buildlib/Lucy/Build/Binding/Store.pm
incubator/lucy/trunk/perl/buildlib/Lucy/Build/Binding/Test/Util.pm
incubator/lucy/trunk/perl/buildlib/Lucy/Build/Binding/Util.pm
incubator/lucy/trunk/perl/buildlib/LucyX/Build/Binding/Search.pm
Modified: incubator/lucy/trunk/clownfish/perl/lib/Clownfish/CFC.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/perl/lib/Clownfish/CFC.pm?rev=1236028&r1=1236027&r2=1236028&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/perl/lib/Clownfish/CFC.pm (original)
+++ incubator/lucy/trunk/clownfish/perl/lib/Clownfish/CFC.pm Thu Jan 26 02:48:39 2012
@@ -635,11 +635,9 @@ BEGIN { XSLoader::load( 'Clownfish::CFC'
use Clownfish::CFC::Util qw( verify_args );
our %new_PARAMS = (
- parcel => undef,
- class_name => undef,
- make_pod => undef,
- xs_code => undef,
- client => undef,
+ parcel => undef,
+ class_name => undef,
+ xs_code => undef,
);
sub new {
@@ -657,15 +655,7 @@ BEGIN { XSLoader::load( 'Clownfish::CFC'
class_name => $args{class_name},
);
- # Create Pod spec if needed.
- my $pod_spec;
- if ( $args{make_pod} ) {
- $pod_spec = Clownfish::CFC::Binding::Perl::Pod->new(
- %{ $args{make_pod} } );
- }
-
- return _new( @args{qw( parcel class_name client xs_code )},
- $pod_spec );
+ return _new( @args{qw( parcel class_name client xs_code )} );
}
our %bind_method_PARAMS = (
@@ -734,48 +724,6 @@ BEGIN { XSLoader::load( 'Clownfish::CFC'
use Clownfish::CFC::Util qw( verify_args );
use Carp;
- our %new_PARAMS = (
- description => undef,
- synopsis => undef,
- constructor => undef,
- constructors => undef,
- methods => undef,
- );
-
- sub new {
- my ( $either, %args ) = @_;
- verify_args( \%new_PARAMS, %args ) or confess $@;
- my $synopsis = $args{synopsis} || '';
- my $description = $args{description} || '';
- my $methods = $args{methods} || [];
- my $constructors = $args{constructors} || [];
- push @$constructors, $args{constructor} if $args{constructor};
- my $self = _new( $synopsis, $description );
-
- for my $meth (@$methods) {
- if ( ref($meth) ) {
- $self->add_method(
- alias => $meth->{alias} || $meth->{name},
- method => $meth->{method},
- sample => $meth->{sample},
- pod => $meth->{pod},
- );
- }
- else {
- $self->add_method( alias => $meth );
- }
- }
- for my $con (@$constructors) {
- $self->add_constructor(
- alias => $con->{alias} || $con->{name},
- initializer => $con->{initializer} || $con->{func},
- sample => $con->{sample},
- pod => $con->{pod},
- );
- }
- return $self;
- }
-
my %add_method_PARAMS = (
alias => undef,
method => undef,
Modified: incubator/lucy/trunk/clownfish/perl/lib/Clownfish/CFC.xs
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/perl/lib/Clownfish/CFC.xs?rev=1236028&r1=1236027&r2=1236028&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/perl/lib/Clownfish/CFC.xs (original)
+++ incubator/lucy/trunk/clownfish/perl/lib/Clownfish/CFC.xs Thu Jan 26 02:48:39 2012
@@ -1857,18 +1857,17 @@ OUTPUT: RETVAL
MODULE = Clownfish PACKAGE = Clownfish::CFC::Binding::Perl::Class
SV*
-_new(parcel, class_name, client, xs_code_sv, pod_spec)
+_new(parcel, class_name, client, xs_code_sv)
CFCParcel *parcel;
const char *class_name;
CFCClass *client;
SV *xs_code_sv;
- CFCPerlPod *pod_spec;
CODE:
const char *xs_code = SvOK(xs_code_sv)
? SvPV_nolen(xs_code_sv)
: NULL;
CFCPerlClass *self
- = CFCPerlClass_new(parcel, class_name, client, xs_code, pod_spec);
+ = CFCPerlClass_new(parcel, class_name, client, xs_code);
RETVAL = S_cfcbase_to_perlref(self);
CFCBase_decref((CFCBase*)self);
OUTPUT: RETVAL
@@ -1955,6 +1954,7 @@ ALIAS:
get_class_name = 2
get_client = 4
get_xs_code = 6
+ set_pod_spec = 7
get_pod_spec = 8
PPCODE:
{
@@ -1976,6 +1976,17 @@ PPCODE:
: newSV(0);
}
break;
+ case 7: {
+ CFCPerlPod *pod_spec = NULL;
+ if (SvOK(ST(1))
+ && sv_derived_from(ST(1), "Clownfish::CFC::Binding::Perl::Pod")
+ ) {
+ IV objint = SvIV((SV*)SvRV(ST(1)));
+ pod_spec = INT2PTR(CFCPerlPod*, objint);
+ }
+ CFCPerlClass_set_pod_spec(self, pod_spec);
+ break;
+ }
case 8: {
CFCPerlPod *value = CFCPerlClass_get_pod_spec(self);
retval = S_cfcbase_to_perlref(value);
@@ -1987,11 +1998,11 @@ PPCODE:
MODULE = Clownfish PACKAGE = Clownfish::CFC::Binding::Perl::Pod
SV*
-_new(synopsis, description)
- const char *synopsis;
- const char *description;
+new(unused)
+ SV *unused;
CODE:
- CFCPerlPod *self = CFCPerlPod_new(synopsis, description);
+ (void)unused;
+ CFCPerlPod *self = CFCPerlPod_new();
RETVAL = S_cfcbase_to_perlref(self);
CFCBase_decref((CFCBase*)self);
OUTPUT: RETVAL
@@ -2045,16 +2056,28 @@ void
_set_or_get(self, ...)
CFCPerlPod *self;
ALIAS:
+ set_synopsis = 1
get_synopsis = 2
+ set_description = 3
get_description = 4
PPCODE:
{
START_SET_OR_GET_SWITCH
+ case 1: {
+ const char *val = SvOK(ST(1)) ? SvPVutf8_nolen(ST(1)) : NULL;
+ CFCPerlPod_set_synopsis(self, val);
+ }
+ break;
case 2: {
const char *value = CFCPerlPod_get_synopsis(self);
retval = newSVpvn(value, strlen(value));
}
break;
+ case 3: {
+ const char *val = SvOK(ST(1)) ? SvPVutf8_nolen(ST(1)) : NULL;
+ CFCPerlPod_set_description(self, val);
+ }
+ break;
case 4: {
const char *value = CFCPerlPod_get_description(self);
retval = newSVpvn(value, strlen(value));
Modified: incubator/lucy/trunk/clownfish/src/CFCPerlClass.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/src/CFCPerlClass.c?rev=1236028&r1=1236027&r2=1236028&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/src/CFCPerlClass.c (original)
+++ incubator/lucy/trunk/clownfish/src/CFCPerlClass.c Thu Jan 26 02:48:39 2012
@@ -60,22 +60,21 @@ const static CFCMeta CFCPERLCLASS_META =
CFCPerlClass*
CFCPerlClass_new(CFCParcel *parcel, const char *class_name, CFCClass *client,
- const char *xs_code, CFCPerlPod *pod_spec) {
+ const char *xs_code) {
CFCPerlClass *self = (CFCPerlClass*)CFCBase_allocate(&CFCPERLCLASS_META);
- return CFCPerlClass_init(self, parcel, class_name, client, xs_code,
- pod_spec);
+ return CFCPerlClass_init(self, parcel, class_name, client, xs_code);
}
CFCPerlClass*
CFCPerlClass_init(CFCPerlClass *self, CFCParcel *parcel,
const char *class_name, CFCClass *client,
- const char *xs_code, CFCPerlPod *pod_spec) {
+ const char *xs_code) {
CFCUTIL_NULL_CHECK(parcel);
CFCUTIL_NULL_CHECK(class_name);
self->parcel = (CFCParcel*)CFCBase_incref((CFCBase*)parcel);
self->client = (CFCClass*)CFCBase_incref((CFCBase*)client);
self->class_name = CFCUtil_strdup(class_name);
- self->pod_spec = (CFCPerlPod*)CFCBase_incref((CFCBase*)pod_spec);
+ self->pod_spec = NULL;
self->xs_code = xs_code ? CFCUtil_strdup(xs_code) : NULL;
self->meth_aliases = NULL;
self->meth_names = NULL;
@@ -412,6 +411,13 @@ CFCPerlClass_get_xs_code(CFCPerlClass *s
return self->xs_code;
}
+void
+CFCPerlClass_set_pod_spec(CFCPerlClass *self, CFCPerlPod *pod_spec) {
+ CFCPerlPod *old_pod_spec = self->pod_spec;
+ self->pod_spec = (CFCPerlPod*)CFCBase_incref((CFCBase*)pod_spec);
+ CFCBase_decref((CFCBase*)old_pod_spec);
+}
+
CFCPerlPod*
CFCPerlClass_get_pod_spec(CFCPerlClass *self) {
return self->pod_spec;
Modified: incubator/lucy/trunk/clownfish/src/CFCPerlClass.h
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/src/CFCPerlClass.h?rev=1236028&r1=1236027&r2=1236028&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/src/CFCPerlClass.h (original)
+++ incubator/lucy/trunk/clownfish/src/CFCPerlClass.h Thu Jan 26 02:48:39 2012
@@ -31,13 +31,12 @@ struct CFCPerlConstructor;
CFCPerlClass*
CFCPerlClass_new(struct CFCParcel *parcel, const char *class_name,
- struct CFCClass *client, const char *xs_code,
- struct CFCPerlPod *pod_spec);
+ struct CFCClass *client, const char *xs_code);
CFCPerlClass*
CFCPerlClass_init(CFCPerlClass *self, struct CFCParcel *parcel,
const char *class_name, struct CFCClass *client,
- const char *xs_code, struct CFCPerlPod *pod_spec);
+ const char *xs_code);
void
CFCPerlClass_destroy(CFCPerlClass *self);
@@ -80,6 +79,9 @@ CFCPerlClass_get_class_name(CFCPerlClass
const char*
CFCPerlClass_get_xs_code(CFCPerlClass *self);
+void
+CFCPerlClass_set_pod_spec(CFCPerlClass *self, struct CFCPerlPod *pod_spec);
+
struct CFCPerlPod*
CFCPerlClass_get_pod_spec(CFCPerlClass *self);
Modified: incubator/lucy/trunk/clownfish/src/CFCPerlPod.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/src/CFCPerlPod.c?rev=1236028&r1=1236027&r2=1236028&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/src/CFCPerlPod.c (original)
+++ incubator/lucy/trunk/clownfish/src/CFCPerlPod.c Thu Jan 26 02:48:39 2012
@@ -57,17 +57,16 @@ const static CFCMeta CFCPERLPOD_META = {
};
CFCPerlPod*
-CFCPerlPod_new(const char *synopsis, const char *description) {
+CFCPerlPod_new(void) {
CFCPerlPod *self
= (CFCPerlPod*)CFCBase_allocate(&CFCPERLPOD_META);
- return CFCPerlPod_init(self, synopsis, description);
+ return CFCPerlPod_init(self);
}
CFCPerlPod*
-CFCPerlPod_init(CFCPerlPod *self, const char *synopsis,
- const char *description) {
- self->synopsis = CFCUtil_strdup(synopsis ? synopsis : "");
- self->description = CFCUtil_strdup(description ? description : "");
+CFCPerlPod_init(CFCPerlPod *self) {
+ self->synopsis = CFCUtil_strdup("");
+ self->description = CFCUtil_strdup("");
self->methods = NULL;
self->constructors = NULL;
self->num_methods = 0;
@@ -124,11 +123,23 @@ CFCPerlPod_add_constructor(CFCPerlPod *s
slot->pod = pod ? CFCUtil_strdup(pod) : NULL;
}
+void
+CFCPerlPod_set_synopsis(CFCPerlPod *self, const char *synopsis) {
+ FREEMEM(self->synopsis);
+ self->synopsis = CFCUtil_strdup(synopsis);
+}
+
const char*
CFCPerlPod_get_synopsis(CFCPerlPod *self) {
return self->synopsis;
}
+void
+CFCPerlPod_set_description(CFCPerlPod *self, const char *description) {
+ FREEMEM(self->description);
+ self->description = CFCUtil_strdup(description);
+}
+
const char*
CFCPerlPod_get_description(CFCPerlPod *self) {
return self->description;
Modified: incubator/lucy/trunk/clownfish/src/CFCPerlPod.h
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/src/CFCPerlPod.h?rev=1236028&r1=1236027&r2=1236028&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/src/CFCPerlPod.h (original)
+++ incubator/lucy/trunk/clownfish/src/CFCPerlPod.h Thu Jan 26 02:48:39 2012
@@ -29,11 +29,10 @@ struct CFCFunction;
struct CFCClass;
CFCPerlPod*
-CFCPerlPod_new(const char *synopsis, const char *description);
+CFCPerlPod_new(void);
CFCPerlPod*
-CFCPerlPod_init(CFCPerlPod *self, const char *synopsis,
- const char *description);
+CFCPerlPod_init(CFCPerlPod *self);
void
CFCPerlPod_destroy(CFCPerlPod *self);
@@ -74,9 +73,15 @@ CFCPerlPod_methods_pod(CFCPerlPod *self,
char*
CFCPerlPod_constructors_pod(CFCPerlPod *self, struct CFCClass *klass);
+void
+CFCPerlPod_set_synopsis(CFCPerlPod *self, const char *synopsis);
+
const char*
CFCPerlPod_get_synopsis(CFCPerlPod *self);
+void
+CFCPerlPod_set_description(CFCPerlPod *self, const char *description);
+
const char*
CFCPerlPod_get_description(CFCPerlPod *self);
Modified: incubator/lucy/trunk/perl/buildlib/Lucy/Build/Binding/Analysis.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/perl/buildlib/Lucy/Build/Binding/Analysis.pm?rev=1236028&r1=1236027&r2=1236028&view=diff
==============================================================================
--- incubator/lucy/trunk/perl/buildlib/Lucy/Build/Binding/Analysis.pm (original)
+++ incubator/lucy/trunk/perl/buildlib/Lucy/Build/Binding/Analysis.pm Thu Jan 26 02:48:39 2012
@@ -32,17 +32,24 @@ sub bind_all {
}
sub bind_analyzer {
+ my @bound = qw( Transform Transform_Text Split );
+
+ my $pod_spec = Clownfish::CFC::Binding::Perl::Pod->new;
+ $pod_spec->set_synopsis(" # Abstract base class.\n");
+
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
- parcel => "Lucy",
- class_name => "Lucy::Analysis::Analyzer",
- make_pod => { synopsis => " # Abstract base class.\n", }
+ parcel => "Lucy",
+ class_name => "Lucy::Analysis::Analyzer",
);
$binding->bind_constructor;
- $binding->bind_method( method => $_ ) for qw( Transform Transform_Text Split );
+ $binding->bind_method( method => $_, alias => lc($_) ) for @bound;
+ $binding->set_pod_spec($pod_spec);
+
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
sub bind_casefolder {
+ my $pod_spec = Clownfish::CFC::Binding::Perl::Pod->new;
my $synopsis = <<'END_SYNOPSIS';
my $case_folder = Lucy::Analysis::CaseFolder->new;
@@ -50,24 +57,24 @@ sub bind_casefolder {
analyzers => [ $case_folder, $tokenizer, $stemmer ],
);
END_SYNOPSIS
-
my $constructor = <<'END_CONSTRUCTOR';
my $case_folder = Lucy::Analysis::CaseFolder->new;
END_CONSTRUCTOR
+ $pod_spec->set_synopsis($synopsis);
+ $pod_spec->add_constructor( alias => 'new', sample => $constructor );
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
- parcel => "Lucy",
- class_name => "Lucy::Analysis::CaseFolder",
- make_pod => {
- synopsis => $synopsis,
- constructor => { sample => $constructor },
- },
+ parcel => "Lucy",
+ class_name => "Lucy::Analysis::CaseFolder",
);
$binding->bind_constructor;
+ $binding->set_pod_spec($pod_spec);
+
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
sub bind_easyanalyzer {
+ my $pod_spec = Clownfish::CFC::Binding::Perl::Pod->new;
my $synopsis = <<'END_SYNOPSIS';
my $schema = Lucy::Plan::Schema->new;
my $analyzer = Lucy::Analysis::EasyAnalyzer->new(
@@ -79,26 +86,27 @@ sub bind_easyanalyzer {
$schema->spec_field( name => 'title', type => $type );
$schema->spec_field( name => 'content', type => $type );
END_SYNOPSIS
-
my $constructor = <<'END_CONSTRUCTOR';
my $analyzer = Lucy::Analysis::EasyAnalyzer->new(
language => 'es',
);
END_CONSTRUCTOR
+ $pod_spec->set_synopsis($synopsis);
+ $pod_spec->add_constructor( alias => 'new', sample => $constructor, );
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
- parcel => "Lucy",
- class_name => "Lucy::Analysis::EasyAnalyzer",
- make_pod => {
- synopsis => $synopsis,
- constructor => { sample => $constructor },
- },
+ parcel => "Lucy",
+ class_name => "Lucy::Analysis::EasyAnalyzer",
);
$binding->bind_constructor;
+ $binding->set_pod_spec($pod_spec);
+
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
sub bind_inversion {
+ my @bound = qw( Append Reset Invert Next );
+
my $xs = <<'END_XS';
MODULE = Lucy PACKAGE = Lucy::Analysis::Inversion
@@ -136,11 +144,13 @@ END_XS
class_name => "Lucy::Analysis::Inversion",
xs_code => $xs,
);
- $binding->bind_method( method => $_ ) for qw( Append Reset Invert Next );
+ $binding->bind_method( method => $_, alias => lc($_) ) for @bound;
+
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
sub bind_normalizer {
+ my $pod_spec = Clownfish::CFC::Binding::Perl::Pod->new;
my $synopsis = <<'END_SYNOPSIS';
my $normalizer = Lucy::Analysis::Normalizer->new;
@@ -148,7 +158,6 @@ sub bind_normalizer {
analyzers => [ $normalizer, $tokenizer, $stemmer ],
);
END_SYNOPSIS
-
my $constructor = <<'END_CONSTRUCTOR';
my $normalizer = Lucy::Analysis::Normalizer->new(
normalization_form => 'NFKC',
@@ -156,20 +165,24 @@ END_SYNOPSIS
strip_accents => 0,
);
END_CONSTRUCTOR
+ $pod_spec->set_synopsis($synopsis);
+ $pod_spec->add_constructor( alias => 'new', sample => $constructor );
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
- parcel => "Lucy",
- class_name => "Lucy::Analysis::Normalizer",
- make_pod => {
- synopsis => $synopsis,
- constructor => { sample => $constructor }
- },
+ parcel => "Lucy",
+ class_name => "Lucy::Analysis::Normalizer",
);
$binding->bind_constructor;
+ $binding->set_pod_spec($pod_spec);
+
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
sub bind_polyanalyzer {
+ my @exposed = qw( Get_Analyzers );
+ my @bound = @exposed;
+
+ my $pod_spec = Clownfish::CFC::Binding::Perl::Pod->new;
my $synopsis = <<'END_SYNOPSIS';
my $schema = Lucy::Plan::Schema->new;
my $polyanalyzer = Lucy::Analysis::PolyAnalyzer->new(
@@ -181,7 +194,6 @@ sub bind_polyanalyzer {
$schema->spec_field( name => 'title', type => $type );
$schema->spec_field( name => 'content', type => $type );
END_SYNOPSIS
-
my $constructor = <<'END_CONSTRUCTOR';
my $analyzer = Lucy::Analysis::PolyAnalyzer->new(
language => 'es',
@@ -195,22 +207,23 @@ END_SYNOPSIS
my $polyanalyzer = Lucy::Analysis::PolyAnalyzer->new(
analyzers => [ $case_folder, $whitespace_tokenizer, $stemmer, ], );
END_CONSTRUCTOR
+ $pod_spec->set_synopsis($synopsis);
+ $pod_spec->add_constructor( alias => 'new', sample => $constructor );
+ $pod_spec->add_method( method => $_, alias => lc($_) ) for @exposed;
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
- parcel => "Lucy",
- class_name => "Lucy::Analysis::PolyAnalyzer",
- make_pod => {
- methods => [qw( get_analyzers )],
- synopsis => $synopsis,
- constructor => { sample => $constructor },
- },
+ parcel => "Lucy",
+ class_name => "Lucy::Analysis::PolyAnalyzer",
);
$binding->bind_constructor;
- $binding->bind_method( method => $_ ) for qw( Get_Analyzers );
+ $binding->bind_method( method => $_, alias => lc($_) ) for @bound;
+ $binding->set_pod_spec($pod_spec);
+
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
sub bind_regextokenizer {
+ my $pod_spec = Clownfish::CFC::Binding::Perl::Pod->new;
my $synopsis = <<'END_SYNOPSIS';
my $whitespace_tokenizer
= Lucy::Analysis::RegexTokenizer->new( pattern => '\S+' );
@@ -226,26 +239,26 @@ sub bind_regextokenizer {
my $polyanalyzer = Lucy::Analysis::PolyAnalyzer->new(
analyzers => [ $case_folder, $word_char_tokenizer, $stemmer ], );
END_SYNOPSIS
-
my $constructor = <<'END_CONSTRUCTOR';
my $word_char_tokenizer = Lucy::Analysis::RegexTokenizer->new(
pattern => '\w+', # required
);
END_CONSTRUCTOR
+ $pod_spec->set_synopsis($synopsis);
+ $pod_spec->add_constructor( alias => 'new', sample => $constructor );
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
- parcel => "Lucy",
- class_name => "Lucy::Analysis::RegexTokenizer",
- make_pod => {
- constructor => { sample => $constructor },
- synopsis => $synopsis,
- },
+ parcel => "Lucy",
+ class_name => "Lucy::Analysis::RegexTokenizer",
);
$binding->bind_constructor( alias => '_new' );
+ $binding->set_pod_spec($pod_spec);
+
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
sub bind_snowballstemmer {
+ my $pod_spec = Clownfish::CFC::Binding::Perl::Pod->new;
my $synopsis = <<'END_SYNOPSIS';
my $stemmer = Lucy::Analysis::SnowballStemmer->new( language => 'es' );
@@ -256,24 +269,24 @@ sub bind_snowballstemmer {
This class is a wrapper around the Snowball stemming library, so it supports
the same languages.
END_SYNOPSIS
-
my $constructor = <<'END_CONSTRUCTOR';
my $stemmer = Lucy::Analysis::SnowballStemmer->new( language => 'es' );
END_CONSTRUCTOR
+ $pod_spec->set_synopsis($synopsis);
+ $pod_spec->add_constructor( alias => 'new', sample => $constructor );
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
- parcel => "Lucy",
- class_name => "Lucy::Analysis::SnowballStemmer",
- make_pod => {
- synopsis => $synopsis,
- constructor => { sample => $constructor }
- },
+ parcel => "Lucy",
+ class_name => "Lucy::Analysis::SnowballStemmer",
);
$binding->bind_constructor;
+ $binding->set_pod_spec($pod_spec);
+
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
sub bind_snowballstopfilter {
+ my $pod_spec = Clownfish::CFC::Binding::Perl::Pod->new;
my $synopsis = <<'END_SYNOPSIS';
my $stopfilter = Lucy::Analysis::SnowballStopFilter->new(
language => 'fr',
@@ -282,7 +295,6 @@ sub bind_snowballstopfilter {
analyzers => [ $case_folder, $tokenizer, $stopfilter, $stemmer ],
);
END_SYNOPSIS
-
my $constructor = <<'END_CONSTRUCTOR';
my $stopfilter = Lucy::Analysis::SnowballStopFilter->new(
language => 'de',
@@ -293,20 +305,21 @@ END_SYNOPSIS
stoplist => \%stoplist,
);
END_CONSTRUCTOR
+ $pod_spec->set_synopsis($synopsis);
+ $pod_spec->add_constructor( alias => 'new', sample => $constructor );
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
- parcel => "Lucy",
- class_name => "Lucy::Analysis::SnowballStopFilter",
- make_pod => {
- synopsis => $synopsis,
- constructor => { sample => $constructor }
- },
+ parcel => "Lucy",
+ class_name => "Lucy::Analysis::SnowballStopFilter",
);
$binding->bind_constructor;
+ $binding->set_pod_spec($pod_spec);
+
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
sub bind_standardtokenizer {
+ my $pod_spec = Clownfish::CFC::Binding::Perl::Pod->new;
my $synopsis = <<'END_SYNOPSIS';
my $tokenizer = Lucy::Analysis::StandardTokenizer->new;
@@ -314,24 +327,30 @@ sub bind_standardtokenizer {
my $polyanalyzer = Lucy::Analysis::PolyAnalyzer->new(
analyzers => [ $case_folder, $tokenizer, $stemmer ], );
END_SYNOPSIS
-
my $constructor = <<'END_CONSTRUCTOR';
my $tokenizer = Lucy::Analysis::StandardTokenizer->new;
END_CONSTRUCTOR
+ $pod_spec->set_synopsis($synopsis);
+ $pod_spec->add_constructor( alias => 'new', sample => $constructor );
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
- parcel => "Lucy",
- class_name => "Lucy::Analysis::StandardTokenizer",
- make_pod => {
- constructor => { sample => $constructor },
- synopsis => $synopsis,
- },
+ parcel => "Lucy",
+ class_name => "Lucy::Analysis::StandardTokenizer",
);
$binding->bind_constructor;
+ $binding->set_pod_spec($pod_spec);
+
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
sub bind_token {
+ my @bound = qw(
+ Get_Start_Offset
+ Get_End_Offset
+ Get_Boost
+ Get_Pos_Inc
+ );
+
my $xs = <<'END_XS';
MODULE = Lucy PACKAGE = Lucy::Analysis::Token
@@ -389,16 +408,12 @@ PPCODE:
END_XS
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
- parcel => "Lucy",
- class_name => "Lucy::Analysis::Token",
- xs_code => $xs,
- );
- $binding->bind_method( method => $_ ) for qw(
- Get_Start_Offset
- Get_End_Offset
- Get_Boost
- Get_Pos_Inc
+ parcel => "Lucy",
+ class_name => "Lucy::Analysis::Token",
+ xs_code => $xs,
);
+ $binding->bind_method( method => $_, alias => lc($_) ) for @bound;
+
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
Modified: incubator/lucy/trunk/perl/buildlib/Lucy/Build/Binding/Docs.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/perl/buildlib/Lucy/Build/Binding/Docs.pm?rev=1236028&r1=1236027&r2=1236028&view=diff
==============================================================================
--- incubator/lucy/trunk/perl/buildlib/Lucy/Build/Binding/Docs.pm (original)
+++ incubator/lucy/trunk/perl/buildlib/Lucy/Build/Binding/Docs.pm Thu Jan 26 02:48:39 2012
@@ -23,15 +23,17 @@ sub bind_all {
}
sub bind_devguide {
+ my $pod_spec = Clownfish::CFC::Binding::Perl::Pod->new;
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
parcel => "Lucy",
class_name => "Lucy::Docs::DevGuide",
- make_pod => {},
);
+ $binding->set_pod_spec($pod_spec);
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
sub bind_filelocking {
+ my $pod_spec = Clownfish::CFC::Binding::Perl::Pod->new;
my $synopsis = <<'END_SYNOPSIS';
use Sys::Hostname qw( hostname );
my $hostname = hostname() or die "Can't get unique hostname";
@@ -50,12 +52,14 @@ sub bind_filelocking {
);
my $searcher = Lucy::Search::IndexSearcher->new( index => $reader );
END_SYNOPSIS
+ $pod_spec->set_synopsis($synopsis);
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
parcel => "Lucy",
class_name => "Lucy::Docs::FileLocking",
- make_pod => { synopsis => $synopsis, },
);
+ $binding->set_pod_spec($pod_spec);
+
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
Modified: incubator/lucy/trunk/perl/buildlib/Lucy/Build/Binding/Document.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/perl/buildlib/Lucy/Build/Binding/Document.pm?rev=1236028&r1=1236027&r2=1236028&view=diff
==============================================================================
--- incubator/lucy/trunk/perl/buildlib/Lucy/Build/Binding/Document.pm (original)
+++ incubator/lucy/trunk/perl/buildlib/Lucy/Build/Binding/Document.pm Thu Jan 26 02:48:39 2012
@@ -23,6 +23,30 @@ sub bind_all {
}
sub bind_doc {
+ my @bound = qw( Set_Doc_ID Get_Doc_ID );
+ my @exposed = ( @bound, 'Get_Fields' );
+
+ my $pod_spec = Clownfish::CFC::Binding::Perl::Pod->new;
+ my $synopsis = <<'END_SYNOPSIS';
+ my $doc = Lucy::Document::Doc->new(
+ fields => { foo => 'foo foo', bar => 'bar bar' },
+ );
+ $indexer->add_doc($doc);
+
+Doc objects allow access to field values via hashref overloading:
+
+ $doc->{foo} = 'new value for field "foo"';
+ print "foo: $doc->{foo}\n";
+END_SYNOPSIS
+ my $constructor = <<'END_CONSTRUCTOR';
+ my $doc = Lucy::Document::Doc->new(
+ fields => { foo => 'foo foo', bar => 'bar bar' },
+ );
+END_CONSTRUCTOR
+ $pod_spec->set_synopsis($synopsis);
+ $pod_spec->add_constructor( alias => 'new', sample => $constructor );
+ $pod_spec->add_method( method => $_, alias => lc($_) ) for @exposed;
+
my $xs_code = <<'END_XS_CODE';
MODULE = Lucy PACKAGE = Lucy::Document::Doc
@@ -75,39 +99,32 @@ PPCODE:
lucy_Doc_set_fields(self, fields);
END_XS_CODE
- my $synopsis = <<'END_SYNOPSIS';
- my $doc = Lucy::Document::Doc->new(
- fields => { foo => 'foo foo', bar => 'bar bar' },
- );
- $indexer->add_doc($doc);
-
-Doc objects allow access to field values via hashref overloading:
-
- $doc->{foo} = 'new value for field "foo"';
- print "foo: $doc->{foo}\n";
-END_SYNOPSIS
-
- my $constructor = <<'END_CONSTRUCTOR';
- my $doc = Lucy::Document::Doc->new(
- fields => { foo => 'foo foo', bar => 'bar bar' },
- );
-END_CONSTRUCTOR
-
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
- parcel => "Lucy",
- class_name => "Lucy::Document::Doc",
- xs_code => $xs_code,
- make_pod => {
- methods => [qw( set_doc_id get_doc_id get_fields )],
- synopsis => $synopsis,
- constructor => { sample => $constructor },
- }
+ parcel => "Lucy",
+ class_name => "Lucy::Document::Doc",
+ xs_code => $xs_code,
);
- $binding->bind_method( method => $_ ) for qw( Set_Doc_ID Get_Doc_ID );
+ $binding->bind_method( method => $_, alias => lc($_) ) for @bound;
+ $binding->set_pod_spec($pod_spec);
+
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
sub bind_hitdoc {
+ my @exposed = qw( Set_Score Get_Score );
+ my @bound = @exposed;
+
+ my $pod_spec = Clownfish::CFC::Binding::Perl::Pod->new;
+ my $synopsis = <<'END_SYNOPSIS';
+ while ( my $hit_doc = $hits->next ) {
+ print "$hit_doc->{title}\n";
+ print $hit_doc->get_score . "\n";
+ ...
+ }
+END_SYNOPSIS
+ $pod_spec->set_synopsis($synopsis);
+ $pod_spec->add_method( method => $_, alias => lc($_) ) for @exposed;
+
my $xs_code = <<'END_XS_CODE';
MODULE = Lucy PACKAGE = Lucy::Document::HitDoc
@@ -147,24 +164,14 @@ CODE:
OUTPUT: RETVAL
END_XS_CODE
- my $synopsis = <<'END_SYNOPSIS';
- while ( my $hit_doc = $hits->next ) {
- print "$hit_doc->{title}\n";
- print $hit_doc->get_score . "\n";
- ...
- }
-END_SYNOPSIS
-
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
- parcel => "Lucy",
- class_name => "Lucy::Document::HitDoc",
- xs_code => $xs_code,
- make_pod => {
- methods => [qw( set_score get_score )],
- synopsis => $synopsis,
- },
+ parcel => "Lucy",
+ class_name => "Lucy::Document::HitDoc",
+ xs_code => $xs_code,
);
- $binding->bind_method( method => $_ ) for qw( Set_Score Get_Score );
+ $binding->bind_method( method => $_, alias => lc($_) ) for @bound;
+ $binding->set_pod_spec($pod_spec);
+
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
Modified: incubator/lucy/trunk/perl/buildlib/Lucy/Build/Binding/Highlight.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/perl/buildlib/Lucy/Build/Binding/Highlight.pm?rev=1236028&r1=1236027&r2=1236028&view=diff
==============================================================================
--- incubator/lucy/trunk/perl/buildlib/Lucy/Build/Binding/Highlight.pm (original)
+++ incubator/lucy/trunk/perl/buildlib/Lucy/Build/Binding/Highlight.pm Thu Jan 26 02:48:39 2012
@@ -23,32 +23,51 @@ sub bind_all {
}
sub bind_heatmap {
+ my @bound = qw(
+ Calc_Proximity_Boost
+ Generate_Proximity_Boosts
+ Flatten_Spans
+ Get_Spans
+ );
+
+ my $pod_spec = Clownfish::CFC::Binding::Perl::Pod->new;
my $constructor = <<'END_CONSTRUCTOR';
my $heat_map = Lucy::Highlight::HeatMap->new(
spans => \@highlight_spans,
window => 100,
);
END_CONSTRUCTOR
+ $pod_spec->add_constructor( alias => 'new', sample => $constructor );
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
- parcel => "Lucy",
- class_name => "Lucy::Highlight::HeatMap",
- #make_pod => {
- # synopsis => " # TODO.\n",
- # constructor => { sample => $constructor },
- #},
+ parcel => "Lucy",
+ class_name => "Lucy::Highlight::HeatMap",
);
$binding->bind_constructor;
- $binding->bind_method( method => $_ ) for qw(
- Calc_Proximity_Boost
- Generate_Proximity_Boosts
- Flatten_Spans
- Get_Spans
- );
+ $binding->bind_method( method => $_, alias => lc($_) ) for @bound;
+ #$binding->set_pod_spec($pod_spec); TODO
+
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
sub bind_highlighter {
+ my @exposed = qw(
+ Create_Excerpt
+ Highlight
+ Encode
+ Set_Pre_Tag
+ Get_Pre_Tag
+ Set_Post_Tag
+ Get_Post_Tag
+ Get_Searcher
+ Get_Query
+ Get_Compiler
+ Get_Excerpt_Length
+ Get_Field
+ );
+ my @bound = ( @exposed, 'Find_Sentences' );
+
+ my $pod_spec = Clownfish::CFC::Binding::Perl::Pod->new;
my $synopsis = <<'END_SYNOPSIS';
my $highlighter = Lucy::Highlight::Highlighter->new(
searcher => $searcher,
@@ -61,7 +80,6 @@ sub bind_highlighter {
...
}
END_SYNOPSIS
-
my $constructor = <<'END_CONSTRUCTOR';
my $highlighter = Lucy::Highlight::Highlighter->new(
searcher => $searcher, # required
@@ -70,47 +88,16 @@ END_SYNOPSIS
excerpt_length => 150, # default: 200
);
END_CONSTRUCTOR
+ $pod_spec->set_synopsis($synopsis);
+ $pod_spec->add_constructor( alias => 'new', sample => $constructor );
+ $pod_spec->add_method( method => $_, alias => lc($_) ) for @exposed;
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
parcel => "Lucy",
class_name => "Lucy::Highlight::Highlighter",
- make_pod => {
- synopsis => $synopsis,
- constructor => { sample => $constructor },
- methods => [
- qw(
- create_excerpt
- highlight
- encode
- set_pre_tag
- get_pre_tag
- set_post_tag
- get_post_tag
- get_searcher
- get_query
- get_compiler
- get_excerpt_length
- get_field
- )
- ]
- },
);
$binding->bind_constructor;
- $binding->bind_method( method => $_ ) for qw(
- Highlight
- Encode
- Create_Excerpt
- Find_Sentences
- Set_Pre_Tag
- Get_Pre_Tag
- Set_Post_Tag
- Get_Post_Tag
- Get_Searcher
- Get_Query
- Get_Compiler
- Get_Excerpt_Length
- Get_Field
- );
+ $binding->bind_method( method => $_ ) for @bound;
$binding->bind_method(
alias => '_find_best_fragment',
method => 'Find_Best_Fragment'
@@ -123,6 +110,8 @@ END_CONSTRUCTOR
alias => '_highlight_excerpt',
method => 'Highlight_Excerpt'
);
+ $binding->set_pod_spec($pod_spec);
+
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
Modified: incubator/lucy/trunk/perl/buildlib/Lucy/Build/Binding/Index.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/perl/buildlib/Lucy/Build/Binding/Index.pm?rev=1236028&r1=1236027&r2=1236028&view=diff
==============================================================================
--- incubator/lucy/trunk/perl/buildlib/Lucy/Build/Binding/Index.pm (original)
+++ incubator/lucy/trunk/perl/buildlib/Lucy/Build/Binding/Index.pm Thu Jan 26 02:48:39 2012
@@ -64,49 +64,53 @@ sub bind_all {
}
sub bind_backgroundmerger {
+ my @exposed = qw( Commit Prepare_Commit Optimize );
+ my @bound = @exposed;
+
+ my $pod_spec = Clownfish::CFC::Binding::Perl::Pod->new;
my $synopsis = <<'END_SYNOPSIS';
my $bg_merger = Lucy::Index::BackgroundMerger->new(
index => '/path/to/index',
);
$bg_merger->commit;
END_SYNOPSIS
-
my $constructor = <<'END_CONSTRUCTOR';
my $bg_merger = Lucy::Index::BackgroundMerger->new(
index => '/path/to/index', # required
manager => $manager # default: created internally
);
END_CONSTRUCTOR
+ $pod_spec->set_synopsis($synopsis);
+ $pod_spec->add_constructor( alias => 'new', sample => $constructor, );
+ $pod_spec->add_method( method => $_, alias => lc($_) ) for @exposed;
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
parcel => "Lucy",
class_name => "Lucy::Index::BackgroundMerger",
- make_pod => {
- methods => [
- qw(
- commit
- prepare_commit
- optimize
- )
- ],
- synopsis => $synopsis,
- constructors => [ { sample => $constructor } ],
- },
);
$binding->bind_constructor;
- $binding->bind_method( method => $_ ) for qw(
- Commit
- Prepare_Commit
- Optimize
- );
+ $binding->bind_method( method => $_, alias => lc($_) ) for @bound;
+ $binding->set_pod_spec($pod_spec);
+
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
sub bind_datareader {
+ my @exposed = qw(
+ Get_Schema
+ Get_Folder
+ Get_Snapshot
+ Get_Segments
+ Get_Segment
+ Get_Seg_Tick
+ Aggregator
+ );
+ my @bound = ( @exposed, 'Close' );
+
+ my $pod_spec = Clownfish::CFC::Binding::Perl::Pod->new;
my $synopsis = <<'END_SYNOPSIS';
# Abstract base class.
END_SYNOPSIS
-
my $constructor = <<'END_CONSTRUCTOR';
my $reader = MyDataReader->new(
schema => $seg_reader->get_schema, # default undef
@@ -116,45 +120,42 @@ END_SYNOPSIS
seg_tick => $seg_reader->get_seg_tick, # default -1
);
END_CONSTRUCTOR
+ $pod_spec->set_synopsis($synopsis);
+ $pod_spec->add_constructor( alias => 'new', sample => $constructor, );
+ $pod_spec->add_method( method => $_, alias => lc($_) ) for @exposed;
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
parcel => "Lucy",
class_name => "Lucy::Index::DataReader",
- make_pod => {
- synopsis => $synopsis,
- constructor => { sample => $constructor, },
- methods => [
- qw(
- get_schema
- get_folder
- get_snapshot
- get_segments
- get_segment
- get_seg_tick
- aggregator
- )
- ]
- },
);
$binding->bind_constructor;
- $binding->bind_method( method => $_ ) for qw(
- Get_Schema
- Get_Folder
- Get_Segments
- Get_Snapshot
- Get_Seg_Tick
- Get_Segment
- Aggregator
- Close
- );
+ $binding->bind_method( method => $_, alias => lc($_) ) for @bound;
+ $binding->set_pod_spec($pod_spec);
+
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
sub bind_datawriter {
+ my @exposed = qw(
+ Add_Inverted_Doc
+ Add_Segment
+ Delete_Segment
+ Merge_Segment
+ Finish
+ Format
+ Metadata
+ Get_Snapshot
+ Get_Segment
+ Get_PolyReader
+ Get_Schema
+ Get_Folder
+ );
+ my @bound = @exposed;
+
+ my $pod_spec = Clownfish::CFC::Binding::Perl::Pod->new;
my $synopsis = <<END_SYNOPSIS;
# Abstract base class.
END_SYNOPSIS
-
my $constructor = <<'END_CONSTRUCTOR';
my $writer = MyDataWriter->new(
snapshot => $snapshot, # required
@@ -162,70 +163,62 @@ END_SYNOPSIS
polyreader => $polyreader, # required
);
END_CONSTRUCTOR
+ $pod_spec->set_synopsis($synopsis);
+ $pod_spec->add_constructor( alias => 'new', sample => $constructor, );
+ $pod_spec->add_method( method => $_, alias => lc($_) ) for @exposed;
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
- parcel => "Lucy",
- class_name => "Lucy::Index::DataWriter",
- make_pod => {
- synopsis => $synopsis,
- constructor => { sample => $constructor },
- methods => [
- qw(
- add_inverted_doc
- add_segment
- delete_segment
- merge_segment
- finish
- format
- metadata
- get_snapshot
- get_segment
- get_polyreader
- get_schema
- get_folder
- )
- ],
- },
+ parcel => "Lucy",
+ class_name => "Lucy::Index::DataWriter",
);
$binding->bind_constructor;
- $binding->bind_method( method => $_ ) for qw(
- Add_Inverted_Doc
- Add_Segment
- Delete_Segment
- Merge_Segment
- Finish
- Format
- Metadata
- Get_Snapshot
- Get_Segment
- Get_PolyReader
- Get_Schema
- Get_Folder
- );
+ $binding->bind_method( method => $_, alias => lc($_) ) for @bound;
+ $binding->set_pod_spec($pod_spec);
+
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
sub bind_deletionsreader {
+ my @bound = qw( Iterator Del_Count );
+
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
parcel => "Lucy",
class_name => "Lucy::Index::DeletionsReader",
);
$binding->bind_constructor;
- $binding->bind_method( method => $_ ) for qw( Iterator Del_Count );
+ $binding->bind_method( method => $_, alias => lc($_) ) for @bound;
+
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
sub bind_defaultdeletionsreader {
+ my @bound = qw( Read_Deletions );
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
parcel => "Lucy",
class_name => "Lucy::Index::DefaultDeletionsReader",
);
$binding->bind_constructor;
- $binding->bind_method( method => $_ ) for qw( Read_Deletions );
+ $binding->bind_method( method => $_, alias => lc($_) ) for @bound;
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
sub bind_deletionswriter {
+ my @exposed = qw(
+ Delete_By_Term
+ Delete_By_Query
+ Updated
+ Seg_Del_Count
+ );
+ my @bound = (
+ @exposed,
+ qw(
+ Generate_Doc_Map
+ Delete_By_Doc_ID
+ Seg_Deletions
+ )
+ );
+
+ my $pod_spec = Clownfish::CFC::Binding::Perl::Pod->new;
my $synopsis = <<'END_SYNOPSIS';
my $polyreader = $del_writer->get_polyreader;
my $seg_readers = $polyreader->seg_readers;
@@ -234,31 +227,16 @@ sub bind_deletionswriter {
...
}
END_SYNOPSIS
+ $pod_spec->set_synopsis($synopsis);
+ $pod_spec->add_method( method => $_, alias => lc($_) ) for @exposed;
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
- parcel => "Lucy",
- class_name => "Lucy::Index::DeletionsWriter",
- make_pod => {
- synopsis => $synopsis,
- methods => [
- qw(
- delete_by_term
- delete_by_query
- updated
- seg_del_count
- )
- ],
- },
- );
- $binding->bind_method( method => $_ ) for qw(
- Generate_Doc_Map
- Delete_By_Term
- Delete_By_Query
- Delete_By_Doc_ID
- Updated
- Seg_Deletions
- Seg_Del_Count
+ parcel => "Lucy",
+ class_name => "Lucy::Index::DeletionsWriter",
);
+ $binding->bind_method( method => $_, alias => lc($_) ) for @bound;
+ $binding->set_pod_spec($pod_spec);
+
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
@@ -272,21 +250,25 @@ sub bind_defaultdeletionswriter {
}
sub bind_docreader {
+ my @bound = qw( Fetch_Doc );
+ my @exposed = ( @bound, 'Aggregator' );
+
+ my $pod_spec = Clownfish::CFC::Binding::Perl::Pod->new;
my $synopsis = <<'END_SYNOPSIS';
my $doc_reader = $seg_reader->obtain("Lucy::Index::DocReader");
my $doc = $doc_reader->fetch_doc($doc_id);
END_SYNOPSIS
+ $pod_spec->set_synopsis($synopsis);
+ $pod_spec->add_method( method => $_, alias => lc($_) ) for @exposed;
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
- parcel => "Lucy",
- class_name => "Lucy::Index::DocReader",
- make_pod => {
- synopsis => $synopsis,
- methods => [qw( fetch_doc aggregator )],
- },
+ parcel => "Lucy",
+ class_name => "Lucy::Index::DocReader",
);
$binding->bind_constructor;
- $binding->bind_method( method => $_ ) for qw( Fetch_Doc );
+ $binding->bind_method( method => $_, alias => lc($_) ) for @bound;
+ $binding->set_pod_spec($pod_spec);
+
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
@@ -300,16 +282,13 @@ sub bind_defaultdocreader {
}
sub bind_docvector {
+ my @bound = qw( Term_Vector Field_Buf Add_Field_Buf );
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
parcel => "Lucy",
class_name => "Lucy::Index::DocVector",
);
$binding->bind_constructor;
- $binding->bind_method( method => $_ ) for qw(
- Term_Vector
- Field_Buf
- Add_Field_Buf
- );
+ $binding->bind_method( method => $_, alias => lc($_) ) for @bound;
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
@@ -323,12 +302,13 @@ sub bind_docwriter {
}
sub bind_filepurger {
+ my @bound = qw( Purge );
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
parcel => "Lucy",
class_name => "Lucy::Index::FilePurger",
);
$binding->bind_constructor;
- $binding->bind_method( method => $_ ) for qw( Purge );
+ $binding->bind_method( method => $_, alias => lc($_) ) for @bound;
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
@@ -360,6 +340,37 @@ sub bind_highlightwriter {
}
sub bind_indexmanager {
+ my @exposed = qw(
+ Make_Write_Lock
+ Recycle
+ Set_Folder
+ Get_Folder
+ Get_Host
+ Set_Write_Lock_Timeout
+ Get_Write_Lock_Timeout
+ Set_Write_Lock_Interval
+ Get_Write_Lock_Interval
+ );
+ my @bound = (
+ @exposed,
+ qw(
+ Make_Deletion_Lock
+ Make_Merge_Lock
+ Make_Snapshot_Read_Lock
+ Highest_Seg_Num
+ Make_Snapshot_Filename
+ Set_Merge_Lock_Timeout
+ Get_Merge_Lock_Timeout
+ Set_Merge_Lock_Interval
+ Get_Merge_Lock_Interval
+ Set_Deletion_Lock_Timeout
+ Get_Deletion_Lock_Timeout
+ Set_Deletion_Lock_Interval
+ Get_Deletion_Lock_Interval
+ )
+ );
+
+ my $pod_spec = Clownfish::CFC::Binding::Perl::Pod->new;
my $synopsis = <<'END_SYNOPSIS';
use Sys::Hostname qw( hostname );
my $hostname = hostname() or die "Can't get unique hostname";
@@ -380,84 +391,47 @@ sub bind_indexmanager {
);
my $searcher = Lucy::Search::IndexSearcher->new( index => $reader );
END_SYNOPSIS
-
my $constructor = <<'END_CONSTRUCTOR';
my $manager = Lucy::Index::IndexManager->new(
host => $hostname, # default: ""
);
END_CONSTRUCTOR
+ $pod_spec->set_synopsis($synopsis);
+ $pod_spec->add_constructor( alias => 'new', sample => $constructor, );
+ $pod_spec->add_method( method => $_, alias => lc($_) ) for @exposed;
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
- parcel => "Lucy",
- class_name => "Lucy::Index::IndexManager",
- make_pod => {
- methods => [
- qw(
- make_write_lock
- recycle
- set_folder
- get_folder
- get_host
- set_write_lock_timeout
- get_write_lock_timeout
- set_write_lock_interval
- get_write_lock_interval
- )
- ],
- synopsis => $synopsis,
- constructor => { sample => $constructor },
- },
+ parcel => "Lucy",
+ class_name => "Lucy::Index::IndexManager",
);
$binding->bind_constructor;
- $binding->bind_method( method => $_ ) for qw(
- Recycle
- Make_Write_Lock
- Make_Deletion_Lock
- Make_Merge_Lock
- Make_Snapshot_Read_Lock
- Highest_Seg_Num
- Make_Snapshot_Filename
- Set_Folder
- Get_Folder
- Get_Host
- Set_Write_Lock_Timeout
- Get_Write_Lock_Timeout
- Set_Write_Lock_Interval
- Get_Write_Lock_Interval
- Set_Merge_Lock_Timeout
- Get_Merge_Lock_Timeout
- Set_Merge_Lock_Interval
- Get_Merge_Lock_Interval
- Set_Deletion_Lock_Timeout
- Get_Deletion_Lock_Timeout
- Set_Deletion_Lock_Interval
- Get_Deletion_Lock_Interval
- );
+ $binding->bind_method( method => $_, alias => lc($_) ) for @bound;
+ $binding->set_pod_spec($pod_spec);
+
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
sub bind_indexreader {
- my $xs_code = <<'END_XS_CODE';
-MODULE = Lucy PACKAGE = Lucy::Index::IndexReader
-
-void
-set_race_condition_debug1(val_sv)
- SV *val_sv;
-PPCODE:
- CFISH_DECREF(lucy_PolyReader_race_condition_debug1);
- lucy_PolyReader_race_condition_debug1 = (lucy_CharBuf*)
- XSBind_maybe_sv_to_cfish_obj(val_sv, LUCY_CHARBUF, NULL);
- if (lucy_PolyReader_race_condition_debug1) {
- (void)CFISH_INCREF(lucy_PolyReader_race_condition_debug1);
- }
-
-int32_t
-debug1_num_passes()
-CODE:
- RETVAL = lucy_PolyReader_debug1_num_passes;
-OUTPUT: RETVAL
-END_XS_CODE
+ my @bound = qw(
+ Doc_Max
+ Doc_Count
+ Del_Count
+ Fetch
+ Obtain
+ Seg_Readers
+ Get_Components
+ );
+ my @exposed = qw(
+ Doc_Max
+ Doc_Count
+ Del_Count
+ Seg_Readers
+ Offsets
+ Fetch
+ Obtain
+ );
+ my $pod_spec = Clownfish::CFC::Binding::Perl::Pod->new;
my $synopsis = <<'END_SYNOPSIS';
my $reader = Lucy::Index::IndexReader->open(
index => '/path/to/index',
@@ -474,7 +448,6 @@ END_XS_CODE
}
}
END_SYNOPSIS
-
my $constructor = <<'END_CONSTRUCTOR';
my $reader = Lucy::Index::IndexReader->open(
index => '/path/to/index', # required
@@ -482,116 +455,63 @@ END_SYNOPSIS
manager => $index_manager,
);
END_CONSTRUCTOR
-
- my $binding = Clownfish::CFC::Binding::Perl::Class->new(
- parcel => "Lucy",
- class_name => "Lucy::Index::IndexReader",
- xs_code => $xs_code,
- make_pod => {
- synopsis => $synopsis,
- constructor => {
- name => 'open',
- func => 'do_open',
- sample => $constructor,
- },
- methods => [
- qw(
- doc_max
- doc_count
- del_count
- seg_readers
- offsets
- fetch
- obtain
- )
- ]
- },
- );
- $binding->bind_constructor(
+ $pod_spec->set_synopsis($synopsis);
+ $pod_spec->add_constructor(
alias => 'open',
initializer => 'do_open',
+ sample => $constructor,
);
- $binding->bind_method( method => $_ ) for qw(
- Doc_Max
- Doc_Count
- Del_Count
- Fetch
- Obtain
- Seg_Readers
- Get_Components
- );
- $binding->bind_method( alias => '_offsets', method => 'Offsets' );
- Clownfish::CFC::Binding::Perl::Class->register($binding);
-}
+ $pod_spec->add_method( method => $_, alias => lc($_) ) for @exposed;
-sub bind_indexer {
my $xs_code = <<'END_XS_CODE';
-MODULE = Lucy PACKAGE = Lucy::Index::Indexer
+MODULE = Lucy PACKAGE = Lucy::Index::IndexReader
-int32_t
-CREATE(...)
-CODE:
- CHY_UNUSED_VAR(items);
- RETVAL = lucy_Indexer_CREATE;
-OUTPUT: RETVAL
+void
+set_race_condition_debug1(val_sv)
+ SV *val_sv;
+PPCODE:
+ CFISH_DECREF(lucy_PolyReader_race_condition_debug1);
+ lucy_PolyReader_race_condition_debug1 = (lucy_CharBuf*)
+ XSBind_maybe_sv_to_cfish_obj(val_sv, LUCY_CHARBUF, NULL);
+ if (lucy_PolyReader_race_condition_debug1) {
+ (void)CFISH_INCREF(lucy_PolyReader_race_condition_debug1);
+ }
int32_t
-TRUNCATE(...)
+debug1_num_passes()
CODE:
- CHY_UNUSED_VAR(items);
- RETVAL = lucy_Indexer_TRUNCATE;
+ RETVAL = lucy_PolyReader_debug1_num_passes;
OUTPUT: RETVAL
+END_XS_CODE
-void
-add_doc(self, ...)
- lucy_Indexer *self;
-PPCODE:
-{
- lucy_Doc *doc = NULL;
- SV *doc_sv = NULL;
- float boost = 1.0;
-
- if (items == 2) {
- doc_sv = ST(1);
- }
- else if (items > 2) {
- chy_bool_t args_ok
- = XSBind_allot_params(&(ST(0)), 1, items,
- "Lucy::Index::Indexer::add_doc_PARAMS",
- ALLOT_SV(&doc_sv, "doc", 3, true),
- ALLOT_F32(&boost, "boost", 5, false),
- NULL);
- if (!args_ok) {
- CFISH_RETHROW(CFISH_INCREF(cfish_Err_get_error()));
- }
- }
- else if (items == 1) {
- CFISH_THROW(LUCY_ERR, "Missing required argument 'doc'");
- }
-
- // Either get a Doc or use the stock doc.
- if (sv_isobject(doc_sv)
- && sv_derived_from(doc_sv, "Lucy::Document::Doc")
- ) {
- IV tmp = SvIV(SvRV(doc_sv));
- doc = INT2PTR(lucy_Doc*, tmp);
- }
- else if (XSBind_sv_defined(doc_sv) && SvROK(doc_sv)) {
- HV *maybe_fields = (HV*)SvRV(doc_sv);
- if (SvTYPE((SV*)maybe_fields) == SVt_PVHV) {
- doc = Lucy_Indexer_Get_Stock_Doc(self);
- Lucy_Doc_Set_Fields(doc, maybe_fields);
- }
- }
- if (!doc) {
- THROW(LUCY_ERR, "Need either a hashref or a %o",
- Lucy_VTable_Get_Name(LUCY_DOC));
- }
+ my $binding = Clownfish::CFC::Binding::Perl::Class->new(
+ parcel => "Lucy",
+ class_name => "Lucy::Index::IndexReader",
+ xs_code => $xs_code,
+ );
+ $binding->bind_constructor(
+ alias => 'open',
+ initializer => 'do_open',
+ );
+ $binding->bind_method( method => $_, alias => lc($_) ) for @bound;
+ $binding->bind_method( alias => '_offsets', method => 'Offsets' );
+ $binding->set_pod_spec($pod_spec);
- Lucy_Indexer_Add_Doc(self, doc, boost);
+ Clownfish::CFC::Binding::Perl::Class->register($binding);
}
-END_XS_CODE
+sub bind_indexer {
+ my @exposed = qw(
+ Add_Index
+ Optimize
+ Commit
+ Prepare_Commit
+ Delete_By_Term
+ Delete_By_Query
+ );
+ my @bound = @exposed;
+
+ my $pod_spec = Clownfish::CFC::Binding::Perl::Pod->new;
my $synopsis = <<'END_SYNOPSIS';
my $indexer = Lucy::Index::Indexer->new(
schema => $schema,
@@ -606,7 +526,6 @@ END_XS_CODE
}
$indexer->commit;
END_SYNOPSIS
-
my $constructor = <<'END_NEW';
=head2 new( I<[labeled params]> )
@@ -646,9 +565,6 @@ B<manager> - An IndexManager.
=back
END_NEW
-
- # Override is necessary because there's no standard way to explain
- # hash/hashref across multiple host languages.
my $add_doc_pod = <<'END_ADD_DOC_POD';
=head2 add_doc(...)
@@ -673,49 +589,104 @@ be attached to a Lucy::Document::Doc obj
B<boost> - A floating point weight which affects how this document scores.
-=back
+=back
+
+END_ADD_DOC_POD
+ $pod_spec->set_synopsis($synopsis);
+
+ # Override necessary because of different handling for flags.
+ $pod_spec->add_constructor( alias => 'new', pod => $constructor );
+
+ # Override is necessary because there's no standard way to explain
+ # hash/hashref across multiple host languages.
+ $pod_spec->add_method(
+ method => 'Add_Doc',
+ alias => 'add_doc',
+ pod => $add_doc_pod,
+ );
+ $pod_spec->add_method( method => $_, alias => lc($_) ) for @exposed;
+
+ my $xs_code = <<'END_XS_CODE';
+MODULE = Lucy PACKAGE = Lucy::Index::Indexer
+
+int32_t
+CREATE(...)
+CODE:
+ CHY_UNUSED_VAR(items);
+ RETVAL = lucy_Indexer_CREATE;
+OUTPUT: RETVAL
+
+int32_t
+TRUNCATE(...)
+CODE:
+ CHY_UNUSED_VAR(items);
+ RETVAL = lucy_Indexer_TRUNCATE;
+OUTPUT: RETVAL
+
+void
+add_doc(self, ...)
+ lucy_Indexer *self;
+PPCODE:
+{
+ lucy_Doc *doc = NULL;
+ SV *doc_sv = NULL;
+ float boost = 1.0;
+
+ if (items == 2) {
+ doc_sv = ST(1);
+ }
+ else if (items > 2) {
+ chy_bool_t args_ok
+ = XSBind_allot_params(&(ST(0)), 1, items,
+ "Lucy::Index::Indexer::add_doc_PARAMS",
+ ALLOT_SV(&doc_sv, "doc", 3, true),
+ ALLOT_F32(&boost, "boost", 5, false),
+ NULL);
+ if (!args_ok) {
+ CFISH_RETHROW(CFISH_INCREF(cfish_Err_get_error()));
+ }
+ }
+ else if (items == 1) {
+ CFISH_THROW(LUCY_ERR, "Missing required argument 'doc'");
+ }
+
+ // Either get a Doc or use the stock doc.
+ if (sv_isobject(doc_sv)
+ && sv_derived_from(doc_sv, "Lucy::Document::Doc")
+ ) {
+ IV tmp = SvIV(SvRV(doc_sv));
+ doc = INT2PTR(lucy_Doc*, tmp);
+ }
+ else if (XSBind_sv_defined(doc_sv) && SvROK(doc_sv)) {
+ HV *maybe_fields = (HV*)SvRV(doc_sv);
+ if (SvTYPE((SV*)maybe_fields) == SVt_PVHV) {
+ doc = Lucy_Indexer_Get_Stock_Doc(self);
+ Lucy_Doc_Set_Fields(doc, maybe_fields);
+ }
+ }
+ if (!doc) {
+ THROW(LUCY_ERR, "Need either a hashref or a %o",
+ Lucy_VTable_Get_Name(LUCY_DOC));
+ }
-END_ADD_DOC_POD
+ Lucy_Indexer_Add_Doc(self, doc, boost);
+}
+END_XS_CODE
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
parcel => "Lucy",
class_name => "Lucy::Index::Indexer",
xs_code => $xs_code,
- make_pod => {
- methods => [
- { name => 'add_doc', pod => $add_doc_pod },
- qw(
- add_index
- optimize
- commit
- prepare_commit
- delete_by_term
- delete_by_query
- )
- ],
- synopsis => $synopsis,
- constructors => [ { pod => $constructor } ],
- },
);
$binding->bind_constructor( alias => '_new' );
- $binding->bind_method( method => $_ ) for qw(
- Delete_By_Term
- Delete_By_Query
- Add_Index
- Commit
- Prepare_Commit
- Optimize
- );
+ $binding->bind_method( method => $_, alias => lc($_) ) for @bound;
+ $binding->set_pod_spec($pod_spec);
+
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
sub bind_inverter {
- my $binding = Clownfish::CFC::Binding::Perl::Class->new(
- parcel => "Lucy",
- class_name => "Lucy::Index::Inverter",
- );
- $binding->bind_constructor;
- $binding->bind_method( method => $_ ) for qw(
+ my @bound = qw(
Get_Doc
Iterate
Next
@@ -727,10 +698,27 @@ sub bind_inverter {
Get_Similarity
Get_Inversion
);
+
+ my $binding = Clownfish::CFC::Binding::Perl::Class->new(
+ parcel => "Lucy",
+ class_name => "Lucy::Index::Inverter",
+ );
+ $binding->bind_constructor;
+ $binding->bind_method( method => $_, alias => lc($_) ) for @bound;
+
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
sub bind_lexicon {
+ my @exposed = qw(
+ Seek
+ Next
+ Get_Term
+ Reset
+ );
+ my @bound = ( @exposed, 'Get_Field' );
+
+ my $pod_spec = Clownfish::CFC::Binding::Perl::Pod->new;
my $synopsis = <<'END_SYNOPSIS';
my $lex_reader = $seg_reader->obtain('Lucy::Index::LexiconReader');
my $lexicon = $lex_reader->lexicon( field => 'content' );
@@ -738,46 +726,40 @@ sub bind_lexicon {
print $lexicon->get_term . "\n";
}
END_SYNOPSIS
+ $pod_spec->set_synopsis($synopsis);
+ $pod_spec->add_method( method => $_, alias => lc($_) ) for @exposed;
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
- parcel => "Lucy",
- class_name => "Lucy::Index::Lexicon",
- make_pod => {
- synopsis => $synopsis,
- methods => [qw( seek next get_term reset )],
- },
+ parcel => "Lucy",
+ class_name => "Lucy::Index::Lexicon",
);
$binding->bind_constructor;
- $binding->bind_method( method => $_ ) for qw(
- Seek
- Next
- Reset
- Get_Term
- Get_Field
- );
+ $binding->bind_method( method => $_, alias => lc($_) ) for @bound;
+ $binding->set_pod_spec($pod_spec);
+
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
sub bind_lexiconreader {
+ my @exposed = qw( Lexicon Doc_Freq );
+ my @bound = ( @exposed, 'Fetch_Term_Info' );
+
+ my $pod_spec = Clownfish::CFC::Binding::Perl::Pod->new;
my $synopsis = <<'END_SYNOPSIS';
my $lex_reader = $seg_reader->obtain("Lucy::Index::LexiconReader");
my $lexicon = $lex_reader->lexicon( field => 'title' );
END_SYNOPSIS
+ $pod_spec->set_synopsis($synopsis);
+ $pod_spec->add_method( method => $_, alias => lc($_) ) for @exposed;
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
- parcel => "Lucy",
- class_name => "Lucy::Index::LexiconReader",
- make_pod => {
- synopsis => $synopsis,
- methods => [qw( lexicon doc_freq )],
- },
+ parcel => "Lucy",
+ class_name => "Lucy::Index::LexiconReader",
);
$binding->bind_constructor;
- $binding->bind_method( method => $_ ) for qw(
- Lexicon
- Doc_Freq
- Fetch_Term_Info
- );
+ $binding->bind_method( method => $_, alias => lc($_) ) for @bound;
+ $binding->set_pod_spec($pod_spec);
+
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
@@ -809,6 +791,9 @@ sub bind_polylexicon {
}
sub bind_polyreader {
+ my @bound = qw( Get_Seg_Readers );
+
+ my $pod_spec = Clownfish::CFC::Binding::Perl::Pod->new;
my $synopsis = <<'END_SYNOPSIS';
my $polyreader = Lucy::Index::IndexReader->open(
index => '/path/to/index',
@@ -819,6 +804,7 @@ sub bind_polyreader {
print " $doc_id: $doc->{title}\n";
}
END_SYNOPSIS
+ $pod_spec->set_synopsis($synopsis);
my $xs_code = <<'END_XS_CODE';
MODULE = Lucy PACKAGE = Lucy::Index::PolyReader
@@ -834,30 +820,46 @@ OUTPUT: RETVAL
END_XS_CODE
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
- parcel => "Lucy",
- class_name => "Lucy::Index::PolyReader",
- make_pod => { synopsis => $synopsis },
- xs_code => $xs_code,
+ parcel => "Lucy",
+ class_name => "Lucy::Index::PolyReader",
+ xs_code => $xs_code,
);
$binding->bind_constructor;
$binding->bind_constructor( alias => 'open', initializer => 'do_open' );
- $binding->bind_method( method => $_ ) for qw( Get_Seg_Readers );
+ $binding->bind_method( method => $_, alias => lc($_) ) for @bound;
+ $binding->set_pod_spec($pod_spec);
+
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
sub bind_posting {
+ my @bound = qw( Get_Doc_ID );
+
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
- parcel => "Lucy",
- class_name => "Lucy::Index::Posting",
- # make_pod => {
- # synopsis => " # Abstract base class.\n",
- # },
+ parcel => "Lucy",
+ class_name => "Lucy::Index::Posting",
);
- $binding->bind_method( method => $_ ) for qw( Get_Doc_ID );
+ $binding->bind_method( method => $_, alias => lc($_) ) for @bound;
+
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
sub bind_postinglist {
+ my @bound = qw(
+ Seek
+ Get_Posting
+ Get_Doc_Freq
+ Make_Matcher
+ );
+ my @exposed = qw(
+ Next
+ Advance
+ Get_Doc_ID
+ Get_Doc_Freq
+ Seek
+ );
+
+ my $pod_spec = Clownfish::CFC::Binding::Perl::Pod->new;
my $synopsis = <<'END_SYNOPSIS';
my $posting_list_reader
= $seg_reader->obtain("Lucy::Index::PostingListReader");
@@ -869,34 +871,25 @@ sub bind_postinglist {
say "Matching doc id: $doc_id";
}
END_SYNOPSIS
+ $pod_spec->set_synopsis($synopsis);
+ $pod_spec->add_method( method => $_, alias => lc($_) ) for @exposed;
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
- parcel => "Lucy",
- class_name => "Lucy::Index::PostingList",
- make_pod => {
- synopsis => $synopsis,
- methods => [
- qw(
- next
- advance
- get_doc_id
- get_doc_freq
- seek
- )
- ],
- },
+ parcel => "Lucy",
+ class_name => "Lucy::Index::PostingList",
);
$binding->bind_constructor;
- $binding->bind_method( method => $_ ) for qw(
- Seek
- Get_Posting
- Get_Doc_Freq
- Make_Matcher
- );
+ $binding->bind_method( method => $_, alias => lc($_) ) for @bound;
+ $binding->set_pod_spec($pod_spec);
+
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
sub bind_postinglistreader {
+ my @exposed = qw( Posting_List );
+ my @bound = ( @exposed, 'Get_Lex_Reader' );
+
+ my $pod_spec = Clownfish::CFC::Binding::Perl::Pod->new;
my $synopsis = <<'END_SYNOPSIS';
my $posting_list_reader
= $seg_reader->obtain("Lucy::Index::PostingListReader");
@@ -905,20 +898,17 @@ sub bind_postinglistreader {
term => 'foo',
);
END_SYNOPSIS
+ $pod_spec->set_synopsis($synopsis);
+ $pod_spec->add_method( method => $_, alias => lc($_) ) for @exposed;
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
- parcel => "Lucy",
- class_name => "Lucy::Index::PostingListReader",
- make_pod => {
- synopsis => $synopsis,
- methods => [qw( posting_list )],
- },
+ parcel => "Lucy",
+ class_name => "Lucy::Index::PostingListReader",
);
$binding->bind_constructor;
- $binding->bind_method( method => $_ ) for qw(
- Posting_List
- Get_Lex_Reader
- );
+ $binding->bind_method( method => $_, alias => lc($_) ) for @bound;
+ $binding->set_pod_spec($pod_spec);
+
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
@@ -948,33 +938,44 @@ END_XS
xs_code => $xs_code,
);
$binding->bind_constructor;
+
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
sub bind_seglexicon {
+ my @bound = qw( Get_Term_Info Get_Field_Num );
+
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
parcel => "Lucy",
class_name => "Lucy::Index::SegLexicon",
);
$binding->bind_constructor;
- $binding->bind_method( method => $_ ) for qw(
- Get_Term_Info
- Get_Field_Num
- );
+ $binding->bind_method( method => $_, alias => lc($_) ) for @bound;
+
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
sub bind_segpostinglist {
+ my @bound = qw( Get_Post_Stream Get_Count );
+
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
- parcel => "Lucy",
- class_name => "Lucy::Index::SegPostingList",
+ parcel => "Lucy",
+ class_name => "Lucy::Index::SegPostingList",
);
$binding->bind_constructor;
- $binding->bind_method( method => $_ ) for qw( Get_Post_Stream Get_Count );
+ $binding->bind_method( method => $_, alias => lc($_) ) for @bound;
+
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
sub bind_segreader {
+ my @exposed = qw(
+ Get_Seg_Name
+ Get_Seg_Num
+ );
+ my @bound = ( @exposed, 'Register' );
+
+ my $pod_spec = Clownfish::CFC::Binding::Perl::Pod->new;
my $synopsis = <<'END_SYNOPSIS';
my $polyreader = Lucy::Index::IndexReader->open(
index => '/path/to/index',
@@ -991,49 +992,68 @@ sub bind_segreader {
}
}
END_SYNOPSIS
+ $pod_spec->set_synopsis($synopsis);
+ $pod_spec->add_method( method => $_, alias => lc($_) ) for @exposed;
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
- parcel => "Lucy",
- class_name => "Lucy::Index::SegReader",
- make_pod => {
- synopsis => $synopsis,
- methods => [qw( Get_Seg_Name Get_Seg_Num )],
- },
+ parcel => "Lucy",
+ class_name => "Lucy::Index::SegReader",
);
$binding->bind_constructor;
- $binding->bind_method( method => $_ ) for qw(
- Get_Seg_Name
- Get_Seg_Num
- Register
- );
+ $binding->bind_method( method => $_, alias => lc($_) ) for @bound;
+ $binding->set_pod_spec($pod_spec);
+
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
sub bind_segwriter {
- my $binding = Clownfish::CFC::Binding::Perl::Class->new(
- parcel => "Lucy",
- class_name => "Lucy::Index::SegWriter",
- make_pod => {
- methods => [
- qw(
- add_doc
- add_writer
- register
- fetch
- )
- ],
- }
- );
- $binding->bind_constructor;
- $binding->bind_method( method => $_ ) for qw(
+ my @bound = qw(
Add_Writer
Register
Fetch
);
+ my @exposed = ( 'Add_Doc', @bound );
+
+ my $pod_spec = Clownfish::CFC::Binding::Perl::Pod->new;
+ $pod_spec->add_method( method => $_, alias => lc($_) ) for @exposed;
+
+ my $binding = Clownfish::CFC::Binding::Perl::Class->new(
+ parcel => "Lucy",
+ class_name => "Lucy::Index::SegWriter",
+ );
+ $binding->bind_constructor;
+ $binding->bind_method( method => $_, alias => lc($_) ) for @bound;
+ $binding->set_pod_spec($pod_spec);
+
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
sub bind_segment {
+ my @bound = qw(
+ Add_Field
+ Fetch_Metadata
+ Field_Num
+ Field_Name
+ Get_Name
+ Get_Number
+ Set_Count
+ Get_Count
+ Write_File
+ Read_File
+ );
+ my @exposed = qw(
+ Add_Field
+ Store_Metadata
+ Fetch_Metadata
+ Field_Num
+ Field_Name
+ Get_Name
+ Get_Number
+ Set_Count
+ Get_Count
+ );
+
+ my $pod_spec = Clownfish::CFC::Binding::Perl::Pod->new;
my $synopsis = <<'END_SYNOPSIS';
# Index-time.
package MyDataWriter;
@@ -1065,60 +1085,39 @@ sub bind_segment {
return $self;
}
END_SYNOPSIS
+ $pod_spec->set_synopsis($synopsis);
+ $pod_spec->add_method( method => $_, alias => lc($_) ) for @exposed;
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
- parcel => "Lucy",
- class_name => "Lucy::Index::Segment",
- make_pod => {
- synopsis => $synopsis,
- methods => [
- qw(
- add_field
- store_metadata
- fetch_metadata
- field_num
- field_name
- get_name
- get_number
- set_count
- get_count
- )
- ],
- },
+ parcel => "Lucy",
+ class_name => "Lucy::Index::Segment",
);
$binding->bind_constructor;
- $binding->bind_method( method => $_ ) for qw(
- Add_Field
- Fetch_Metadata
- Field_Num
- Field_Name
- Get_Name
- Get_Number
- Set_Count
- Get_Count
- Write_File
- Read_File
- );
+ $binding->bind_method( method => $_, alias => lc($_) ) for @bound;
$binding->bind_method(
alias => '_store_metadata',
method => 'Store_Metadata',
);
+ $binding->set_pod_spec($pod_spec);
+
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
sub bind_similarity {
- my $xs_code = <<'END_XS_CODE';
-MODULE = Lucy PACKAGE = Lucy::Index::Similarity
-
-SV*
-get_norm_decoder(self)
- lucy_Similarity *self;
-CODE:
- RETVAL = newSVpvn((char*)Lucy_Sim_Get_Norm_Decoder(self),
- (256 * sizeof(float)));
-OUTPUT: RETVAL
-END_XS_CODE
+ my @bound = qw(
+ IDF
+ TF
+ Encode_Norm
+ Decode_Norm
+ Query_Norm
+ Length_Norm
+ Coord
+ );
+ my @exposed = qw(
+ Length_Norm
+ );
+ my $pod_spec = Clownfish::CFC::Binding::Perl::Pod->new;
my $synopsis = <<'END_SYNOPSIS';
package MySimilarity;
@@ -1129,79 +1128,76 @@ END_XS_CODE
sub make_similarity { MySimilarity->new }
END_SYNOPSIS
-
my $constructor = qq| my \$sim = Lucy::Index::Similarity->new;\n|;
+ $pod_spec->set_synopsis($synopsis);
+ $pod_spec->add_constructor( alias => 'new', sample => $constructor, );
+ $pod_spec->add_method( method => $_, alias => lc($_) ) for @exposed;
+
+ my $xs_code = <<'END_XS_CODE';
+MODULE = Lucy PACKAGE = Lucy::Index::Similarity
+
+SV*
+get_norm_decoder(self)
+ lucy_Similarity *self;
+CODE:
+ RETVAL = newSVpvn((char*)Lucy_Sim_Get_Norm_Decoder(self),
+ (256 * sizeof(float)));
+OUTPUT: RETVAL
+END_XS_CODE
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
- parcel => "Lucy",
- class_name => "Lucy::Index::Similarity",
- xs_code => $xs_code,
- make_pod => {
- synopsis => $synopsis,
- constructor => { sample => $constructor },
- methods => [qw( length_norm )],
- }
+ parcel => "Lucy",
+ class_name => "Lucy::Index::Similarity",
+ xs_code => $xs_code,
);
$binding->bind_constructor;
- $binding->bind_method( method => $_ ) for qw(
- IDF
- TF
- Encode_Norm
- Decode_Norm
- Query_Norm
- Length_Norm
- Coord
- );
+ $binding->bind_method( method => $_, alias => lc($_) ) for @bound;
+ $binding->set_pod_spec($pod_spec);
+
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
sub bind_snapshot {
+ my @exposed = qw(
+ List
+ Num_Entries
+ Add_Entry
+ Delete_Entry
+ Read_File
+ Write_File
+ Set_Path
+ Get_Path
+ );
+ my @bound = @exposed;
+
+ my $pod_spec = Clownfish::CFC::Binding::Perl::Pod->new;
my $synopsis = <<'END_SYNOPSIS';
my $snapshot = Lucy::Index::Snapshot->new;
$snapshot->read_file( folder => $folder ); # load most recent snapshot
my $files = $snapshot->list;
print "$_\n" for @$files;
END_SYNOPSIS
-
my $constructor = <<'END_CONSTRUCTOR';
my $snapshot = Lucy::Index::Snapshot->new;
END_CONSTRUCTOR
+ $pod_spec->set_synopsis($synopsis);
+ $pod_spec->add_constructor( alias => 'new', sample => $constructor, );
+ $pod_spec->add_method( method => $_, alias => lc($_) ) for @exposed;
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
- parcel => "Lucy",
- class_name => "Lucy::Index::Snapshot",
- make_pod => {
- synopsis => $synopsis,
- constructor => { sample => $constructor },
- methods => [
- qw(
- list
- num_entries
- add_entry
- delete_entry
- read_file
- write_file
- set_path
- get_path
- )
- ],
- },
+ parcel => "Lucy",
+ class_name => "Lucy::Index::Snapshot",
);
$binding->bind_constructor;
- $binding->bind_method( method => $_ ) for qw(
- List
- Num_Entries
- Add_Entry
- Delete_Entry
- Read_File
- Write_File
- Set_Path
- Get_Path
- );
+ $binding->bind_method( method => $_, alias => lc($_) ) for @bound;
+ $binding->set_pod_spec($pod_spec);
+
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
sub bind_sortcache {
+ my @bound = qw( Ordinal Find );
+
my $xs_code = <<'END_XS_CODE';
MODULE = Lucy PACKAGE = Lucy::Index::SortCache
@@ -1234,17 +1230,19 @@ END_XS_CODE
class_name => "Lucy::Index::SortCache",
xs_code => $xs_code,
);
- $binding->bind_method( method => $_ ) for qw( Ordinal Find );
+ $binding->bind_method( method => $_, alias => lc($_) ) for @bound;
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
sub bind_sortreader {
+ my @bound = qw( Fetch_Sort_Cache );
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
parcel => "Lucy",
class_name => "Lucy::Index::SortReader",
);
$binding->bind_constructor;
- $binding->bind_method( method => $_ ) for qw( Fetch_Sort_Cache );
+ $binding->bind_method( method => $_, alias => lc($_) ) for @bound;
+
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
@@ -1254,6 +1252,7 @@ sub bind_defaultsortreader {
class_name => "Lucy::Index::DefaultSortReader",
);
$binding->bind_constructor;
+
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
@@ -1274,16 +1273,12 @@ END_XS
xs_code => $xs_code,
);
$binding->bind_constructor;
+
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
sub bind_terminfo {
- my $binding = Clownfish::CFC::Binding::Perl::Class->new(
- parcel => "Lucy",
- class_name => "Lucy::Index::TermInfo",
- );
- $binding->bind_constructor;
- $binding->bind_method( method => $_ ) for qw(
+ my @bound = qw(
Get_Doc_Freq
Get_Lex_FilePos
Get_Post_FilePos
@@ -1294,20 +1289,31 @@ sub bind_terminfo {
Set_Skip_FilePos
Reset
);
+
+ my $binding = Clownfish::CFC::Binding::Perl::Class->new(
+ parcel => "Lucy",
+ class_name => "Lucy::Index::TermInfo",
+ );
+ $binding->bind_constructor;
+ $binding->bind_method( method => $_, alias => lc($_) ) for @bound;
+
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
sub bind_termvector {
+ my @bound = qw(
+ Get_Positions
+ Get_Start_Offsets
+ Get_End_Offsets
+ );
+
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
parcel => "Lucy",
class_name => "Lucy::Index::TermVector",
);
$binding->bind_constructor;
- $binding->bind_method( method => $_ ) for qw(
- Get_Positions
- Get_Start_Offsets
- Get_End_Offsets
- );
+ $binding->bind_method( method => $_, alias => lc($_) ) for @bound;
+
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
Modified: incubator/lucy/trunk/perl/buildlib/Lucy/Build/Binding/Index/Posting.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/perl/buildlib/Lucy/Build/Binding/Index/Posting.pm?rev=1236028&r1=1236027&r2=1236028&view=diff
==============================================================================
--- incubator/lucy/trunk/perl/buildlib/Lucy/Build/Binding/Index/Posting.pm (original)
+++ incubator/lucy/trunk/perl/buildlib/Lucy/Build/Binding/Index/Posting.pm Thu Jan 26 02:48:39 2012
@@ -24,47 +24,25 @@ sub bind_all {
}
sub bind_matchposting {
- my $synopsis = <<'END_SYNOPSIS';
- # MatchPosting is used indirectly, by specifying in FieldType subclass.
- package MySchema::Category;
- use base qw( Lucy::Plan::FullTextType );
- sub posting {
- my $self = shift;
- return Lucy::Index::Posting::MatchPosting->new(@_);
- }
-END_SYNOPSIS
+ my @bound = qw( Get_Freq );
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
- parcel => "Lucy",
- class_name => "Lucy::Index::Posting::MatchPosting",
- # make_pod => {
- # synopsis => $synopsis,
- # }
+ parcel => "Lucy",
+ class_name => "Lucy::Index::Posting::MatchPosting",
);
$binding->bind_constructor;
- $binding->bind_method( method => $_ ) for qw( Get_Freq );
+ $binding->bind_method( method => $_, alias => lc($_) ) for @bound;
+
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
sub bind_richposting {
- my $synopsis = <<'END_SYNOPSIS';
- # RichPosting is used indirectly, by specifying in FieldType subclass.
- package MySchema::Category;
- use base qw( Lucy::Plan::FullTextType );
- sub posting {
- my $self = shift;
- return Lucy::Index::Posting::RichPosting->new(@_);
- }
-END_SYNOPSIS
-
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
- parcel => "Lucy",
- class_name => "Lucy::Index::Posting::RichPosting",
- # make_pod => {
- # synopsis => $synopsis,
- # }
+ parcel => "Lucy",
+ class_name => "Lucy::Index::Posting::RichPosting",
);
$binding->bind_constructor;
+
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
@@ -91,26 +69,13 @@ CODE:
OUTPUT: RETVAL
END_XS_CODE
- my $synopsis = <<'END_SYNOPSIS';
- # ScorePosting is used indirectly, by specifying in FieldType subclass.
- package MySchema::Category;
- use base qw( Lucy::Plan::FullTextType );
- # (It's the default, so you don't need to spec it.)
- # sub posting {
- # my $self = shift;
- # return Lucy::Index::Posting::ScorePosting->new(@_);
- # }
-END_SYNOPSIS
-
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
- parcel => "Lucy",
- class_name => "Lucy::Index::Posting::ScorePosting",
- xs_code => $xs_code,
- # make_pod => {
- # synopsis => $synopsis,
- # }
+ parcel => "Lucy",
+ class_name => "Lucy::Index::Posting::ScorePosting",
+ xs_code => $xs_code,
);
$binding->bind_constructor;
+
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
Modified: incubator/lucy/trunk/perl/buildlib/Lucy/Build/Binding/Lucy.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/perl/buildlib/Lucy/Build/Binding/Lucy.pm?rev=1236028&r1=1236027&r2=1236028&view=diff
==============================================================================
--- incubator/lucy/trunk/perl/buildlib/Lucy/Build/Binding/Lucy.pm (original)
+++ incubator/lucy/trunk/perl/buildlib/Lucy/Build/Binding/Lucy.pm Thu Jan 26 02:48:39 2012
@@ -20,6 +20,8 @@ sub bind_all {
my $class = shift;
$class->bind_lucy;
$class->bind_test;
+ $class->bind_testutils;
+ $class->bind_testqueryparsersyntax;
$class->bind_testschema;
}
@@ -74,14 +76,6 @@ END_XS_CODE
sub bind_test {
my $xs_code = <<'END_XS_CODE';
-MODULE = Lucy PACKAGE = Lucy::Test::TestUtils
-
-SV*
-doc_set()
-CODE:
- RETVAL = CFISH_OBJ_TO_SV_NOINC(lucy_TestUtils_doc_set());
-OUTPUT: RETVAL
-
MODULE = Lucy PACKAGE = Lucy::Test
void
@@ -293,7 +287,36 @@ PPCODE:
THROW(LUCY_ERR, "Unknown test id: %s", package);
}
}
+END_XS_CODE
+
+ my $binding = Clownfish::CFC::Binding::Perl::Class->new(
+ parcel => "Lucy",
+ class_name => "Lucy::Test",
+ xs_code => $xs_code,
+ );
+ Clownfish::CFC::Binding::Perl::Class->register($binding);
+}
+sub bind_testutils {
+ my $xs_code = <<'END_XS_CODE';
+MODULE = Lucy PACKAGE = Lucy::Test::TestUtils
+
+SV*
+doc_set()
+CODE:
+ RETVAL = CFISH_OBJ_TO_SV_NOINC(lucy_TestUtils_doc_set());
+OUTPUT: RETVAL
+END_XS_CODE
+ my $binding = Clownfish::CFC::Binding::Perl::Class->new(
+ parcel => "Lucy",
+ class_name => "Lucy::Test::TestUtils",
+ xs_code => $xs_code,
+ );
+ Clownfish::CFC::Binding::Perl::Class->register($binding);
+}
+
+sub bind_testqueryparsersyntax {
+ my $xs_code = <<'END_XS_CODE';
MODULE = Lucy PACKAGE = Lucy::Test::Search::TestQueryParserSyntax
void
@@ -305,7 +328,7 @@ END_XS_CODE
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
parcel => "Lucy",
- class_name => "Lucy::Test",
+ class_name => "Lucy::Test::Search::TestQueryParserSyntax",
xs_code => $xs_code,
);
Clownfish::CFC::Binding::Perl::Class->register($binding);