1 ################################################################################
5 ## $Date: 2010/03/07 13:15:46 +0100 $
7 ################################################################################
9 ## Version 3.x, Copyright (C) 2004-2010, Marcus Holland-Moritz.
10 ## Version 2.x, Copyright (C) 2001, Paul Marquess.
11 ## Version 1.x, Copyright (C) 1999, Kenneth Albanowski.
13 ## This program is free software; you can redistribute it and/or
14 ## modify it under the same terms as Perl itself.
16 ################################################################################
24 __UNDEFINED__ SvMAGIC_set(sv, val) \
25 STMT_START { assert(SvTYPE(sv) >= SVt_PVMG); \
26 (((XPVMG*) SvANY(sv))->xmg_magic = (val)); } STMT_END
28 #if { VERSION < 5.9.3 }
30 __UNDEFINED__ SvPVX_const(sv) ((const char*) (0 + SvPVX(sv)))
31 __UNDEFINED__ SvPVX_mutable(sv) (0 + SvPVX(sv))
33 __UNDEFINED__ SvRV_set(sv, val) \
34 STMT_START { assert(SvTYPE(sv) >= SVt_RV); \
35 (((XRV*) SvANY(sv))->xrv_rv = (val)); } STMT_END
39 __UNDEFINED__ SvPVX_const(sv) ((const char*)((sv)->sv_u.svu_pv))
40 __UNDEFINED__ SvPVX_mutable(sv) ((sv)->sv_u.svu_pv)
42 __UNDEFINED__ SvRV_set(sv, val) \
43 STMT_START { assert(SvTYPE(sv) >= SVt_RV); \
44 ((sv)->sv_u.svu_rv = (val)); } STMT_END
48 __UNDEFINED__ SvSTASH_set(sv, val) \
49 STMT_START { assert(SvTYPE(sv) >= SVt_PVMG); \
50 (((XPVMG*) SvANY(sv))->xmg_stash = (val)); } STMT_END
52 #if { VERSION < 5.004 }
54 __UNDEFINED__ SvUV_set(sv, val) \
55 STMT_START { assert(SvTYPE(sv) == SVt_IV || SvTYPE(sv) >= SVt_PVIV); \
56 (((XPVIV*) SvANY(sv))->xiv_iv = (IV) (val)); } STMT_END
60 __UNDEFINED__ SvUV_set(sv, val) \
61 STMT_START { assert(SvTYPE(sv) == SVt_IV || SvTYPE(sv) >= SVt_PVIV); \
62 (((XPVUV*) SvANY(sv))->xuv_uv = (val)); } STMT_END
74 RETVAL = SvUVX(sv) == val ? 42 : -1;
82 RETVAL = strEQ(SvPVX_const(sv), "mhx") ? 43 : -1;
90 RETVAL = strEQ(SvPVX_mutable(sv), "mhx") ? 44 : -1;
95 TestSvSTASH_set(sv, name)
100 SvREFCNT_dec(SvSTASH(sv));
101 SvSTASH_set(sv, (HV*) SvREFCNT_inc(gv_stashpv(name, 0)));
106 ok(&Devel::PPPort::TestSvUV_set($foo, 12345), 42);
107 ok(&Devel::PPPort::TestSvPVX_const("mhx"), 43);
108 ok(&Devel::PPPort::TestSvPVX_mutable("mhx"), 44);
113 ok($bar->x(), 'foobar');
115 Devel::PPPort::TestSvSTASH_set($bar, 'bar');
116 ok($bar->x(), 'hacker');