line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
MODE: INLINE |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
#include |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
struct Point { |
6
|
|
|
|
|
|
|
double x; |
7
|
|
|
|
|
|
|
double y; |
8
|
|
|
|
|
|
|
}; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
struct ShapeA { |
11
|
|
|
|
|
|
|
size_t point_count() const { return points.size(); } |
12
|
|
|
|
|
|
|
Point& get_point(size_t idx) { return points.at(idx); } |
13
|
|
|
|
|
|
|
void add_point(const Point& pt) { points.push_back(pt); } |
14
|
|
|
|
|
|
|
private: |
15
|
|
|
|
|
|
|
std::vector points; |
16
|
|
|
|
|
|
|
}; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
struct XSShapeA : public ShapeA { |
19
|
|
|
|
|
|
|
void add_label(SV* maybe_label = nullptr) { |
20
|
|
|
|
|
|
|
Sv label = maybe_label ? Sv{maybe_label} : Sv::undef; |
21
|
|
|
|
|
|
|
labels.push_back(Ref::create(maybe_label)); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
Ref& get_ref(size_t idx) { return labels.at(idx); } |
24
|
|
|
|
|
|
|
private: |
25
|
|
|
|
|
|
|
std::vector[ labels; ] |
26
|
|
|
|
|
|
|
}; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
namespace xs { |
30
|
|
|
|
|
|
|
template <> |
31
|
|
|
|
|
|
|
struct Typemap : TypemapObject { |
32
|
|
|
|
|
|
|
static std::string package () { return "MyTest::Cookbook::Point"; } |
33
|
|
|
|
|
|
|
}; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
template |
36
|
|
|
|
|
|
|
struct Typemap : TypemapObject { |
37
|
|
|
|
|
|
|
static std::string package () { return "MyTest::Cookbook::ShapeA"; } |
38
|
|
|
|
|
|
|
}; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
template <> |
41
|
|
|
|
|
|
|
struct Typemap : Typemap { |
42
|
|
|
|
|
|
|
static std::string package () { return "MyTest::Cookbook::ShapeB"; } |
43
|
|
|
|
|
|
|
}; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
static xs::Sv::payload_marker_t payload_marker_09; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
MODULE = MyTest::Cookbook PACKAGE = MyTest::Cookbook::Point |
50
|
|
|
|
|
|
|
PROTOTYPES: DISABLE |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
double Point::x(SV* new_val = nullptr) : ALIAS(y = 1) { |
53
|
0
|
|
|
|
|
|
double* val = nullptr; |
54
|
0
|
0
|
|
|
|
|
switch(ix) { |
55
|
0
|
|
|
|
|
|
case 1: val = &THIS->y; break; |
56
|
0
|
|
|
|
|
|
default: val = &THIS->x; break; |
57
|
|
|
|
|
|
|
} |
58
|
0
|
0
|
|
|
|
|
if (new_val) { |
59
|
0
|
0
|
|
|
|
|
*val = SvNV(new_val); |
|
|
0
|
|
|
|
|
|
60
|
|
|
|
|
|
|
} |
61
|
0
|
|
|
|
|
|
RETVAL = *val; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Point* Point::new(double x = 0, double y = 0) { |
65
|
0
|
|
|
|
|
|
RETVAL = new Point{x, y}; |
66
|
0
|
0
|
|
|
|
|
} |
67
|
0
|
0
|
|
|
|
|
|
68
|
|
|
|
|
|
|
MODULE = MyTest::Cookbook PACKAGE = MyTest::Cookbook::ShapeA |
69
|
|
|
|
|
|
|
PROTOTYPES: DISABLE |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
size_t ShapeA::point_count() |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
void ShapeA::get_point(size_t idx) { |
74
|
0
|
0
|
|
|
|
|
Object self{ST(0)}; |
75
|
0
|
0
|
|
|
|
|
Array payload(self.payload(&payload_marker_09).obj); |
76
|
|
|
|
|
|
|
|
77
|
0
|
0
|
|
|
|
|
auto& pt = THIS->get_point(idx); |
78
|
0
|
0
|
|
|
|
|
auto pt_copy = new Point{pt.x, pt.y}; |
79
|
0
|
0
|
|
|
|
|
auto wrapped_pt = xs::out<>(pt_copy); |
80
|
0
|
0
|
|
|
|
|
mXPUSHs(wrapped_pt.detach()); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
82
|
0
|
0
|
|
|
|
|
if (GIMME_V == G_ARRAY) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
83
|
0
|
0
|
|
|
|
|
auto ref = payload.at(idx); |
84
|
0
|
|
|
|
|
|
Sv value = SvRV(ref); |
85
|
0
|
0
|
|
|
|
|
mXPUSHs(value.detach()); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
void ShapeA::add_point(Point* pt, SV* maybe_label = nullptr) { |
90
|
0
|
0
|
|
|
|
|
THIS->add_point(*pt); |
91
|
0
|
0
|
|
|
|
|
Object self{ST(0)}; |
92
|
0
|
0
|
|
|
|
|
Array payload(self.payload(&payload_marker_09).obj); |
93
|
0
|
0
|
|
|
|
|
Sv label = maybe_label ? Sv{maybe_label} : Sv::undef; |
|
|
0
|
|
|
|
|
|
94
|
0
|
0
|
|
|
|
|
Sv ref = Ref::create(maybe_label); |
95
|
0
|
0
|
|
|
|
|
payload.push(ref); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Sv ShapeA::new() { |
99
|
0
|
0
|
|
|
|
|
auto shape = new ShapeA(); |
100
|
0
|
0
|
|
|
|
|
Object obj = xs::out<>(shape, CLASS); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
101
|
0
|
0
|
|
|
|
|
auto payload = Array::create(); |
|
|
0
|
|
|
|
|
|
102
|
0
|
0
|
|
|
|
|
obj.payload_attach(payload, &payload_marker_09); |
103
|
0
|
0
|
|
|
|
|
RETVAL = obj.ref(); |
|
|
0
|
|
|
|
|
|
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
MODULE = MyTest::Cookbook PACKAGE = MyTest::Cookbook::ShapeB |
107
|
|
|
|
|
|
|
PROTOTYPES: DISABLE |
108
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
XSShapeA* XSShapeA::new() |
110
|
0
|
0
|
|
|
|
|
|
111
|
0
|
0
|
|
|
|
|
void XSShapeA::add_point(Point* pt, SV* maybe_label = nullptr) { |
112
|
0
|
|
|
|
|
|
THIS->add_point(*pt); |
113
|
0
|
|
|
|
|
|
THIS->add_label(maybe_label); |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
void XSShapeA::get_point(size_t idx) { |
117
|
0
|
0
|
|
|
|
|
auto& pt = THIS->get_point(idx); |
118
|
0
|
0
|
|
|
|
|
auto pt_copy = new Point{pt.x, pt.y}; |
119
|
0
|
0
|
|
|
|
|
auto wrapped_pt = xs::out<>(pt_copy); |
120
|
0
|
0
|
|
|
|
|
mXPUSHs(wrapped_pt.detach()); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
121
|
0
|
0
|
|
|
|
|
if (GIMME_V == G_ARRAY) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
122
|
0
|
0
|
|
|
|
|
Sv value = SvRV(THIS->get_ref(idx)); |
123
|
0
|
0
|
|
|
|
|
mXPUSHs(value.detach()); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
BOOT { |
128
|
68
|
50
|
|
|
|
|
auto stash = Stash(__PACKAGE__, GV_ADD); |
129
|
34
|
50
|
|
|
|
|
stash.inherit("MyTest::Cookbook::ShapeA"); |
130
|
|
|
|
|
|
|
} |