From: Vincent Pit Date: Sun, 17 May 2009 15:41:59 +0000 (+0200) Subject: Add prototypes X-Git-Tag: v0.06~6 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=dec1755eec42f54c4d57813ed03393c0f765a699;p=perl%2Fmodules%2FScalar-Vec-Util.git Add prototypes --- diff --git a/Util.xs b/Util.xs index f954a42..75ba8ca 100644 --- a/Util.xs +++ b/Util.xs @@ -28,6 +28,7 @@ BOOT: void vfill(SV *sv, SV *ss, SV *sl, SV *sf) +PROTOTYPE: $$$$ PREINIT: size_t s, l, n, o; char f, *v; @@ -59,6 +60,7 @@ CODE: void vcopy(SV *sf, SV *sfs, SV *st, SV *sts, SV *sl) +PROTOTYPE: $$$$$ PREINIT: size_t fs, ts, l, lf = 0, n, o; char *t, *f; @@ -107,6 +109,7 @@ CODE: SV * veq(SV *sv1, SV *ss1, SV *sv2, SV *ss2, SV *sl) +PROTOTYPE: $$$$$ PREINIT: size_t s1, s2, l, o, n; char *v1, *v2; diff --git a/lib/Scalar/Vec/Util.pm b/lib/Scalar/Vec/Util.pm index dd8b1cb..b7ab6ab 100644 --- a/lib/Scalar/Vec/Util.pm +++ b/lib/Scalar/Vec/Util.pm @@ -77,7 +77,7 @@ sub _alldef { return 1; } -sub vfill_pp { +sub vfill_pp ($$$$) { (undef, my $s, my $l, my $x) = @_; croak "Invalid argument" unless _alldef @_; return unless $l; @@ -103,7 +103,7 @@ Doesn't need to allocate any extra memory. =cut -sub vcopy_pp { +sub vcopy_pp ($$$$$) { my ($fs, $ts, $l) = @_[1, 3, 4]; croak "Invalid argument" unless _alldef @_; return unless $l; @@ -124,7 +124,7 @@ Doesn't need to allocate any extra memory. =cut -sub vshift { +sub vshift ($$$$;$) { my ($start, $length, $bits, $insert) = @_[1 .. 4]; return unless $bits; my $left = 1; @@ -154,7 +154,7 @@ Currently allocates an extra buffer of size C. =cut -sub vrot { +sub vrot ($$$$) { my ($start, $length, $bits) = @_[1 .. 3]; return unless $length and $bits; my $left = 1; @@ -184,7 +184,7 @@ If needed, C<$length> is decreased to fit inside C<$v1> and C<$v2> boundaries. =cut -sub veq_pp { +sub veq_pp ($$$$$) { my ($s1, $s2, $l) = @_[1, 3, 4]; croak "Invalid argument" unless _alldef @_; my $i = 0; diff --git a/t/01-import.t b/t/01-import.t index 939ee22..454862e 100644 --- a/t/01-import.t +++ b/t/01-import.t @@ -3,11 +3,22 @@ use strict; use warnings; -use Test::More tests => 6; +use Test::More tests => 2 * 7; require Scalar::Vec::Util; -for (qw/vfill vcopy vshift veq SVU_PP SVU_SIZE/) { +my %syms = ( + vfill => '$$$$', + vcopy => '$$$$$', + veq => '$$$$$', + vshift => '$$$$;$', + vrot => '$$$$', + SVU_PP => '', + SVU_SIZE => '', +); + +for (keys %syms) { eval { Scalar::Vec::Util->import($_) }; - ok(!$@, 'import ' . $_); + is $@, '', "import $_"; + is prototype($_), $syms{$_}, "prototype $_"; }