Commit | Line | Data |
adfe19db |
1 | ################################################################################ |
2 | ## |
bfc37ff7 |
3 | ## $Revision: 12 $ |
adfe19db |
4 | ## $Author: mhx $ |
bfc37ff7 |
5 | ## $Date: 2010/03/07 13:15:47 +0100 $ |
adfe19db |
6 | ## |
7 | ################################################################################ |
8 | ## |
bfc37ff7 |
9 | ## Version 3.x, Copyright (C) 2004-2010, Marcus Holland-Moritz. |
adfe19db |
10 | ## Version 2.x, Copyright (C) 2001, Paul Marquess. |
11 | ## Version 1.x, Copyright (C) 1999, Kenneth Albanowski. |
12 | ## |
13 | ## This program is free software; you can redistribute it and/or |
14 | ## modify it under the same terms as Perl itself. |
15 | ## |
16 | ################################################################################ |
17 | |
18 | =provides |
19 | |
20 | __UNDEFINED__ |
21 | |
22 | =implementation |
23 | |
c1a049cb |
24 | __UNDEFINED__ mPUSHs(s) PUSHs(sv_2mortal(s)) |
adfe19db |
25 | __UNDEFINED__ PUSHmortal PUSHs(sv_newmortal()) |
c1a049cb |
26 | __UNDEFINED__ mPUSHp(p,l) sv_setpvn(PUSHmortal, (p), (l)) |
27 | __UNDEFINED__ mPUSHn(n) sv_setnv(PUSHmortal, (NV)(n)) |
28 | __UNDEFINED__ mPUSHi(i) sv_setiv(PUSHmortal, (IV)(i)) |
29 | __UNDEFINED__ mPUSHu(u) sv_setuv(PUSHmortal, (UV)(u)) |
adfe19db |
30 | |
c1a049cb |
31 | __UNDEFINED__ mXPUSHs(s) XPUSHs(sv_2mortal(s)) |
adfe19db |
32 | __UNDEFINED__ XPUSHmortal XPUSHs(sv_newmortal()) |
c1a049cb |
33 | __UNDEFINED__ mXPUSHp(p,l) STMT_START { EXTEND(sp,1); sv_setpvn(PUSHmortal, (p), (l)); } STMT_END |
34 | __UNDEFINED__ mXPUSHn(n) STMT_START { EXTEND(sp,1); sv_setnv(PUSHmortal, (NV)(n)); } STMT_END |
35 | __UNDEFINED__ mXPUSHi(i) STMT_START { EXTEND(sp,1); sv_setiv(PUSHmortal, (IV)(i)); } STMT_END |
36 | __UNDEFINED__ mXPUSHu(u) STMT_START { EXTEND(sp,1); sv_setuv(PUSHmortal, (UV)(u)); } STMT_END |
adfe19db |
37 | |
38 | =xsubs |
39 | |
40 | void |
c1a049cb |
41 | mPUSHs() |
42 | PPCODE: |
43 | EXTEND(SP, 3); |
44 | mPUSHs(newSVpv("foo", 0)); |
45 | mPUSHs(newSVpv("bar13", 3)); |
46 | mPUSHs(newSViv(42)); |
47 | XSRETURN(3); |
48 | |
49 | void |
adfe19db |
50 | mPUSHp() |
51 | PPCODE: |
52 | EXTEND(SP, 3); |
53 | mPUSHp("one", 3); |
54 | mPUSHp("two", 3); |
55 | mPUSHp("three", 5); |
56 | XSRETURN(3); |
57 | |
58 | void |
59 | mPUSHn() |
60 | PPCODE: |
61 | EXTEND(SP, 3); |
62 | mPUSHn(0.5); |
63 | mPUSHn(-0.25); |
64 | mPUSHn(0.125); |
65 | XSRETURN(3); |
66 | |
67 | void |
68 | mPUSHi() |
69 | PPCODE: |
70 | EXTEND(SP, 3); |
71 | mPUSHi(-1); |
72 | mPUSHi(2); |
73 | mPUSHi(-3); |
74 | XSRETURN(3); |
75 | |
76 | void |
77 | mPUSHu() |
78 | PPCODE: |
79 | EXTEND(SP, 3); |
80 | mPUSHu(1); |
81 | mPUSHu(2); |
82 | mPUSHu(3); |
83 | XSRETURN(3); |
84 | |
85 | void |
c1a049cb |
86 | mXPUSHs() |
87 | PPCODE: |
88 | mXPUSHs(newSVpv("foo", 0)); |
89 | mXPUSHs(newSVpv("bar13", 3)); |
90 | mXPUSHs(newSViv(42)); |
91 | XSRETURN(3); |
92 | |
93 | void |
adfe19db |
94 | mXPUSHp() |
95 | PPCODE: |
96 | mXPUSHp("one", 3); |
97 | mXPUSHp("two", 3); |
98 | mXPUSHp("three", 5); |
99 | XSRETURN(3); |
100 | |
101 | void |
102 | mXPUSHn() |
103 | PPCODE: |
104 | mXPUSHn(0.5); |
105 | mXPUSHn(-0.25); |
106 | mXPUSHn(0.125); |
107 | XSRETURN(3); |
108 | |
109 | void |
110 | mXPUSHi() |
111 | PPCODE: |
112 | mXPUSHi(-1); |
113 | mXPUSHi(2); |
114 | mXPUSHi(-3); |
115 | XSRETURN(3); |
116 | |
117 | void |
118 | mXPUSHu() |
119 | PPCODE: |
120 | mXPUSHu(1); |
121 | mXPUSHu(2); |
122 | mXPUSHu(3); |
123 | XSRETURN(3); |
124 | |
c1a049cb |
125 | =tests plan => 10 |
adfe19db |
126 | |
c1a049cb |
127 | ok(join(':', &Devel::PPPort::mPUSHs()), "foo:bar:42"); |
adfe19db |
128 | ok(join(':', &Devel::PPPort::mPUSHp()), "one:two:three"); |
129 | ok(join(':', &Devel::PPPort::mPUSHn()), "0.5:-0.25:0.125"); |
130 | ok(join(':', &Devel::PPPort::mPUSHi()), "-1:2:-3"); |
131 | ok(join(':', &Devel::PPPort::mPUSHu()), "1:2:3"); |
132 | |
c1a049cb |
133 | ok(join(':', &Devel::PPPort::mXPUSHs()), "foo:bar:42"); |
adfe19db |
134 | ok(join(':', &Devel::PPPort::mXPUSHp()), "one:two:three"); |
135 | ok(join(':', &Devel::PPPort::mXPUSHn()), "0.5:-0.25:0.125"); |
136 | ok(join(':', &Devel::PPPort::mXPUSHi()), "-1:2:-3"); |
137 | ok(join(':', &Devel::PPPort::mXPUSHu()), "1:2:3"); |
138 | |