summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorStephen McCamant <smcc@mit.edu>2003-07-27 10:07:46 -0400
committerJarkko Hietaniemi <jhi@iki.fi>2003-07-28 04:56:48 +0000
commit429a5ce7398d47be4197dc655076a6fb2a8dc641 (patch)
tree7da55163cbb172ac46884c0b9175a916c779fa0d /ext
parentd10dc2ae49cc86b60fcfeb2fbd54ff9f07d3ccc3 (diff)
downloadperl-429a5ce7398d47be4197dc655076a6fb2a8dc641.tar.gz
B enhancements
Message-ID: <16164.5362.577992.841787@syllepsis.MIT.EDU> p4raw-id: //depot/perl@20253
Diffstat (limited to 'ext')
-rw-r--r--ext/B/B.pm13
-rw-r--r--ext/B/B.xs18
-rw-r--r--ext/B/defsubs_h.PL7
3 files changed, 36 insertions, 2 deletions
diff --git a/ext/B/B.pm b/ext/B/B.pm
index b1a68b9cf1..85b88fc592 100644
--- a/ext/B/B.pm
+++ b/ext/B/B.pm
@@ -570,6 +570,14 @@ C<REFCNT> (corresponding to the C function C<SvREFCNT>).
=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<ARRAY>, 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 cfe00792d6..2f87065f76 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 4c6b4cbbd7..7f4ea300a7 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);