File Coverage

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


line stmt bran cond sub pod time code
1             #pragma once
2             #include "../Sv.h"
3              
4             namespace xs {
5              
6             namespace typemap {
7             struct DefaultType {};
8             }
9              
10             template <class TYPEMAP, class TYPE = TYPEMAP> struct Typemap { using _not_exists = void; };
11              
12             template <class T, typename = void> struct has_typemap : std::true_type {};
13             template <class T> struct has_typemap<T, typename Typemap<T>::_not_exists> : std::false_type {};
14              
15             template <class TYPEMAP, class TYPE = TYPEMAP> struct TypemapBase {
16             static inline TYPE in (SV*) = delete;
17              
18             static inline Sv create (const TYPE&, const Sv& = Sv()) = delete;
19              
20             static inline Sv out (const TYPE& var, const Sv& proto = Sv()) {
21             return Typemap<TYPE>::create(var, proto);
22             }
23              
24             static inline void destroy (const TYPE&, SV*) {}
25             };
26              
27             template <class TYPE>
28 18342           auto in (SV* arg) -> decltype(Typemap<TYPE>::in(arg)) {
29 18342           return Typemap<TYPE>::in(arg);
30             }
31              
32             template <class TYPEMAP = typemap::DefaultType, class TYPE, typename TM = std::conditional_t<std::is_same<TYPEMAP, typemap::DefaultType>::value, std::decay_t<TYPE>, TYPEMAP>>
33 7162           Sv out (TYPE&& var, const Sv& proto = Sv()) {
34 7162           return Typemap<TM>::out(std::forward<TYPE>(var), proto);
35             }
36              
37             }