From: Stephen McCamant Date: Sun, 27 Jul 2003 14:07:46 +0000 (-0400) Subject: B enhancements X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=429a5ce7398d47be4197dc655076a6fb2a8dc641;p=p5sagit%2Fp5-mst-13.2.git B enhancements Message-ID: <16164.5362.577992.841787@syllepsis.MIT.EDU> p4raw-id: //depot/perl@20253 --- diff --git a/ext/B/B.pm b/ext/B/B.pm index b1a68b9..85b88fc 100644 --- a/ext/B/B.pm +++ b/ext/B/B.pm @@ -570,6 +570,14 @@ C (corresponding to the C function C). =item FLAGS +=item object_2svref + +Returns a reference to the regular scalar corresponding to this +B::SV object. In other words, this method is the inverse operation +to the svref_2object() subroutine. This scalar and other data it points +at should be considered read-only: modifying them is neither safe nor +guaranteed to have a sensible effect. + =back =head2 B::IV Methods @@ -820,6 +828,11 @@ IoIFP($io) == PerlIO_stdin() ). =item ARRAY +=item ARRAYelt + +Like C, but takes an index as an argument to get only one element, +rather than a list of all of them. + =item AvFLAGS =back diff --git a/ext/B/B.xs b/ext/B/B.xs index cfe0079..2f87065 100644 --- a/ext/B/B.xs +++ b/ext/B/B.xs @@ -1049,6 +1049,13 @@ U32 SvTYPE(sv) B::SV sv +#define object_2svref(sv) sv +#define SVREF SV * + +SVREF +object_2svref(sv) + B::SV sv + MODULE = B PACKAGE = B::SV PREFIX = Sv U32 @@ -1518,6 +1525,17 @@ AvARRAY(av) XPUSHs(make_sv_object(aTHX_ sv_newmortal(), svp[i])); } +void +AvARRAYelt(av, idx) + B::AV av + int idx + PPCODE: + if (idx >= 0 && AvFILL(av) >= 0 && idx <= AvFILL(av)) + XPUSHs(make_sv_object(aTHX_ sv_newmortal(), (AvARRAY(av)[idx]))); + else + XPUSHs(make_sv_object(aTHX_ sv_newmortal(), NULL)); + + MODULE = B PACKAGE = B::AV U8 diff --git a/ext/B/defsubs_h.PL b/ext/B/defsubs_h.PL index 4c6b4cb..7f4ea30 100644 --- a/ext/B/defsubs_h.PL +++ b/ext/B/defsubs_h.PL @@ -21,8 +21,11 @@ foreach my $const (qw( CVf_CLONE CVf_CLONED CVf_ANON CVf_OLDSTYLE CVf_UNIQUE CVf_NODEBUG CVf_METHOD CVf_LOCKED CVf_LVALUE CVf_CONST CVf_WEAKOUTSIDE CVf_ASSERTION - SVpad_OUR SVf_FAKE SVf_IOK SVf_IVisUV SVf_NOK SVf_POK - SVf_ROK SVp_IOK SVp_POK SVp_NOK SVt_PVGV SVt_PVHV SVs_RMG + SVpad_OUR SVf_FAKE SVf_IVisUV + SVf_IOK SVf_NOK SVf_POK SVf_ROK + SVp_IOK SVp_NOK SVp_POK + SVt_PVGV SVt_PVHV + SVs_RMG SVs_SMG )) { doconst($const);