is not NULL. Since we don't have to check the NULLness, it's faster
and smaller.
-=for apidoc Am|SV*|SvREFCNT_inc_void|SV* sv
+=for apidoc Am|void|SvREFCNT_inc_void|SV* sv
Same as SvREFCNT_inc, but can only be used if you don't need the
return value. The macro doesn't need to return a meaningful value.
-=for apidoc Am|SV*|SvREFCNT_inc_void_NN|SV* sv
+=for apidoc Am|void|SvREFCNT_inc_void_NN|SV* sv
Same as SvREFCNT_inc, but can only be used if you don't need the return
value, and you know that I<sv> is not NULL. The macro doesn't need
to return a meaningful value, or check for NULLness, so it's smaller
is not NULL. Since we don't have to check the NULLness, it's faster
and smaller.
-=for apidoc Am|SV*|SvREFCNT_inc_simple_void|SV* sv
+=for apidoc Am|void|SvREFCNT_inc_simple_void|SV* sv
Same as SvREFCNT_inc_simple, but can only be used if you don't need the
return value. The macro doesn't need to return a meaningful value.
-=for apidoc Am|SV*|SvREFCNT_inc|SV* sv
-Increments the reference count of the given SV.
+=for apidoc Am|void|SvREFCNT_inc_simple_void_NN|SV* sv
+Same as SvREFCNT_inc, but can only be used if you don't need the return
+value, and you know that I<sv> is not NULL. The macro doesn't need
+to return a meaningful value, or check for NULLness, so it's smaller
+and faster.
=for apidoc Am|void|SvREFCNT_dec|SV* sv
Decrements the reference count of the given SV.
#endif
/* These guys don't need the curly blocks */
-#define SvREFCNT_inc_simple_void(sv) if (sv) (SvREFCNT(sv)++);
+#define SvREFCNT_inc_simple_void(sv) STMT_START { if (sv) SvREFCNT(sv)++; } STMT_END
#define SvREFCNT_inc_simple_NN(sv) (++(SvREFCNT(sv)),(SV*)(sv))
#define SvREFCNT_inc_void_NN(sv) (void)(++SvREFCNT((SV*)(sv)))
#define SvREFCNT_inc_simple_void_NN(sv) (void)(++SvREFCNT((SV*)(sv)))
#endif
#define SVTYPEMASK 0xff
-#define SvTYPE(sv) ((sv)->sv_flags & SVTYPEMASK)
+#define SvTYPE(sv) (svtype)((sv)->sv_flags & SVTYPEMASK)
/* Sadly there are some parts of the core that have pointers to already-freed
SV heads, and rely on being able to tell that they are now free. So mark
#define SVphv_CLONEABLE 0x00008000 /* PVHV (stashes) clone its objects */
#define SVs_PADSTALE 0x00010000 /* lexical has gone out of scope */
+#define SVpad_STATE 0x00010000 /* pad name is a "state" var */
#define SVs_PADTMP 0x00020000 /* in use as tmp */
#define SVpad_TYPED 0x00020000 /* pad name is a Typed Lexical */
#define SVs_PADMY 0x00040000 /* in use a "my" variable */
keys live on shared string table */
/* PVNV, PVMG, PVGV, presumably only inside pads */
#define SVpad_NAME 0x40000000 /* This SV is a name in the PAD, so
- SVpad_TYPED and SVpad_OUR apply */
+ SVpad_TYPED, SVpad_OUR and
+ SVpad_STATE apply */
/* PVAV */
#define SVpav_REAL 0x40000000 /* free old entries */
/* PVHV */
=for apidoc Am|void|SvMAGIC_set|SV* sv|MAGIC* val
Set the value of the MAGIC pointer in sv to val. See C<SvIV_set>.
-=for apidoc Am|void|SvSTASH_set|SV* sv|STASH* val
+=for apidoc Am|void|SvSTASH_set|SV* sv|HV* val
Set the value of the STASH pointer in sv to val. See C<SvIV_set>.
=for apidoc Am|void|SvCUR_set|SV* sv|STRLEN len
SvFLAGS(sv) |= (SVf_POK|SVp_POK))
#define SvVOK(sv) (SvMAGICAL(sv) \
+ && mg_find(sv,PERL_MAGIC_vstring))
+/* returns the vstring magic, if any */
+#define SvVSTRING_mg(sv) (SvMAGICAL(sv) \
? mg_find(sv,PERL_MAGIC_vstring) : NULL)
+
#define SvOOK(sv) (SvFLAGS(sv) & SVf_OOK)
#define SvOOK_on(sv) ((void)SvIOK_off(sv), SvFLAGS(sv) |= SVf_OOK)
#define SvOOK_off(sv) ((void)(SvOOK(sv) && sv_backoff(sv)))
(SvROK(sv) && (SvFLAGS(SvRV(sv)) &= ~SVf_AMAGIC))
#endif
+/*
+=for apidoc Am|char*|SvGAMAGIC|SV* sv
+
+Returns true if the SV has get magic or overloading. If either is true then
+the scalar is active data, and has the potential to return a new value every
+time it is accessed. Hence you must be careful to only read it once per user
+logical operation and work with that returned value. If neither is true then
+the scalar's value cannot change unless written to.
+
+=cut
+*/
+
#define SvGAMAGIC(sv) (SvGMAGICAL(sv) || SvAMAGIC(sv))
#define Gv_AMG(stash) (PL_amagic_generation && Gv_AMupdate(stash))
((SvFLAGS(sv) & (SVpad_NAME|SVpad_OUR)) == (SVpad_NAME|SVpad_OUR))
#define SvPAD_OUR_on(sv) (SvFLAGS(sv) |= SVpad_NAME|SVpad_OUR)
+#define SvPAD_STATE(sv) \
+ ((SvFLAGS(sv) & (SVpad_NAME|SVpad_STATE)) == (SVpad_NAME|SVpad_STATE))
+#define SvPAD_STATE_on(sv) (SvFLAGS(sv) |= SVpad_NAME|SVpad_STATE)
+
#define OURSTASH(sv) \
(SvPAD_OUR(sv) ? ((XPVMG*) SvANY(sv))->xmg_u.xmg_ourstash : NULL)
#define OURSTASH_set(sv, st) \
# define SvMAGIC(sv) \
(*({ SV *const _svi = (SV *) sv; \
assert(SvTYPE(_svi) >= SVt_PVMG); \
+ if(SvTYPE(_svi) == SVt_PVMG) \
+ assert(!SvPAD_OUR(_svi)); \
&(((XPVMG*) SvANY(_svi))->xmg_u.xmg_magic); \
}))
# define SvSTASH(sv) \
#define SV_CONST_RETURN 32
#define SV_MUTABLE_RETURN 64
#define SV_SMAGIC 128
+#define SV_HAS_TRAILING_NUL 256
#define sv_unref(sv) sv_unref_flags(sv, 0)
#define sv_force_normal(sv) sv_force_normal_flags(sv, 0)
+#define sv_usepvn(sv, p, l) sv_usepvn_flags(sv, p, l, 0)
+#define sv_usepvn_mg(sv, p, l) sv_usepvn_flags(sv, p, l, SV_SMAGIC)
/* We are about to replace the SV's current value. So if it's copy on write
we need to normalise it. Use the SV_COW_DROP_PV flag hint to say that