summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2006-12-31 00:08:00 +0000
committerNicholas Clark <nick@ccl4.org>2006-12-31 00:08:00 +0000
commit1cb9cd5016282146cd55ab904078500def5f5754 (patch)
tree4952a1cfb2e8ca1b21b5c8c452ec04043a27857e
parentf6fd7794b9baf00eb9b1d47e4ad481f2e8866e76 (diff)
downloadperl-1cb9cd5016282146cd55ab904078500def5f5754.tar.gz
Move SVt_BIND to be the lowest type after SVt_NULL. This will force all
code attempting to upgrade a BIND to anything into sv_upgrade(), which for now will croak, but in future can DTRT, for whatever TRT is decided to be. Make SvOK() check the flags of the referenant for a BIND, as I envisage that the only flag bit that will get set on a BIND is SVf_UTF8 even if the referant has a defined value. p4raw-id: //depot/perl@29642
-rw-r--r--dump.c4
-rw-r--r--ext/B/B.xs6
-rw-r--r--sv.c8
-rw-r--r--sv.h12
4 files changed, 17 insertions, 13 deletions
diff --git a/dump.c b/dump.c
index 0ad48d1e99..7f221814a9 100644
--- a/dump.c
+++ b/dump.c
@@ -29,10 +29,10 @@
static const char* const svtypenames[SVt_LAST] = {
"NULL",
+ "BIND",
"IV",
"NV",
"RV",
- "BIND",
"PV",
"PVIV",
"PVNV",
@@ -49,10 +49,10 @@ static const char* const svtypenames[SVt_LAST] = {
static const char* const svshorttypenames[SVt_LAST] = {
"UNDEF",
+ "BIND",
"IV",
"NV",
"RV",
- "BIND",
"PV",
"PVIV",
"PVNV",
diff --git a/ext/B/B.xs b/ext/B/B.xs
index 84b29055c6..a782d68963 100644
--- a/ext/B/B.xs
+++ b/ext/B/B.xs
@@ -21,12 +21,12 @@ typedef FILE * InputStream;
static const char* const svclassnames[] = {
"B::NULL",
- "B::IV",
- "B::NV",
- "B::RV",
#if PERL_VERSION >= 9
"B::BIND",
#endif
+ "B::IV",
+ "B::NV",
+ "B::RV",
"B::PV",
"B::PVIV",
"B::PVNV",
diff --git a/sv.c b/sv.c
index 65060fa12f..6303c4c36e 100644
--- a/sv.c
+++ b/sv.c
@@ -887,6 +887,11 @@ static const struct body_details bodies_by_type[] = {
{ sizeof(HE), 0, 0, SVt_NULL,
FALSE, NONV, NOARENA, FIT_ARENA(0, sizeof(HE)) },
+ /* The bind placeholder pretends to be an RV for now.
+ Also it's marked as "can't upgrade" top stop anyone using it before it's
+ implemented. */
+ { 0, 0, 0, SVt_BIND, TRUE, NONV, NOARENA, 0 },
+
/* IVs are in the head, so the allocation size is 0.
However, the slot is overloaded for PTEs. */
{ sizeof(struct ptr_tbl_ent), /* This is used for PTEs. */
@@ -904,9 +909,6 @@ static const struct body_details bodies_by_type[] = {
/* RVs are in the head now. */
{ 0, 0, 0, SVt_RV, FALSE, NONV, NOARENA, 0 },
- /* The bind placeholder pretends to be an RV for now. */
- { 0, 0, 0, SVt_BIND, FALSE, NONV, NOARENA, 0 },
-
/* 8 bytes on most ILP32 with IEEE doubles */
{ sizeof(xpv_allocated),
copy_length(XPV, xpv_len)
diff --git a/sv.h b/sv.h
index f7a7ba0935..0bafb9914d 100644
--- a/sv.h
+++ b/sv.h
@@ -45,10 +45,10 @@ Type flag for code refs. See C<svtype>.
typedef enum {
SVt_NULL, /* 0 */
- SVt_IV, /* 1 */
- SVt_NV, /* 2 */
- SVt_RV, /* 3 */
- SVt_BIND, /* 4 */
+ SVt_BIND, /* 1 */
+ SVt_IV, /* 2 */
+ SVt_NV, /* 3 */
+ SVt_RV, /* 4 */
SVt_PV, /* 5 */
SVt_PVIV, /* 6 */
SVt_PVNV, /* 7 */
@@ -942,7 +942,9 @@ Set the actual length of the string which is in the SV. See C<SvIV_set>.
#define assert_not_glob(sv)
#endif
-#define SvOK(sv) (SvFLAGS(sv) & SVf_OK)
+#define SvOK(sv) ((SvTYPE(sv) == SVt_BIND) \
+ ? (SvFLAGS(SvRV(sv)) & SVf_OK) \
+ : (SvFLAGS(sv) & SVf_OK))
#define SvOK_off(sv) (assert_not_ROK(sv) assert_not_glob(sv) \
SvFLAGS(sv) &= ~(SVf_OK| \
SVf_IVisUV|SVf_UTF8), \