| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#include "EXTERN.h" |
|
2
|
|
|
|
|
|
|
#include "perl.h" |
|
3
|
|
|
|
|
|
|
#include "XSUB.h" |
|
4
|
|
|
|
|
|
|
#include "ppport.h" |
|
5
|
|
|
|
|
|
|
#include "ffi_platypus.h" |
|
6
|
|
|
|
|
|
|
#include "ffi_platypus_guts.h" |
|
7
|
|
|
|
|
|
|
|
|
8
|
4
|
|
|
|
|
|
XS(ffi_pl_record_accessor_string_ro) |
|
9
|
|
|
|
|
|
|
{ |
|
10
|
|
|
|
|
|
|
ffi_pl_record_member *member; |
|
11
|
|
|
|
|
|
|
SV *self; |
|
12
|
|
|
|
|
|
|
char *ptr1; |
|
13
|
|
|
|
|
|
|
char **ptr2; |
|
14
|
|
|
|
|
|
|
|
|
15
|
4
|
|
|
|
|
|
dVAR; dXSARGS; |
|
16
|
|
|
|
|
|
|
|
|
17
|
4
|
50
|
|
|
|
|
if(items == 0) |
|
18
|
0
|
|
|
|
|
|
croak("This is a method, you must provide at least the object"); |
|
19
|
|
|
|
|
|
|
|
|
20
|
4
|
|
|
|
|
|
member = (ffi_pl_record_member*) CvXSUBANY(cv).any_ptr; |
|
21
|
|
|
|
|
|
|
|
|
22
|
4
|
|
|
|
|
|
self = ST(0); |
|
23
|
4
|
50
|
|
|
|
|
if(SvROK(self)) |
|
24
|
4
|
|
|
|
|
|
self = SvRV(self); |
|
25
|
|
|
|
|
|
|
|
|
26
|
4
|
50
|
|
|
|
|
if(!SvOK(self)) |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
croak("Null record error"); |
|
28
|
|
|
|
|
|
|
|
|
29
|
4
|
50
|
|
|
|
|
ptr1 = (char*) SvPV_nolen(self); |
|
30
|
4
|
|
|
|
|
|
ptr2 = (char**) &ptr1[member->offset]; |
|
31
|
|
|
|
|
|
|
|
|
32
|
4
|
100
|
|
|
|
|
if(items > 1) |
|
33
|
|
|
|
|
|
|
{ |
|
34
|
1
|
|
|
|
|
|
croak("member is read only"); |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
3
|
50
|
|
|
|
|
if(GIMME_V == G_VOID) |
|
|
|
50
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
XSRETURN_EMPTY; |
|
39
|
|
|
|
|
|
|
|
|
40
|
3
|
100
|
|
|
|
|
if(*ptr2 != NULL) |
|
41
|
1
|
|
|
|
|
|
XSRETURN_PV(*ptr2); |
|
42
|
|
|
|
|
|
|
else |
|
43
|
2
|
|
|
|
|
|
XSRETURN_EMPTY; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
35
|
|
|
|
|
|
XS(ffi_pl_record_accessor_string_rw) |
|
47
|
|
|
|
|
|
|
{ |
|
48
|
|
|
|
|
|
|
ffi_pl_record_member *member; |
|
49
|
|
|
|
|
|
|
SV *self; |
|
50
|
|
|
|
|
|
|
SV *arg; |
|
51
|
|
|
|
|
|
|
char *ptr1; |
|
52
|
|
|
|
|
|
|
char **ptr2; |
|
53
|
|
|
|
|
|
|
char *arg_ptr; |
|
54
|
|
|
|
|
|
|
STRLEN len; |
|
55
|
|
|
|
|
|
|
|
|
56
|
35
|
|
|
|
|
|
dVAR; dXSARGS; |
|
57
|
|
|
|
|
|
|
|
|
58
|
35
|
50
|
|
|
|
|
if(items == 0) |
|
59
|
0
|
|
|
|
|
|
croak("This is a method, you must provide at least the object"); |
|
60
|
|
|
|
|
|
|
|
|
61
|
35
|
|
|
|
|
|
member = (ffi_pl_record_member*) CvXSUBANY(cv).any_ptr; |
|
62
|
|
|
|
|
|
|
|
|
63
|
35
|
|
|
|
|
|
self = ST(0); |
|
64
|
35
|
50
|
|
|
|
|
if(SvROK(self)) |
|
65
|
35
|
|
|
|
|
|
self = SvRV(self); |
|
66
|
|
|
|
|
|
|
|
|
67
|
35
|
50
|
|
|
|
|
if(!SvOK(self)) |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
croak("Null record error"); |
|
69
|
|
|
|
|
|
|
|
|
70
|
35
|
50
|
|
|
|
|
ptr1 = (char*) SvPV_nolen(self); |
|
71
|
35
|
|
|
|
|
|
ptr2 = (char**) &ptr1[member->offset]; |
|
72
|
|
|
|
|
|
|
|
|
73
|
35
|
100
|
|
|
|
|
if(items > 1) |
|
74
|
|
|
|
|
|
|
{ |
|
75
|
22
|
100
|
|
|
|
|
if(SvREADONLY(self)) |
|
76
|
|
|
|
|
|
|
{ |
|
77
|
2
|
|
|
|
|
|
croak("record is read-only"); |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
else |
|
80
|
|
|
|
|
|
|
{ |
|
81
|
20
|
|
|
|
|
|
arg = ST(1); |
|
82
|
20
|
100
|
|
|
|
|
if(SvOK(arg)) |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
{ |
|
84
|
10
|
100
|
|
|
|
|
arg_ptr = SvPV(arg, len); |
|
85
|
10
|
|
|
|
|
|
*ptr2 = realloc(*ptr2, len+1); |
|
86
|
10
|
|
|
|
|
|
(*ptr2)[len] = 0; |
|
87
|
10
|
|
|
|
|
|
memcpy(*ptr2, arg_ptr, len); |
|
88
|
|
|
|
|
|
|
} |
|
89
|
10
|
50
|
|
|
|
|
else if(*ptr2 != NULL) |
|
90
|
|
|
|
|
|
|
{ |
|
91
|
10
|
|
|
|
|
|
free(*ptr2); |
|
92
|
10
|
|
|
|
|
|
*ptr2 = NULL; |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
33
|
100
|
|
|
|
|
if(GIMME_V == G_VOID) |
|
|
|
100
|
|
|
|
|
|
|
98
|
20
|
|
|
|
|
|
XSRETURN_EMPTY; |
|
99
|
|
|
|
|
|
|
|
|
100
|
13
|
100
|
|
|
|
|
if(*ptr2 != NULL) |
|
101
|
12
|
|
|
|
|
|
XSRETURN_PV(*ptr2); |
|
102
|
|
|
|
|
|
|
else |
|
103
|
33
|
|
|
|
|
|
XSRETURN_EMPTY; |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
|
|
106
|
27
|
|
|
|
|
|
XS(ffi_pl_record_accessor_string_fixed) |
|
107
|
|
|
|
|
|
|
{ |
|
108
|
|
|
|
|
|
|
ffi_pl_record_member *member; |
|
109
|
|
|
|
|
|
|
SV *self; |
|
110
|
|
|
|
|
|
|
SV *arg; |
|
111
|
|
|
|
|
|
|
SV *value; |
|
112
|
|
|
|
|
|
|
char *ptr1; |
|
113
|
|
|
|
|
|
|
char *ptr2; |
|
114
|
|
|
|
|
|
|
char *arg_ptr; |
|
115
|
|
|
|
|
|
|
STRLEN len; |
|
116
|
|
|
|
|
|
|
|
|
117
|
27
|
|
|
|
|
|
dVAR; dXSARGS; |
|
118
|
|
|
|
|
|
|
|
|
119
|
27
|
50
|
|
|
|
|
if(items == 0) |
|
120
|
0
|
|
|
|
|
|
croak("This is a method, you must provide at least the object"); |
|
121
|
|
|
|
|
|
|
|
|
122
|
27
|
|
|
|
|
|
member = (ffi_pl_record_member*) CvXSUBANY(cv).any_ptr; |
|
123
|
|
|
|
|
|
|
|
|
124
|
27
|
|
|
|
|
|
self = ST(0); |
|
125
|
27
|
50
|
|
|
|
|
if(SvROK(self)) |
|
126
|
27
|
|
|
|
|
|
self = SvRV(self); |
|
127
|
|
|
|
|
|
|
|
|
128
|
27
|
50
|
|
|
|
|
if(!SvOK(self)) |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
129
|
0
|
|
|
|
|
|
croak("Null record error"); |
|
130
|
|
|
|
|
|
|
|
|
131
|
27
|
50
|
|
|
|
|
ptr1 = (char*) SvPV_nolen(self); |
|
132
|
27
|
|
|
|
|
|
ptr2 = (char*) &ptr1[member->offset]; |
|
133
|
|
|
|
|
|
|
|
|
134
|
27
|
100
|
|
|
|
|
if(items > 1) |
|
135
|
|
|
|
|
|
|
{ |
|
136
|
13
|
100
|
|
|
|
|
if(SvREADONLY(self)) |
|
137
|
|
|
|
|
|
|
{ |
|
138
|
2
|
|
|
|
|
|
croak("record is read-only"); |
|
139
|
|
|
|
|
|
|
} |
|
140
|
|
|
|
|
|
|
else |
|
141
|
|
|
|
|
|
|
{ |
|
142
|
11
|
|
|
|
|
|
arg = ST(1); |
|
143
|
11
|
50
|
|
|
|
|
if(SvOK(arg)) |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
{ |
|
145
|
11
|
50
|
|
|
|
|
arg_ptr = SvPV(ST(1), len); |
|
146
|
11
|
100
|
|
|
|
|
if(len > member->count) |
|
147
|
1
|
|
|
|
|
|
len = member->count; |
|
148
|
11
|
|
|
|
|
|
memcpy(ptr2, arg_ptr, len); |
|
149
|
|
|
|
|
|
|
} |
|
150
|
|
|
|
|
|
|
else |
|
151
|
|
|
|
|
|
|
{ |
|
152
|
0
|
|
|
|
|
|
croak("Cannot assign undef to a fixed string field"); |
|
153
|
|
|
|
|
|
|
} |
|
154
|
|
|
|
|
|
|
} |
|
155
|
|
|
|
|
|
|
} |
|
156
|
|
|
|
|
|
|
|
|
157
|
25
|
50
|
|
|
|
|
if(GIMME_V == G_VOID) |
|
|
|
100
|
|
|
|
|
|
|
158
|
11
|
|
|
|
|
|
XSRETURN_EMPTY; |
|
159
|
|
|
|
|
|
|
|
|
160
|
14
|
|
|
|
|
|
value = sv_newmortal(); |
|
161
|
14
|
|
|
|
|
|
sv_setpvn(value, ptr2, member->count); |
|
162
|
14
|
|
|
|
|
|
ST(0) = value; |
|
163
|
25
|
|
|
|
|
|
XSRETURN(1); |
|
164
|
|
|
|
|
|
|
} |