line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#include |
2
|
|
|
|
|
|
|
#include |
3
|
|
|
|
|
|
|
using namespace xs; |
4
|
|
|
|
|
|
|
using namespace xs::exp; |
5
|
|
|
|
|
|
|
|
6
|
0
|
|
|
|
|
|
static void throw_nopackage (const Simple& name) { |
7
|
0
|
0
|
|
|
|
|
throw Simple::format("Export::XS: context package '%" SVf "' doesn't exist", SVfARG(name.get())); |
8
|
|
|
|
|
|
|
} |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
MODULE = Export::XS PACKAGE = Export::XS |
11
|
|
|
|
|
|
|
PROTOTYPES: DISABLE |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
void import (Simple ctx_class, ...) { |
14
|
32
|
50
|
|
|
|
|
Stash caller_stash = CopSTASH(PL_curcop); |
15
|
|
|
|
|
|
|
|
16
|
16
|
|
|
|
|
|
bool create = false; |
17
|
16
|
50
|
|
|
|
|
panda::string_view ctx_clname = ctx_class; |
18
|
16
|
50
|
|
|
|
|
if (ctx_clname == "Export::XS") create = true; |
|
|
100
|
|
|
|
|
|
19
|
8
|
50
|
|
|
|
|
else if (ctx_clname == "Export::XS::Auto") { |
|
|
100
|
|
|
|
|
|
20
|
2
|
|
|
|
|
|
create = true; |
21
|
2
|
50
|
|
|
|
|
autoexport(caller_stash); |
|
|
50
|
|
|
|
|
|
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
16
|
100
|
|
|
|
|
if (create) { |
25
|
10
|
100
|
|
|
|
|
if (items < 2) XSRETURN_EMPTY; |
26
|
7
|
50
|
|
|
|
|
if (Sv(ST(1)).is_hash_ref()) create_constants(caller_stash, ST(1)); |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
27
|
6
|
50
|
|
|
|
|
else create_constants(caller_stash, &ST(1), items-1); |
|
|
100
|
|
|
|
|
|
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
else { |
30
|
12
|
50
|
|
|
|
|
auto ctx_stash = Stash::from_name(ctx_class); |
31
|
6
|
50
|
|
|
|
|
if (!ctx_stash) throw_nopackage(ctx_class); |
|
|
0
|
|
|
|
|
|
32
|
6
|
100
|
|
|
|
|
if (items > 1) { |
33
|
12
|
100
|
|
|
|
|
for (I32 i = 1; i < items; ++i) { |
34
|
9
|
50
|
|
|
|
|
panda::string_view name = Simple(ST(i)); |
|
|
50
|
|
|
|
|
|
35
|
9
|
50
|
|
|
|
|
if (name == ":const") export_constants(ctx_stash, caller_stash); |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
36
|
8
|
50
|
|
|
|
|
else export_sub(ctx_stash, caller_stash, name); |
|
|
100
|
|
|
|
|
|
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
2
|
50
|
|
|
|
|
else export_constants(ctx_stash, caller_stash); |
|
|
50
|
|
|
|
|
|
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Array constants_list (Simple ctx_class) { |
44
|
0
|
0
|
|
|
|
|
auto ctx_stash = Stash::from_name(ctx_class); |
|
|
0
|
|
|
|
|
|
45
|
0
|
0
|
|
|
|
|
if (!ctx_stash) throw_nopackage(ctx_class); |
|
|
0
|
|
|
|
|
|
46
|
0
|
0
|
|
|
|
|
RETVAL = constants_list(ctx_stash); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
void export_constants (Simple ctx_class, Simple trg_class) { |
50
|
0
|
0
|
|
|
|
|
auto ctx_stash = Stash::from_name(ctx_class); |
51
|
0
|
0
|
|
|
|
|
auto trg_stash = Stash::from_name(trg_class); |
52
|
|
|
|
|
|
|
|
53
|
0
|
0
|
|
|
|
|
export_constants(ctx_stash, trg_stash); |
|
|
0
|
|
|
|
|
|
54
|
|
|
|
|
|
|
} |