File Coverage

/usr/local/lib/perl5/site_perl/5.26.1/x86_64-linux/XS/Framework.x/i/xs/KeyProxy.h
Criterion Covered Total %
statement 10 11 90.9
branch 6 14 42.8
condition n/a
subroutine n/a
pod n/a
total 16 25 64.0


line stmt bran cond sub pod time code
1             #pragma once
2             #include
3              
4             namespace xs {
5              
6             struct Sub; struct Hash; struct Array;
7              
8 66           struct KeyProxy : Scalar {
9 33 50         KeyProxy (SV** ptr, bool nullok) : Scalar(), ptr(ptr), nullok(nullok) { set(*ptr); }
10             KeyProxy (const KeyProxy&) = default;
11             KeyProxy (KeyProxy&&) = default;
12              
13             KeyProxy& operator= (std::nullptr_t) { return operator=(Scalar()); }
14             KeyProxy& operator= (const KeyProxy& v) { return operator=((Scalar)v); }
15 3           KeyProxy& operator= (const Scalar& val) {
16 3 50         Scalar::operator=(val);
17 3           SV* newsv = val;
18 3 50         if (nullok || newsv) SvREFCNT_inc_simple_void(newsv);
    50          
    50          
19 0 0         else newsv = newSV(0);
20 3           auto old = *ptr;
21 3           *ptr = newsv;
22 3 50         SvREFCNT_dec(old);
23 3           return *this;
24             }
25             KeyProxy& operator= (SV* v) { return operator=(Scalar(v)); }
26             KeyProxy& operator= (const Sv& v) { return operator=(Scalar(v)); }
27             KeyProxy& operator= (const Array&) = delete;
28             KeyProxy& operator= (const Hash&) = delete;
29             KeyProxy& operator= (const Sub&) = delete;
30             KeyProxy& operator= (const Io&) = delete;
31              
32             template >
33             KeyProxy operator[] (T key) { return _geti(key); }
34             KeyProxy operator[] (const panda::string_view& key);
35              
36             private:
37             SV** ptr;
38             bool nullok;
39            
40             KeyProxy _geti (size_t key);
41             };
42              
43             }