Perl bindings for Clownfish::HashIterator
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/5583961b Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/5583961b Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/5583961b Branch: refs/heads/master Commit: 5583961b5894e6d74ff693414e3f7c51732ed712 Parents: 49093b3 Author: Nick Wellnhofer <wellnho...@aevum.de> Authored: Sun Nov 15 17:19:26 2015 +0100 Committer: Nick Wellnhofer <wellnho...@aevum.de> Committed: Tue Nov 17 19:08:43 2015 +0100 ---------------------------------------------------------------------- .../perl/buildlib/Clownfish/Build/Binding.pm | 48 ++++++++++++++++++++ runtime/perl/lib/Clownfish/HashIterator.pm | 25 ++++++++++ 2 files changed, 73 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/5583961b/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 d2a99fa..ecb6bba 100644 --- a/runtime/perl/buildlib/Clownfish/Build/Binding.pm +++ b/runtime/perl/buildlib/Clownfish/Build/Binding.pm @@ -31,6 +31,7 @@ sub bind_all { $class->bind_string; $class->bind_err; $class->bind_hash; + $class->bind_hashiterator; $class->bind_float; $class->bind_integer; $class->bind_obj; @@ -366,6 +367,53 @@ END_XS_CODE Clownfish::CFC::Binding::Perl::Class->register($binding); } +sub bind_hashiterator { + my $pod_spec = Clownfish::CFC::Binding::Perl::Pod->new; + my $synopsis = <<'END_SYNOPSIS'; + my $iter = Clownfish::HashIterator->new($hash); + while ($iter->next) { + my $key = $iter->get_key; + my $value = $iter->get_value; + } +END_SYNOPSIS + my $constructor = <<'END_CONSTRUCTOR'; +=head2 new(hash) + + my $iter = Clownfish::HashIterator->new($hash); + +Return a HashIterator for the passed-in Hash. +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::HashIterator + +SV* +new(either_sv, hash) + SV *either_sv; + cfish_Hash *hash; +CODE: +{ + cfish_HashIterator *self + = (cfish_HashIterator*)XSBind_new_blank_obj(aTHX_ either_sv); + cfish_HashIter_init(self, hash); + 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::HashIterator", + ); + $binding->set_pod_spec($pod_spec); + $binding->append_xs($xs_code); + $binding->exclude_constructor; + + Clownfish::CFC::Binding::Perl::Class->register($binding); +} + sub bind_float { my $xs_code = <<'END_XS_CODE'; MODULE = Clownfish PACKAGE = Clownfish::Float http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/5583961b/runtime/perl/lib/Clownfish/HashIterator.pm ---------------------------------------------------------------------- diff --git a/runtime/perl/lib/Clownfish/HashIterator.pm b/runtime/perl/lib/Clownfish/HashIterator.pm new file mode 100644 index 0000000..f667c06 --- /dev/null +++ b/runtime/perl/lib/Clownfish/HashIterator.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::HashIterator; +use Clownfish; +our $VERSION = '0.004000'; +$VERSION = eval $VERSION; + +1; + +__END__ + +