Skip to content

Commit

Permalink
WS Cleanup Stage #3 - break multiline define
Browse files Browse the repository at this point in the history
  • Loading branch information
demerphq committed Sep 9, 2022
1 parent e5d309e commit df51954
Show file tree
Hide file tree
Showing 26 changed files with 760 additions and 529 deletions.
5 changes: 3 additions & 2 deletions XSUB.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,9 @@ is a lexical C<$_> in scope.
I32 ax = XS_SETXSUBFN_POPMARK; \
SV **mark = PL_stack_base + ax - 1; dSP; dITEMS

#define dXSTARG SV * const targ = ((PL_op->op_private & OPpENTERSUB_HASTARG) \
? PAD_SV(PL_op->op_targ) : sv_newmortal())
#define dXSTARG \
SV * const targ = ((PL_op->op_private & OPpENTERSUB_HASTARG)\
? PAD_SV(PL_op->op_targ) : sv_newmortal())

/* Should be used before final PUSHi etc. if not in PPCODE section. */
#define XSprePUSH (sp = PL_stack_base + ax - 1)
Expand Down
5 changes: 3 additions & 2 deletions av.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ If all you need is to look up an array element, then prefer C<av_fetch>.

#define AvREALISH(av) (SvFLAGS(av) & (SVpav_REAL|SVpav_REIFY))

#define AvFILL(av) ((SvRMAGICAL((const SV *) (av))) \
? mg_size(MUTABLE_SV(av)) : AvFILLp(av))
#define AvFILL(av) \
((SvRMAGICAL((const SV *) (av)))\
? mg_size(MUTABLE_SV(av)) : AvFILLp(av))
#define av_top_index(av) AvFILL(av)
#define av_tindex(av) av_top_index(av)

Expand Down
67 changes: 40 additions & 27 deletions cop.h
Original file line number Diff line number Diff line change
Expand Up @@ -509,23 +509,28 @@ string C<p>, creating the package if necessary.
#ifdef USE_ITHREADS

# define CopFILE(c) ((c)->cop_file)
# define CopFILEGV(c) (CopFILE(c) \
? gv_fetchfile(CopFILE(c)) : NULL)
# define CopFILEGV(c) \
(CopFILE(c)\
? gv_fetchfile(CopFILE(c)) : NULL)

# define CopFILE_set(c,pv) ((c)->cop_file = savesharedpv(pv))
# define CopFILE_setn(c,pv,l) ((c)->cop_file = savesharedpvn((pv),(l)))

# define CopFILESV(c) (CopFILE(c) \
? GvSV(gv_fetchfile(CopFILE(c))) : NULL)
# define CopFILEAV(c) (CopFILE(c) \
? GvAV(gv_fetchfile(CopFILE(c))) : NULL)
# define CopFILEAVx(c) (assert_(CopFILE(c)) \
GvAV(gv_fetchfile(CopFILE(c))))
# define CopFILESV(c) \
(CopFILE(c)\
? GvSV(gv_fetchfile(CopFILE(c))) : NULL)
# define CopFILEAV(c) \
(CopFILE(c)\
? GvAV(gv_fetchfile(CopFILE(c))) : NULL)
# define CopFILEAVx(c) \
(assert_(CopFILE(c))\
GvAV(gv_fetchfile(CopFILE(c))))
# define CopFILEAVn(c) (cop_file_avn(c))
# define CopSTASH(c) PL_stashpad[(c)->cop_stashoff]
# define CopSTASH_set(c,hv) ((c)->cop_stashoff = (hv) \
? alloccopstash(hv) \
: 0)
# define CopSTASH_set(c,hv) \
((c)->cop_stashoff = (hv)\
? alloccopstash(hv) \
: 0)
# define CopFILE_free(c) (PerlMemShared_free(CopFILE(c)),(CopFILE(c) = NULL))

