File Coverage

/usr/local/lib/perl5/site_perl/5.26.1/x86_64-linux/XS/Framework.x/i/xs/typemap/auto.h
Criterion Covered Total %
statement 4 4 100.0
branch 1 2 50.0
condition n/a
subroutine n/a
pod n/a
total 5 6 83.3


line stmt bran cond sub pod time code
1             #pragma once
2             #include "base.h"
3             #include <panda/refcnt.h>
4              
5             namespace xs {
6              
7             // automatic default typemap for <const TYPE*> if typemap for <TYPE*> defined
8             template <class TYPEMAP, class TYPE> struct Typemap<const TYPEMAP*, TYPE> : Typemap<TYPEMAP*, TYPE> {};
9              
10             // automatic default reference resolving
11             template <class TYPE, bool = has_typemap<std::remove_reference_t<TYPE>*>::value> struct TypemapResolveReference {};
12             template <class TYPE> struct TypemapResolveReference<TYPE&, true> : Typemap<TYPE*> {
13             using Super = Typemap<TYPE*>;
14 2           static TYPE& in (SV* arg) {
15 2           auto ret = Super::in(arg);
16 2 50         if (!ret) throw "invalid value: undef not allowed";
17 2           return *ret;
18             }
19             static Sv out (TYPE& var, const Sv& = {}) = delete;
20             };
21             template <class TYPE> struct TypemapResolveReference<TYPE&, false> : Typemap<std::remove_const_t<TYPE>> {};
22             template <class TYPEMAP, class TYPE> struct Typemap<TYPEMAP&, TYPE> : TypemapResolveReference<TYPE> {};
23              
24             // automatic default typemap for <iptr<TYPE>> if typemap for <TYPE> defined
25             template <class TYPEMAP, class TYPE> struct Typemap<panda::iptr<TYPEMAP>, panda::iptr<TYPE>> : Typemap<TYPE*> {
26             using Super = Typemap<TYPE*>;
27             static panda::iptr<TYPE> in (SV* arg) { return Super::in(arg); }
28              
29             static Sv out (const panda::iptr<TYPE>& var, const Sv& proto = {}) {
30             return Super::out(var.get(), proto);
31             }
32             };
33              
34             }