line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
MODULE = FFI::Platypus PACKAGE = FFI::Platypus::Buffer |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
void |
4
|
|
|
|
|
|
|
window(sv, addr, len = 0, utf8 = 0) |
5
|
|
|
|
|
|
|
SV* sv |
6
|
|
|
|
|
|
|
void *addr |
7
|
|
|
|
|
|
|
size_t len |
8
|
|
|
|
|
|
|
IV utf8 |
9
|
|
|
|
|
|
|
PROTOTYPE: $$;$$ |
10
|
|
|
|
|
|
|
CODE: |
11
|
3
|
100
|
|
|
|
|
if(len == 0) |
12
|
1
|
|
|
|
|
|
len = strlen((char*)addr); |
13
|
3
|
50
|
|
|
|
|
SvUPGRADE(sv, SVt_PV); |
14
|
3
|
|
|
|
|
|
SvPVX(sv) = addr; |
15
|
3
|
|
|
|
|
|
SvCUR_set(sv, len); |
16
|
3
|
|
|
|
|
|
SvLEN_set(sv, 0); |
17
|
3
|
|
|
|
|
|
SvPOK_only(sv); |
18
|
3
|
|
|
|
|
|
SvREADONLY_on(sv); |
19
|
3
|
100
|
|
|
|
|
if(utf8) |
20
|
1
|
|
|
|
|
|
SvUTF8_on(sv); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
void |
23
|
|
|
|
|
|
|
grow (sv, size, ... ) |
24
|
|
|
|
|
|
|
SV *sv |
25
|
|
|
|
|
|
|
STRLEN size |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
PROTOTYPE: $$;$ |
28
|
|
|
|
|
|
|
PREINIT: |
29
|
9
|
|
|
|
|
|
int clear = 1; |
30
|
9
|
|
|
|
|
|
int set_length = 1; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
PPCODE: |
33
|
9
|
100
|
|
|
|
|
if (SvROK (sv)) |
34
|
1
|
|
|
|
|
|
croak("buffer argument must be a scalar"); |
35
|
|
|
|
|
|
|
|
36
|
8
|
100
|
|
|
|
|
if ( items > 2 ) { |
37
|
|
|
|
|
|
|
|
38
|
5
|
|
|
|
|
|
HV* hash = NULL; |
39
|
5
|
|
|
|
|
|
SV* options = ST(2); |
40
|
|
|
|
|
|
|
char *key; |
41
|
|
|
|
|
|
|
I32 len; |
42
|
|
|
|
|
|
|
SV* value; |
43
|
|
|
|
|
|
|
|
44
|
5
|
50
|
|
|
|
|
if ( SvROK(options) ) |
45
|
5
|
|
|
|
|
|
hash = (HV*) SvRV(options); |
46
|
|
|
|
|
|
|
|
47
|
5
|
50
|
|
|
|
|
if ( !hash || SvTYPE(hash) != SVt_PVHV ) |
|
|
50
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
croak("options argument must be a hash"); |
49
|
|
|
|
|
|
|
|
50
|
5
|
|
|
|
|
|
hv_iterinit(hash); |
51
|
12
|
100
|
|
|
|
|
while( (value = hv_iternextsv(hash, &key, &len)) != NULL ) { |
52
|
|
|
|
|
|
|
|
53
|
8
|
100
|
|
|
|
|
if ( 0 == strncmp( key, "clear", len ) ) { |
54
|
3
|
50
|
|
|
|
|
clear = SvTRUE( value ); |
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
55
|
|
|
|
|
|
|
} |
56
|
5
|
100
|
|
|
|
|
else if ( 0 == strncmp( key, "set_length", len ) ) { |
57
|
4
|
50
|
|
|
|
|
set_length = SvTRUE( value ); |
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
else { |
60
|
1
|
|
|
|
|
|
croak("unknown option: %s", key ); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
/* if not a string turn it into an empty one, or if clearing is |
66
|
|
|
|
|
|
|
requested, reset string length */ |
67
|
7
|
100
|
|
|
|
|
if (!SvPOK (sv) || clear ) { |
|
|
100
|
|
|
|
|
|
68
|
|
|
|
|
|
|
#if PERL_API_VERSION >= 26 |
69
|
6
|
|
|
|
|
|
SvPVCLEAR(sv); |
70
|
|
|
|
|
|
|
#else |
71
|
|
|
|
|
|
|
sv_setpvn (sv, "", 0); |
72
|
|
|
|
|
|
|
#endif |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
6
|
100
|
|
|
|
|
SvGROW (sv, size); |
|
|
50
|
|
|
|
|
|
76
|
6
|
100
|
|
|
|
|
if ( set_length ) |
77
|
3
|
|
|
|
|
|
SvCUR_set( sv, size ); |
78
|
6
|
50
|
|
|
|
|
EXTEND (SP, 1); |
79
|
6
|
|
|
|
|
|
mPUSHi (SvLEN (sv)); |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
STRLEN |
83
|
|
|
|
|
|
|
set_used_length( sv, size ) |
84
|
|
|
|
|
|
|
SV *sv |
85
|
|
|
|
|
|
|
STRLEN size |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
PROTOTYPE: $$ |
88
|
|
|
|
|
|
|
PREINIT: |
89
|
|
|
|
|
|
|
STRLEN len; |
90
|
|
|
|
|
|
|
CODE: |
91
|
6
|
100
|
|
|
|
|
if (SvROK (sv)) |
92
|
1
|
|
|
|
|
|
croak("buffer argument must be a scalar"); |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
/* add some stringiness if necessary; svCUR_set only works on PV's */ |
95
|
5
|
100
|
|
|
|
|
if (!SvPOK (sv)) |
96
|
2
|
|
|
|
|
|
sv_setpvn (sv, "", 0); |
97
|
|
|
|
|
|
|
|
98
|
4
|
|
|
|
|
|
len = SvLEN( sv ); |
99
|
4
|
|
|
|
|
|
RETVAL = size > len ? len : size; |
100
|
4
|
|
|
|
|
|
SvCUR_set( sv, RETVAL ); |
101
|
|
|
|
|
|
|
OUTPUT: |
102
|
|
|
|
|
|
|
RETVAL |