lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nwelln...@apache.org
Subject [lucy-commits] [05/10] git commit: Perl bindings for CFCPrereq
Date Mon, 17 Mar 2014 17:27:52 GMT
Perl bindings for CFCPrereq


Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/b7189acf
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/b7189acf
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/b7189acf

Branch: refs/heads/explicit-dependencies-wip2
Commit: b7189acf01d49a93cdb4055b46c056b2c432d87c
Parents: cd402eb
Author: Nick Wellnhofer <wellnhofer@aevum.de>
Authored: Mon Mar 17 17:51:59 2014 +0100
Committer: Nick Wellnhofer <wellnhofer@aevum.de>
Committed: Mon Mar 17 18:25:30 2014 +0100

----------------------------------------------------------------------
 compiler/perl/lib/Clownfish/CFC.pm              | 20 +++++++++++
 compiler/perl/lib/Clownfish/CFC.xs              | 36 ++++++++++++++++++++
 compiler/perl/lib/Clownfish/CFC/Model/Prereq.pm | 20 +++++++++++
 compiler/perl/t/403-parcel.t                    | 15 +++++++-
 compiler/perl/typemap                           |  1 +
 5 files changed, 91 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/b7189acf/compiler/perl/lib/Clownfish/CFC.pm
----------------------------------------------------------------------
diff --git a/compiler/perl/lib/Clownfish/CFC.pm b/compiler/perl/lib/Clownfish/CFC.pm
index c918155..d5a070b 100644
--- a/compiler/perl/lib/Clownfish/CFC.pm
+++ b/compiler/perl/lib/Clownfish/CFC.pm
@@ -390,6 +390,26 @@ BEGIN { XSLoader::load( 'Clownfish::CFC', '0.01' ) }
 }
 
 {
+    package Clownfish::CFC::Model::Prereq;
+    BEGIN { push our @ISA, 'Clownfish::CFC::Base' }
+    use Clownfish::CFC::Util qw( verify_args );
+    use Scalar::Util qw( blessed );
+    use Carp;
+
+    our %new_PARAMS = (
+        name        => undef,
+        version     => undef,
+    );
+
+    sub new {
+        my ( $either, %args ) = @_;
+        verify_args( \%new_PARAMS, %args ) or confess $@;
+        confess "no subclassing allowed" unless $either eq __PACKAGE__;
+        return _new( @args{qw( name version )} );
+    }
+}
+
+{
     package Clownfish::CFC::Model::Symbol;
     BEGIN { push our @ISA, 'Clownfish::CFC::Base' }
     use Clownfish::CFC::Util qw( verify_args );

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/b7189acf/compiler/perl/lib/Clownfish/CFC.xs
----------------------------------------------------------------------
diff --git a/compiler/perl/lib/Clownfish/CFC.xs b/compiler/perl/lib/Clownfish/CFC.xs
index f69dfc4..fe23b86 100644
--- a/compiler/perl/lib/Clownfish/CFC.xs
+++ b/compiler/perl/lib/Clownfish/CFC.xs
@@ -1205,6 +1205,42 @@ PPCODE:
 }
 
 
+MODULE = Clownfish::CFC   PACKAGE = Clownfish::CFC::Model::Prereq
+
+SV*
+_new(name_sv, version)
+    SV *name_sv;
+    CFCVersion *version;
+CODE:
+    const char *name  = SvOK(name_sv)  ? SvPV_nolen(name_sv)  : NULL;
+    CFCPrereq *self = CFCPrereq_new(name, version);
+    RETVAL = S_cfcbase_to_perlref(self);
+    CFCBase_decref((CFCBase*)self);
+OUTPUT: RETVAL
+
+void
+_set_or_get(self, ...)
+    CFCPrereq *self;
+ALIAS:
+    get_name    = 2
+    get_version = 4
+PPCODE:
+{
+    START_SET_OR_GET_SWITCH
+        case 2: {
+                const char *name = CFCPrereq_get_name(self);
+                retval = newSVpvn(name, strlen(name));
+            }
+            break;
+        case 4: {
+                CFCVersion *value = CFCPrereq_get_version(self);
+                retval = S_cfcbase_to_perlref(value);
+            }
+            break;
+    END_SET_OR_GET_SWITCH
+}
+
+
 MODULE = Clownfish::CFC   PACKAGE = Clownfish::CFC::Model::Symbol
 
 SV*

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/b7189acf/compiler/perl/lib/Clownfish/CFC/Model/Prereq.pm
----------------------------------------------------------------------
diff --git a/compiler/perl/lib/Clownfish/CFC/Model/Prereq.pm b/compiler/perl/lib/Clownfish/CFC/Model/Prereq.pm
new file mode 100644
index 0000000..99a4eca
--- /dev/null
+++ b/compiler/perl/lib/Clownfish/CFC/Model/Prereq.pm
@@ -0,0 +1,20 @@
+# 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::CFC::Model::Prereq;
+use Clownfish::CFC;
+
+1;
+

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/b7189acf/compiler/perl/t/403-parcel.t
----------------------------------------------------------------------
diff --git a/compiler/perl/t/403-parcel.t b/compiler/perl/t/403-parcel.t
index 540e6ba..fb23b08 100644
--- a/compiler/perl/t/403-parcel.t
+++ b/compiler/perl/t/403-parcel.t
@@ -16,9 +16,22 @@
 use strict;
 use warnings;
 
-use Test::More tests => 17;
+use Test::More tests => 21;
 use File::Spec::Functions qw( catfile );
 
+BEGIN { use_ok('Clownfish::CFC::Model::Prereq') }
+
+{
+    my $version = Clownfish::CFC::Model::Version->new( vstring => 'v34.5.67' );
+    my $prereq  = Clownfish::CFC::Model::Prereq->new(
+        name    => 'Flour',
+        version => $version,
+    );
+    ok( $prereq, "new prereq" );
+    is( $prereq->get_name, 'Flour', 'prereq get_name' );
+    is( $prereq->get_version->compare_to($version), 0, 'prereq get_version');
+}
+
 BEGIN { use_ok('Clownfish::CFC::Model::Parcel') }
 
 my $foo = Clownfish::CFC::Model::Parcel->new( name => "Foo" );

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/b7189acf/compiler/perl/typemap
----------------------------------------------------------------------
diff --git a/compiler/perl/typemap b/compiler/perl/typemap
index d744071..a83840e 100644
--- a/compiler/perl/typemap
+++ b/compiler/perl/typemap
@@ -27,6 +27,7 @@ CFCMemPool*	CLOWNFISH_TYPE
 CFCParamList*	CLOWNFISH_MODEL
 CFCParcel*	CLOWNFISH_MODEL
 CFCParser*	CLOWNFISH_TYPE
+CFCPrereq*	CLOWNFISH_MODEL
 CFCSymbol*	CLOWNFISH_MODEL
 CFCTest*	CLOWNFISH_TYPE
 CFCType*	CLOWNFISH_MODEL


Mime
View raw message