#else /* Above: yes threads; Below no threads */
Expand All @@ -542,8 +547,9 @@ string C<p>, creating the package if necessary.
# define CopFILEAVx(c) (GvAV(CopFILEGV(c)))
# endif
# define CopFILEAVn(c) (CopFILEGV(c) ? GvAVn(CopFILEGV(c)) : NULL)
# define CopFILE(c) (CopFILEGV(c) /* +2 for '_<' */ \
? GvNAME(CopFILEGV(c))+2 : NULL)
# define CopFILE(c) \
(CopFILEGV(c) /* +2 for '_<' */\
? GvNAME(CopFILEGV(c))+2 : NULL)
# define CopSTASH(c) ((c)->cop_stash)
# define CopSTASH_set(c,hv) ((c)->cop_stash = (hv))
# define CopFILE_free(c) (SvREFCNT_dec(CopFILEGV(c)),(CopFILEGV(c) = NULL))
Expand Down Expand Up @@ -690,9 +696,10 @@ by setting C<*flags> to 0 or C<SVf_UTF8>.
#define OutCopFILE(c) CopFILE(c)

#define CopHINTS_get(c) ((c)->cop_hints + 0)
#define CopHINTS_set(c, h) STMT_START { \
(c)->cop_hints = (h); \
} STMT_END
#define CopHINTS_set(c, h) \
STMT_START {\
(c)->cop_hints = (h); \
} STMT_END

/*
* Here we have some enormously heavy (or at least ponderous) wizardry.
Expand Down Expand Up @@ -945,7 +952,8 @@ struct subst {
#define sb_rxres cx_u.cx_subst.sbu_rxres
#define sb_rx cx_u.cx_subst.sbu_rx

# define CX_PUSHSUBST(cx) CXINC, cx = CX_CUR(), \
# define CX_PUSHSUBST(cx) \
CXINC, cx = CX_CUR(),\
cx->blk_oldsaveix = oldsave, \
cx->sb_iters = iters, \
cx->sb_maxiters = maxiters, \
Expand Down Expand Up @@ -1040,17 +1048,22 @@ struct context {
#define CXp_ONCE 0x10 /* What was sbu_once in struct subst */

#define CxTYPE(c) ((c)->cx_type & CXTYPEMASK)
#define CxTYPE_is_LOOP(c) ( CxTYPE(cx) >= CXt_LOOP_ARY \
&& CxTYPE(cx) <= CXt_LOOP_PLAIN)
#define CxTYPE_is_LOOP(c) \
( CxTYPE(cx) >= CXt_LOOP_ARY\
&& CxTYPE(cx) <= CXt_LOOP_PLAIN)
#define CxMULTICALL(c) ((c)->cx_type & CXp_MULTICALL)
#define CxREALEVAL(c) (((c)->cx_type & (CXTYPEMASK|CXp_REAL)) \
== (CXt_EVAL|CXp_REAL))
#define CxEVALBLOCK(c) (((c)->cx_type & (CXTYPEMASK|CXp_EVALBLOCK)) \
== (CXt_EVAL|CXp_EVALBLOCK))
#define CxTRY(c) (((c)->cx_type & (CXTYPEMASK|CXp_TRY)) \
== (CXt_EVAL|CXp_TRY))
#define CxFOREACH(c) ( CxTYPE(cx) >= CXt_LOOP_ARY \
&& CxTYPE(cx) <= CXt_LOOP_LIST)
#define CxREALEVAL(c) \
(((c)->cx_type & (CXTYPEMASK|CXp_REAL))\
== (CXt_EVAL|CXp_REAL))
#define CxEVALBLOCK(c) \
(((c)->cx_type & (CXTYPEMASK|CXp_EVALBLOCK))\
== (CXt_EVAL|CXp_EVALBLOCK))
#define CxTRY(c) \
(((c)->cx_type & (CXTYPEMASK|CXp_TRY))\
== (CXt_EVAL|CXp_TRY))
#define CxFOREACH(c) \
( CxTYPE(cx) >= CXt_LOOP_ARY\
&& CxTYPE(cx) <= CXt_LOOP_LIST)

/* private flags for CXt_DEFER */
#define CXp_FINALLY 0x20 /* `finally` block; semantically identical
Expand Down
12 changes: 8 additions & 4 deletions cv.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,17 @@ See L<perlguts/Autoloading with XSUBs>.
#define CvDEPTHunsafe(sv) ((XPVCV*)MUTABLE_PTR(SvANY(sv)))->xcv_depth

