X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=sv.h;h=e99891dd22c0efc25d1a3f6bdc8dec4108f72f48;hb=04dc9db9ad04317b0c2997dfa065b4061e90e683;hp=a08a9c823907753d70a3093aac4f5a7b21035b40;hpb=9e7bc3e8c0a5a5a357a2bda9981a86c5a61092c1;p=p5sagit%2Fp5-mst-13.2.git diff --git a/sv.h b/sv.h index a08a9c8..e99891d 100644 --- a/sv.h +++ b/sv.h @@ -1,6 +1,6 @@ /* sv.h * - * Copyright (c) 1991-1997, Larry Wall + * Copyright (c) 1991-1999, Larry Wall * * You may distribute under the terms of either the GNU General Public * License or the Artistic License, as specified in the README file. @@ -137,7 +137,7 @@ struct io { #define SVf_BREAK 0x00400000 /* refcnt is artificially low */ #define SVf_READONLY 0x00800000 /* may not be modified */ -#define SVf_THINKFIRST (SVf_READONLY|SVf_ROK) +#define SVf_THINKFIRST (SVf_READONLY|SVf_ROK|SVf_FAKE) #define SVp_IOK 0x01000000 /* has valid non-public integer value */ #define SVp_NOK 0x02000000 /* has valid non-public numeric value */ @@ -153,14 +153,22 @@ struct io { /* Some private flags. */ -#define SVpfm_COMPILED 0x80000000 +#define SVpad_OUR 0x80000000 /* pad name is "our" instead of "my" */ + +#define SVf_IVisUV 0x80000000 /* use XPVUV instead of XPVIV */ + +#define SVpfm_COMPILED 0x80000000 /* FORMLINE is compiled */ #define SVpbm_VALID 0x80000000 #define SVpbm_TAIL 0x40000000 +#define SVrepl_EVAL 0x40000000 /* Replacement part of s///e */ + #define SVphv_SHAREKEYS 0x20000000 /* keys live on shared string table */ #define SVphv_LAZYDEL 0x40000000 /* entry in xhv_eiter must be deleted */ +#define SVprv_WEAKREF 0x80000000 /* Weak reference */ + struct xrv { SV * xrv_rv; /* pointer to another SV */ }; @@ -190,7 +198,7 @@ struct xpvnv { STRLEN xpv_cur; /* length of xpv_pv as a C string */ STRLEN xpv_len; /* allocated size */ IV xiv_iv; /* integer value or pv offset */ - double xnv_nv; /* numeric value, if any */ + NV xnv_nv; /* numeric value, if any */ }; /* These structure must match the beginning of struct xpvhv in hv.h. */ @@ -199,7 +207,7 @@ struct xpvmg { STRLEN xpv_cur; /* length of xpv_pv as a C string */ STRLEN xpv_len; /* allocated size */ IV xiv_iv; /* integer value or pv offset */ - double xnv_nv; /* numeric value, if any */ + NV xnv_nv; /* numeric value, if any */ MAGIC* xmg_magic; /* linked list of magicalness */ HV* xmg_stash; /* class package */ }; @@ -209,7 +217,7 @@ struct xpvlv { STRLEN xpv_cur; /* length of xpv_pv as a C string */ STRLEN xpv_len; /* allocated size */ IV xiv_iv; /* integer value or pv offset */ - double xnv_nv; /* numeric value, if any */ + NV xnv_nv; /* numeric value, if any */ MAGIC* xmg_magic; /* linked list of magicalness */ HV* xmg_stash; /* class package */ @@ -224,7 +232,7 @@ struct xpvgv { STRLEN xpv_cur; /* length of xpv_pv as a C string */ STRLEN xpv_len; /* allocated size */ IV xiv_iv; /* integer value or pv offset */ - double xnv_nv; /* numeric value, if any */ + NV xnv_nv; /* numeric value, if any */ MAGIC* xmg_magic; /* linked list of magicalness */ HV* xmg_stash; /* class package */ @@ -240,7 +248,7 @@ struct xpvbm { STRLEN xpv_cur; /* length of xpv_pv as a C string */ STRLEN xpv_len; /* allocated size */ IV xiv_iv; /* integer value or pv offset */ - double xnv_nv; /* numeric value, if any */ + NV xnv_nv; /* numeric value, if any */ MAGIC* xmg_magic; /* linked list of magicalness */ HV* xmg_stash; /* class package */ @@ -258,14 +266,14 @@ struct xpvfm { STRLEN xpv_cur; /* length of xpv_pv as a C string */ STRLEN xpv_len; /* allocated size */ IV xiv_iv; /* integer value or pv offset */ - double xnv_nv; /* numeric value, if any */ + NV xnv_nv; /* numeric value, if any */ MAGIC* xmg_magic; /* linked list of magicalness */ HV* xmg_stash; /* class package */ HV * xcv_stash; OP * xcv_start; OP * xcv_root; - void (*xcv_xsub)_((CV* _CPERLproto)); + void (*xcv_xsub)(pTHXo_ CV*); ANY xcv_xsubany; GV * xcv_gv; GV * xcv_filegv; @@ -286,7 +294,7 @@ struct xpvio { STRLEN xpv_cur; /* length of xpv_pv as a C string */ STRLEN xpv_len; /* allocated size */ IV xiv_iv; /* integer value or pv offset */ - double xnv_nv; /* numeric value, if any */ + NV xnv_nv; /* numeric value, if any */ MAGIC* xmg_magic; /* linked list of magicalness */ HV* xmg_stash; /* class package */ @@ -313,16 +321,20 @@ struct xpvio { #define IOf_FLUSH 4 /* this fp wants a flush after write op */ #define IOf_DIDTOP 8 /* just did top of form */ #define IOf_UNTAINT 16 /* consider this fp (and its data) "safe" */ +#define IOf_NOLINE 32 /* slurped a pseudo-line from empty file */ /* The following macros define implementation-independent predicates on SVs. */ #define SvNIOK(sv) (SvFLAGS(sv) & (SVf_IOK|SVf_NOK)) #define SvNIOKp(sv) (SvFLAGS(sv) & (SVp_IOK|SVp_NOK)) #define SvNIOK_off(sv) (SvFLAGS(sv) &= ~(SVf_IOK|SVf_NOK| \ - SVp_IOK|SVp_NOK)) + SVp_IOK|SVp_NOK|SVf_IVisUV)) #define SvOK(sv) (SvFLAGS(sv) & SVf_OK) -#define SvOK_off(sv) (SvFLAGS(sv) &= ~(SVf_OK|SVf_AMAGIC), \ +#define SvOK_off(sv) (SvFLAGS(sv) &= ~(SVf_OK|SVf_AMAGIC| \ + SVf_IVisUV), \ + SvOOK_off(sv)) +#define SvOK_off_exc_UV(sv) (SvFLAGS(sv) &= ~(SVf_OK|SVf_AMAGIC), \ SvOOK_off(sv)) #define SvOKp(sv) (SvFLAGS(sv) & (SVp_IOK|SVp_NOK|SVp_POK)) @@ -336,9 +348,20 @@ struct xpvio { #define SvIOK(sv) (SvFLAGS(sv) & SVf_IOK) #define SvIOK_on(sv) (SvOOK_off(sv), \ SvFLAGS(sv) |= (SVf_IOK|SVp_IOK)) -#define SvIOK_off(sv) (SvFLAGS(sv) &= ~(SVf_IOK|SVp_IOK)) +#define SvIOK_off(sv) (SvFLAGS(sv) &= ~(SVf_IOK|SVp_IOK|SVf_IVisUV)) #define SvIOK_only(sv) (SvOK_off(sv), \ SvFLAGS(sv) |= (SVf_IOK|SVp_IOK)) +#define SvIOK_only_UV(sv) (SvOK_off_exc_UV(sv), \ + SvFLAGS(sv) |= (SVf_IOK|SVp_IOK)) + +#define SvIOK_UV(sv) ((SvFLAGS(sv) & (SVf_IOK|SVf_IVisUV)) \ + == (SVf_IOK|SVf_IVisUV)) +#define SvIOK_notUV(sv) ((SvFLAGS(sv) & (SVf_IOK|SVf_IVisUV)) \ + == SVf_IOK) + +#define SvIsUV(sv) (SvFLAGS(sv) & SVf_IVisUV) +#define SvIsUV_on(sv) (SvFLAGS(sv) |= SVf_IVisUV) +#define SvIsUV_off(sv) (SvFLAGS(sv) &= ~SVf_IVisUV) #define SvNOK(sv) (SvFLAGS(sv) & SVf_NOK) #define SvNOK_on(sv) (SvFLAGS(sv) |= (SVf_NOK|SVp_NOK)) @@ -349,7 +372,7 @@ struct xpvio { #define SvPOK(sv) (SvFLAGS(sv) & SVf_POK) #define SvPOK_on(sv) (SvFLAGS(sv) |= (SVf_POK|SVp_POK)) #define SvPOK_off(sv) (SvFLAGS(sv) &= ~(SVf_POK|SVp_POK)) -#define SvPOK_only(sv) (SvFLAGS(sv) &= ~(SVf_OK|SVf_AMAGIC), \ +#define SvPOK_only(sv) (SvFLAGS(sv) &= ~(SVf_OK|SVf_AMAGIC|SVf_IVisUV), \ SvFLAGS(sv) |= (SVf_POK|SVp_POK)) #define SvOOK(sv) (SvFLAGS(sv) & SVf_OOK) @@ -391,6 +414,11 @@ struct xpvio { */ #define Gv_AMG(stash) (PL_amagic_generation && Gv_AMupdate(stash)) +#define SvWEAKREF(sv) ((SvFLAGS(sv) & (SVf_ROK|SVprv_WEAKREF)) \ + == (SVf_ROK|SVprv_WEAKREF)) +#define SvWEAKREF_on(sv) (SvFLAGS(sv) |= (SVf_ROK|SVprv_WEAKREF)) +#define SvWEAKREF_off(sv) (SvFLAGS(sv) &= ~(SVf_ROK|SVprv_WEAKREF)) + #define SvTHINKFIRST(sv) (SvFLAGS(sv) & SVf_THINKFIRST) #define SvPADBUSY(sv) (SvFLAGS(sv) & SVs_PADBUSY) @@ -422,6 +450,10 @@ struct xpvio { #define SvCOMPILED_on(sv) (SvFLAGS(sv) |= SVpfm_COMPILED) #define SvCOMPILED_off(sv) (SvFLAGS(sv) &= ~SVpfm_COMPILED) +#define SvEVALED(sv) (SvFLAGS(sv) & SVrepl_EVAL) +#define SvEVALED_on(sv) (SvFLAGS(sv) |= SVrepl_EVAL) +#define SvEVALED_off(sv) (SvFLAGS(sv) &= ~SVrepl_EVAL) + #define SvTAIL(sv) (SvFLAGS(sv) & SVpbm_TAIL) #define SvTAIL_on(sv) (SvFLAGS(sv) |= SVpbm_TAIL) #define SvTAIL_off(sv) (SvFLAGS(sv) &= ~SVpbm_TAIL) @@ -511,6 +543,7 @@ struct xpvio { #define SvPV_force(sv, lp) sv_pvn_force(sv, &lp) #define SvPV(sv, lp) sv_pvn(sv, &lp) +#define SvPV_nolen(sv) sv_pv(sv) #define SvIVx(sv) sv_iv(sv) #define SvUVx(sv) sv_uv(sv) #define SvNVx(sv) sv_nv(sv) @@ -520,12 +553,13 @@ struct xpvio { #define SvIV(sv) SvIVx(sv) #define SvNV(sv) SvNVx(sv) -#define SvUV(sv) SvIVx(sv) +#define SvUV(sv) SvUVx(sv) #define SvTRUE(sv) SvTRUEx(sv) #ifndef CRIPPLED_CC /* redefine some things to more efficient inlined versions */ +/* Let us hope that bitmaps for UV and IV are the same */ #undef SvIV #define SvIV(sv) (SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv)) @@ -544,6 +578,10 @@ struct xpvio { ((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_pvn_force(sv, &lp)) +#undef SvPV_nolen +#define SvPV_nolen(sv) \ + (SvPOK(sv) ? SvPVX(sv) : sv_2pv_nolen(sv)) + #ifdef __GNUC__ # undef SvIVx # undef SvUVx @@ -656,12 +694,5 @@ struct xpvio { #define isGV(sv) (SvTYPE(sv) == SVt_PVGV) -#ifndef DOSISH -# define SvGROW(sv,len) (SvLEN(sv) < (len) ? sv_grow(sv,len) : SvPVX(sv)) -# define Sv_Grow sv_grow -#else - /* extra parentheses intentionally NOT placed around "len"! */ -# define SvGROW(sv,len) ((SvLEN(sv) < (unsigned long)len) \ - ? sv_grow(sv,(unsigned long)len) : SvPVX(sv)) -# define Sv_Grow(sv,len) sv_grow(sv,(unsigned long)(len)) -#endif /* DOSISH */ +#define SvGROW(sv,len) (SvLEN(sv) < (len) ? sv_grow(sv,len) : SvPVX(sv)) +#define Sv_Grow sv_grow