X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=av.c;h=264fe23b10da3adbe4e8c3d413919e2a8a8bfab2;hb=954c1994944eafa74aaac1bab94e820b6e447da9;hp=af8296a841e2b963ade237d1e1ef71861122c814;hpb=030866aa8d0911636ef2210b710f544fd2c85c8e;p=p5sagit%2Fp5-mst-13.2.git diff --git a/av.c b/av.c index af8296a..264fe23 100644 --- a/av.c +++ b/av.c @@ -46,6 +46,15 @@ Perl_av_reify(pTHX_ AV *av) AvREAL_on(av); } +/* +=for apidoc av_extend + +Pre-extend an array. The C is the index to which the array should be +extended. + +=cut +*/ + void Perl_av_extend(pTHX_ AV *av, I32 key) { @@ -151,6 +160,19 @@ Perl_av_extend(pTHX_ AV *av, I32 key) } } +/* +=for apidoc av_fetch + +Returns the SV at the specified index in the array. The C is the +index. If C 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. + +See L for more information +on how to use this function on tied arrays. + +=cut +*/ + SV** Perl_av_fetch(pTHX_ register AV *av, I32 key, I32 lval) { @@ -198,6 +220,23 @@ Perl_av_fetch(pTHX_ register AV *av, I32 key, I32 lval) return &AvARRAY(av)[key]; } +/* +=for apidoc av_store + +Stores an SV in an array. The array index is specified as C. The +return value will be NULL if the operation failed or if the value did not +need to be actually stored within the array (as in the case of tied +arrays). Otherwise it can be dereferenced to get the original C. Note +that the caller is responsible for suitably incrementing the reference +count of C before the call, and decrementing it if the function +returned NULL. + +See L for +more information on how to use this function on tied arrays. + +=cut +*/ + SV** Perl_av_store(pTHX_ register AV *av, I32 key, SV *val) { @@ -257,6 +296,14 @@ Perl_av_store(pTHX_ register AV *av, I32 key, SV *val) return &ary[key]; } +/* +=for apidoc newAV + +Creates a new AV. The reference count is set to 1. + +=cut +*/ + AV * Perl_newAV(pTHX) { @@ -271,6 +318,16 @@ Perl_newAV(pTHX) return av; } +/* +=for apidoc av_make + +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. + +=cut +*/ + AV * Perl_av_make(pTHX_ register I32 size, register SV **strp) { @@ -320,6 +377,15 @@ Perl_av_fake(pTHX_ register I32 size, register SV **strp) return av; } +/* +=for apidoc av_clear + +Clears an array, making it empty. Does not free the memory used by the +array itself. + +=cut +*/ + void Perl_av_clear(pTHX_ register AV *av) { @@ -361,6 +427,14 @@ Perl_av_clear(pTHX_ register AV *av) } +/* +=for apidoc av_undef + +Undefines the array. Frees the memory used by the array itself. + +=cut +*/ + void Perl_av_undef(pTHX_ register AV *av) { @@ -389,6 +463,15 @@ Perl_av_undef(pTHX_ register AV *av) } } +/* +=for apidoc av_push + +Pushes an SV onto the end of the array. The array will grow automatically +to accommodate the addition. + +=cut +*/ + void Perl_av_push(pTHX_ register AV *av, SV *val) { @@ -415,6 +498,15 @@ Perl_av_push(pTHX_ register AV *av, SV *val) av_store(av,AvFILLp(av)+1,val); } +/* +=for apidoc av_pop + +Pops an SV off the end of the array. Returns C<&PL_sv_undef> if the array +is empty. + +=cut +*/ + SV * Perl_av_pop(pTHX_ register AV *av) { @@ -448,6 +540,16 @@ Perl_av_pop(pTHX_ register AV *av) return retval; } +/* +=for apidoc av_unshift + +Unshift the given number of C values onto the beginning of the +array. The array will grow automatically to accommodate the addition. You +must then use C to assign values to these new elements. + +=cut +*/ + void Perl_av_unshift(pTHX_ register AV *av, register I32 num) { @@ -501,6 +603,14 @@ Perl_av_unshift(pTHX_ register AV *av, register I32 num) } } +/* +=for apidoc av_shift + +Shifts an SV off the beginning of the array. + +=cut +*/ + SV * Perl_av_shift(pTHX_ register AV *av) { @@ -538,6 +648,15 @@ Perl_av_shift(pTHX_ register AV *av) return retval; } +/* +=for apidoc av_len + +Returns the highest index in the array. Returns -1 if the array is +empty. + +=cut +*/ + I32 Perl_av_len(pTHX_ register AV *av) {