/* these CvPADLIST/CvRESERVED asserts can be reverted one day, once stabilized */
#define CvPADLIST(sv) (*(assert_(!CvISXSUB((CV*)(sv))) \
#define CvPADLIST(sv) \
(*(assert_(!CvISXSUB((CV*)(sv)))\
&(((XPVCV*)MUTABLE_PTR(SvANY(sv)))->xcv_padlist_u.xcv_padlist)))
/* CvPADLIST_set is not public API, it can be removed one day, once stabilized */
#ifdef DEBUGGING
# define CvPADLIST_set(sv, padlist) Perl_set_padlist((CV*)sv, padlist)
#else
# define CvPADLIST_set(sv, padlist) (CvPADLIST(sv) = (padlist))
#endif
#define CvHSCXT(sv) *(assert_(CvISXSUB((CV*)(sv))) \
#define CvHSCXT(sv) \
*(assert_(CvISXSUB((CV*)(sv)))\
&(((XPVCV*)MUTABLE_PTR(SvANY(sv)))->xcv_padlist_u.xcv_hscxt))
#ifdef DEBUGGING
# if PTRSIZE == 8
Expand Down Expand Up @@ -279,15 +281,17 @@ CvNAME_HEK(CV *sv)
/* helper for the common pattern:
CvNAMED(sv) ? CvNAME_HEK((CV *)sv) : GvNAME_HEK(CvGV(sv))
*/
#define CvGvNAME_HEK(sv) ( \
#define CvGvNAME_HEK(sv) \
(\
CvNAMED((CV*)sv) ? \
((XPVCV*)MUTABLE_PTR(SvANY((SV*)sv)))->xcv_gv_u.xcv_hek\
: GvNAME_HEK(CvGV( (SV*) sv)) \
)

/* This lowers the reference count of the previous value, but does *not*
increment the reference count of the new value. */
#define CvNAME_HEK_set(cv, hek) ( \
#define CvNAME_HEK_set(cv, hek) \
(\
CvNAME_HEK((CV *)(cv)) \
? unshare_hek(SvANY((CV *)(cv))->xcv_gv_u.xcv_hek) \
: (void)0, \
Expand Down
21 changes: 12 additions & 9 deletions gv.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,10 @@ Return the CV from the GV.

#define GvSV(gv) (GvGP(gv)->gp_sv)
#ifdef PERL_DONT_CREATE_GVSV
#define GvSVn(gv) (*(GvGP(gv)->gp_sv ? \
&(GvGP(gv)->gp_sv) : \
&(GvGP(gv_SVadd(gv))->gp_sv)))
#define GvSVn(gv) \
(*(GvGP(gv)->gp_sv ?\
&(GvGP(gv)->gp_sv) : \
&(GvGP(gv_SVadd(gv))->gp_sv)))
#else
#define GvSVn(gv) GvSV(gv)
#endif
Expand All @@ -125,14 +126,16 @@ Return the CV from the GV.
#define GvFORM(gv) (GvGP(gv)->gp_form)
#define GvAV(gv) (GvGP(gv)->gp_av)

#define GvAVn(gv) (GvGP(gv)->gp_av ? \
GvGP(gv)->gp_av : \
GvGP(gv_AVadd(gv))->gp_av)
#define GvAVn(gv) \
(GvGP(gv)->gp_av ?\
GvGP(gv)->gp_av : \
GvGP(gv_AVadd(gv))->gp_av)
#define GvHV(gv) ((GvGP(gv))->gp_hv)

#define GvHVn(gv) (GvGP(gv)->gp_hv ? \
GvGP(gv)->gp_hv : \
GvGP(gv_HVadd(gv))->gp_hv)
#define GvHVn(gv) \
(GvGP(gv)->gp_hv ?\
GvGP(gv)->gp_hv : \
GvGP(gv_HVadd(gv))->gp_hv)

#define GvCV(gv) ((CV*)GvGP(gv)->gp_cv)
#define GvCV_set(gv,cv) (GvGP(gv)->gp_cv = (cv))
Expand Down

0 comments on commit df51954

Please sign in to comment.