line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#pragma once |
2
|
|
|
|
|
|
|
#include |
3
|
|
|
|
|
|
|
#include |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
namespace xs { |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
using xs::my_perl; |
8
|
|
|
|
|
|
|
|
9
|
0
|
|
|
|
|
|
struct Scalar : Sv { |
10
|
|
|
|
|
|
|
static const Scalar undef; |
11
|
|
|
|
|
|
|
static const Scalar yes; |
12
|
|
|
|
|
|
|
static const Scalar no; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
static Scalar create () { return Scalar(newSV(0), NONE); } |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
static Scalar noinc (SV* val) { return Scalar(val, NONE); } |
17
|
|
|
|
|
|
|
static Scalar noinc (GV* val) { return Scalar(val, NONE); } |
18
|
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
|
Scalar (std::nullptr_t = nullptr) {} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
Scalar (SV* sv, bool policy = INCREMENT) : Sv(sv, policy) { _validate(); } |
22
|
|
|
|
|
|
|
Scalar (GV* sv, bool policy = INCREMENT) : Sv(sv, policy) {} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
Scalar (const Scalar& oth) : Sv(oth) {} |
25
|
|
|
|
|
|
|
Scalar (Scalar&& oth) : Sv(std::move(oth)) {} |
26
|
|
|
|
|
|
|
Scalar (const Sv& oth) : Scalar(oth.get()) {} |
27
|
|
|
|
|
|
|
Scalar (Sv&& oth) : Sv(std::move(oth)) { _validate(); } |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Scalar (const Array&) = delete; |
30
|
|
|
|
|
|
|
Scalar (const Hash&) = delete; |
31
|
|
|
|
|
|
|
Scalar (const Sub&) = delete; |
32
|
|
|
|
|
|
|
Scalar (const Io&) = delete; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Scalar& operator= (SV* val) { |
35
|
|
|
|
|
|
|
Sv::operator=(val); |
36
|
|
|
|
|
|
|
_validate(); |
37
|
|
|
|
|
|
|
return *this; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Scalar& operator= (GV* val) { |
41
|
|
|
|
|
|
|
Sv::operator=(val); |
42
|
|
|
|
|
|
|
return *this; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Scalar& operator= (const Scalar& oth) { |
46
|
|
|
|
|
|
|
Sv::operator=(oth.sv); |
47
|
|
|
|
|
|
|
return *this; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Scalar& operator= (Scalar&& oth) { |
51
|
|
|
|
|
|
|
Sv::operator=(std::move(oth)); |
52
|
|
|
|
|
|
|
return *this; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Scalar& operator= (const Sv& oth) { return operator=(oth.get()); } |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Scalar& operator= (Sv&& oth) { |
58
|
|
|
|
|
|
|
Sv::operator=(std::move(oth)); |
59
|
|
|
|
|
|
|
_validate(); |
60
|
|
|
|
|
|
|
return *this; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Scalar& operator= (const Array&) = delete; |
64
|
|
|
|
|
|
|
Scalar& operator= (const Hash&) = delete; |
65
|
|
|
|
|
|
|
Scalar& operator= (const Sub&) = delete; |
66
|
|
|
|
|
|
|
Scalar& operator= (const Io&) = delete; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
void set (SV* val) { Sv::operator=(val); } |
69
|
|
|
|
|
|
|
void set (GV* val) { Sv::operator=(val); } |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
operator AV* () const = delete; |
72
|
|
|
|
|
|
|
operator HV* () const = delete; |
73
|
|
|
|
|
|
|
operator CV* () const = delete; |
74
|
|
|
|
|
|
|
operator IO* () const = delete; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
template panda::enable_if_one_of_t* get () const { return (T*)sv; } |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
void upgrade (svtype type) { |
79
|
|
|
|
|
|
|
if (type > SVt_PVMG && type != SVt_PVGV) throw std::logic_error("can't upgrade Scalar to something bigger than PVMG (and != PVGV)"); |
80
|
|
|
|
|
|
|
Sv::upgrade(type); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
template T as_string () const; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
template T as_number () const; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
static void __at_perl_destroy (); |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
private: |
90
|
|
|
|
|
|
|
void _validate () { |
91
|
|
|
|
|
|
|
if (!sv) return; |
92
|
|
|
|
|
|
|
if (is_scalar_unsafe()) return; |
93
|
|
|
|
|
|
|
reset(); |
94
|
|
|
|
|
|
|
throw std::invalid_argument("SV is not a scalar value"); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
}; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
} |