line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#pragma once |
2
|
|
|
|
|
|
|
#include |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
namespace xs { namespace _tm { |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
template |
7
|
|
|
|
|
|
|
inline DOWN downgrade (UP* var) { return static_cast(var); } |
8
|
|
|
|
|
|
|
template |
9
|
|
|
|
|
|
|
inline DOWN downgrade (const panda::shared_ptr& sp) { return panda::static_pointer_cast(sp); } |
10
|
|
|
|
|
|
|
template |
11
|
|
|
|
|
|
|
inline DOWN downgrade (const panda::shared_ptr& sp) { return panda::static_pointer_cast(sp); } |
12
|
|
|
|
|
|
|
template |
13
|
|
|
|
|
|
|
inline DOWN downgrade (const std::shared_ptr& sp) { return std::static_pointer_cast(sp); } |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
template |
16
|
|
|
|
|
|
|
inline UP upgrade (DOWN* var) { return panda::dyn_cast(var); } |
17
|
|
|
|
|
|
|
template |
18
|
|
|
|
|
|
|
inline UP upgrade (const panda::shared_ptr& sp) { return panda::dynamic_pointer_cast(sp); } |
19
|
|
|
|
|
|
|
template |
20
|
|
|
|
|
|
|
inline UP upgrade (const panda::shared_ptr& sp) { return panda::dynamic_pointer_cast(sp); } |
21
|
|
|
|
|
|
|
template |
22
|
|
|
|
|
|
|
inline UP upgrade (const std::shared_ptr& sp) { return std::dynamic_pointer_cast(sp); } |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
inline SV* out_oref (pTHX_ SV* var, HV* CLASS) { |
26
|
|
|
|
|
|
|
return var ? sv_bless(newRV_noinc(var), CLASS) : &PL_sv_undef; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
inline SV* out_oref (pTHX_ SV* var, const char* CLASS) { |
29
|
|
|
|
|
|
|
return out_oref(aTHX_ var, gv_stashpvn(CLASS, strlen(CLASS), GV_ADD)); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
inline SV* out_oref (pTHX_ SV* var, SV* CLASS) { |
32
|
|
|
|
|
|
|
return out_oref(aTHX_ var, gv_stashsv(CLASS, GV_ADD)); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
1
|
|
|
|
|
|
inline SV* out_optr (pTHX_ void* var, HV* CLASS) { |
36
|
1
|
50
|
|
|
|
|
return var ? sv_bless(newRV_noinc(newSViv((IV)var)), CLASS) : &PL_sv_undef; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
inline SV* out_optr (pTHX_ void* var, const char* CLASS) { |
39
|
|
|
|
|
|
|
return out_optr(aTHX_ var, gv_stashpvn(CLASS, strlen(CLASS), GV_ADD)); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
inline SV* out_optr (pTHX_ void* var, SV* CLASS) { |
42
|
|
|
|
|
|
|
return out_optr(aTHX_ var, gv_stashsv(CLASS, GV_ADD)); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
template |
46
|
|
|
|
|
|
|
inline SV* out_optr (pTHX_ const panda::shared_ptr& sp, C CLASS) { |
47
|
|
|
|
|
|
|
if (sp) sp->retain(); |
48
|
|
|
|
|
|
|
return out_optr(aTHX_ sp.get(), CLASS); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
template |
52
|
|
|
|
|
|
|
inline SV* out_optr (pTHX_ const panda::shared_ptr& sp, C CLASS) { |
53
|
|
|
|
|
|
|
return out_optr(aTHX_ new panda::shared_ptr(sp), CLASS); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
template |
57
|
|
|
|
|
|
|
inline SV* out_optr (pTHX_ const std::shared_ptr& sp, C CLASS) { |
58
|
|
|
|
|
|
|
return out_optr(aTHX_ new std::shared_ptr(sp), CLASS); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
template |
64
|
2
|
|
|
|
|
|
void* out_oext_mgp (T* varptr) { return varptr; } |
65
|
|
|
|
|
|
|
template |
66
|
|
|
|
|
|
|
void* out_oext_mgp (const panda::shared_ptr& sp) { if (sp) sp->retain(); return sp.get(); } |
67
|
|
|
|
|
|
|
template |
68
|
|
|
|
|
|
|
void* out_oext_mgp (const panda::shared_ptr& sp) { return new panda::shared_ptr(sp); } |
69
|
|
|
|
|
|
|
template |
70
|
|
|
|
|
|
|
void* out_oext_mgp (const std::shared_ptr& sp) { return new std::shared_ptr(sp); } |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
SV* _out_oext (pTHX_ SV* self, void* var, HV* CLASS, payload_marker_t* marker = NULL); |
73
|
|
|
|
|
|
|
SV* _out_oext (pTHX_ SV* self, void* var, SV* CLASS, payload_marker_t* marker = NULL); |
74
|
|
|
|
|
|
|
SV* _out_oext (pTHX_ SV* self, void* var, const char* CLASS, payload_marker_t* marker = NULL); |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
template |
77
|
1
|
|
|
|
|
|
inline SV* out_oext (pTHX_ SV* self, T var, C CLASS, payload_marker_t* marker = NULL) { |
78
|
1
|
|
|
|
|
|
return _out_oext(aTHX_ self, out_oext_mgp(var), CLASS, marker); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
template |
84
|
0
|
|
|
|
|
|
inline void* in_optr (pTHX_ SV* arg, T* varptr) { |
85
|
0
|
0
|
|
|
|
|
if (sv_isobject(arg)) { |
86
|
0
|
|
|
|
|
|
SV* obj = SvRV(arg); |
87
|
0
|
0
|
|
|
|
|
if (SvIOK(obj)) { |
88
|
0
|
|
|
|
|
|
void* mgp = (void*)SvIVX(obj); |
89
|
0
|
|
|
|
|
|
*varptr = static_cast(mgp); |
90
|
0
|
|
|
|
|
|
return mgp; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
} |
93
|
0
|
|
|
|
|
|
*varptr = NULL; |
94
|
0
|
|
|
|
|
|
return NULL; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
template |
98
|
|
|
|
|
|
|
inline void* in_optr (pTHX_ SV* arg, panda::shared_ptr* sptr) { |
99
|
|
|
|
|
|
|
void* mgp; |
100
|
|
|
|
|
|
|
in_optr(aTHX_ arg, &mgp); |
101
|
|
|
|
|
|
|
*sptr = static_cast(mgp); |
102
|
|
|
|
|
|
|
return mgp; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
template |
106
|
|
|
|
|
|
|
inline void* in_optr (pTHX_ SV* arg, panda::shared_ptr* sptr) { |
107
|
|
|
|
|
|
|
void* mgp; |
108
|
|
|
|
|
|
|
in_optr(aTHX_ arg, &mgp); |
109
|
|
|
|
|
|
|
*sptr = *(static_cast*>(mgp)); |
110
|
|
|
|
|
|
|
return mgp; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
template |
114
|
|
|
|
|
|
|
inline void* in_optr (pTHX_ SV* arg, std::shared_ptr* sptr) { |
115
|
|
|
|
|
|
|
void* mgp; |
116
|
|
|
|
|
|
|
in_optr(aTHX_ arg, &mgp); |
117
|
|
|
|
|
|
|
*sptr = *(static_cast*>(mgp)); |
118
|
|
|
|
|
|
|
return mgp; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
template |
124
|
13
|
|
|
|
|
|
inline void in_oext_mgp (T* varptr, void* mgp) { *varptr = static_cast(mgp); } |
125
|
|
|
|
|
|
|
template |
126
|
|
|
|
|
|
|
inline void in_oext_mgp (panda::shared_ptr* sptr, void* mgp) { *sptr = static_cast(mgp); } |
127
|
|
|
|
|
|
|
template |
128
|
|
|
|
|
|
|
inline void in_oext_mgp (panda::shared_ptr* sptr, void* mgp) { *sptr = *(static_cast*>(mgp)); } |
129
|
|
|
|
|
|
|
template |
130
|
|
|
|
|
|
|
inline void in_oext_mgp (std::shared_ptr* sptr, void* mgp) { *sptr = *(static_cast*>(mgp)); } |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
// set null only for pointers, not for shared pointers as they are already nulls on creation |
133
|
|
|
|
|
|
|
template |
134
|
0
|
|
|
|
|
|
inline void vnull (T** varptr) { *varptr = NULL; } |
135
|
|
|
|
|
|
|
template |
136
|
|
|
|
|
|
|
inline void vnull (T* varptr) { PERL_UNUSED_VAR(varptr); } |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
template |
139
|
13
|
|
|
|
|
|
inline void* in_oext (pTHX_ SV* arg, T* varptr, payload_marker_t* marker = NULL) { |
140
|
13
|
0
|
|
|
|
|
if (SvROK(arg)) { |
|
|
50
|
|
|
|
|
|
141
|
13
|
|
|
|
|
|
void* mgp = rv_payload(aTHX_ arg, marker); |
142
|
13
|
|
|
|
|
|
if (mgp) { |
143
|
13
|
|
|
|
|
|
in_oext_mgp(varptr, mgp); |
144
|
13
|
|
|
|
|
|
return mgp; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
} |
147
|
0
|
|
|
|
|
|
vnull(varptr); |
148
|
0
|
|
|
|
|
|
return NULL; |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
template |
153
|
|
|
|
|
|
|
struct AutoRelease { |
154
|
|
|
|
|
|
|
T obj; |
155
|
|
|
|
|
|
|
AutoRelease (T obj) : obj(obj) {} |
156
|
|
|
|
|
|
|
~AutoRelease () { xs::refcnt_dec(obj); } |
157
|
|
|
|
|
|
|
}; |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
template |
160
|
|
|
|
|
|
|
struct AutoDelete { |
161
|
|
|
|
|
|
|
UP obj; |
162
|
1
|
|
|
|
|
|
AutoDelete (UP obj, void* /*mgp*/) : obj(obj) {} |
163
|
2
|
0
|
|
|
|
|
~AutoDelete () { delete obj; } |
|
|
50
|
|
|
|
|
|
164
|
|
|
|
|
|
|
}; |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
// These destructors don't kill an object instantly, because it is possibly needed for user-defined XS DESTROY function code. |
167
|
|
|
|
|
|
|
// local $var shared ptr holds it until the end of DESTROY XS function |
168
|
|
|
|
|
|
|
// These funcs just decrease refcnt, so that local $var shared ptr becomes the last owner of the object. |
169
|
|
|
|
|
|
|
template |
170
|
|
|
|
|
|
|
struct AutoDelete, DOWN> { |
171
|
|
|
|
|
|
|
AutoDelete (const panda::shared_ptr& sp, void* /*mgp*/) { sp->release(); } |
172
|
|
|
|
|
|
|
}; |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
template |
175
|
|
|
|
|
|
|
struct AutoDelete, DOWN> { |
176
|
|
|
|
|
|
|
AutoDelete (const panda::shared_ptr& /*sp*/, void* mgp) { delete static_cast*>(mgp); } |
177
|
|
|
|
|
|
|
}; |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
template |
180
|
|
|
|
|
|
|
struct AutoDelete, DOWN> { |
181
|
|
|
|
|
|
|
AutoDelete (const std::shared_ptr& /*sp*/, void* mgp) { delete static_cast*>(mgp); } |
182
|
|
|
|
|
|
|
}; |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
template |
185
|
|
|
|
|
|
|
xs::XSBackref* get_xsbr (T var) { return panda::dyn_cast(var); } |
186
|
|
|
|
|
|
|
template |
187
|
|
|
|
|
|
|
xs::XSBackref* get_xsbr (panda::shared_ptr& var) { return panda::dyn_cast(var.get()); } |
188
|
|
|
|
|
|
|
template |
189
|
|
|
|
|
|
|
xs::XSBackref* get_xsbr (panda::shared_ptr& var) { return panda::dyn_cast(var.get()); } |
190
|
|
|
|
|
|
|
template |
191
|
|
|
|
|
|
|
xs::XSBackref* get_xsbr (std::shared_ptr& var) { return panda::dyn_cast(var.get()); } |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
template |
194
|
|
|
|
|
|
|
T svdup_clone (pTHX_ T obj) { return obj->clone(); } |
195
|
|
|
|
|
|
|
template |
196
|
|
|
|
|
|
|
T svdup_retain (pTHX_ T obj) { xs::refcnt_inc(obj); return obj; } |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
}} |