Author: marvin
Date: Wed Sep 26 22:17:04 2012
New Revision: 1390756
URL: http://svn.apache.org/viewvc?rev=1390756&view=rev
Log:
Adapt Clownfish::Build::Binding for new layout.
Modified:
lucy/trunk/clownfish/runtime/perl/buildlib/Clownfish/Build/Binding.pm
Modified: lucy/trunk/clownfish/runtime/perl/buildlib/Clownfish/Build/Binding.pm
URL:
http://svn.apache.org/viewvc/lucy/trunk/clownfish/runtime/perl/buildlib/Clownfish/Build/Binding.pm?rev=1390756&r1=1390755&r2=1390756&view=diff
==============================================================================
--- lucy/trunk/clownfish/runtime/perl/buildlib/Clownfish/Build/Binding.pm
(original)
+++ lucy/trunk/clownfish/runtime/perl/buildlib/Clownfish/Build/Binding.pm Wed
Sep 26 22:17:04 2012
@@ -12,7 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-package Lucy::Build::Binding::Object;
+package Clownfish::Build::Binding;
use strict;
use warnings;
@@ -21,13 +21,11 @@ $VERSION = eval $VERSION;
sub bind_all {
my $class = shift;
- $class->bind_bitvector;
$class->bind_bytebuf;
$class->bind_charbuf;
$class->bind_err;
$class->bind_hash;
$class->bind_host;
- $class->bind_i32array;
$class->bind_lockfreeregistry;
$class->bind_float32;
$class->bind_float64;
@@ -36,51 +34,6 @@ sub bind_all {
$class->bind_vtable;
}
-sub bind_bitvector {
- my @exposed = qw(
- Get
- Set
- Clear
- Clear_All
- And
- Or
- And_Not
- Xor
- Flip
- Flip_Block
- Next_Hit
- To_Array
- Grow
- Count
- );
-
- my $pod_spec = Clownfish::CFC::Binding::Perl::Pod->new;
- my $synopsis = <<'END_SYNOPSIS';
- my $bit_vec = Lucy::Object::BitVector->new( capacity => 8 );
- my $other = Lucy::Object::BitVector->new( capacity => 8 );
- $bit_vec->set($_) for ( 0, 2, 4, 6 );
- $other->set($_) for ( 1, 3, 5, 7 );
- $bit_vec->or($other);
- print "$_\n" for @{ $bit_vec->to_array }; # prints 0 through 7.
-END_SYNOPSIS
- my $constructor = <<'END_CONSTRUCTOR';
- my $bit_vec = Lucy::Object::BitVector->new(
- capacity => $doc_max + 1, # default 0,
- );
-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::Object::BitVector",
- );
- $binding->set_pod_spec($pod_spec);
-
- Clownfish::CFC::Binding::Perl::Class->register($binding);
-}
-
sub bind_bytebuf {
my $xs_code = <<'END_XS_CODE';
MODULE = Lucy PACKAGE = Clownfish::ByteBuf
@@ -395,82 +348,6 @@ END_XS_CODE
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
-sub bind_i32array {
- my $xs_code = <<'END_XS_CODE';
-MODULE = Lucy PACKAGE = Lucy::Object::I32Array
-
-SV*
-new(either_sv, ...)
- SV *either_sv;
-CODE:
-{
- SV *ints_sv = NULL;
- lucy_I32Array *self = NULL;
-
- chy_bool_t args_ok
- = XSBind_allot_params(&(ST(0)), 1, items,
- ALLOT_SV(&ints_sv, "ints", 4, true),
- NULL);
- if (!args_ok) {
- CFISH_RETHROW(CFISH_INCREF(cfish_Err_get_error()));
- }
-
- AV *ints_av = NULL;
- if (SvROK(ints_sv)) {
- ints_av = (AV*)SvRV(ints_sv);
- }
- if (ints_av && SvTYPE(ints_av) == SVt_PVAV) {
- int32_t size = av_len(ints_av) + 1;
- int32_t *ints = (int32_t*)LUCY_MALLOCATE(size * sizeof(int32_t));
- int32_t i;
-
- for (i = 0; i < size; i++) {
- SV **const sv_ptr = av_fetch(ints_av, i, 0);
- ints[i] = (sv_ptr && XSBind_sv_defined(*sv_ptr))
- ? SvIV(*sv_ptr)
- : 0;
- }
- self = (lucy_I32Array*)XSBind_new_blank_obj(either_sv);
- lucy_I32Arr_init(self, ints, size);
- }
- else {
- THROW(LUCY_ERR, "Required param 'ints' isn't an arrayref");
- }
-
- RETVAL = CFISH_OBJ_TO_SV_NOINC(self);
-}
-OUTPUT: RETVAL
-
-SV*
-to_arrayref(self)
- lucy_I32Array *self;
-CODE:
-{
- AV *out_av = newAV();
- uint32_t i;
- uint32_t size = Lucy_I32Arr_Get_Size(self);
-
- av_extend(out_av, size);
- for (i = 0; i < size; i++) {
- int32_t result = Lucy_I32Arr_Get(self, i);
- SV* result_sv = result == -1 ? newSV(0) : newSViv(result);
- av_push(out_av, result_sv);
- }
- RETVAL = newRV_noinc((SV*)out_av);
-}
-OUTPUT: RETVAL
-END_XS_CODE
-
- my $binding = Clownfish::CFC::Binding::Perl::Class->new(
- parcel => "Lucy",
- class_name => "Lucy::Object::I32Array",
- );
- $binding->append_xs($xs_code);
- $binding->exclude_constructor;
-
- Clownfish::CFC::Binding::Perl::Class->register($binding);
-}
-
sub bind_lockfreeregistry {
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
parcel => "Lucy",