t/typemap/object/static_cast.xsi

filter: Statementstmt 85.7% 24 / 28 Branchbran 46.6% 28 / 60 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 59.0% 52 / 88 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« src/xs/typemap/object.cc ↑ Summary t/cookbook/cookbook.xs »
1 MODE: INLINE
2  
3 template <int i>
4 class _MyStatic {
5 public:
6 int val;
7 _MyStatic (int val) : val(val) { }
8 virtual ~_MyStatic () {}
9 };
10  
11 template <int i>
12 class _MyStaticChild : public _MyStatic<i> {
13 public:
14 int val2;
15 _MyStaticChild (int val, int val2) : _MyStatic<i>(val), val2(val2) { }
16 };
17  
18 using PTRMyStatic = _MyStatic<0>;
19 using PTRMyStaticChild = _MyStaticChild<0>;
20 using MyStatic = _MyStatic<1>;
21 using MyStaticChild = _MyStaticChild<1>;
22  
23 namespace xs {
24  
25 template <class TYPE> struct Typemap<PTRMyStatic*, TYPE> : TypemapObject<PTRMyStatic*, TYPE, ObjectTypePtr, ObjectStorageIV, StaticCast> {
26 static std::string package () { return "MyTest::PTRMyStatic"; }
27 };
28
29 template <> struct Typemap<PTRMyStaticChild*> : Typemap<PTRMyStatic*, PTRMyStaticChild*> {
30 static std::string package () { return "MyTest::PTRMyStaticChild"; }
31 };
32
33 template <class TYPE> struct Typemap<MyStatic*, TYPE> : TypemapObject<MyStatic*, TYPE, ObjectTypePtr, ObjectStorageMG, StaticCast> {
34 static std::string package () { return "MyTest::MyStatic"; }
35 };
36
37 template <> struct Typemap<MyStaticChild*> : Typemap<MyStatic*, MyStaticChild*> {
38 static std::string package () { return "MyTest::MyStaticChild"; }
39 };
40  
41 }
42  
43  
44 MODULE = MyTest::Typemap::Object PACKAGE = MyTest::PTRMyStatic
45 PROTOTYPES: DISABLE
46  
47 PTRMyStatic* PTRMyStatic::new (int arg) {
48 1 if (arg) RETVAL = new PTRMyStatic(arg);
49 1 ▶ else RETVAL = NULL;
Branch: 1 branch
BranchTrueFalseTotal
else RETVAL = NULL; 1 0 1
50 1 ▶}
Branch: 2 branches
BranchTrueFalseTotal
} 1 0 1
} 1 0 1
51 0  
52 int PTRMyStatic::val (SV* newval = NULL) {
53 2 ▶ if (newval) THIS->val = SvIV(newval);
Branch: 1 branch
BranchTrueFalseTotal
if (newval) THIS->val = SvIV(newval); 0 2 2
54 2 ▶ RETVAL = THIS->val;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = THIS->val; 0 2 2
55 }
56  
57 2 ▶void PTRMyStatic::DESTROY ()
Branch: 1 branch
BranchTrueFalseTotal
void PTRMyStatic::DESTROY () 2 0 2
58  
59  
60  
61 MODULE = MyTest::Typemap::Object PACKAGE = MyTest::PTRMyStaticChild
62 PROTOTYPES: DISABLE
63  
64 BOOT {
65 35 ▶ Stash("MyTest::PTRMyStaticChild").inherit(Stash("MyTest::PTRMyStatic"));
Branch: 3 branches
BranchTrueFalseTotal
Stash("MyTest::PTRMyStaticChild").inherit(Stash("MyTest::PTRMyStatic")); 35 0 35
Stash("MyTest::PTRMyStaticChild").inherit(Stash("MyTest::PTRMyStatic")); 35 0 35
Stash("MyTest::PTRMyStaticChild").inherit(Stash("MyTest::PTRMyStatic")); 35 0 35
66 }
67  
68 PTRMyStaticChild* PTRMyStaticChild::new (int arg1, int arg2) {
69 1 if (arg1 || arg2) RETVAL = new PTRMyStaticChild(arg1, arg2);
70 1 ▶ else RETVAL = NULL;
Branch: 1 branch
BranchTrueFalseTotal
else RETVAL = NULL; 1 0 1
71 1 ▶}
Branch: 3 branches
BranchTrueFalseTotal
} 0 1 1
} 0 0 0
} 1 0 1
72 0  
73 int PTRMyStaticChild::val2 (SV* newval = NULL) {
74 1 ▶ if (newval) THIS->val2 = SvIV(newval);
Branch: 1 branch
BranchTrueFalseTotal
if (newval) THIS->val2 = SvIV(newval); 0 1 1
75 1 ▶ RETVAL = THIS->val2;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = THIS->val2; 0 1 1
76 }
77  
78  
79  
80 MODULE = MyTest::Typemap::Object PACKAGE = MyTest::MyStatic
81 PROTOTYPES: DISABLE
82  
83 MyStatic* MyStatic::new (int arg) {
84 1 if (arg) RETVAL = new MyStatic(arg);
85 1 ▶ else RETVAL = NULL;
Branch: 1 branch
BranchTrueFalseTotal
else RETVAL = NULL; 1 0 1
86 1 ▶}
Branch: 2 branches
BranchTrueFalseTotal
} 1 0 1
} 1 0 1
87 0  
88 int MyStatic::val (SV* newval = NULL) {
89 2 ▶ if (newval) THIS->val = SvIV(newval);
Branch: 1 branch
BranchTrueFalseTotal
if (newval) THIS->val = SvIV(newval); 0 2 2
90 2 ▶ RETVAL = THIS->val;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = THIS->val; 2 0 2
91 }
92  
93 2 ▶void MyStatic::DESTROY ()
Branch: 1 branch
BranchTrueFalseTotal
void MyStatic::DESTROY () 2 0 2
94  
95  
96  
97 MODULE = MyTest::Typemap::Object PACKAGE = MyTest::MyStaticChild
98 PROTOTYPES: DISABLE
99  
100 BOOT {
101 35 ▶ Stash("MyTest::MyStaticChild").inherit(Stash("MyTest::MyStatic"));
Branch: 3 branches
BranchTrueFalseTotal
Stash("MyTest::MyStaticChild").inherit(Stash("MyTest::MyStatic")); 35 0 35
Stash("MyTest::MyStaticChild").inherit(Stash("MyTest::MyStatic")); 35 0 35
Stash("MyTest::MyStaticChild").inherit(Stash("MyTest::MyStatic")); 35 0 35
102 }
103  
104 MyStaticChild* MyStaticChild::new (int arg1, int arg2) {
105 1 if (arg1 || arg2) RETVAL = new MyStaticChild(arg1, arg2);
106 1 ▶ else RETVAL = NULL;
Branch: 1 branch
BranchTrueFalseTotal
else RETVAL = NULL; 1 0 1
107 1 ▶}
Branch: 3 branches
BranchTrueFalseTotal
} 0 1 1
} 0 0 0
} 1 0 1
108 0  
109 int MyStaticChild::val2 (SV* newval = NULL) {
110 1 ▶ if (newval) THIS->val2 = SvIV(newval);
Branch: 1 branch
BranchTrueFalseTotal
if (newval) THIS->val2 = SvIV(newval); 0 1 1
111 1 ▶ RETVAL = THIS->val2;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = THIS->val2; 1 0 1
112 }
« src/xs/typemap/object.cc ↑ Summary t/cookbook/cookbook.xs »