| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#define PERL_NO_GET_CONTEXT // we'll define thread context if necessary (faster) |
|
2
|
|
|
|
|
|
|
#include "EXTERN.h" // globals/constant import locations |
|
3
|
|
|
|
|
|
|
#include "perl.h" // Perl symbols, structures and constants definition |
|
4
|
|
|
|
|
|
|
#include "XSUB.h" // xsubpp functions and macros |
|
5
|
|
|
|
|
|
|
#include "stdint.h" // portable integers |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
MODULE = XS::Tutorial::Two PACKAGE = XS::Tutorial::Two |
|
8
|
|
|
|
|
|
|
PROTOTYPES: ENABLE |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
SV * |
|
11
|
|
|
|
|
|
|
add_ints (...) |
|
12
|
|
|
|
|
|
|
PPCODE: |
|
13
|
|
|
|
|
|
|
uint32_t i; |
|
14
|
3
|
|
|
|
|
|
int32_t total = 0; |
|
15
|
3
|
100
|
|
|
|
|
if (items > 0) { |
|
16
|
7
|
100
|
|
|
|
|
for (i = 0; i < items; i++) { |
|
17
|
5
|
50
|
|
|
|
|
if (!SvOK(ST(i)) || !SvIOK(ST(i))) |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
|
croak("requires a list of integers"); |
|
19
|
|
|
|
|
|
|
|
|
20
|
5
|
|
|
|
|
|
total += SvIVX(ST(i)); |
|
21
|
|
|
|
|
|
|
} |
|
22
|
2
|
|
|
|
|
|
PUSHs(sv_2mortal(newSViv(total))); |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
else { |
|
25
|
1
|
|
|
|
|
|
PUSHs(sv_newmortal()); |
|
26
|
|
|
|
|
|
|
} |