line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#include |
2
|
|
|
|
|
|
|
using namespace xs::exp; |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
#define EX_CROAK_NOPACKAGE(pack) croak("Panda::Export: context package '%" SVf "' doesn't exist", SVfARG(pack)) |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
MODULE = Panda::Export PACKAGE = Panda::Export |
7
|
|
|
|
|
|
|
PROTOTYPES: DISABLE |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
void import (SV* ctx_class, ...) { |
10
|
10
|
|
|
|
|
|
HV* caller_stash = CopSTASH(PL_curcop); |
11
|
10
|
50
|
|
|
|
|
if (strEQ(SvPV_nolen(ctx_class), "Panda::Export")) { |
|
|
100
|
|
|
|
|
|
12
|
5
|
100
|
|
|
|
|
if (items < 2) XSRETURN(0); |
13
|
4
|
|
|
|
|
|
SV* arg = ST(1); |
14
|
4
|
50
|
|
|
|
|
if (SvROK(arg) && SvTYPE(SvRV(arg)) == SVt_PVHV) create_constants(aTHX_ caller_stash, (HV*)SvRV(arg)); |
|
|
100
|
|
|
|
|
|
15
|
3
|
|
|
|
|
|
else create_constants(aTHX_ caller_stash, &ST(1), items-1); |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
else { |
18
|
5
|
|
|
|
|
|
HV* ctx_stash = gv_stashsv(ctx_class, 0); |
19
|
5
|
50
|
|
|
|
|
if (ctx_stash == NULL) EX_CROAK_NOPACKAGE(ctx_class); |
20
|
5
|
100
|
|
|
|
|
if (items > 1) export_subs(aTHX_ ctx_stash, caller_stash, &ST(1), items-1); |
21
|
1
|
|
|
|
|
|
else export_constants(aTHX_ ctx_stash, caller_stash); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
SV* constants_list (SV* ctx_class) { |
26
|
0
|
|
|
|
|
|
HV* ctx_stash = gv_stashsv(ctx_class, 0); |
27
|
0
|
0
|
|
|
|
|
if (ctx_stash == NULL) EX_CROAK_NOPACKAGE(ctx_class); |
28
|
0
|
|
|
|
|
|
RETVAL = newRV((SV*)constants_list(aTHX_ ctx_stash)); |
29
|
|
|
|
|
|
|
} |