This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Update Devel-PPPort to match 3.67
[perl5.git] / dist / Devel-PPPort / parts / inc / newSV_type
CommitLineData
8565c31a
MHM
1################################################################################
2##
b2049988 3## Version 3.x, Copyright (C) 2004-2013, Marcus Holland-Moritz.
8565c31a
MHM
4## Version 2.x, Copyright (C) 2001, Paul Marquess.
5## Version 1.x, Copyright (C) 1999, Kenneth Albanowski.
6##
7## This program is free software; you can redistribute it and/or
8## modify it under the same terms as Perl itself.
9##
10################################################################################
11
12=provides
13
14newSV_type
15
16=implementation
17
18#ifndef newSV_type
46677718 19#if defined(PERL_USE_GCC_BRACE_GROUPS)
e2e74bab
P
20# define newSV_type(t) ({ SV *_sv = newSV(0); sv_upgrade(_sv, (t)); _sv; })
21#else
22# define newSV_type(t) ((PL_Sv = newSV(0)), sv_upgrade(PL_Sv, (t)), PL_Sv)
8565c31a 23#endif
8565c31a
MHM
24#endif
25
8565c31a
MHM
26=xsubs
27
28int
29newSV_type()
b2049988
MHM
30 PREINIT:
31 SV* sv;
32 CODE:
33 RETVAL = 0;
34 sv = newSV_type(SVt_NULL);
35 if (SvTYPE(sv) == SVt_NULL)
36 {
37 RETVAL++;
38 }
39 SvREFCNT_dec(sv);
40
41 sv = newSV_type(SVt_PVIV);
42 if (SvTYPE(sv) == SVt_PVIV)
43 {
44 RETVAL++;
45 }
46 SvREFCNT_dec(sv);
47
48 sv = newSV_type(SVt_PVHV);
49 if (SvTYPE(sv) == SVt_PVHV)
50 {
51 RETVAL++;
52 }
53 SvREFCNT_dec(sv);
54
55 sv = newSV_type(SVt_PVAV);
56 if (SvTYPE(sv) == SVt_PVAV)
57 {
58 RETVAL++;
59 }
60 SvREFCNT_dec(sv);
61 OUTPUT:
62 RETVAL
8565c31a
MHM
63
64
65=tests plan => 1
66
8154c0b1 67is(Devel::PPPort::newSV_type(), 4);