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 2011/12/10 00:25:09 UTC
[lucy-commits] svn commit: r1212684 - in /incubator/lucy/trunk/clownfish/lib: ./
Clownfish/Binding/ Clownfish/Binding/Core/ Clownfish/Binding/Perl/
Author: marvin
Date: Fri Dec 9 23:25:08 2011
New Revision: 1212684
URL: http://svn.apache.org/viewvc?rev=1212684&view=rev
Log:
Consolidate most Clownfish::Binding::* Perl code.
Move most Perl code which implements Clownfish::Binding::* into Clownfish.pm.
The exceptions are Clownfish::Binding::Perl and
Clownfish::Binding::Perl::Class, for which porting to C is not yet finished.
Modified:
incubator/lucy/trunk/clownfish/lib/Clownfish.pm
incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core.pm
incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/Aliases.pm
incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/Class.pm
incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/File.pm
incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/Function.pm
incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/Method.pm
incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl.pm
incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Class.pm
incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Constructor.pm
incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Method.pm
incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Pod.pm
incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Subroutine.pm
incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/TypeMap.pm
Modified: incubator/lucy/trunk/clownfish/lib/Clownfish.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/lib/Clownfish.pm?rev=1212684&r1=1212683&r2=1212684&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/lib/Clownfish.pm (original)
+++ incubator/lucy/trunk/clownfish/lib/Clownfish.pm Fri Dec 9 23:25:08 2011
@@ -497,6 +497,191 @@ BEGIN { XSLoader::load( 'Clownfish', '0.
}
}
+{
+ package Clownfish::Binding::Core;
+ use Clownfish::Util qw( verify_args );
+ use Carp;
+
+ our %new_PARAMS = (
+ hierarchy => undef,
+ dest => undef,
+ header => undef,
+ footer => undef,
+ );
+
+ sub new {
+ my ( $either, %args ) = @_;
+ verify_args( \%new_PARAMS, %args ) or confess $@;
+ return _new( @args{qw( hierarchy dest header footer )} );
+ }
+}
+
+{
+ package Clownfish::Binding::Core::Class;
+ use Clownfish::Util qw( a_isa_b verify_args );
+ use Carp;
+
+ our %new_PARAMS = ( client => undef, );
+
+ sub new {
+ my ( $either, %args ) = @_;
+ verify_args( \%new_PARAMS, %args ) or confess $@;
+ return _new( $args{client} );
+ }
+}
+
+{
+ package Clownfish::Binding::Core::File;
+ use Clownfish::Util qw( verify_args );
+ use Carp;
+
+ my %write_h_PARAMS = (
+ file => undef,
+ dest => undef,
+ header => undef,
+ footer => undef,
+ );
+
+ sub write_h {
+ my ( undef, %args ) = @_;
+ verify_args( \%write_h_PARAMS, %args ) or confess $@;
+ _write_h( @args{qw( file dest header footer )} );
+ }
+}
+
+{
+ package Clownfish::Binding::Core::Method;
+
+ sub method_def {
+ my ( undef, %args ) = @_;
+ return _method_def( @args{qw( method class )} );
+ }
+
+ sub callback_obj_def {
+ my ( undef, %args ) = @_;
+ return _callback_obj_def( @args{qw( method offset )} );
+ }
+}
+
+{
+ package Clownfish::Binding::Perl;
+ use Clownfish::Binding::Perl;
+}
+
+{
+ package Clownfish::Binding::Perl::Class;
+ use Clownfish::Binding::Perl::Class;
+}
+
+{
+ package Clownfish::Binding::Perl::Constructor;
+ BEGIN { push our @ISA, 'Clownfish::Binding::Perl::Subroutine' }
+ use Carp;
+ use Clownfish::Util qw( verify_args );
+
+ our %new_PARAMS = (
+ class => undef,
+ alias => undef,
+ );
+
+ sub new {
+ my ( $either, %args ) = @_;
+ confess $@ unless verify_args( \%new_PARAMS, %args );
+ return _new( @args{qw( class alias )} );
+ }
+}
+
+{
+ package Clownfish::Binding::Perl::Method;
+ BEGIN { push our @ISA, 'Clownfish::Binding::Perl::Subroutine' }
+ use Clownfish::Util qw( verify_args );
+ use Carp;
+
+ our %new_PARAMS = (
+ method => undef,
+ alias => undef,
+ );
+
+ sub new {
+ my ( $either, %args ) = @_;
+ confess $@ unless verify_args( \%new_PARAMS, %args );
+ return _new( @args{qw( method alias )} );
+ }
+}
+
+{
+ package Clownfish::Binding::Perl::Pod;
+ BEGIN { push our @ISA, 'Clownfish::Base' }
+ use Clownfish::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 (@$methods) {
+ if ( ref($_) ) {
+ _add_method( $self, $_->{name}, $_->{pod} );
+ }
+ else {
+ _add_method( $self, $_, undef );
+ }
+ }
+ for my $con (@$constructors) {
+ _add_constructor( $self, @{$con}{qw( name pod func sample )} );
+ }
+ return $self;
+ }
+}
+
+{
+ package Clownfish::Binding::Perl::Subroutine;
+ use Carp;
+ use Clownfish::Util qw( verify_args );
+
+ our %new_PARAMS = (
+ param_list => undef,
+ alias => undef,
+ class_name => undef,
+ use_labeled_params => undef,
+ );
+
+ sub new {
+ my ( $either, %args ) = @_;
+ verify_args( \%new_PARAMS, %args ) or confess $@;
+ return _new( ref($either) || $either,
+ @args{qw( param_list class_name alias use_labeled_params )} );
+ }
+
+ sub xsub_def { confess "Abstract method" }
+}
+
+{
+ package Clownfish::Binding::Perl::TypeMap;
+ use base qw( Exporter );
+
+ our @EXPORT_OK = qw( from_perl to_perl );
+
+ sub write_xs_typemap {
+ my ( undef, %args ) = @_;
+ _write_xs_typemap( $args{hierarchy} );
+ }
+}
+
1;
=head1 NAME
Modified: incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core.pm?rev=1212684&r1=1212683&r2=1212684&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core.pm (original)
+++ incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core.pm Fri Dec 9 23:25:08 2011
@@ -13,29 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-use strict;
-use warnings;
-
package Clownfish::Binding::Core;
-use Clownfish::Util qw( verify_args );
-use Clownfish::Binding::Core::Function;
-use Clownfish::Binding::Core::Method;
-use Clownfish::Binding::Core::Class;
-use Clownfish::Binding::Core::File;
-use Clownfish::Binding::Core::Aliases;
-
-our %new_PARAMS = (
- hierarchy => undef,
- dest => undef,
- header => undef,
- footer => undef,
-);
-
-sub new {
- my ( $either, %args ) = @_;
- verify_args( \%new_PARAMS, %args ) or confess $@;
- return _new( @args{qw( hierarchy dest header footer )} );
-}
+use Clownfish;
1;
Modified: incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/Aliases.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/Aliases.pm?rev=1212684&r1=1212683&r2=1212684&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/Aliases.pm (original)
+++ incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/Aliases.pm Fri Dec 9 23:25:08 2011
@@ -13,11 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-use strict;
-use warnings;
-use Clownfish;
-
package Clownfish::Binding::Core::Aliases;
+use Clownfish;
1;
Modified: incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/Class.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/Class.pm?rev=1212684&r1=1212683&r2=1212684&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/Class.pm (original)
+++ incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/Class.pm Fri Dec 9 23:25:08 2011
@@ -13,22 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-use strict;
-use warnings;
-
package Clownfish::Binding::Core::Class;
-use Clownfish::Util qw( a_isa_b verify_args );
-use Clownfish::Binding::Core::Method;
-use Clownfish::Binding::Core::Function;
-use File::Spec::Functions qw( catfile );
-
-our %new_PARAMS = ( client => undef, );
-
-sub new {
- my ( $either, %args ) = @_;
- verify_args( \%new_PARAMS, %args ) or confess $@;
- return _new( $args{client} );
-}
+use Clownfish;
1;
Modified: incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/File.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/File.pm?rev=1212684&r1=1212683&r2=1212684&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/File.pm (original)
+++ incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/File.pm Fri Dec 9 23:25:08 2011
@@ -13,24 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-use strict;
-use warnings;
-
package Clownfish::Binding::Core::File;
-use Clownfish::Util qw( verify_args );
-
-my %write_h_PARAMS = (
- file => undef,
- dest => undef,
- header => undef,
- footer => undef,
-);
-
-sub write_h {
- my ( undef, %args ) = @_;
- verify_args( \%write_h_PARAMS, %args ) or confess $@;
- _write_h( @args{qw( file dest header footer )} );
-}
+use Clownfish;
1;
Modified: incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/Function.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/Function.pm?rev=1212684&r1=1212683&r2=1212684&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/Function.pm (original)
+++ incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/Function.pm Fri Dec 9 23:25:08 2011
@@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+package Clownfish::Binding::Core::Function;
use Clownfish;
1;
Modified: incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/Method.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/Method.pm?rev=1212684&r1=1212683&r2=1212684&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/Method.pm (original)
+++ incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/Method.pm Fri Dec 9 23:25:08 2011
@@ -13,22 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-use strict;
-use warnings;
-
package Clownfish::Binding::Core::Method;
-use Clownfish::Util qw( a_isa_b );
-use Carp;
-
-sub method_def {
- my ( undef, %args ) = @_;
- return _method_def( @args{qw( method class )} );
-}
-
-sub callback_obj_def {
- my ( undef, %args ) = @_;
- return _callback_obj_def( @args{qw( method offset )} );
-}
+use Clownfish;
1;
Modified: incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl.pm?rev=1212684&r1=1212683&r2=1212684&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl.pm (original)
+++ incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl.pm Fri Dec 9 23:25:08 2011
@@ -17,6 +17,7 @@ use strict;
use warnings;
package Clownfish::Binding::Perl;
+use base qw( Clownfish::Base );
use Clownfish::Hierarchy;
use Carp;
Modified: incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Class.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Class.pm?rev=1212684&r1=1212683&r2=1212684&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Class.pm (original)
+++ incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Class.pm Fri Dec 9 23:25:08 2011
@@ -17,6 +17,7 @@ use strict;
use warnings;
package Clownfish::Binding::Perl::Class;
+use base qw( Clownfish::Base );
use Clownfish::Util qw( verify_args );
use Clownfish::Binding::Perl::Pod;
use Carp;
Modified: incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Constructor.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Constructor.pm?rev=1212684&r1=1212683&r2=1212684&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Constructor.pm (original)
+++ incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Constructor.pm Fri Dec 9 23:25:08 2011
@@ -13,24 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-use strict;
-use warnings;
-
package Clownfish::Binding::Perl::Constructor;
-use base qw( Clownfish::Binding::Perl::Subroutine );
-use Carp;
-use Clownfish::Util qw( verify_args );
-
-our %new_PARAMS = (
- class => undef,
- alias => undef,
-);
-
-sub new {
- my ( $either, %args ) = @_;
- confess $@ unless verify_args( \%new_PARAMS, %args );
- return _new( @args{qw( class alias )} );
-}
+use Clownfish;
1;
Modified: incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Method.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Method.pm?rev=1212684&r1=1212683&r2=1212684&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Method.pm (original)
+++ incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Method.pm Fri Dec 9 23:25:08 2011
@@ -13,25 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-use strict;
-use warnings;
-
package Clownfish::Binding::Perl::Method;
-use base qw( Clownfish::Binding::Perl::Subroutine );
-use Clownfish::Util qw( verify_args );
-use Clownfish::Binding::Perl::TypeMap qw( from_perl to_perl );
-use Carp;
-
-our %new_PARAMS = (
- method => undef,
- alias => undef,
-);
-
-sub new {
- my ( $either, %args ) = @_;
- confess $@ unless verify_args( \%new_PARAMS, %args );
- return _new( @args{qw( method alias )} );
-}
+use Clownfish;
1;
Modified: incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Pod.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Pod.pm?rev=1212684&r1=1212683&r2=1212684&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Pod.pm (original)
+++ incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Pod.pm Fri Dec 9 23:25:08 2011
@@ -13,45 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-use strict;
-use warnings;
-
package Clownfish::Binding::Perl::Pod;
-use base qw( Clownfish::Base );
-use Clownfish::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 (@$methods) {
- if ( ref($_) ) {
- _add_method( $self, $_->{name}, $_->{pod} );
- }
- else {
- _add_method( $self, $_, undef );
- }
- }
- for my $con (@$constructors) {
- _add_constructor( $self, @{$con}{qw( name pod func sample )} );
- }
- return $self;
-}
+use Clownfish;
1;
Modified: incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Subroutine.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Subroutine.pm?rev=1212684&r1=1212683&r2=1212684&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Subroutine.pm (original)
+++ incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Subroutine.pm Fri Dec 9 23:25:08 2011
@@ -13,33 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-use strict;
-use warnings;
-
package Clownfish::Binding::Perl::Subroutine;
-use Carp;
-use Clownfish::Class;
-use Clownfish::Function;
-use Clownfish::Method;
-use Clownfish::Variable;
-use Clownfish::ParamList;
-use Clownfish::Util qw( verify_args );
-
-our %new_PARAMS = (
- param_list => undef,
- alias => undef,
- class_name => undef,
- use_labeled_params => undef,
-);
-
-sub new {
- my ( $either, %args ) = @_;
- verify_args( \%new_PARAMS, %args ) or confess $@;
- return _new( ref($either) || $either,
- @args{qw( param_list class_name alias use_labeled_params )} );
-}
-
-sub xsub_def { confess "Abstract method" }
+use Clownfish;
1;
Modified: incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/TypeMap.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/TypeMap.pm?rev=1212684&r1=1212683&r2=1212684&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/TypeMap.pm (original)
+++ incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/TypeMap.pm Fri Dec 9 23:25:08 2011
@@ -13,18 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-use strict;
-use warnings;
-
package Clownfish::Binding::Perl::TypeMap;
-use base qw( Exporter );
-
-our @EXPORT_OK = qw( from_perl to_perl );
-
-sub write_xs_typemap {
- my ( undef, %args ) = @_;
- _write_xs_typemap( $args{hierarchy} );
-}
+use Clownfish;
1;