X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=sv.h;h=cc7edb9049f8ad8794fed0b70390c3d405fbd200;hb=842c41230043ce99d4bf7b2c79aed85ce2908e89;hp=0d275d25cf490e5a8eb6b86f90c24502e113a2cb;hpb=b6f609162799aa49813b53c8242464db37fcee9b;p=p5sagit%2Fp5-mst-13.2.git diff --git a/sv.h b/sv.h index 0d275d2..cc7edb9 100644 --- a/sv.h +++ b/sv.h @@ -76,13 +76,9 @@ typedef enum { #endif /* There is collusion here with sv_clear - sv_clear exits early for SVt_NULL - and SVt_IV, so never reaches the clause at the end that uses - sv_type_details->body_size to determine whether to call safefree(). Hence - body_size can be set no-zero to record the size of PTEs and HEs, without - fear of bogus frees. */ -#ifdef PERL_IN_SV_C -#define PTE_SVSLOT SVt_IV -#endif + so never reaches the clause at the end that uses sv_type_details->body_size + to determine whether to call safefree(). Hence body_size can be set + non-zero to record the size of HEs, without fear of bogus frees. */ #if defined(PERL_IN_HV_C) || defined(PERL_IN_XS_APITEST) #define HE_SVSLOT SVt_NULL #endif @@ -103,10 +99,10 @@ typedef struct hek HEK; #define _SV_HEAD_UNION \ union { \ + char* svu_pv; /* pointer to malloced string */ \ IV svu_iv; \ UV svu_uv; \ SV* svu_rv; /* pointer to another SV */ \ - char* svu_pv; /* pointer to malloced string */ \ SV** svu_array; \ HE** svu_hash; \ GP* svu_gp; \ @@ -398,14 +394,12 @@ perform the upgrade if necessary. See C. /* RV upwards. However, SVf_ROK and SVp_IOK are exclusive */ #define SVprv_WEAKREF 0x80000000 /* Weak reference */ -#define _XPV_ALLOCATED_HEAD \ +#define _XPV_HEAD \ + HV* xmg_stash; /* class package */ \ + union _xmgu xmg_u; \ STRLEN xpv_cur; /* length of svu_pv as a C string */ \ STRLEN xpv_len /* allocated size */ -#define _XPV_HEAD \ - union _xnvu xnv_u; \ - _XPV_ALLOCATED_HEAD - union _xnvu { NV xnv_nv; /* numeric value, if any */ HV * xgv_stash; @@ -422,12 +416,9 @@ union _xnvu { union _xivu { IV xivu_iv; /* integer value */ - /* xpvfm: lines */ UV xivu_uv; - void * xivu_p1; - I32 xivu_i32; + I32 xivu_i32; /* BmUSEFUL */ HEK * xivu_namehek; /* xpvlv, xpvgv: GvNAME */ - HV * xivu_hv; /* regexp: paren_names */ }; union _xmgu { @@ -439,20 +430,11 @@ struct xpv { _XPV_HEAD; }; -typedef struct { - _XPV_ALLOCATED_HEAD; -} xpv_allocated; - struct xpviv { _XPV_HEAD; union _xivu xiv_u; }; -typedef struct { - _XPV_ALLOCATED_HEAD; - union _xivu xiv_u; -} xpviv_allocated; - #define xiv_iv xiv_u.xivu_iv struct xpvuv { @@ -465,23 +447,20 @@ struct xpvuv { struct xpvnv { _XPV_HEAD; union _xivu xiv_u; + union _xnvu xnv_u; }; -#define _XPVMG_HEAD \ - union _xivu xiv_u; \ - union _xmgu xmg_u; \ - HV* xmg_stash /* class package */ - -/* These structure must match the beginning of struct xpvhv in hv.h. */ +/* This structure must match the beginning of struct xpvhv in hv.h. */ struct xpvmg { _XPV_HEAD; - _XPVMG_HEAD; + union _xivu xiv_u; + union _xnvu xnv_u; }; struct xpvlv { _XPV_HEAD; - _XPVMG_HEAD; - + union _xivu xiv_u; + union _xnvu xnv_u; STRLEN xlv_targoff; STRLEN xlv_targlen; SV* xlv_targ; @@ -493,7 +472,8 @@ struct xpvlv { Boyer-Moore. */ struct xpvgv { _XPV_HEAD; - _XPVMG_HEAD; + union _xivu xiv_u; + union _xnvu xnv_u; }; /* This structure must match XPVCV in cv.h */ @@ -521,16 +501,10 @@ typedef U16 cv_flags_t; struct xpvfm { _XPV_HEAD; - _XPVMG_HEAD; _XPVCV_COMMON; + IV xfm_lines; }; -typedef struct { - _XPV_ALLOCATED_HEAD; - _XPVMG_HEAD; - _XPVCV_COMMON; -} xpvfm_allocated; - #define _XPVIO_TAIL \ PerlIO * xio_ifp; /* ifp and ofp are normally the same */ \ PerlIO * xio_ofp; /* but sockets need separate streams */ \ @@ -547,7 +521,7 @@ typedef struct { DIR * xiou_dirp; /* for opendir, readdir, etc */ \ void * xiou_any; /* for alignment */ \ } xio_dirpu; \ - IV xio_lines; /* $. */ \ + /* IV xio_lines is now in IVX $. */ \ IV xio_page; /* $% */ \ IV xio_page_len; /* $= */ \ IV xio_lines_left; /* $- */ \ @@ -563,7 +537,7 @@ typedef struct { struct xpvio { _XPV_HEAD; - _XPVMG_HEAD; + union _xivu xiv_u; _XPVIO_TAIL; }; @@ -1089,6 +1063,8 @@ the scalar's value cannot change unless written to. assert(SvTYPE(_svivx) != SVt_PVHV); \ assert(SvTYPE(_svivx) != SVt_PVCV); \ assert(SvTYPE(_svivx) != SVt_PVFM); \ + assert(SvTYPE(_svivx) != SVt_PVIO); \ + assert(SvTYPE(_svivx) != SVt_REGEXP); \ assert(!isGV_with_GP(_svivx)); \ &(((XPVIV*) MUTABLE_PTR(SvANY(_svivx)))->xiv_iv); \ })) @@ -1099,6 +1075,8 @@ the scalar's value cannot change unless written to. assert(SvTYPE(_svuvx) != SVt_PVHV); \ assert(SvTYPE(_svuvx) != SVt_PVCV); \ assert(SvTYPE(_svuvx) != SVt_PVFM); \ + assert(SvTYPE(_svuvx) != SVt_PVIO); \ + assert(SvTYPE(_svuvx) != SVt_REGEXP); \ assert(!isGV_with_GP(_svuvx)); \ &(((XPVUV*) MUTABLE_PTR(SvANY(_svuvx)))->xuv_uv); \ })) @@ -1110,6 +1088,7 @@ the scalar's value cannot change unless written to. assert(SvTYPE(_svnvx) != SVt_PVCV); \ assert(SvTYPE(_svnvx) != SVt_PVFM); \ assert(SvTYPE(_svnvx) != SVt_PVIO); \ + assert(SvTYPE(_svnvx) != SVt_REGEXP); \ assert(!isGV_with_GP(_svnvx)); \ &(((XPVNV*) MUTABLE_PTR(SvANY(_svnvx)))->xnv_u.xnv_nv); \ })) @@ -1184,6 +1163,9 @@ the scalar's value cannot change unless written to. #define SvIV_please(sv) \ STMT_START {if (!SvIOKp(sv) && (SvNOK(sv) || SvPOK(sv))) \ (void) SvIV(sv); } STMT_END +#define SvIV_please_nomg(sv) \ + STMT_START {if (!SvIOKp(sv) && (SvNOK(sv) || SvPOK(sv))) \ + (void) SvIV_nomg(sv); } STMT_END #define SvIV_set(sv, val) \ STMT_START { assert(SvTYPE(sv) == SVt_IV || SvTYPE(sv) >= SVt_PVIV); \ assert(SvTYPE(sv) != SVt_PVAV); \ @@ -1322,7 +1304,7 @@ the scalar's value cannot change unless written to. #endif -#define FmLINES(sv) ((XPVFM*) SvANY(sv))->xiv_u.xivu_iv +#define FmLINES(sv) ((XPVFM*) SvANY(sv))->xfm_lines #define LvTYPE(sv) ((XPVLV*) SvANY(sv))->xlv_type #define LvTARG(sv) ((XPVLV*) SvANY(sv))->xlv_targ @@ -1333,7 +1315,7 @@ the scalar's value cannot change unless written to. #define IoOFP(sv) ((XPVIO*) SvANY(sv))->xio_ofp #define IoDIRP(sv) ((XPVIO*) SvANY(sv))->xio_dirp #define IoANY(sv) ((XPVIO*) SvANY(sv))->xio_any -#define IoLINES(sv) ((XPVIO*) SvANY(sv))->xio_lines +#define IoLINES(sv) ((XPVIO*) SvANY(sv))->xiv_u.xivu_iv #define IoPAGE(sv) ((XPVIO*) SvANY(sv))->xio_page #define IoPAGE_LEN(sv) ((XPVIO*) SvANY(sv))->xio_page_len #define IoLINES_LEFT(sv)((XPVIO*) SvANY(sv))->xio_lines_left @@ -1440,6 +1422,9 @@ otherwise use the more efficient C. Coerce the given SV to a double and return it. See C for a version which guarantees to evaluate sv only once. +=for apidoc Am|NV|SvNV_nomg|SV* sv +Like C but doesn't process magic. + =for apidoc Am|NV|SvNVx|SV* sv Coerces the given SV to a double and returns it. Guarantees to evaluate C only once. Only use this if C is an expression with side effects, @@ -1531,6 +1516,7 @@ Like sv_utf8_upgrade, but doesn't do magic on C #define SvIV_nomg(sv) (SvIOK(sv) ? SvIVX(sv) : sv_2iv_flags(sv, 0)) #define SvUV_nomg(sv) (SvIOK(sv) ? SvUVX(sv) : sv_2uv_flags(sv, 0)) +#define SvNV_nomg(sv) (SvNOK(sv) ? SvNVX(sv) : sv_2nv_flags(sv, 0)) /* ----*/ @@ -1714,6 +1700,9 @@ Like sv_utf8_upgrade, but doesn't do magic on C * This is used when the caller has already determined it is, and avoids * redundant work */ #define SV_FORCE_UTF8_UPGRADE 4096 +/* if (after resolving magic etc), the SV is found to be overloaded, + * don't call the overload magic, just return as-is */ +#define SV_SKIP_OVERLOAD 8192 /* The core is safe for this COW optimisation. XS code on CPAN may not be. So only default to doing the COW setup if we're in the core. @@ -1794,6 +1783,7 @@ mg.c:1024: warning: left-hand operand of comma expression has no effect #define sv_utf8_upgrade(sv) sv_utf8_upgrade_flags(sv, SV_GMAGIC) #define sv_2iv(sv) sv_2iv_flags(sv, SV_GMAGIC) #define sv_2uv(sv) sv_2uv_flags(sv, SV_GMAGIC) +#define sv_2nv(sv) sv_2nv_flags(sv, SV_GMAGIC) #define sv_insert(bigstr, offset, len, little, littlelen) \ Perl_sv_insert_flags(aTHX_ (bigstr),(offset), (len), (little), \ (littlelen), SV_GMAGIC) @@ -2016,6 +2006,9 @@ Evaluates I more than once. Sets I to 0 if C is false. } \ } STMT_END #endif + +#define newIO() MUTABLE_IO(newSV_type(SVt_PVIO)) + /* * Local variables: * c-indentation-style: bsd