diff options
author | David Mitchell <davem@iabyn.com> | 2011-01-21 10:25:03 +0000 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2011-01-21 13:46:03 +0000 |
commit | c43ae56ff9cdb8e0fb3d1724f564378b031a4d49 (patch) | |
tree | 8006882d503c9f300a7d366d851636ae13b97d17 /gv.h | |
parent | 79c861242b428940e97f668b35b0faeb25a2b9bb (diff) | |
download | perl-c43ae56ff9cdb8e0fb3d1724f564378b031a4d49.tar.gz |
add GvCV_set() and GvGP_set() macros.
and make GvCV() and GvGP() rvalue-only.
This it to allow a future commit to eliminate some backref magic between
GV and CVs, which will require complete control over assignment to the
gp_cv slot.
Diffstat (limited to 'gv.h')
-rw-r--r-- | gv.h | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -27,10 +27,15 @@ struct gp { #if defined (DEBUGGING) && defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN) && !defined(__INTEL_COMPILER) # define GvGP(gv) \ - (*({GV *const _gvgp = (GV *) (gv); \ + (0+(*({GV *const _gvgp = (GV *) (gv); \ assert(SvTYPE(_gvgp) == SVt_PVGV || SvTYPE(_gvgp) == SVt_PVLV); \ assert(isGV_with_GP(_gvgp)); \ - &((_gvgp)->sv_u.svu_gp);})) + &((_gvgp)->sv_u.svu_gp);}))) +# define GvGP_set(gv,gp) \ + {GV *const _gvgp = (GV *) (gv); \ + assert(SvTYPE(_gvgp) == SVt_PVGV || SvTYPE(_gvgp) == SVt_PVLV); \ + assert(isGV_with_GP(_gvgp)); \ + (_gvgp)->sv_u.svu_gp = (gp); } # define GvFLAGS(gv) \ (*({GV *const _gvflags = (GV *) (gv); \ assert(SvTYPE(_gvflags) == SVt_PVGV || SvTYPE(_gvflags) == SVt_PVLV); \ @@ -52,7 +57,8 @@ struct gp { # define GvNAME_get(gv) ({ assert(GvNAME_HEK(gv)); (char *)HEK_KEY(GvNAME_HEK(gv)); }) # define GvNAMELEN_get(gv) ({ assert(GvNAME_HEK(gv)); HEK_LEN(GvNAME_HEK(gv)); }) #else -# define GvGP(gv) ((gv)->sv_u.svu_gp) +# define GvGP(gv) (0+(gv)->sv_u.svu_gp) +# define GvGP_set(gv,gp) ((gv)->sv_u.svu_gp = (gp)) # define GvFLAGS(gv) (GvXPVGV(gv)->xpv_cur) # define GvSTASH(gv) (GvXPVGV(gv)->xnv_u.xgv_stash) # define GvNAME_HEK(gv) (GvXPVGV(gv)->xiv_u.xivu_namehek) @@ -114,7 +120,8 @@ Return the SV from the GV. GvGP(gv)->gp_hv : \ GvGP(gv_HVadd(gv))->gp_hv) -#define GvCV(gv) (GvGP(gv)->gp_cv) +#define GvCV(gv) (0+GvGP(gv)->gp_cv) +#define GvCV_set(gv,cv) (GvGP(gv)->gp_cv = (cv)) #define GvCVGEN(gv) (GvGP(gv)->gp_cvgen) #define GvCVu(gv) (GvGP(gv)->gp_cvgen ? NULL : GvGP(gv)->gp_cv) |