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              
11             KeyProxy& operator= (std::nullptr_t) { return operator=(Scalar()); }
12             KeyProxy& operator= (const KeyProxy& v) { return operator=((Scalar)v); }
13 3           KeyProxy& operator= (const Scalar& val) {
14 3 50         Scalar::operator=(val);
15 3           SV* newsv = val;
16 3 50         if (nullok || newsv) SvREFCNT_inc_simple_void(newsv);
    50          
    50          
17 0 0         else newsv = newSV(0);
18 3           auto old = *ptr;
19 3           *ptr = newsv;
20 3 50         SvREFCNT_dec(old);
21 3           return *this;
22             }
23             KeyProxy& operator= (SV* v) { return operator=(Scalar(v)); }
24             KeyProxy& operator= (const Sv& v) { return operator=(Scalar(v)); }
25             KeyProxy& operator= (const Array&) = delete;
26             KeyProxy& operator= (const Hash&) = delete;
27             KeyProxy& operator= (const Sub&) = delete;
28             KeyProxy& operator= (const Io&) = delete;
29              
30             template >
31             KeyProxy operator[] (T key) { return _geti(key); }
32             KeyProxy operator[] (const panda::string_view& key);
33              
34             private:
35             SV** ptr;
36             bool nullok;
37            
38             KeyProxy _geti (size_t key);
39             };
40              
41             }