line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
MODULE = XLog PACKAGE = XLog::Module |
2
|
|
|
|
|
|
|
PROTOTYPES: DISABLE |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
#// ->new($name, [$level]) |
5
|
|
|
|
|
|
|
#// ->new($name, $module, [$level]) |
6
|
|
|
|
|
|
|
Sv new (SV* cls, string name, Sv arg1 = {}, Sv arg2 = {}) { |
7
|
24
|
|
|
|
|
|
--items; |
8
|
|
|
|
|
|
|
Module* module; |
9
|
24
|
100
|
|
|
|
|
if (items == 1) { |
10
|
8
|
50
|
|
|
|
|
module = new Module(name); |
|
|
50
|
|
|
|
|
|
11
|
|
|
|
|
|
|
} |
12
|
16
|
100
|
|
|
|
|
else if (items == 2) { |
13
|
15
|
100
|
|
|
|
|
if (!arg1.defined() || arg1.is_object_ref()) module = new Module(name, xs::in(arg1)); |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
14
|
15
|
50
|
|
|
|
|
else module = new Module(name, xs::in(arg1)); |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
15
|
|
|
|
|
|
|
} else { |
16
|
1
|
50
|
|
|
|
|
module = new Module(name, xs::in(arg1), xs::in(arg2)); |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
// Module* has non-owning ptr typemap. In case of creating object from perl we must switch to "owning" behaviour |
20
|
|
|
|
|
|
|
// so we need to hook sv destruction and delete the object if we created it in this method. |
21
|
|
|
|
|
|
|
static Sv::payload_marker_t module_dtor_marker; |
22
|
86
|
|
|
|
|
|
module_dtor_marker.svt_free = [](pTHX_ SV*, MAGIC* mg) { |
23
|
19
|
50
|
|
|
|
|
delete (Module*)mg->mg_ptr; |
24
|
19
|
|
|
|
|
|
return 0; |
25
|
43
|
|
|
|
|
|
}; |
26
|
|
|
|
|
|
|
|
27
|
48
|
50
|
|
|
|
|
Object o = xs::out(module, cls); |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
28
|
24
|
50
|
|
|
|
|
o.payload_attach(module, &module_dtor_marker); |
29
|
|
|
|
|
|
|
|
30
|
24
|
50
|
|
|
|
|
RETVAL = o.ref(); |
|
|
50
|
|
|
|
|
|
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
4
|
50
|
|
|
|
|
string Module::name () |
|
|
50
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
10
|
|
|
|
|
|
Level Module::level () |
36
|
5
|
50
|
|
|
|
|
|
37
|
0
|
0
|
|
|
|
|
bool Module::passthrough () |
38
|
|
|
|
|
|
|
|
39
|
2
|
|
|
|
|
|
void Module::set_level (Level level) |
40
|
|
|
|
|
|
|
|
41
|
4
|
50
|
|
|
|
|
void Module::set_logger (ILoggerSP logger, bool passthrough = false) |
|
|
50
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
2
|
50
|
|
|
|
|
void Module::set_formatter (IFormatterSP formatter) |
|
|
50
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
ILoggerSP Module::get_logger () |
46
|
0
|
0
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
IFormatterSP Module::get_formatter () |