In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/775f1d61966fb2c5300c9c08fa931980430ed0da?hp=d5cd9e7bba185db6dc6b1e6fa215978a38ae9ea8>
- Log ----------------------------------------------------------------- commit 775f1d61966fb2c5300c9c08fa931980430ed0da Author: Shlomi Fish <[email protected]> Date: Mon May 24 23:40:48 2010 +0300 Add the perl equivalent for av_make. Signed-off-by: David Golden <[email protected]> M av.c commit a8676f70bbd19ba630d2e76288f31b4a2d7a63f1 Author: Shlomi Fish <[email protected]> Date: Wed May 19 20:11:03 2010 +0300 Add the Perl equivalent for av_len. Signed-off-by: David Golden <[email protected]> M av.c commit 1a3362a5d4e9f2d3548e2937ecf5a9a8a1ac7898 Author: Shlomi Fish <[email protected]> Date: Wed May 19 17:46:43 2010 +0300 Add a missing comma in the av_fill() docs. Minor, but still good enough for a commit. Signed-off-by: David Golden <[email protected]> M av.c commit 1a32886282d60539000205670909069b85d9eedd Author: Shlomi Fish <[email protected]> Date: Tue May 18 17:42:52 2010 +0300 Clarify the av_fetch() documentation. Thanks to LeoNerd and Zefram on #p5p on IRC for some insights and suggesting versions for the modified text. I ended up using Zefram's version. Signed-off-by: David Golden <[email protected]> M av.c commit b7ff7ff211d0d5fc593efe5c9d305d197ecb8d86 Author: Shlomi Fish <[email protected]> Date: Tue May 18 15:31:41 2010 +0300 Add Perl equivalent for av_exists(). This mentions that it's equivalent to exists($myarray[$key]). Signed-off-by: David Golden <[email protected]> M av.c commit 71282cab69578876db765e8d8aadb9cc2331ebf2 Author: Shlomi Fish <[email protected]> Date: Sat May 15 22:13:59 2010 +0300 Add a Perl equivalent to av_delete(). Signed-off-by: David Golden <[email protected]> M av.c commit 31bde0acd044dc2a6e4ccd40fa4660a6009fcb9d Author: Shlomi Fish <[email protected]> Date: Sat May 15 21:44:58 2010 +0300 Add the Perl equivalent example to av_clear. Signed-off-by: David Golden <[email protected]> M av.c commit 683d9ad15a8b09b17249f2efd39d10a9a251cd95 Author: Shlomi Fish <[email protected]> Date: Sat May 15 21:37:46 2010 +0300 Link from GIMME_V to perlcall for a usage example. Added a link from the GIMME_V entry to perlcall for a usage example. Signed-off-by: David Golden <[email protected]> M op.h ----------------------------------------------------------------------- Summary of changes: av.c | 20 +++++++++++++++----- op.h | 2 +- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/av.c b/av.c index b93a6d5..219870c 100644 --- a/av.c +++ b/av.c @@ -191,12 +191,14 @@ Perl_av_extend(pTHX_ AV *av, I32 key) =for apidoc av_fetch Returns the SV at the specified index in the array. The C<key> is the -index. If C<lval> is set then the fetch will be part of a store. Check -that the return value is non-null before dereferencing it to a C<SV*>. +index. If lval is true, you are guaranteed to get a real SV back (in case +it wasn't real before), which you can then modify. Check that the return +value is non-null before dereferencing it to a C<SV*>. See L<perlguts/"Understanding the Magic of Tied Hashes and Arrays"> for more information on how to use this function on tied arrays. +The rough perl equivalent is C<$myarray[$idx]>. =cut */ @@ -377,6 +379,8 @@ Creates a new AV and populates it with a list of SVs. The SVs are copied into the array, so they may be freed after the call to av_make. The new AV will have a reference count of 1. +Perl equivalent: C<my @new_array = ($scalar1, $scalar2, $scalar3...);> + =cut */ @@ -415,7 +419,7 @@ Perl_av_make(pTHX_ register I32 size, register SV **strp) =for apidoc av_clear Clears an array, making it empty. Does not free the memory used by the -array itself. +array itself. Perl equivalent: C<@myarray = ();>. =cut */ @@ -719,6 +723,8 @@ Perl_av_shift(pTHX_ register AV *av) Returns the highest index in the array. The number of elements in the array is C<av_len(av) + 1>. Returns -1 if the array is empty. +The Perl equivalent for this is C<$#myarray>. + =cut */ @@ -738,7 +744,7 @@ Set the highest index in the array to the given number, equivalent to Perl's C<$#array = $fill;>. The number of elements in the an array will be C<fill + 1> after -av_fill() returns. If the array was previously shorter then the +av_fill() returns. If the array was previously shorter, then the additional elements appended are set to C<PL_sv_undef>. If the array was longer, then the excess elements are freed. C<av_fill(av, -1)> is the same as C<av_clear(av)>. @@ -791,7 +797,9 @@ Perl_av_fill(pTHX_ register AV *av, I32 fill) Deletes the element indexed by C<key> from the array. Returns the deleted element. If C<flags> equals C<G_DISCARD>, the element is freed -and null is returned. +and null is returned. Perl equivalent: C<my $elem = delete($myarray[$idx]);> +for the non-C<G_DISCARD> version and a void-context C<delete($myarray[$idx]);> +for the C<G_DISCARD> version. =cut */ @@ -883,6 +891,8 @@ Returns true if the element indexed by C<key> has been initialized. This relies on the fact that uninitialized array elements are set to C<&PL_sv_undef>. +Perl equivalent: C<exists($myarray[$key])>. + =cut */ bool diff --git a/op.h b/op.h index b66c4a1..712039c 100644 --- a/op.h +++ b/op.h @@ -85,7 +85,7 @@ typedef PERL_BITFIELD16 Optype; =for apidoc Amn|U32|GIMME_V The XSUB-writer's equivalent to Perl's C<wantarray>. Returns C<G_VOID>, C<G_SCALAR> or C<G_ARRAY> for void, scalar or list context, -respectively. +respectively. See L<perlcall> for a usage example. =for apidoc Amn|U32|GIMME A backward-compatible version of C<GIMME_V> which can only return -- Perl5 Master Repository
