1 ################################################################################
5 ## $Date: 2010/03/07 13:15:47 +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 ################################################################################
25 __UNDEFINED__ sv_setuv(sv, uv) \
28 if (TeMpUv <= IV_MAX) \
29 sv_setiv(sv, TeMpUv); \
31 sv_setnv(sv, (double)TeMpUv); \
34 __UNDEFINED__ newSVuv(uv) ((uv) <= IV_MAX ? newSViv((IV)uv) : newSVnv((NV)uv))
36 __UNDEFINED__ sv_2uv(sv) ((PL_Sv = (sv)), (UV) (SvNOK(PL_Sv) ? SvNV(PL_Sv) : sv_2nv(PL_Sv)))
37 __UNDEFINED__ SvUVX(sv) ((UV)SvIVX(sv))
38 __UNDEFINED__ SvUVXx(sv) SvUVX(sv)
39 __UNDEFINED__ SvUV(sv) (SvIOK(sv) ? SvUVX(sv) : sv_2uv(sv))
40 __UNDEFINED__ SvUVx(sv) ((PL_Sv = (sv)), SvUV(PL_Sv))
43 * Always use the SvUVx() macro instead of sv_uv().
45 __UNDEFINED__ sv_uv(sv) SvUVx(sv)
47 #if !defined(SvUOK) && defined(SvIOK_UV)
48 # define SvUOK(sv) SvIOK_UV(sv)
51 __UNDEFINED__ XST_mUV(i,v) (ST(i) = sv_2mortal(newSVuv(v)) )
52 __UNDEFINED__ XSRETURN_UV(v) STMT_START { XST_mUV(0,v); XSRETURN(1); } STMT_END
54 __UNDEFINED__ PUSHu(u) STMT_START { sv_setuv(TARG, (UV)(u)); PUSHTARG; } STMT_END
55 __UNDEFINED__ XPUSHu(u) STMT_START { sv_setuv(TARG, (UV)(u)); XPUSHTARG; } STMT_END
103 TARG = sv_newmortal();
113 TARG = sv_newmortal();
119 ok(&Devel::PPPort::sv_setuv(42), 42);
120 ok(&Devel::PPPort::newSVuv(123), 123);
121 ok(&Devel::PPPort::sv_2uv("4711"), 4711);
122 ok(&Devel::PPPort::sv_2uv("1735928559"), 1735928559);
123 ok(&Devel::PPPort::SvUVx("1735928559"), 1735928559);
124 ok(&Devel::PPPort::SvUVx(1735928559), 1735928559);
125 ok(&Devel::PPPort::SvUVx(0xdeadbeef), 0xdeadbeef);
126 ok(&Devel::PPPort::XSRETURN_UV(), 42);
127 ok(&Devel::PPPort::PUSHu(), 42);
128 ok(&Devel::PPPort::XPUSHu(), 43);