line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#include |
2
|
|
|
|
|
|
|
#include |
3
|
|
|
|
|
|
|
#include |
4
|
|
|
|
|
|
|
#include |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
namespace xs { |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
|
|
|
Glob Glob::create (const Stash& stash, panda::string_view name, U32 flags) { |
9
|
1
|
|
|
|
|
|
GV* gv = (GV*)newSV(0); |
10
|
1
|
|
|
|
|
|
flags |= GV_ADDMULTI; // suppress 'used only once' warning |
11
|
1
|
|
|
|
|
|
gv_init_pvn(gv, stash, name.data(), name.length(), flags); |
12
|
1
|
|
|
|
|
|
return gv; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
4
|
|
|
|
|
|
Stash Glob::stash () const { return GvSTASH((GV*)sv); } |
16
|
2
|
50
|
|
|
|
|
Stash Glob::effective_stash () const { return GvESTASH((GV*)sv); } |
17
|
|
|
|
|
|
|
|
18
|
69
|
|
|
|
|
|
static inline void _set_slot (SV** where, SV* what) { |
19
|
69
|
|
|
|
|
|
auto old = *where; |
20
|
69
|
|
|
|
|
|
*where = what; |
21
|
69
|
100
|
|
|
|
|
SvREFCNT_inc_simple_void(what); |
22
|
69
|
50
|
|
|
|
|
SvREFCNT_dec(old); |
23
|
69
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
17
|
|
|
|
|
|
static inline void _set_slot (GV* where, CV* what) { |
26
|
17
|
|
|
|
|
|
auto old = GvCV(where); |
27
|
17
|
|
|
|
|
|
GvCV_set(where, what); |
28
|
17
|
100
|
|
|
|
|
SvREFCNT_inc_simple_void(what); |
29
|
17
|
50
|
|
|
|
|
SvREFCNT_dec(old); |
30
|
17
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
24
|
|
|
|
|
|
void Glob::slot (SV* val) { |
33
|
24
|
|
|
|
|
|
GV* gv = (GV*)sv; |
34
|
24
|
100
|
|
|
|
|
if (!val || SvTYPE(val) <= SVt_PVMG) _set_slot(&GvSV(gv), val); |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
35
|
13
|
|
|
|
|
|
else switch (SvTYPE(val)) { |
36
|
3
|
50
|
|
|
|
|
case SVt_PVCV: _set_slot(gv, (CV*)val); break; |
37
|
3
|
50
|
|
|
|
|
case SVt_PVHV: _set_slot((SV**)&GvHV(gv), val); break; |
38
|
6
|
50
|
|
|
|
|
case SVt_PVAV: _set_slot((SV**)&GvAV(gv), val); break; |
39
|
1
|
50
|
|
|
|
|
case SVt_PVIO: _set_slot((SV**)&GvIOp(gv), val); break; |
40
|
0
|
0
|
|
|
|
|
default: throw std::invalid_argument("can set unsupported type to a typeglob"); |
41
|
|
|
|
|
|
|
} |
42
|
24
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
26
|
|
|
|
|
|
void Glob::slot (AV* val) { _set_slot((SV**)&GvAV((GV*)sv), (SV*)val); } |
45
|
30
|
|
|
|
|
|
void Glob::slot (HV* val) { _set_slot((SV**)&GvHV((GV*)sv), (SV*)val); } |
46
|
28
|
|
|
|
|
|
void Glob::slot (CV* val) { _set_slot((GV*)sv, val); } |
47
|
6
|
|
|
|
|
|
void Glob::slot (IO* val) { _set_slot((SV**)&GvIOp((GV*)sv), (SV*)val); } |
48
|
34
|
|
|
|
|
|
void Glob::slot (const Scalar& val) { _set_slot(&GvSV((GV*)sv), val); } |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
} |