lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nwelln...@apache.org
Subject [09/19] lucy-clownfish git commit: Perl bindings for Clownfish::Integer
Date Fri, 20 Nov 2015 14:05:30 GMT
Perl bindings for Clownfish::Integer


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

Branch: refs/heads/master
Commit: 41a2c226a0cbae13de4c8522dc498f7db7bfc46e
Parents: be98b65
Author: Nick Wellnhofer <wellnhofer@aevum.de>
Authored: Sun Nov 15 15:30:03 2015 +0100
Committer: Nick Wellnhofer <wellnhofer@aevum.de>
Committed: Tue Nov 17 19:08:43 2015 +0100

----------------------------------------------------------------------
 .../perl/buildlib/Clownfish/Build/Binding.pm    | 49 +++++++++++++++++++-
 runtime/perl/lib/Clownfish/Float.pm             | 25 ++++++++++
 runtime/perl/lib/Clownfish/Integer.pm           | 25 ++++++++++
 runtime/perl/lib/Clownfish/Num.pm               | 25 ----------
 4 files changed, 97 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/41a2c226/runtime/perl/buildlib/Clownfish/Build/Binding.pm
----------------------------------------------------------------------
diff --git a/runtime/perl/buildlib/Clownfish/Build/Binding.pm b/runtime/perl/buildlib/Clownfish/Build/Binding.pm
index aa9bcd2..3b7c14c 100644
--- a/runtime/perl/buildlib/Clownfish/Build/Binding.pm
+++ b/runtime/perl/buildlib/Clownfish/Build/Binding.pm
@@ -30,6 +30,7 @@ sub bind_all {
     $class->bind_err;
     $class->bind_hash;
     $class->bind_float;
+    $class->bind_integer;
     $class->bind_obj;
     $class->bind_vector;
     $class->bind_class;
@@ -289,7 +290,7 @@ END_XS_CODE
 }
 
 sub bind_float {
-    my $float_xs_code = <<'END_XS_CODE';
+    my $xs_code = <<'END_XS_CODE';
 MODULE = Clownfish   PACKAGE = Clownfish::Float
 
 SV*
@@ -310,7 +311,51 @@ END_XS_CODE
         parcel     => "Clownfish",
         class_name => "Clownfish::Float",
     );
-    $binding->append_xs($float_xs_code);
+    $binding->append_xs($xs_code);
+    $binding->exclude_constructor;
+
+    Clownfish::CFC::Binding::Perl::Class->register($binding);
+}
+
+sub bind_integer {
+    my $pod_spec = Clownfish::CFC::Binding::Perl::Pod->new;
+    my $synopsis = <<'END_SYNOPSIS';
+    my $integer = Clownfish::Integer->new(7);
+    my $value = $integer->get_value;
+END_SYNOPSIS
+    my $constructor = <<'END_CONSTRUCTOR';
+=head2 new(value)
+
+    my $integer = Clownfish::Integer->new($value);
+
+Create an Integer containing the passed-in value.
+END_CONSTRUCTOR
+    $pod_spec->set_synopsis($synopsis);
+    $pod_spec->add_constructor( alias => 'new', pod => $constructor );
+
+    my $xs_code = <<'END_XS_CODE';
+MODULE = Clownfish   PACKAGE = Clownfish::Integer
+
+SV*
+new(either_sv, value)
+    SV      *either_sv;
+    int64_t  value;
+CODE:
+{
+    cfish_Integer *self
+        = (cfish_Integer*)XSBind_new_blank_obj(aTHX_ either_sv);
+    cfish_Int_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::Integer",
+    );
+    $binding->set_pod_spec($pod_spec);
+    $binding->append_xs($xs_code);
     $binding->exclude_constructor;
 
     Clownfish::CFC::Binding::Perl::Class->register($binding);

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/41a2c226/runtime/perl/lib/Clownfish/Float.pm
----------------------------------------------------------------------
diff --git a/runtime/perl/lib/Clownfish/Float.pm b/runtime/perl/lib/Clownfish/Float.pm
new file mode 100644
index 0000000..ad8b846
--- /dev/null
+++ b/runtime/perl/lib/Clownfish/Float.pm
@@ -0,0 +1,25 @@
+# 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::Float;
+use Clownfish;
+our $VERSION = '0.004000';
+$VERSION = eval $VERSION;
+
+1;
+
+__END__
+
+

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/41a2c226/runtime/perl/lib/Clownfish/Integer.pm
----------------------------------------------------------------------
diff --git a/runtime/perl/lib/Clownfish/Integer.pm b/runtime/perl/lib/Clownfish/Integer.pm
new file mode 100644
index 0000000..98968b0
--- /dev/null
+++ b/runtime/perl/lib/Clownfish/Integer.pm
@@ -0,0 +1,25 @@
+# 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::Integer;
+use Clownfish;
+our $VERSION = '0.004000';
+$VERSION = eval $VERSION;
+
+1;
+
+__END__
+
+

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/41a2c226/runtime/perl/lib/Clownfish/Num.pm
----------------------------------------------------------------------
diff --git a/runtime/perl/lib/Clownfish/Num.pm b/runtime/perl/lib/Clownfish/Num.pm
deleted file mode 100644
index c343762..0000000
--- a/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.004000';
-$VERSION = eval $VERSION;
-
-1;
-
-__END__
-
-


Mime
View raw message