X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=sv.h;h=53fc1f0ad516c4e952813ee5afb6d893473288dd;hb=777d2cf58fa8e7c971ce9115520838a43768a81d;hp=6625730e7210a355efe99fabde3755b196fb9d6f;hpb=659239a4cd11b2ba8db82db8b10f3ce574b1b819;p=p5sagit%2Fp5-mst-13.2.git diff --git a/sv.h b/sv.h index 6625730..53fc1f0 100644 --- a/sv.h +++ b/sv.h @@ -61,7 +61,7 @@ typedef enum { /* Using C's structural equivalence to help emulate C++ inheritance here... */ -struct sv { +struct STRUCT_SV { void* sv_any; /* pointer to something */ U32 sv_refcnt; /* how many references to us */ U32 sv_flags; /* what we are */ @@ -442,6 +442,18 @@ Unsets the IV status of an SV. =for apidoc Am|void|SvIOK_only|SV* sv Tells an SV that it is an integer and disables all other OK bits. +=for apidoc Am|void|SvIOK_only_UV|SV* sv +Tells and SV that it is an unsigned integer and disables all other OK bits. + +=for apidoc Am|void|SvIOK_UV|SV* sv +Returns a boolean indicating whether the SV contains an unsigned integer. + +=for apidoc Am|void|SvUOK|SV* sv +Returns a boolean indicating whether the SV contains an unsigned integer. + +=for apidoc Am|void|SvIOK_notUV|SV* sv +Returns a boolean indicating whether the SV contains an signed integer. + =for apidoc Am|bool|SvNOK|SV* sv Returns a boolean indicating whether the SV contains a double. @@ -553,6 +565,7 @@ Set the length of the string which is in the SV. See C. #define SvIOK_UV(sv) ((SvFLAGS(sv) & (SVf_IOK|SVf_IVisUV)) \ == (SVf_IOK|SVf_IVisUV)) +#define SvUOK(sv) SvIOK_UV(sv) #define SvIOK_notUV(sv) ((SvFLAGS(sv) & (SVf_IOK|SVf_IVisUV)) \ == SVf_IOK) @@ -566,6 +579,23 @@ Set the length of the string which is in the SV. See C. #define SvNOK_only(sv) ((void)SvOK_off(sv), \ SvFLAGS(sv) |= (SVf_NOK|SVp_NOK)) +/* +=for apidoc Am|void|SvUTF8|SV* sv +Returns a boolean indicating whether the SV contains UTF-8 encoded data. + +=for apidoc Am|void|SvUTF8_on|SV *sv +Tells an SV that it is a string and encoded in UTF8. Do not use frivolously. + +=for apidoc Am|void|SvUTF8_off|SV *sv +Unsets the UTF8 status of an SV. + +=for apidoc Am|void|SvPOK_only_UTF8|SV* sv +Tells an SV that it is a UTF8 string (do not use frivolously) +and disables all other OK bits. + +=cut + */ + #define SvUTF8(sv) (SvFLAGS(sv) & SVf_UTF8) #define SvUTF8_on(sv) (SvFLAGS(sv) |= (SVf_UTF8)) #define SvUTF8_off(sv) (SvFLAGS(sv) &= ~(SVf_UTF8)) @@ -612,6 +642,8 @@ Set the length of the string which is in the SV. See C. #define SvAMAGIC_on(sv) (SvFLAGS(sv) |= SVf_AMAGIC) #define SvAMAGIC_off(sv) (SvFLAGS(sv) &= ~SVf_AMAGIC) +#define SvGAMAGIC(sv) (SvFLAGS(sv) & (SVs_GMG|SVf_AMAGIC)) + /* #define Gv_AMG(stash) \ (HV_AMAGICmb(stash) && \ @@ -686,6 +718,12 @@ Set the length of the string which is in the SV. See C. #define SvMAGIC(sv) ((XPVMG*) SvANY(sv))->xmg_magic #define SvSTASH(sv) ((XPVMG*) SvANY(sv))->xmg_stash +/* Ask a scalar nicely to try to become an IV, if possible. + Not guaranteed to stay returning void */ +/* Macro won't actually call sv_2iv if already IOK */ +#define SvIV_please(sv) \ + STMT_START {if (!SvIOKp(sv) && (SvNOK(sv) || SvPOK(sv))) \ + (void) SvIV(sv); } STMT_END #define SvIV_set(sv, val) \ STMT_START { assert(SvTYPE(sv) == SVt_IV || SvTYPE(sv) >= SVt_PVIV); \ (((XPVIV*) SvANY(sv))->xiv_iv = val); } STMT_END @@ -734,18 +772,15 @@ Set the length of the string which is in the SV. See C. #define IoTYPE(sv) ((XPVIO*) SvANY(sv))->xio_type #define IoFLAGS(sv) ((XPVIO*) SvANY(sv))->xio_flags -/* -IoTYPE(sv) is a single character saying what type of I/O connection -this is: - | pipe - - stdin or stdout - < read-only - > write-only - a append - + read and write - s socket - space closed -*/ +/* IoTYPE(sv) is a single character telling the type of I/O connection. */ +#define IoTYPE_RDONLY '<' +#define IoTYPE_WRONLY '>' +#define IoTYPE_RDWR '+' +#define IoTYPE_APPEND 'a' +#define IoTYPE_PIPE '|' +#define IoTYPE_STD '-' /* stdin or stdout */ +#define IoTYPE_SOCKET 's' +#define IoTYPE_CLOSED ' ' /* =for apidoc Am|bool|SvTAINTED|SV* sv @@ -776,7 +811,6 @@ Taints an SV if tainting is enabled #define SvTAINT(sv) \ STMT_START { \ if (PL_tainting) { \ - dTHR; \ if (PL_tainted) \ SvTAINTED_on(sv); \ } \ @@ -1072,3 +1106,4 @@ Returns a pointer to the character buffer. #define SvGROW(sv,len) (SvLEN(sv) < (len) ? sv_grow(sv,len) : SvPVX(sv)) #define Sv_Grow sv_grow +#define SV_IMMEDIATE_UNREF 1