[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]
[PATCH] readable assertion names
I find it rather odd to parse random temp. assertion vars. shplep, yaah, zzzz
So I started with gv.h
With this patch the type of failed variable is obvious without
grepping the code.
/usr/local/bin/perl5.11.0d-nt.exe -Mblib
-MO=-qq,Bytecode,-s,-obytecode11s_5.11.0d-nt.plc bytecode11.pl
=>
assertion "isGV_with_GP(_gvstash)" failed: file "B.c", line 4990
(GvSTASH failed)
assertion "isGV_with_GP(_gvgp)" failed: file "B.c", line 4990 (GvGP failed)
assertion "isGV_with_GP(_gvflags)" failed: file "B.c", line 5400
(GvFLAGS failed)
is more readable than
assertion "isGV_with_GP(_gv)" failed: file "B.c", line 4990
assertion "isGV_with_GP(shplep)" failed: file "B.c", line 4961
assertion "isGV_with_GP(yaah)" failed: file "B.c", line 5400
If this is a good idea and leads to no symbol clashes,
I'll do the same for the other new assertions in sv.h and friends.
SvVALID thwacke
SvTAIL _svi
SvPAD whap
...
--
Reini Urban
difforig gv.h
diff -u gv.h.orig gv.h
--- gv.h.orig 2008-04-17 10:00:08.000000000 +0200
+++ gv.h 2008-06-08 14:20:59.828125000 +0200
@@ -27,27 +27,27 @@
#if defined (DEBUGGING) && defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN) && !defined(__INTEL_COMPILER)
# define GvGP(gv) \
- (*({GV *const shplep = (GV *) (gv); \
- assert(SvTYPE(shplep) == SVt_PVGV || SvTYPE(shplep) == SVt_PVLV); \
- assert(isGV_with_GP(shplep)); \
- &((shplep)->sv_u.svu_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);}))
# define GvFLAGS(gv) \
- (*({GV *const yaah = (GV *) (gv); \
- assert(SvTYPE(yaah) == SVt_PVGV || SvTYPE(yaah) == SVt_PVLV); \
- assert(isGV_with_GP(yaah)); \
- &(GvXPVGV(yaah)->xpv_cur);}))
+ (*({GV *const _gvflags = (GV *) (gv); \
+ assert(SvTYPE(_gvflags) == SVt_PVGV || SvTYPE(_gvflags) == SVt_PVLV); \
+ assert(isGV_with_GP(_gvflags)); \
+ &(GvXPVGV(_gvflags)->xpv_cur);}))
# define GvSTASH(gv) \
- (*({ GV * const _gv = (GV *) (gv); \
- assert(isGV_with_GP(_gv)); \
- assert(SvTYPE(_gv) == SVt_PVGV || SvTYPE(_gv) >= SVt_PVLV); \
- &(GvXPVGV(_gv)->xnv_u.xgv_stash); \
+ (*({ GV * const _gvstash = (GV *) (gv); \
+ assert(isGV_with_GP(_gvstash)); \
+ assert(SvTYPE(_gvstash) == SVt_PVGV || SvTYPE(_gvstash) >= SVt_PVLV); \
+ &(GvXPVGV(_gvstash)->xnv_u.xgv_stash); \
}))
# define GvNAME_HEK(gv) \
- (*({ GV * const zzzz = (GV *) (gv); \
- assert(isGV_with_GP(zzzz)); \
- assert(SvTYPE(zzzz) == SVt_PVGV || SvTYPE(zzzz) >= SVt_PVLV); \
- assert(!SvVALID(zzzz)); \
- &(GvXPVGV(zzzz)->xiv_u.xivu_namehek); \
+ (*({ GV * const _gvname_hek = (GV *) (gv); \
+ assert(isGV_with_GP(_gvname_hek)); \
+ assert(SvTYPE(_gvname_hek) == SVt_PVGV || SvTYPE(_gvname_hek) >= SVt_PVLV); \
+ assert(!SvVALID(_gvname_hek)); \
+ &(GvXPVGV(_gvname_hek)->xiv_u.xivu_namehek); \
}))
# define GvNAME_get(gv) ({ assert(GvNAME_HEK(gv)); HEK_KEY(GvNAME_HEK(gv)); })
# define GvNAMELEN_get(gv) ({ assert(GvNAME_HEK(gv)); HEK_LEN(GvNAME_HEK(gv)); })
- Follow-Ups from:
-
"Rafael Garcia-Suarez" <rgarciasuarez@gmail.com>
[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]