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 2014/04/12 08:49:37 UTC
[lucy-commits] [02/27] Remove bundled Clownfish.
http://git-wip-us.apache.org/repos/asf/lucy/blob/1704c275/clownfish/runtime/perl/buildlib/Clownfish/Build.pm
----------------------------------------------------------------------
diff --git a/clownfish/runtime/perl/buildlib/Clownfish/Build.pm b/clownfish/runtime/perl/buildlib/Clownfish/Build.pm
deleted file mode 100644
index 9a28a55..0000000
--- a/clownfish/runtime/perl/buildlib/Clownfish/Build.pm
+++ /dev/null
@@ -1,281 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# 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.
-
-use strict;
-use warnings;
-
-use lib '../../compiler/perl/blib/arch';
-use lib '../../compiler/perl/blib/lib';
-
-package Clownfish::Build;
-
-# We want to subclass Clownfish::CFC::Perl::Build, but CFC might not be built
-# yet. So we look in 'clownfish/compiler/perl/lib' directly and cleanup @INC
-# afterwards.
-use lib '../../compiler/perl/lib';
-use base qw( Clownfish::CFC::Perl::Build );
-no lib '../../compiler/perl/lib';
-
-our $VERSION = '0.003000';
-$VERSION = eval $VERSION;
-
-use File::Spec::Functions qw( catdir catfile updir rel2abs );
-use File::Path qw( rmtree );
-use File::Copy qw( move );
-use Config;
-use Carp;
-use Cwd qw( getcwd );
-
-my @BASE_PATH = __PACKAGE__->cf_base_path;
-
-my $COMMON_SOURCE_DIR = catdir( @BASE_PATH, 'common' );
-my $CHARMONIZER_C = catfile( $COMMON_SOURCE_DIR, 'charmonizer.c' );
-my $CORE_SOURCE_DIR = catdir( @BASE_PATH, 'core' );
-my $CFC_DIR = catdir( @BASE_PATH, updir(), 'compiler', 'perl' );
-my $CFC_BUILD = catfile( $CFC_DIR, 'Build' );
-my $LIB_DIR = 'lib';
-
-sub new {
- my $self = shift->SUPER::new( recursive_test_files => 1, @_ );
-
- if ( $ENV{LUCY_VALGRIND} ) {
- my $optimize = $self->config('optimize') || '';
- $optimize =~ s/\-O\d+/-O1/g;
- $self->config( optimize => $optimize );
- }
-
- $self->charmonizer_params( charmonizer_c => $CHARMONIZER_C );
-
- $self->clownfish_params( autogen_header => $self->autogen_header );
-
- return $self;
-}
-
-sub _run_make {
- my ( $self, %params ) = @_;
- my @command = @{ $params{args} };
- my $dir = $params{dir};
- my $current_directory = getcwd();
- chdir $dir if $dir;
- unshift @command, 'CC=' . $self->config('cc');
- if ( $self->config('cc') =~ /^cl\b/ ) {
- unshift @command, "-f", "Makefile.MSVC";
- }
- elsif ( $^O =~ /mswin/i ) {
- unshift @command, "-f", "Makefile.MinGW";
- }
- unshift @command, "$Config{make}";
- system(@command) and confess("$Config{make} failed");
- chdir $current_directory if $dir;
-}
-
-sub ACTION_cfc {
- my $self = shift;
- my $old_dir = getcwd();
- chdir($CFC_DIR);
- if ( !-f 'Build' ) {
- print "\nBuilding Clownfish compiler... \n";
- system("$^X Build.PL");
- system("$^X Build code");
- print "\nFinished building Clownfish compiler.\n\n";
- }
- chdir($old_dir);
-}
-
-sub ACTION_copy_clownfish_includes {
- my $self = shift;
-
- $self->dispatch('charmony');
-
- $self->SUPER::ACTION_copy_clownfish_includes;
-
- $self->cf_copy_include_file( 'charmony.h' );
- $self->cf_copy_include_file( 'XSBind.h' );
-}
-
-sub ACTION_clownfish {
- my $self = shift;
-
- $self->dispatch('charmony');
- $self->dispatch('cfc');
-
- $self->SUPER::ACTION_clownfish;
-}
-
-sub ACTION_suppressions {
- my $self = shift;
- my $LOCAL_SUPP = 'local.supp';
- return
- if $self->up_to_date( '../devel/bin/valgrind_triggers.pl',
- $LOCAL_SUPP );
-
- # Generate suppressions.
- print "Writing $LOCAL_SUPP...\n";
- $self->add_to_cleanup($LOCAL_SUPP);
- my $command
- = "yes | "
- . $self->_valgrind_base_command
- . "--gen-suppressions=yes "
- . $self->perl
- . " ../devel/bin/valgrind_triggers.pl 2>&1";
- my $suppressions = `$command`;
- $suppressions =~ s/^==.*?\n//mg;
- $suppressions =~ s/^--.*?\n//mg;
- my $rule_number = 1;
-
- while ( $suppressions =~ /<insert.a.*?>/ ) {
- $suppressions =~ s/^\s*<insert.a.*?>/{\n <core_perl_$rule_number>/m;
- $rule_number++;
- }
-
- # Change e.g. fun:_vgrZU_libcZdsoZa_calloc to fun:calloc
- $suppressions =~ s/fun:\w+_((m|c|re)alloc)/fun:$1/g;
-
- # Write local suppressions file.
- open( my $supp_fh, '>', $LOCAL_SUPP )
- or confess("Can't open '$LOCAL_SUPP': $!");
- print $supp_fh $suppressions;
-}
-
-sub _valgrind_base_command {
- return
- "PERL_DESTRUCT_LEVEL=2 LUCY_VALGRIND=1 valgrind "
- . "--leak-check=yes "
- . "--show-reachable=yes "
- . "--num-callers=10 "
- . "--dsymutil=yes "
- . "--suppressions=../devel/conf/lucyperl.supp ";
-}
-
-# Run the entire test suite under Valgrind.
-#
-# For this to work, Lucy must be compiled with the LUCY_VALGRIND environment
-# variable set to a true value, under a debugging Perl.
-#
-# A custom suppressions file will probably be needed -- use your judgment.
-# To pass in one or more local suppressions files, provide a comma separated
-# list like so:
-#
-# $ ./Build test_valgrind --suppressions=foo.supp,bar.supp
-sub ACTION_test_valgrind {
- my $self = shift;
- die "Must be run under a perl that was compiled with -DDEBUGGING"
- unless $self->config('ccflags') =~ /-D?DEBUGGING\b/;
- if ( !$ENV{LUCY_VALGRIND} ) {
- warn "\$ENV{LUCY_VALGRIND} not true -- possible false positives";
- }
- $self->dispatch('code');
- $self->dispatch('suppressions');
-
- # Unbuffer STDOUT, grab test file names and suppressions files.
- $|++;
- my $t_files = $self->find_test_files; # not public M::B API, may fail
- my $valgrind_command = $self->_valgrind_base_command;
- $valgrind_command .= "--suppressions=local.supp ";
-
- if ( my $local_supp = $self->args('suppressions') ) {
- for my $supp ( split( ',', $local_supp ) ) {
- $valgrind_command .= "--suppressions=$supp ";
- }
- }
-
- # Iterate over test files.
- my @failed;
- for my $t_file (@$t_files) {
-
- # Run test file under Valgrind.
- print "Testing $t_file...";
- die "Can't find '$t_file'" unless -f $t_file;
- my $command = "$valgrind_command $^X -Mblib $t_file 2>&1";
- my $output = "\n" . ( scalar localtime(time) ) . "\n$command\n";
- $output .= `$command`;
-
- # Screen-scrape Valgrind output, looking for errors and leaks.
- if ( $?
- or $output =~ /ERROR SUMMARY:\s+[^0\s]/
- or $output =~ /definitely lost:\s+[^0\s]/
- or $output =~ /possibly lost:\s+[^0\s]/
- or $output =~ /still reachable:\s+[^0\s]/ )
- {
- print " failed.\n";
- push @failed, $t_file;
- print "$output\n";
- }
- else {
- print " succeeded.\n";
- }
- }
-
- # If there are failed tests, print a summary list.
- if (@failed) {
- print "\nFailed "
- . scalar @failed . "/"
- . scalar @$t_files
- . " test files:\n "
- . join( "\n ", @failed ) . "\n";
- exit(1);
- }
-}
-
-sub autogen_header {
- my $self = shift;
- return <<"END_AUTOGEN";
-/***********************************************
-
- !!!! DO NOT EDIT !!!!
-
- This file was auto-generated by Build.PL.
-
- ***********************************************/
-
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-END_AUTOGEN
-}
-
-# Run the cleanup targets for independent prerequisite builds.
-sub _clean_prereq_builds {
- my $self = shift;
- if ( -e $CFC_BUILD ) {
- my $old_dir = getcwd();
- chdir $CFC_DIR;
- system("$^X Build realclean")
- and die "Clownfish clean failed";
- chdir $old_dir;
- }
-}
-
-sub ACTION_clean {
- my $self = shift;
- _clean_prereq_builds($self);
- $self->SUPER::ACTION_clean;
-}
-
-1;
-
http://git-wip-us.apache.org/repos/asf/lucy/blob/1704c275/clownfish/runtime/perl/buildlib/Clownfish/Build/Binding.pm
----------------------------------------------------------------------
diff --git a/clownfish/runtime/perl/buildlib/Clownfish/Build/Binding.pm b/clownfish/runtime/perl/buildlib/Clownfish/Build/Binding.pm
deleted file mode 100644
index d61718d..0000000
--- a/clownfish/runtime/perl/buildlib/Clownfish/Build/Binding.pm
+++ /dev/null
@@ -1,730 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# 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 Clownfish::Build::Binding;
-use strict;
-use warnings;
-
-our $VERSION = '0.003000';
-$VERSION = eval $VERSION;
-
-sub bind_all {
- my $class = shift;
- $class->bind_clownfish;
- $class->bind_test;
- $class->bind_bytebuf;
- $class->bind_string;
- $class->bind_err;
- $class->bind_hash;
- $class->bind_float32;
- $class->bind_float64;
- $class->bind_obj;
- $class->bind_varray;
- $class->bind_vtable;
- $class->bind_stringhelper;
-}
-
-sub bind_clownfish {
- my $xs_code = <<'END_XS_CODE';
-MODULE = Clownfish PACKAGE = Clownfish
-
-BOOT:
- cfish_Clownfish_bootstrap();
-
-IV
-_dummy_function()
-CODE:
- RETVAL = 1;
-OUTPUT:
- RETVAL
-
-SV*
-to_clownfish(sv)
- SV *sv;
-CODE:
-{
- cfish_Obj *obj = XSBind_perl_to_cfish(sv);
- RETVAL = CFISH_OBJ_TO_SV_NOINC(obj);
-}
-OUTPUT: RETVAL
-
-SV*
-to_perl(sv)
- SV *sv;
-CODE:
-{
- if (sv_isobject(sv) && sv_derived_from(sv, "Clownfish::Obj")) {
- IV tmp = SvIV(SvRV(sv));
- cfish_Obj* obj = INT2PTR(cfish_Obj*, tmp);
- RETVAL = XSBind_cfish_to_perl(obj);
- }
- else {
- RETVAL = newSVsv(sv);
- }
-}
-OUTPUT: RETVAL
-END_XS_CODE
-
- my $binding = Clownfish::CFC::Binding::Perl::Class->new(
- parcel => "Clownfish",
- class_name => "Clownfish",
- );
- $binding->append_xs($xs_code);
-
- Clownfish::CFC::Binding::Perl::Class->register($binding);
-}
-
-sub bind_test {
- my $xs_code = <<'END_XS_CODE';
-MODULE = Clownfish PACKAGE = Clownfish::Test
-
-bool
-run_tests(package)
- char *package;
-CODE:
- cfish_String *class_name = cfish_Str_newf("%s", package);
- cfish_TestFormatter *formatter
- = (cfish_TestFormatter*)cfish_TestFormatterTAP_new();
- cfish_TestSuite *suite = testcfish_Test_create_test_suite();
- bool result = CFISH_TestSuite_Run_Batch(suite, class_name, formatter);
- CFISH_DECREF(class_name);
- CFISH_DECREF(formatter);
- CFISH_DECREF(suite);
-
- RETVAL = result;
-OUTPUT: RETVAL
-END_XS_CODE
-
- my $binding = Clownfish::CFC::Binding::Perl::Class->new(
- parcel => "TestClownfish",
- class_name => "Clownfish::Test",
- );
- $binding->append_xs($xs_code);
-
- Clownfish::CFC::Binding::Perl::Class->register($binding);
-}
-
-sub bind_bytebuf {
- my $xs_code = <<'END_XS_CODE';
-MODULE = Clownfish PACKAGE = Clownfish::ByteBuf
-
-SV*
-new(either_sv, sv)
- SV *either_sv;
- SV *sv;
-CODE:
-{
- STRLEN size;
- char *ptr = SvPV(sv, size);
- cfish_ByteBuf *self = (cfish_ByteBuf*)XSBind_new_blank_obj(either_sv);
- cfish_BB_init(self, size);
- CFISH_BB_Mimic_Bytes(self, ptr, size);
- RETVAL = CFISH_OBJ_TO_SV_NOINC(self);
-}
-OUTPUT: RETVAL
-END_XS_CODE
-
- my $binding = Clownfish::CFC::Binding::Perl::Class->new(
- parcel => "Clownfish",
- class_name => "Clownfish::ByteBuf",
- );
- $binding->append_xs($xs_code);
- $binding->exclude_constructor;
-
- Clownfish::CFC::Binding::Perl::Class->register($binding);
-}
-
-sub bind_string {
- my $xs_code = <<'END_XS_CODE';
-MODULE = Clownfish PACKAGE = Clownfish::String
-
-SV*
-new(either_sv, sv)
- SV *either_sv;
- SV *sv;
-CODE:
-{
- STRLEN size;
- char *ptr = SvPVutf8(sv, size);
- cfish_String *self = (cfish_String*)XSBind_new_blank_obj(either_sv);
- cfish_Str_init_from_trusted_utf8(self, ptr, size);
- RETVAL = CFISH_OBJ_TO_SV_NOINC(self);
-}
-OUTPUT: RETVAL
-
-SV*
-_clone(self)
- cfish_String *self;
-CODE:
- RETVAL = CFISH_OBJ_TO_SV_NOINC(CFISH_Str_Clone_IMP(self));
-OUTPUT: RETVAL
-
-SV*
-to_perl(self)
- cfish_String *self;
-CODE:
- RETVAL = XSBind_str_to_sv(self);
-OUTPUT: RETVAL
-END_XS_CODE
-
- my $binding = Clownfish::CFC::Binding::Perl::Class->new(
- parcel => "Clownfish",
- class_name => "Clownfish::String",
- );
- $binding->append_xs($xs_code);
- $binding->exclude_constructor;
-
- Clownfish::CFC::Binding::Perl::Class->register($binding);
-}
-
-sub bind_err {
- my $pod_spec = Clownfish::CFC::Binding::Perl::Pod->new;
- my $synopsis = <<'END_SYNOPSIS';
- package MyErr;
- use base qw( Clownfish::Err );
-
- ...
-
- package main;
- use Scalar::Util qw( blessed );
- while (1) {
- eval {
- do_stuff() or MyErr->throw("retry");
- };
- if ( blessed($@) and $@->isa("MyErr") ) {
- warn "Retrying...\n";
- }
- else {
- # Re-throw.
- die "do_stuff() died: $@";
- }
- }
-END_SYNOPSIS
- $pod_spec->set_synopsis($synopsis);
-
- my $xs_code = <<'END_XS_CODE';
-MODULE = Clownfish PACKAGE = Clownfish::Err
-
-SV*
-trap(routine_sv, context_sv)
- SV *routine_sv;
- SV *context_sv;
-CODE:
- cfish_Err *error = XSBind_trap(routine_sv, context_sv);
- RETVAL = CFISH_OBJ_TO_SV_NOINC(error);
-OUTPUT: RETVAL
-END_XS_CODE
-
- my $binding = Clownfish::CFC::Binding::Perl::Class->new(
- parcel => "Clownfish",
- class_name => "Clownfish::Err",
- );
- $binding->bind_constructor( alias => '_new' );
- $binding->set_pod_spec($pod_spec);
- $binding->append_xs($xs_code);
-
- Clownfish::CFC::Binding::Perl::Class->register($binding);
-}
-
-sub bind_hash {
- my @hand_rolled = qw(
- Store
- Next
- );
-
- my $xs_code = <<'END_XS_CODE';
-MODULE = Clownfish PACKAGE = Clownfish::Hash
-SV*
-_fetch(self, key)
- cfish_Hash *self;
- cfish_String *key;
-CODE:
- RETVAL = CFISH_OBJ_TO_SV(CFISH_Hash_Fetch_IMP(self, (cfish_Obj*)key));
-OUTPUT: RETVAL
-
-void
-store(self, key, value);
- cfish_Hash *self;
- cfish_String *key;
- cfish_Obj *value;
-PPCODE:
-{
- if (value) { CFISH_INCREF(value); }
- CFISH_Hash_Store_IMP(self, (cfish_Obj*)key, value);
-}
-
-void
-next(self)
- cfish_Hash *self;
-PPCODE:
-{
- cfish_Obj *key;
- cfish_Obj *val;
-
- if (CFISH_Hash_Next(self, &key, &val)) {
- SV *key_sv = (SV*)CFISH_Obj_To_Host(key);
- SV *val_sv = (SV*)CFISH_Obj_To_Host(val);
-
- XPUSHs(sv_2mortal(key_sv));
- XPUSHs(sv_2mortal(val_sv));
- XSRETURN(2);
- }
- else {
- XSRETURN_EMPTY;
- }
-}
-END_XS_CODE
-
- my $binding = Clownfish::CFC::Binding::Perl::Class->new(
- parcel => "Clownfish",
- class_name => "Clownfish::Hash",
- );
- $binding->exclude_method($_) for @hand_rolled;
- $binding->append_xs($xs_code);
-
- Clownfish::CFC::Binding::Perl::Class->register($binding);
-}
-
-sub bind_float32 {
- my $float32_xs_code = <<'END_XS_CODE';
-MODULE = Clownfish PACKAGE = Clownfish::Float32
-
-SV*
-new(either_sv, value)
- SV *either_sv;
- float value;
-CODE:
-{
- cfish_Float32 *self = (cfish_Float32*)XSBind_new_blank_obj(either_sv);
- cfish_Float32_init(self, value);
- RETVAL = CFISH_OBJ_TO_SV_NOINC(self);
-}
-OUTPUT: RETVAL
-END_XS_CODE
-
- my $binding = Clownfish::CFC::Binding::Perl::Class->new(
- parcel => "Clownfish",
- class_name => "Clownfish::Float32",
- );
- $binding->append_xs($float32_xs_code);
- $binding->exclude_constructor;
-
- Clownfish::CFC::Binding::Perl::Class->register($binding);
-}
-
-sub bind_float64 {
- my $float64_xs_code = <<'END_XS_CODE';
-MODULE = Clownfish PACKAGE = Clownfish::Float64
-
-SV*
-new(either_sv, value)
- SV *either_sv;
- double value;
-CODE:
-{
- cfish_Float64 *self = (cfish_Float64*)XSBind_new_blank_obj(either_sv);
- cfish_Float64_init(self, value);
- RETVAL = CFISH_OBJ_TO_SV_NOINC(self);
-}
-OUTPUT: RETVAL
-END_XS_CODE
-
- my $binding = Clownfish::CFC::Binding::Perl::Class->new(
- parcel => "Clownfish",
- class_name => "Clownfish::Float64",
- );
- $binding->append_xs($float64_xs_code);
- $binding->exclude_constructor;
-
- Clownfish::CFC::Binding::Perl::Class->register($binding);
-}
-
-sub bind_obj {
- my @exposed = qw(
- To_String
- To_I64
- To_F64
- Equals
- );
- my @hand_rolled = qw(
- Is_A
- );
-
- my $pod_spec = Clownfish::CFC::Binding::Perl::Pod->new;
- my $synopsis = <<'END_SYNOPSIS';
- package MyObj;
- use base qw( Clownfish::Obj );
-
- # Inside-out member var.
- my %foo;
-
- sub new {
- my ( $class, %args ) = @_;
- my $foo = delete $args{foo};
- my $self = $class->SUPER::new(%args);
- $foo{$$self} = $foo;
- return $self;
- }
-
- sub get_foo {
- my $self = shift;
- return $foo{$$self};
- }
-
- sub DESTROY {
- my $self = shift;
- delete $foo{$$self};
- $self->SUPER::DESTROY;
- }
-END_SYNOPSIS
- my $description = <<'END_DESCRIPTION';
-Clownfish::Obj is the base class of the Clownfish object hierarchy.
-
-From the standpoint of a Perl programmer, all classes are implemented as
-blessed scalar references, with the scalar storing a pointer to a C struct.
-
-=head2 Subclassing
-
-The recommended way to subclass Clownfish::Obj and its descendants is
-to use the inside-out design pattern. (See L<Class::InsideOut> for an
-introduction to inside-out techniques.)
-
-Since the blessed scalar stores a C pointer value which is unique per-object,
-C<$$self> can be used as an inside-out ID.
-
- # Accessor for 'foo' member variable.
- sub get_foo {
- my $self = shift;
- return $foo{$$self};
- }
-
-
-Caveats:
-
-=over
-
-=item *
-
-Inside-out aficionados will have noted that the "cached scalar id" stratagem
-recommended above isn't compatible with ithreads.
-
-=item *
-
-Overridden methods must not return undef unless the API specifies that
-returning undef is permissible. (Failure to adhere to this rule currently
-results in a segfault rather than an exception.)
-
-=back
-
-=head1 CONSTRUCTOR
-
-=head2 new()
-
-Abstract constructor -- must be invoked via a subclass. Attempting to
-instantiate objects of class "Clownfish::Obj" directly causes an
-error.
-
-Takes no arguments; if any are supplied, an error will be reported.
-
-=head1 DESTRUCTOR
-
-=head2 DESTROY
-
-All Clownfish classes implement a DESTROY method; if you override it in a
-subclass, you must call C<< $self->SUPER::DESTROY >> to avoid leaking memory.
-END_DESCRIPTION
- $pod_spec->set_synopsis($synopsis);
- $pod_spec->set_description($description);
- $pod_spec->add_method( method => $_, alias => lc($_) ) for @exposed;
-
- my $xs_code = <<'END_XS_CODE';
-MODULE = Clownfish PACKAGE = Clownfish::Obj
-
-bool
-is_a(self, class_name)
- cfish_Obj *self;
- cfish_String *class_name;
-CODE:
-{
- cfish_VTable *target = cfish_VTable_fetch_vtable(class_name);
- RETVAL = CFISH_Obj_Is_A(self, target);
-}
-OUTPUT: RETVAL
-END_XS_CODE
-
- my $binding = Clownfish::CFC::Binding::Perl::Class->new(
- parcel => "Clownfish",
- class_name => "Clownfish::Obj",
- );
- $binding->exclude_method($_) for @hand_rolled;
- $binding->append_xs($xs_code);
- $binding->set_pod_spec($pod_spec);
-
- Clownfish::CFC::Binding::Perl::Class->register($binding);
-}
-
-sub bind_varray {
- my @hand_rolled = qw(
- Shallow_Copy
- Shift
- Pop
- Delete
- Store
- Fetch
- );
-
- my $xs_code = <<'END_XS_CODE';
-MODULE = Clownfish PACKAGE = Clownfish::VArray
-
-SV*
-shallow_copy(self)
- cfish_VArray *self;
-CODE:
- RETVAL = CFISH_OBJ_TO_SV_NOINC(CFISH_VA_Shallow_Copy(self));
-OUTPUT: RETVAL
-
-SV*
-_clone(self)
- cfish_VArray *self;
-CODE:
- RETVAL = CFISH_OBJ_TO_SV_NOINC(CFISH_VA_Clone(self));
-OUTPUT: RETVAL
-
-SV*
-shift(self)
- cfish_VArray *self;
-CODE:
- RETVAL = CFISH_OBJ_TO_SV_NOINC(CFISH_VA_Shift(self));
-OUTPUT: RETVAL
-
-SV*
-pop(self)
- cfish_VArray *self;
-CODE:
- RETVAL = CFISH_OBJ_TO_SV_NOINC(CFISH_VA_Pop(self));
-OUTPUT: RETVAL
-
-SV*
-delete(self, tick)
- cfish_VArray *self;
- uint32_t tick;
-CODE:
- RETVAL = CFISH_OBJ_TO_SV_NOINC(CFISH_VA_Delete(self, tick));
-OUTPUT: RETVAL
-
-void
-store(self, tick, value);
- cfish_VArray *self;
- uint32_t tick;
- cfish_Obj *value;
-PPCODE:
-{
- if (value) { CFISH_INCREF(value); }
- CFISH_VA_Store_IMP(self, tick, value);
-}
-
-SV*
-fetch(self, tick)
- cfish_VArray *self;
- uint32_t tick;
-CODE:
- RETVAL = CFISH_OBJ_TO_SV(CFISH_VA_Fetch(self, tick));
-OUTPUT: RETVAL
-END_XS_CODE
-
- my $binding = Clownfish::CFC::Binding::Perl::Class->new(
- parcel => "Clownfish",
- class_name => "Clownfish::VArray",
- );
- $binding->exclude_method($_) for @hand_rolled;
- $binding->append_xs($xs_code);
-
- Clownfish::CFC::Binding::Perl::Class->register($binding);
-}
-
-sub bind_vtable {
- my @hand_rolled = qw( Make_Obj );
-
- my $xs_code = <<'END_XS_CODE';
-MODULE = Clownfish PACKAGE = Clownfish::VTable
-
-SV*
-_get_registry()
-CODE:
- if (cfish_VTable_registry == NULL) {
- cfish_VTable_init_registry();
- }
- RETVAL = (SV*)CFISH_Obj_To_Host((cfish_Obj*)cfish_VTable_registry);
-OUTPUT: RETVAL
-
-SV*
-fetch_vtable(unused_sv, class_name_sv)
- SV *unused_sv;
- SV *class_name_sv;
-CODE:
-{
- CFISH_UNUSED_VAR(unused_sv);
- STRLEN size;
- char *ptr = SvPVutf8(class_name_sv, size);
- cfish_StackString *class_name = CFISH_SSTR_WRAP_UTF8(ptr, size);
- cfish_VTable *vtable
- = cfish_VTable_fetch_vtable((cfish_String*)class_name);
- RETVAL = vtable ? (SV*)CFISH_VTable_To_Host(vtable) : &PL_sv_undef;
-}
-OUTPUT: RETVAL
-
-SV*
-singleton(unused_sv, ...)
- SV *unused_sv;
-CODE:
-{
- CFISH_UNUSED_VAR(unused_sv);
- cfish_String *class_name = NULL;
- cfish_VTable *parent = NULL;
- bool args_ok
- = XSBind_allot_params(&(ST(0)), 1, items,
- ALLOT_OBJ(&class_name, "class_name", 10, true,
- CFISH_STRING, alloca(cfish_SStr_size())),
- ALLOT_OBJ(&parent, "parent", 6, false,
- CFISH_VTABLE, NULL),
- NULL);
- if (!args_ok) {
- CFISH_RETHROW(CFISH_INCREF(cfish_Err_get_error()));
- }
- cfish_VTable *singleton = cfish_VTable_singleton(class_name, parent);
- RETVAL = (SV*)CFISH_VTable_To_Host(singleton);
-}
-OUTPUT: RETVAL
-
-SV*
-make_obj(self)
- cfish_VTable *self;
-CODE:
- cfish_Obj *blank = CFISH_VTable_Make_Obj(self);
- RETVAL = CFISH_OBJ_TO_SV_NOINC(blank);
-OUTPUT: RETVAL
-END_XS_CODE
-
- my $binding = Clownfish::CFC::Binding::Perl::Class->new(
- parcel => "Clownfish",
- class_name => "Clownfish::VTable",
- );
- $binding->exclude_method($_) for @hand_rolled;
- $binding->append_xs($xs_code);
-
- Clownfish::CFC::Binding::Perl::Class->register($binding);
-}
-
-sub bind_stringhelper {
- my $xs_code = <<'END_XS_CODE';
-MODULE = Clownfish PACKAGE = Clownfish::Util::StringHelper
-
-=for comment
-
-Turn an SV's UTF8 flag on. Equivalent to Encode::_utf8_on, but we don't have
-to load Encode.
-
-=cut
-
-void
-utf8_flag_on(sv)
- SV *sv;
-PPCODE:
- SvUTF8_on(sv);
-
-=for comment
-
-Turn an SV's UTF8 flag off.
-
-=cut
-
-void
-utf8_flag_off(sv)
- SV *sv;
-PPCODE:
- SvUTF8_off(sv);
-
-SV*
-to_base36(num)
- uint64_t num;
-CODE:
-{
- char base36[cfish_StrHelp_MAX_BASE36_BYTES];
- size_t size = cfish_StrHelp_to_base36(num, &base36);
- RETVAL = newSVpvn(base36, size);
-}
-OUTPUT: RETVAL
-
-IV
-from_base36(str)
- char *str;
-CODE:
- RETVAL = strtol(str, NULL, 36);
-OUTPUT: RETVAL
-
-=for comment
-
-Upgrade a SV to UTF8, converting Latin1 if necessary. Equivalent to
-utf::upgrade().
-
-=cut
-
-void
-utf8ify(sv)
- SV *sv;
-PPCODE:
- sv_utf8_upgrade(sv);
-
-bool
-utf8_valid(sv)
- SV *sv;
-CODE:
-{
- STRLEN len;
- char *ptr = SvPV(sv, len);
- RETVAL = cfish_StrHelp_utf8_valid(ptr, len);
-}
-OUTPUT: RETVAL
-
-=for comment
-
-Concatenate one scalar onto the end of the other, ignoring UTF-8 status of the
-second scalar. This is necessary because $not_utf8 . $utf8 results in a
-scalar which has been infected by the UTF-8 flag of the second argument.
-
-=cut
-
-void
-cat_bytes(sv, catted)
- SV *sv;
- SV *catted;
-PPCODE:
-{
- STRLEN len;
- char *ptr = SvPV(catted, len);
- if (SvUTF8(sv)) { CFISH_THROW(CFISH_ERR, "Can't cat_bytes onto a UTF-8 SV"); }
- sv_catpvn(sv, ptr, len);
-}
-END_XS_CODE
-
- my $binding = Clownfish::CFC::Binding::Perl::Class->new(
- parcel => "Clownfish",
- class_name => "Clownfish::Util::StringHelper",
- );
- $binding->append_xs($xs_code);
-
- Clownfish::CFC::Binding::Perl::Class->register($binding);
-}
-
-1;
http://git-wip-us.apache.org/repos/asf/lucy/blob/1704c275/clownfish/runtime/perl/lib/Clownfish.pm
----------------------------------------------------------------------
diff --git a/clownfish/runtime/perl/lib/Clownfish.pm b/clownfish/runtime/perl/lib/Clownfish.pm
deleted file mode 100644
index d683245..0000000
--- a/clownfish/runtime/perl/lib/Clownfish.pm
+++ /dev/null
@@ -1,225 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# 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.
-
-use strict;
-use warnings;
-
-package Clownfish;
-
-use 5.008003;
-
-our $VERSION = '0.003000';
-$VERSION = eval $VERSION;
-
-use Exporter 'import';
-BEGIN {
- our @EXPORT_OK = qw(
- to_clownfish
- to_perl
- kdump
- );
-}
-
-# On most UNIX variants, this flag makes DynaLoader pass RTLD_GLOBAL to
-# dl_open, so extensions can resolve the needed symbols without explicitly
-# linking against the DSO.
-sub dl_load_flags { 1 }
-
-BEGIN {
- require DynaLoader;
- our @ISA = qw( DynaLoader );
- # This loads a large number of disparate subs.
- bootstrap Clownfish '0.3.0';
- _init_autobindings();
-}
-
-sub kdump {
- require Data::Dumper;
- my $kdumper = Data::Dumper->new( [@_] );
- $kdumper->Sortkeys( sub { return [ sort keys %{ $_[0] } ] } );
- $kdumper->Indent(1);
- warn $kdumper->Dump;
-}
-
-sub error {$Clownfish::Err::error}
-
-{
- package Clownfish::Util::StringHelper;
- our $VERSION = '0.003000';
- $VERSION = eval $VERSION;
- BEGIN {
- push our @ISA, 'Exporter';
- our @EXPORT_OK = qw(
- utf8_flag_on
- utf8_flag_off
- to_base36
- from_base36
- utf8ify
- utf8_valid
- cat_bytes
- );
- }
-}
-
-{
- package Clownfish::LockFreeRegistry;
- our $VERSION = '0.003000';
- $VERSION = eval $VERSION;
- no warnings 'redefine';
- sub DESTROY { } # leak all
-}
-
-{
- package Clownfish::Obj;
- our $VERSION = '0.003000';
- $VERSION = eval $VERSION;
- use Clownfish qw( to_clownfish to_perl );
-}
-
-{
- package Clownfish::VTable;
- our $VERSION = '0.003000';
- $VERSION = eval $VERSION;
-
- sub _find_parent_class {
- my $package = shift;
- no strict 'refs';
- for my $parent ( @{"$package\::ISA"} ) {
- return $parent if $parent->isa('Clownfish::Obj');
- }
- return;
- }
-
- sub _fresh_host_methods {
- my $package = shift;
- no strict 'refs';
- my $stash = \%{"$package\::"};
- my $methods
- = Clownfish::VArray->new( capacity => scalar keys %$stash );
- while ( my ( $symbol, $glob ) = each %$stash ) {
- next if ref $glob;
- next unless *$glob{CODE};
- $methods->push( Clownfish::String->new($symbol) );
- }
- return $methods;
- }
-
- sub _register {
- my ( $singleton, $parent ) = @_;
- my $singleton_class = $singleton->get_name;
- my $parent_class = $parent->get_name;
- if ( !$singleton_class->isa($parent_class) ) {
- no strict 'refs';
- push @{"$singleton_class\::ISA"}, $parent_class;
- }
- }
-
- no warnings 'redefine';
- sub DESTROY { } # leak all
-}
-
-{
- package Clownfish::Method;
- our $VERSION = '0.003000';
- $VERSION = eval $VERSION;
- no warnings 'redefine';
- sub DESTROY { } # leak all
-}
-
-{
- package Clownfish::ViewByteBuf;
- our $VERSION = '0.003000';
- $VERSION = eval $VERSION;
- use Carp;
- sub new { confess "ViewByteBuf objects can only be created from C." }
-}
-
-{
- package Clownfish::String;
- our $VERSION = '0.003000';
- $VERSION = eval $VERSION;
-
- {
- # Defeat obscure bugs in the XS auto-generation by redefining clone().
- # (Because of how the typemap works for String*,
- # the auto-generated methods return UTF-8 Perl scalars rather than
- # actual String objects.)
- no warnings 'redefine';
- sub clone { shift->_clone(@_) }
- }
-}
-
-{
- package Clownfish::StackString;
- our $VERSION = '0.003000';
- $VERSION = eval $VERSION;
- use Carp;
- sub new { confess "StackString objects can only be created from C." }
- no warnings 'redefine';
- sub DESTROY { }
-}
-
-{
- package Clownfish::Err;
- our $VERSION = '0.003000';
- $VERSION = eval $VERSION;
- sub do_to_string { shift->to_string }
- use Scalar::Util qw( blessed );
- use Carp qw( confess longmess );
- use overload
- '""' => \&do_to_string,
- fallback => 1;
-
- sub new {
- my ( $either, $message ) = @_;
- my ( undef, $file, $line ) = caller;
- $message .= ", $file line $line\n";
- return $either->_new( mess => Clownfish::String->new($message) );
- }
-
- sub do_throw {
- my $err = shift;
- my $longmess = longmess();
- $longmess =~ s/^\s*/\t/;
- $err->cat_mess($longmess);
- die $err;
- }
-
- our $error;
- sub set_error {
- my $val = $_[1];
- if ( defined $val ) {
- confess("Not a Clownfish::Err")
- unless ( blessed($val)
- && $val->isa("Clownfish::Err") );
- }
- $error = $val;
- }
- sub get_error {$error}
-}
-
-{
- package Clownfish::VArray;
- our $VERSION = '0.003000';
- $VERSION = eval $VERSION;
- no warnings 'redefine';
- sub clone { CORE::shift->_clone }
-}
-
-1;
-
-__END__
-
-
http://git-wip-us.apache.org/repos/asf/lucy/blob/1704c275/clownfish/runtime/perl/lib/Clownfish.pod
----------------------------------------------------------------------
diff --git a/clownfish/runtime/perl/lib/Clownfish.pod b/clownfish/runtime/perl/lib/Clownfish.pod
deleted file mode 100644
index 60609c2..0000000
--- a/clownfish/runtime/perl/lib/Clownfish.pod
+++ /dev/null
@@ -1,618 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# 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.
-
-=head1 NAME
-
-Clownfish - Symbiotic object system.
-
-=head1 VERSION
-
-0.3.0
-
-=head1 DESCRIPTION
-
-Clownfish is a "symbiotic" object system for C which is designed to pair
-with a "host" dynamic language environment, facilitating the development
-of high performance host language extensions. Clownfish classes are
-declared in header files with a C<.cfh> extension. The Clownfish headers
-are used by the Clownfish compiler to generate C header files and host
-language bindings. Methods, functions and variables are defined in normal
-C source files.
-
-=head2 Features
-
-=over
-
-=item *
-
-Designed to support multiple host languages. Currently, only Perl is supported.
-
-=item *
-
-Support for stand-alone C libraries and executables.
-
-=item *
-
-Subclassing and method overriding from the host language.
-
-=item *
-
-Support for host language idioms like named parameters or default argument
-values.
-
-=item *
-
-Highly performant object system with lazy creation of host language objects.
-
-=item *
-
-Runtime with classes for commonly used data structures like strings, dynamic
-arrays and hash tables.
-
-=item *
-
-Modularity.
-
-=item *
-
-Introspection.
-
-=item *
-
-Documentation generator.
-
-=back
-
-=head2 Planned features
-
-=over
-
-=item *
-
-Support for more host languages.
-
-=item *
-
-Guaranteed ABI stability when adding or reordering methods or instance
-variables.
-
-=back
-
-=head1 USING CLOWNFISH CLASSES
-
-TODO: Simple introduction
-
-=head1 WRITING CLOWNFISH CLASSES
-
-=head2 Parcels
-
-Every Clownfish class belongs to a Clownfish parcel. Parcels are used for
-namespacing and versioning. Information about parcels is stored in C<.cfp>
-files which contain a JSON hash with the following keys:
-
-=over
-
-=item name
-
-The parcel's name. It must contain only letters.
-
-=item nickname
-
-A short nickname. It must contain only letters. This nickname, followed by an
-underscore, is used to prefix generated C symbols and macros. Depending on the
-kind of symbol, a lowercase, mixed case, or uppercase prefix will be used.
-
-=item version
-
-A version specifier of the following form (without whitespace):
-
- version-specifier = "v" version-number
- version-number = digit | digit "." version-number
-
-=back
-
-An example C<.cfp> file might look like:
-
- {
- "name": "Pathfinder",
- "nickname": "Pfind",
- "version": "v2.3.8"
- }
-
-A parcel specifier of the following form is used in Clownfish header files:
-
- parcel-specifier = "parcel" parcel-name ";"
- parcel-name = identifier
-
-For example:
-
- parcel Pathfinder;
-
-All classes following a parcel specifier will be associated with that parcel.
-
-=head3 Initialization
-
-Every Clownfish parcel must be initialized before it is used. The
-initialization function is named C<{parcel_nick}_bootstrap_parcel> and takes
-no arguments.
-
-Example call:
-
- pfind_bootstrap_parcel();
-
-=head3 Short names
-
-If a macro with the uppercase name C<{PARCEL_NICK}_USE_SHORT_NAMES> is
-defined before including a generated C header, additional macros without the
-parcel prefix will be defined for most symbols.
-
-Example:
-
- #define PFIND_USE_SHORT_NAMES
- #include <Pathfinder/Graph.h>
- #include <Pathfinder/Path.h>
-
- /* Prefixes can be omitted. */
- Path *path = Graph_Find_Shortest_Path(graph);
-
- /* Without PFIND_USE_SHORT_NAMES, one would have to write: */
- pfind_Path *path = Pfind_Graph_Find_Shortest_Path(graph);
-
-For object types in Clownfish header files, prefixes of class structs can
-also be omitted unless multiple parcels declare classes with the same last
-component of the class name.
-
-=head3 The "Clownfish" parcel
-
-The Clownfish runtime classes live in a parcel named C<Clownfish> with
-nickname C<Cfish>. Consequently, the short name macro is named
-C<CFISH_USE_SHORT_NAMES>.
-
-=head2 Declaring classes
-
-Classes are declared in Clownfish header files using a declaration of the
-following form:
-
- class-declaration = class-exposure-specifier?
- class-modifier*
- "class" class-name
- ("cnick" class-nickname)?
- ("inherits" class-name)?
- "{" class-contents "}"
- class-exposure-specifier = "public"
- class-modifier = "inert" | "final"
- class-name = identifier | identifier "::" class-name
- class-nickname = identifier
- class-contents = (variable-declaration | function-declaration)*
-
-Class name components must start with an uppercase letter and must not contain
-underscores. The last component must contain at least one lowercase letter and
-must be unique for every class in a parcel.
-
-For every class, a struct with the name C<{parcel_nick}_{Class_Last_Comp}>
-and a corresponding typedef are declared in the generated C header. The struct
-members are only visible if the uppercase macro
-C<C_{PARCEL_NICK}_{CLASS_LAST_COMP}> is defined before including the header
-file.
-
-For every class, a global variable with the uppercase name
-C<{PARCEL_NICK}_{CLASS_LAST_COMP}> is defined. This variable is a pointer to
-a Clownfish::VTable object which is initialized when bootstrapping the parcel.
-
-Example of a class declaration:
-
- parcel Pathfinder;
-
- public class Pathfinder::Graph::VisibilityGraph cnick VisGraph
- extends Clownfish::Obj {
- /* Variables and functions */
- }
-
-This will generate:
-
- struct pfind_VisibilityGraph {
- /* Instance variables */
- };
- typedef struct pfind_VisibilityGraph pfind_VisibilityGraph;
- extern cfish_VTable *PFIND_VISIBILITYGRAPH;
-
-=head3 Class exposure
-
-Classes without public exposure have parcel exposure. They are not visible
-outside of the parcel and must not contain public variables or functions.
-
-=head3 Inert classes
-
-Inert classes must contain only inert variables or inert methods, that is,
-neither instance variables nor methods. They must not inherit from another
-class or be inherited from. Non-inert classes inherit from Clownfish::Obj by
-default.
-
-=head3 Final classes
-
-For final classes, every method is made final, regardless of the method
-modifier. Final classes must not be inherited from.
-
-=head2 Variables
-
-Variables are declared with a declaration of the following form:
-
- variable-declaration = variable-exposure-specifier?
- variable-modifier*
- type variable-name ";"
- variable-exposure-specifier = "public"
- variable-modifier = "inert"
- variable-name = identifier
-
-=head3 Inert variables
-
-Inert variables are class variables of which only a single copy exists.
-They are declared in the generated C header with the name
-C<{parcel_nick}_{Class_Nick}_{Variable_Name}> and must be defined in a C
-source file.
-
-Example:
-
- public class Pathfinder::Path {
- public inert int max_path_length;
- }
-
-This will generate:
-
- extern int pfind_Path_max_path_length;
-
-The C source file defining the variable will typically use short names. So the
-definition will look like:
-
- int Path_max_path_length = 5000;
-
-=head3 Inert variable exposure
-
-Inert variables without public exposure have parcel exposure. They are not
-visible outside of the parcel.
-
-=head3 Instance variables
-
-Non-inert variables are instance variables and added to the class struct. They
-must not have an exposure specifier.
-
-Example:
-
- public class Pathfinder::Path {
- int num_nodes;
-
- public int
- Get_Num_Nodes(Path *self);
- }
-
-This will add a C<num_nodes> member to struct C<pfind_Path>. To access the
-member, the macro C<C_PFIND_PATH> must be defined before including the
-generated header file:
-
- #define C_PFIND_PATH
- #define PFIND_USE_SHORT_NAMES
- #include "Pathfinder/Path.h"
-
- int
- Path_get_num_nodes(Path *self) {
- return self->num_nodes;
- }
-
-=head2 Functions
-
- function-declaration = function-exposure-specifier?
- function-modifier*
- return-type function-name
- "(" param-list? ")" ";"
- function-exposure-specifier = "public"
- function-modifier = "inert" | "inline" | "abstract" | "final"
- return-type = return-type-qualifier* type
- return-type-qualifier = "incremented" | "nullable"
- function-name = identifier
- param-list = param | param "," param-list
- param = param-qualifier* type param-name ("=" scalar-constant)?
- param-name = identifier
- param-qualifier = "decremented"
-
-=head3 Function exposure
-
-Functions without public exposure have parcel exposure. They are not
-visible outside of the parcel.
-
-=head3 Inert functions
-
-Inert functions are dispatched statically. They are declared in the generated
-C header with the name C<{parcel_nick}_{Class_Nick}_{Function_Name}>
-and must be defined in a C source file. They must be neither abstract nor
-final.
-
-Example:
-
- public class Pathfinder::Graph::VisibilityGraph cnick VisGraph
- extends Clownfish::Obj {
-
- public inert incremented VisibilityGraph*
- new(int node_capacity);
- }
-
-This will generate:
-
- pfind_VisibilityGraph*
- pfind_VisGraph_new(int node_capacity);
-
-The C source file implementing the inert function will typically use short
-names. So the implementation will look like:
-
- #define PFIND_USE_SHORT_NAMES
- #include "Pathfinder/Graph/VisibilityGraph.h"
-
- VisibilityGraph*
- VisGraph_new(int node_capacity) {
- /* Implementation */
- }
-
-=head3 Inline functions
-
-Inert functions can be inline. They should be defined as static inline
-functions in a C block in the Clownfish header file. The macro C<CFISH_INLINE>
-expands to the C compiler's inline keyword and should be used for portability.
-
-=head3 Methods
-
-Non-inert functions are dynamically dispatched methods. Their name must start
-with an uppercase letter and every underscore must be followed by an uppercase
-letter. Methods must not be declared inline.
-
-The first parameter of a method must be a pointer to an object of the method's
-class which receives the object on which the method was invoked. By convention,
-this parameter is named C<self>.
-
-For every method, an inline wrapper for dynamic dispatch is defined in
-the generated C header with the name
-C<{Parcel_Nick}_{Class_Nick}_{Method_Name}>. Additionally, an
-implementing function is declared with the name
-C<{Parcel_Nick}_{Class_Nick}_{Method_Name}_IMP>. The Clownfish compiler also
-generates a typedef for the method's function pointer type named
-C<{Parcel_Nick}_{Class_Nick}_{Method_Name}_t>. Wrappers and typedefs are
-created for all subclasses whether they override a method or not.
-
-Example:
-
- public class Pathfinder::Graph::VisibilityGraph cnick VisGraph
- extends Clownfish::Obj {
-
- public void
- Add_Node(VisibilityGraph *self, decremented Node *node);
- }
-
-This will generate:
-
- /* Wrapper for dynamic dispatch */
- static inline void
- Pfind_VisGraph_Add_Node(pfind_VisibilityGraph *self, pfind_Node *node) {
- /* Inline code for wrapper */
- }
-
- /* Declaration of implementing function */
- void
- Pfind_VisGraph_Add_Node_IMP(pfind_VisibilityGraph *self,
- pfind_Node *node);
-
- /* Declaration of function pointer type */
- typedef void
- (*Pfind_VisGraph_Add_Node_t)(pfind_VisibilityGraph *self,
- pfind_Node *node);
-
-The implementing function of non-abstract methods must be defined in a C source
-file. This file will typically define the short names macro. So the
-implementation will look like:
-
- #define PFIND_USE_SHORT_NAMES
- #include "Pathfinder/Graph/VisibilityGraph.h"
-
- void
- VisGraph_Add_Node_IMP(VisibilityGraph *self, Node *node) {
- /* Implementation */
- }
-
-=head3 Looking up function pointers
-
-Clownfish defines a macro named C<CFISH_METHOD_PTR> that looks up the pointer
-to the implementing function of a method. The first parameter of the macro is
-a pointer to the Clownfish::VTable object of the method's class, the second is
-the unshortened name of the method wrapper. If short names for the Clownfish
-parcel are used, the macro is also available under the name C<METHOD_PTR>.
-
-To lookup methods from a superclass, there's a macro C<CFISH_SUPER_METHOD_PTR>
-with the same parameters.
-
-Example using short names:
-
- VisGraph_Add_Node_t add_node
- = METHOD_PTR(PFIND_VISIBILITYGRAPH, Pfind_VisGraph_Add_Node);
-
- VisGraph_Add_Node_t super_add_node
- = SUPER_METHOD_PTR(PFIND_VISIBILITYGRAPH, Pfind_VisGraph_Add_Node);
-
-=head3 Abstract methods
-
-For abstract methods, the Clownfish compiler generates an implementing function
-which throws an error. They should be overridden in a subclass.
-
-=head3 Final methods
-
-Final methods must not be overridden. They must not be abstract.
-
-=head3 Nullable return type
-
-If a function has a nullable return type, it must return a pointer.
-Non-nullable functions must never return the NULL pointer.
-
-=head3 Incremented return type
-
-Incremented return types must be pointers to Clownfish objects. The function
-will either return a new object with an initial reference count of 1 or
-increment the reference count. The caller must decrement the reference count of
-the returned object when it's no longer used.
-
-For returned objects with non-incremented return type, usually no additional
-handling of reference counts is required. Only if an object is returned from an
-accessor or a collection object and the caller wants to use the object longer
-than the returning object retains a reference, it must increment the reference
-count itself and decrement when the object is no longer used.
-
-=head3 Decremented parameters
-
-Decremented parameters must be pointers to Clownfish objects. The function
-will either decrement the reference count of the passed-in object or retain a
-reference without incrementing the reference count. If the caller wants to use
-the passed-in object afterwards, it usually must increment its reference count
-before the call and decrement it when it's no longer used. If the caller does
-not make further use of the passed-in object, it must not decrement its
-reference count after the call.
-
-=head3 Default parameter values
-
-Default parameter values can be given as integer, float, or string literals.
-The values C<true>, C<false>, and C<NULL> are also supported. The default
-values are only used by the host language bindings. They're not supported
-when calling a function from C.
-
-=head2 C blocks
-
-Clownfish headers can contain C blocks which start with a line containing the
-string C<__C__> and end on a line containing the string C<__END_C__>. The
-contents of a C block are copied verbatim to the generated C header.
-
-Example:
-
- __C__
-
- struct pfind_AuxiliaryStruct {
- int a;
- int b;
- };
-
- __END_C__
-
-=head2 Object life cycle
-
-=head3 Object creation
-
-Objects are allocated by invoking the C<Make_Obj> method on a class's
-Clownfish::VTable object.
-
-Any inert function can be used to construct objects from C. But to support
-inheritance and object creation from the host language, Clownfish classes
-need a separate function to initialize objects. The initializer must take a
-pointer to an object as first argument and return a pointer to the same
-object. If the parent class has an initializer, it should be called first by
-the subclass's initializer.
-
-By convention, the standard constructor is named C<new>. If a class has an
-inert function named C<init>, it is used as initializer to create a host
-language constructor by default.
-
-Example:
-
- /* Clownfish header */
-
- class Vehicle {
- double max_speed;
-
- inert Vehicle*
- init(Vehicle *self, double max_speed);
- }
-
- class Train inherits Vehicle {
- double track_gauge;
-
- inert incremented Train*
- new(double max_speed, double track_gauge);
-
- inert Train*
- init(Train *self, double max_speed, double track_gauge);
- }
-
- /* Implementation */
-
- Train*
- Train_new(double max_speed, double track_gauge) {
- Train *self = (Train*)VTable_Make_Obj(TRAIN);
- return Train_init(self, max_speed, track_gauge);
- }
-
- Train*
- Train_init(Train *self, double max_speed, double track_gauge) {
- Vehicle_init((Vehicle*)self, max_speed);
- self->track_gauge = track_gauge;
- return self;
- }
-
-=head3 Reference counting
-
-Clownfish uses reference counting for memory management. Objects are created
-with a reference count of 1. There are two macros C<CFISH_INCREF> and
-C<CFISH_DECREF> to increment and decrement reference counts. If short names
-for the Clownfish parcel are enabled, the macros can be abbreviated to
-C<INCREF> and C<DECREF>. Both macros take a pointer to an object as argument.
-NULL pointers are allowed. C<CFISH_INCREF> returns a pointer to the object.
-This value might differ from the passed-in pointer in some cases. So if a
-reference is retained, the pointer returned from C<CFISH_INCREF> should be
-used. C<CFISH_DECREF> returns the modified reference count.
-
-Examples:
-
- self->value = INCREF(arg);
-
- DECREF(object);
-
-=head3 Object destruction
-
-If an object's reference count reaches 0, its C<Destroy> method is called.
-This public method takes no arguments besides C<self> and has no return value.
-It should release the resources held by the object and finally call the
-C<Destroy> method of the superclass via the C<CFISH_SUPER_DESTROY> macro with
-short name C<SUPER_DESTROY>. This macro takes the C<self> pointer as first
-argument and a pointer to the object's Clownfish::VTable as second argument.
-The C<Destroy> method of the Clownfish::Obj class will eventually free the
-object struct.
-
-Example:
-
- /* Clownfish header */
-
- class Path {
- VArray *nodes;
-
- public void
- Destroy(Path *self);
- }
-
- /* Implementation */
-
- void
- Path_Destroy_IMP(Path *self) {
- DECREF(self->nodes);
- SUPER_DESTROY(self, PATH);
- }
-
-=head1 COPYRIGHT
-
-Clownfish is distributed under the Apache License, Version 2.0, as described
-in the file C<LICENSE> included with the distribution.
-
-=cut
-
http://git-wip-us.apache.org/repos/asf/lucy/blob/1704c275/clownfish/runtime/perl/lib/Clownfish/ByteBuf.pm
----------------------------------------------------------------------
diff --git a/clownfish/runtime/perl/lib/Clownfish/ByteBuf.pm b/clownfish/runtime/perl/lib/Clownfish/ByteBuf.pm
deleted file mode 100644
index cab5b7d..0000000
--- a/clownfish/runtime/perl/lib/Clownfish/ByteBuf.pm
+++ /dev/null
@@ -1,25 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# 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 Clownfish::ByteBuf;
-use Clownfish;
-our $VERSION = '0.003000';
-$VERSION = eval $VERSION;
-
-1;
-
-__END__
-
-
http://git-wip-us.apache.org/repos/asf/lucy/blob/1704c275/clownfish/runtime/perl/lib/Clownfish/CharBuf.pm
----------------------------------------------------------------------
diff --git a/clownfish/runtime/perl/lib/Clownfish/CharBuf.pm b/clownfish/runtime/perl/lib/Clownfish/CharBuf.pm
deleted file mode 100644
index a6458c8..0000000
--- a/clownfish/runtime/perl/lib/Clownfish/CharBuf.pm
+++ /dev/null
@@ -1,25 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# 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 Clownfish::String;
-use Clownfish;
-our $VERSION = '0.003000';
-$VERSION = eval $VERSION;
-
-1;
-
-__END__
-
-
http://git-wip-us.apache.org/repos/asf/lucy/blob/1704c275/clownfish/runtime/perl/lib/Clownfish/Err.pm
----------------------------------------------------------------------
diff --git a/clownfish/runtime/perl/lib/Clownfish/Err.pm b/clownfish/runtime/perl/lib/Clownfish/Err.pm
deleted file mode 100644
index 61a8a5a..0000000
--- a/clownfish/runtime/perl/lib/Clownfish/Err.pm
+++ /dev/null
@@ -1,25 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# 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 Clownfish::Err;
-use Clownfish;
-our $VERSION = '0.003000';
-$VERSION = eval $VERSION;
-
-1;
-
-__END__
-
-
http://git-wip-us.apache.org/repos/asf/lucy/blob/1704c275/clownfish/runtime/perl/lib/Clownfish/Hash.pm
----------------------------------------------------------------------
diff --git a/clownfish/runtime/perl/lib/Clownfish/Hash.pm b/clownfish/runtime/perl/lib/Clownfish/Hash.pm
deleted file mode 100644
index b542f59..0000000
--- a/clownfish/runtime/perl/lib/Clownfish/Hash.pm
+++ /dev/null
@@ -1,25 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# 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 Clownfish::Hash;
-use Clownfish;
-our $VERSION = '0.003000';
-$VERSION = eval $VERSION;
-
-1;
-
-__END__
-
-
http://git-wip-us.apache.org/repos/asf/lucy/blob/1704c275/clownfish/runtime/perl/lib/Clownfish/LockFreeRegistry.pm
----------------------------------------------------------------------
diff --git a/clownfish/runtime/perl/lib/Clownfish/LockFreeRegistry.pm b/clownfish/runtime/perl/lib/Clownfish/LockFreeRegistry.pm
deleted file mode 100644
index e13e53c..0000000
--- a/clownfish/runtime/perl/lib/Clownfish/LockFreeRegistry.pm
+++ /dev/null
@@ -1,25 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# 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 Clownfish::LockFreeRegistry;
-use Clownfish;
-our $VERSION = '0.003000';
-$VERSION = eval $VERSION;
-
-1;
-
-__END__
-
-
http://git-wip-us.apache.org/repos/asf/lucy/blob/1704c275/clownfish/runtime/perl/lib/Clownfish/Num.pm
----------------------------------------------------------------------
diff --git a/clownfish/runtime/perl/lib/Clownfish/Num.pm b/clownfish/runtime/perl/lib/Clownfish/Num.pm
deleted file mode 100644
index 72bafaa..0000000
--- a/clownfish/runtime/perl/lib/Clownfish/Num.pm
+++ /dev/null
@@ -1,25 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# 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 Clownfish::Num;
-use Clownfish;
-our $VERSION = '0.003000';
-$VERSION = eval $VERSION;
-
-1;
-
-__END__
-
-
http://git-wip-us.apache.org/repos/asf/lucy/blob/1704c275/clownfish/runtime/perl/lib/Clownfish/Obj.pm
----------------------------------------------------------------------
diff --git a/clownfish/runtime/perl/lib/Clownfish/Obj.pm b/clownfish/runtime/perl/lib/Clownfish/Obj.pm
deleted file mode 100644
index 3036630..0000000
--- a/clownfish/runtime/perl/lib/Clownfish/Obj.pm
+++ /dev/null
@@ -1,25 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# 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 Clownfish::Obj;
-use Clownfish;
-our $VERSION = '0.003000';
-$VERSION = eval $VERSION;
-
-1;
-
-__END__
-
-
http://git-wip-us.apache.org/repos/asf/lucy/blob/1704c275/clownfish/runtime/perl/lib/Clownfish/Test.pm
----------------------------------------------------------------------
diff --git a/clownfish/runtime/perl/lib/Clownfish/Test.pm b/clownfish/runtime/perl/lib/Clownfish/Test.pm
deleted file mode 100644
index aad0681..0000000
--- a/clownfish/runtime/perl/lib/Clownfish/Test.pm
+++ /dev/null
@@ -1,25 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# 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 Clownfish::Test;
-use Clownfish;
-our $VERSION = '0.003000';
-$VERSION = eval $VERSION;
-
-1;
-
-__END__
-
-
http://git-wip-us.apache.org/repos/asf/lucy/blob/1704c275/clownfish/runtime/perl/lib/Clownfish/Util/StringHelper.pm
----------------------------------------------------------------------
diff --git a/clownfish/runtime/perl/lib/Clownfish/Util/StringHelper.pm b/clownfish/runtime/perl/lib/Clownfish/Util/StringHelper.pm
deleted file mode 100644
index 47d9120..0000000
--- a/clownfish/runtime/perl/lib/Clownfish/Util/StringHelper.pm
+++ /dev/null
@@ -1,25 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# 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 Clownfish::Util::StringHelper;
-use Clownfish;
-our $VERSION = '0.003000';
-$VERSION = eval $VERSION;
-
-1;
-
-__END__
-
-
http://git-wip-us.apache.org/repos/asf/lucy/blob/1704c275/clownfish/runtime/perl/lib/Clownfish/VArray.pm
----------------------------------------------------------------------
diff --git a/clownfish/runtime/perl/lib/Clownfish/VArray.pm b/clownfish/runtime/perl/lib/Clownfish/VArray.pm
deleted file mode 100644
index 949a904..0000000
--- a/clownfish/runtime/perl/lib/Clownfish/VArray.pm
+++ /dev/null
@@ -1,25 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# 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 Clownfish::VArray;
-use Clownfish;
-our $VERSION = '0.003000';
-$VERSION = eval $VERSION;
-
-1;
-
-__END__
-
-
http://git-wip-us.apache.org/repos/asf/lucy/blob/1704c275/clownfish/runtime/perl/lib/Clownfish/VTable.pm
----------------------------------------------------------------------
diff --git a/clownfish/runtime/perl/lib/Clownfish/VTable.pm b/clownfish/runtime/perl/lib/Clownfish/VTable.pm
deleted file mode 100644
index b5f5eb5..0000000
--- a/clownfish/runtime/perl/lib/Clownfish/VTable.pm
+++ /dev/null
@@ -1,25 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# 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 Clownfish::VTable;
-use Clownfish;
-our $VERSION = '0.003000';
-$VERSION = eval $VERSION;
-
-1;
-
-__END__
-
-
http://git-wip-us.apache.org/repos/asf/lucy/blob/1704c275/clownfish/runtime/perl/t/002-clownfish.t
----------------------------------------------------------------------
diff --git a/clownfish/runtime/perl/t/002-clownfish.t b/clownfish/runtime/perl/t/002-clownfish.t
deleted file mode 100644
index d3e36b7..0000000
--- a/clownfish/runtime/perl/t/002-clownfish.t
+++ /dev/null
@@ -1,52 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# 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.
-
-use strict;
-use warnings;
-
-use Test::More;
-use File::Find 'find';
-
-my @modules;
-
-# None for now -- until we remove a module.
-my %excluded = map { ( $_ => 1 ) } qw();
-
-find(
- { no_chdir => 1,
- wanted => sub {
- return unless $File::Find::name =~ /\.pm$/;
- push @modules, $File::Find::name;
- }
- },
- 'lib'
-);
-
-plan( tests => scalar @modules );
-
-for (@modules) {
- s/^.*?Clownfish/Clownfish/;
- s/\.pm$//;
- s/\W+/::/g;
- if ( $excluded{$_} ) {
- eval qq|use $_;|;
- like( $@, qr/removed|replaced|renamed/i,
- "Removed module '$_' throws error on load" );
- }
- else {
- use_ok($_);
- }
-}
-
http://git-wip-us.apache.org/repos/asf/lucy/blob/1704c275/clownfish/runtime/perl/t/018-host.t
----------------------------------------------------------------------
diff --git a/clownfish/runtime/perl/t/018-host.t b/clownfish/runtime/perl/t/018-host.t
deleted file mode 100644
index 5a79eff..0000000
--- a/clownfish/runtime/perl/t/018-host.t
+++ /dev/null
@@ -1,42 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# 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.
-
-use strict;
-use warnings;
-
-use Test::More tests => 3;
-use Clownfish qw( to_perl to_clownfish );
-
-my %complex_data_structure = (
- a => [ 1, 2, 3, { ooga => 'booga' } ],
- b => { foo => 'foofoo', bar => 'barbar' },
-);
-my $kobj = to_clownfish( \%complex_data_structure );
-isa_ok( $kobj, 'Clownfish::Obj' );
-my $transformed = to_perl($kobj);
-is_deeply( $transformed, \%complex_data_structure,
- "transform from Perl to Clownfish data structures and back" );
-
-my $bread_and_butter = Clownfish::Hash->new;
-$bread_and_butter->store( 'bread', Clownfish::ByteBuf->new('butter') );
-my $salt_and_pepper = Clownfish::Hash->new;
-$salt_and_pepper->store( 'salt', Clownfish::ByteBuf->new('pepper') );
-$complex_data_structure{c} = $bread_and_butter;
-$complex_data_structure{d} = $salt_and_pepper;
-$transformed = to_perl( to_clownfish( \%complex_data_structure ) );
-$complex_data_structure{c} = { bread => 'butter' };
-$complex_data_structure{d} = { salt => 'pepper' };
-is_deeply( $transformed, \%complex_data_structure,
- "handle mixed data structure correctly" );
http://git-wip-us.apache.org/repos/asf/lucy/blob/1704c275/clownfish/runtime/perl/t/021-vtable.t
----------------------------------------------------------------------
diff --git a/clownfish/runtime/perl/t/021-vtable.t b/clownfish/runtime/perl/t/021-vtable.t
deleted file mode 100644
index d2e0c14..0000000
--- a/clownfish/runtime/perl/t/021-vtable.t
+++ /dev/null
@@ -1,57 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# 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.
-
-use strict;
-use warnings;
-
-package MyHash;
-use base qw( Clownfish::Hash );
-
-sub oodle { }
-
-package main;
-
-use Test::More tests => 5;
-
-my $stringified;
-my $storage = Clownfish::Hash->new;
-
-{
- my $subclassed_hash = MyHash->new;
- $stringified = $subclassed_hash->to_string;
-
- isa_ok( $subclassed_hash, "MyHash", "Perl isa reports correct subclass" );
-
- # Store the subclassed object. At the end of this block, the Perl object
- # will go out of scope and DESTROY will be called, but the Clownfish object
- # will persist.
- $storage->store( "test", $subclassed_hash );
-}
-
-my $resurrected = $storage->_fetch("test");
-
-isa_ok( $resurrected, "MyHash", "subclass name survived Perl destruction" );
-is( $resurrected->to_string, $stringified,
- "It's the same Hash from earlier (though a different Perl object)" );
-
-my $booga = Clownfish::String->new("booga");
-$resurrected->store( "ooga", $booga );
-
-is( $resurrected->fetch("ooga"),
- "booga", "subclassed object still performs correctly at the C level" );
-
-my $methods = Clownfish::VTable::_fresh_host_methods('MyHash');
-is_deeply( $methods->to_perl, ['oodle'], "fresh_host_methods" );
-
http://git-wip-us.apache.org/repos/asf/lucy/blob/1704c275/clownfish/runtime/perl/t/binding/016-varray.t
----------------------------------------------------------------------
diff --git a/clownfish/runtime/perl/t/binding/016-varray.t b/clownfish/runtime/perl/t/binding/016-varray.t
deleted file mode 100644
index 4397cf5..0000000
--- a/clownfish/runtime/perl/t/binding/016-varray.t
+++ /dev/null
@@ -1,29 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# 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.
-
-use strict;
-use warnings;
-
-use Test::More tests => 1;
-use Clownfish;
-
-my ( $varray, $twin );
-
-$varray = Clownfish::VArray->new;
-$varray->push( Clownfish::String->new($_) ) for 1 .. 5;
-$varray->delete(3);
-$twin = $varray->_clone;
-is_deeply( $twin->to_perl, $varray->to_perl, "clone" );
-
http://git-wip-us.apache.org/repos/asf/lucy/blob/1704c275/clownfish/runtime/perl/t/binding/017-hash.t
----------------------------------------------------------------------
diff --git a/clownfish/runtime/perl/t/binding/017-hash.t b/clownfish/runtime/perl/t/binding/017-hash.t
deleted file mode 100644
index 1843198..0000000
--- a/clownfish/runtime/perl/t/binding/017-hash.t
+++ /dev/null
@@ -1,32 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# 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.
-
-use strict;
-use warnings;
-
-use Test::More tests => 2;
-use Clownfish qw( to_perl to_clownfish );
-
-my $hash = Clownfish::Hash->new( capacity => 10 );
-$hash->store( "foo", Clownfish::String->new("bar") );
-$hash->store( "baz", Clownfish::String->new("banana") );
-
-ok( !defined( $hash->fetch("blah") ),
- "fetch for a non-existent key returns undef" );
-
-my %hash_with_utf8_keys = ( "\x{263a}" => "foo" );
-my $round_tripped = to_perl( to_clownfish( \%hash_with_utf8_keys ) );
-is_deeply( $round_tripped, \%hash_with_utf8_keys,
- "Round trip conversion of hash with UTF-8 keys" );
http://git-wip-us.apache.org/repos/asf/lucy/blob/1704c275/clownfish/runtime/perl/t/binding/019-obj.t
----------------------------------------------------------------------
diff --git a/clownfish/runtime/perl/t/binding/019-obj.t b/clownfish/runtime/perl/t/binding/019-obj.t
deleted file mode 100644
index 5560f48..0000000
--- a/clownfish/runtime/perl/t/binding/019-obj.t
+++ /dev/null
@@ -1,96 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# 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.
-
-use strict;
-use warnings;
-
-use Test::More tests => 15;
-
-package TestObj;
-use base qw( Clownfish::Obj );
-
-our $version = $Clownfish::VERSION;
-
-package SonOfTestObj;
-use base qw( TestObj );
-{
- sub to_string {
- my $self = shift;
- return "STRING: " . $self->SUPER::to_string;
- }
-}
-
-package BadRefCount;
-use base qw( Clownfish::Obj );
-{
- sub inc_refcount {
- my $self = shift;
- $self->SUPER::inc_refcount;
- return;
- }
-}
-
-package main;
-
-ok( defined $TestObj::version,
- "Using base class should grant access to "
- . "package globals in the Clownfish:: namespace"
-);
-
-my $object = TestObj->new;
-isa_ok( $object, "Clownfish::Obj",
- "Clownfish objects can be subclassed" );
-
-ok( $object->is_a("Clownfish::Obj"), "custom is_a correct" );
-ok( !$object->is_a("Clownfish::Object"), "custom is_a too long" );
-ok( !$object->is_a("Clownfish"), "custom is_a substring" );
-ok( !$object->is_a(""), "custom is_a blank" );
-ok( !$object->is_a("thing"), "custom is_a wrong" );
-
-eval { my $another_obj = TestObj->new( kill_me_now => 1 ) };
-like( $@, qr/kill_me_now/, "reject bad param" );
-
-my $stringified_perl_obj = "$object";
-require Clownfish::Hash;
-my $hash = Clownfish::Hash->new;
-$hash->store( foo => $object );
-is( $object->get_refcount, 2, "refcount increased via C code" );
-is( $object->get_refcount, 2, "refcount increased via C code" );
-undef $object;
-$object = $hash->fetch("foo");
-is( "$object", $stringified_perl_obj, "same perl object as before" );
-
-is( $object->get_refcount, 2, "correct refcount after retrieval" );
-undef $hash;
-is( $object->get_refcount, 1, "correct refcount after destruction of ref" );
-
-$object = SonOfTestObj->new;
-like( $object->to_string, qr/STRING:.*?SonOfTestObj/,
- "overridden XS bindings can be called via SUPER" );
-
-SKIP: {
- skip( "Exception thrown within callback leaks", 1 )
- if $ENV{LUCY_VALGRIND};
-
- # The Perl binding for VArray#store calls inc_refcount() from C space.
- # This test verifies that the Perl bindings generated by CFC handle
- # non-`nullable` return values correctly, by ensuring that the Perl
- # callback wrapper for inc_refcount() checks the return value and throws
- # an exception if a Perl-space implementation returns undef.
- my $array = Clownfish::VArray->new;
- eval { $array->store( 1, BadRefCount->new ); };
- like( $@, qr/NULL/,
- "Don't allow methods without nullable return values to return NULL" );
-}
http://git-wip-us.apache.org/repos/asf/lucy/blob/1704c275/clownfish/runtime/perl/t/binding/029-charbuf.t
----------------------------------------------------------------------
diff --git a/clownfish/runtime/perl/t/binding/029-charbuf.t b/clownfish/runtime/perl/t/binding/029-charbuf.t
deleted file mode 100644
index bc802e5..0000000
--- a/clownfish/runtime/perl/t/binding/029-charbuf.t
+++ /dev/null
@@ -1,43 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# 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.
-
-use strict;
-use warnings;
-use lib 'buildlib';
-
-use Test::More tests => 3;
-use Encode qw( _utf8_off );
-use Clownfish;
-
-# Return 3 strings useful for verifying UTF-8 integrity.
-sub utf8_test_strings {
- my $smiley = "\x{263a}";
- my $not_a_smiley = $smiley;
- _utf8_off($not_a_smiley);
- my $frowny = $not_a_smiley;
- utf8::upgrade($frowny);
- return ( $smiley, $not_a_smiley, $frowny );
-}
-
-my ( $smiley, $not_a_smiley, $frowny ) = utf8_test_strings();
-
-my $string = Clownfish::String->new($smiley);
-isa_ok( $string, "Clownfish::String" );
-is( $string->to_perl, $smiley, "round trip UTF-8" );
-
-$string = Clownfish::String->new($smiley);
-my $clone = $string->clone;
-is( $clone->to_perl, Clownfish::String->new($smiley)->to_perl, "clone" );
-
http://git-wip-us.apache.org/repos/asf/lucy/blob/1704c275/clownfish/runtime/perl/t/binding/034-err.t
----------------------------------------------------------------------
diff --git a/clownfish/runtime/perl/t/binding/034-err.t b/clownfish/runtime/perl/t/binding/034-err.t
deleted file mode 100644
index ae91063..0000000
--- a/clownfish/runtime/perl/t/binding/034-err.t
+++ /dev/null
@@ -1,70 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# 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.
-
-use strict;
-use warnings;
-use Clownfish;
-
-package Nirvana;
-
-sub enter {
- die Clownfish::Err->new("blam");
-}
-
-package GloriousDeath;
-use base qw( Clownfish::Err );
-
-package main;
-use Test::More tests => 10;
-
-isa_ok( Clownfish::Err->new("Bad stuff happened"),
- 'Clownfish::Err', "new" );
-
-my $glorious = GloriousDeath->new("Banzai");
-isa_ok( $glorious, 'GloriousDeath', "subclass" );
-isa_ok( $glorious, 'Clownfish::Err', "subclass" );
-
-isa_ok( Clownfish::Err::trap( "bite_the_dust", undef ),
- 'Clownfish::Err', "trap string call" );
-
-isa_ok( Clownfish::Err::trap( "Nirvana::enter", undef ),
- 'Clownfish::Err', "trap string call in another package" );
-
-isa_ok( Clownfish::Err::trap( \&bite_the_dust, undef ),
- 'Clownfish::Err', "trap sub ref" );
-
-isa_ok( Clownfish::Err::trap( \&Nirvana::enter, undef ),
- 'Clownfish::Err', "trap sub ref to another package" );
-
-isa_ok( Clownfish::Err::trap( \&judge_gladiator, "down" ),
- 'Clownfish::Err', "pass argument to 'trap'" );
-
-my $last_words = sub { die "Rosebud" };
-isa_ok( Clownfish::Err::trap( $last_words, undef ),
- 'Clownfish::Err', "Wrap host exception in Err" );
-
-my $succeed = sub { };
-ok( !defined( Clownfish::Err::trap( $succeed, undef ) ),
- "nothing to trap" );
-
-sub bite_the_dust { die Clownfish::Err->new("gasp") }
-
-sub judge_gladiator {
- my $thumb = shift;
- if ( $thumb and $thumb eq 'down' ) {
- die GloriousDeath->new("gurgle");
- }
-}
-
http://git-wip-us.apache.org/repos/asf/lucy/blob/1704c275/clownfish/runtime/perl/t/binding/038-lock_free_registry.t
----------------------------------------------------------------------
diff --git a/clownfish/runtime/perl/t/binding/038-lock_free_registry.t b/clownfish/runtime/perl/t/binding/038-lock_free_registry.t
deleted file mode 100644
index 0c9f60a..0000000
--- a/clownfish/runtime/perl/t/binding/038-lock_free_registry.t
+++ /dev/null
@@ -1,75 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# 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.
-
-use strict;
-use warnings;
-
-use Config;
-use Test::More;
-BEGIN {
- if ( $ENV{LUCY_VALGRIND} ) {
- plan( skip_all => 'Known leaks' );
- }
- elsif ( !defined( $ENV{LUCY_DEBUG} ) ) {
- plan( skip_all => 'Debug-only test' );
- }
- elsif ( $Config{usethreads} and $^O !~ /mswin/i ) {
- plan( tests => 1 );
- }
- else {
- plan( skip_all => 'No thread support' );
- }
-}
-use threads;
-use threads::shared;
-use Time::HiRes qw( time usleep );
-use List::Util qw( shuffle );
-use Clownfish;
-
-my $registry = Clownfish::LockFreeRegistry->new( capacity => 32 );
-
-sub register_many {
- my ( $nums, $delay ) = @_;
-
- # Encourage contention, so that all threads try to register at the same
- # time.
- sleep $delay;
- threads->yield();
-
- my $succeeded = 0;
- for my $number (@$nums) {
- my $obj = Clownfish::String->new($number);
- $succeeded += $registry->register( key => $obj, value => $obj );
- }
-
- return $succeeded;
-}
-
-my @threads;
-
-my $target_time = time() + .5;
-my @num_sets = map { [ shuffle( 1 .. 10000 ) ] } 1 .. 5;
-for my $num ( 1 .. 5 ) {
- my $delay = $target_time - time();
- my $thread = threads->create( \®ister_many, pop @num_sets, $delay );
- push @threads, $thread;
-}
-
-my $total_succeeded = 0;
-$total_succeeded += $_->join for @threads;
-
-is( $total_succeeded, 10000,
- "registered exactly the right number of entries across all threads" );
-