From: Nicholas Clark Date: Sun, 31 Dec 2006 00:08:00 +0000 (+0000) Subject: Move SVt_BIND to be the lowest type after SVt_NULL. This will force all X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1cb9cd5016282146cd55ab904078500def5f5754;p=p5sagit%2Fp5-mst-13.2.git 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 --- diff --git a/dump.c b/dump.c index 0ad48d1..7f22181 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 84b2905..a782d68 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 65060fa..6303c4c 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 f7a7ba0..0bafb99 100644 --- a/sv.h +++ b/sv.h @@ -45,10 +45,10 @@ Type flag for code refs. See C. 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. #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), \