FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python/include/boost/python/to_python_converter.hpp at python313 · boostorg/python · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
boostorg
/
python
Public
Notifications
You must be signed in to change notification settings
Fork
223
Star
537
Code
Issues
173
Pull requests
34
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
python
/
include
/
boost
/
python
/
to_python_converter.hpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
94 lines (74 loc) · 2.37 KB
Breadcrumbs
python
/
include
/
boost
/
python
/
to_python_converter.hpp
Copy path
File metadata and controls
94 lines (74 loc) · 2.37 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//
Copyright David Abrahams 2002.
//
Distributed under the Boost Software License, Version 1.0. (See
//
accompanying file LICENSE_1_0.txt or copy at
//
http://www.boost.org/LICENSE_1_0.txt)
#
ifndef
TO_PYTHON_CONVERTER_DWA200221_HPP
#
define
TO_PYTHON_CONVERTER_DWA200221_HPP
#
include
<
boost/python/detail/prefix.hpp
>
#
include
<
boost/python/converter/registry.hpp
>
#
include
<
boost/python/converter/as_to_python_function.hpp
>
#
ifndef
BOOST_PYTHON_NO_PY_SIGNATURES
#
include
<
boost/python/converter/pytype_function.hpp
>
#
endif
#
include
<
boost/python/type_id.hpp
>
namespace
boost
{
namespace
python
{
#
if
0
//get_pytype member detection
namespace detail
{
typedef char yes_type;
typedef struct {char a[2]; } no_type;
template<PyTypeObject const * (*f)()> struct test_get_pytype1 { };
template<PyTypeObject * (*f)()> struct test_get_pytype2 { };
template<class T> yes_type tester(test_get_pytype1<&T::get_pytype>*);
template<class T> yes_type tester(test_get_pytype2<&T::get_pytype>*);
template<class T> no_type tester(...);
template<class T>
struct test_get_pytype_base
{
BOOST_STATIC_CONSTANT(bool, value= (sizeof(detail::tester<T>(0)) == sizeof(yes_type)));
};
template<class T>
struct test_get_pytype : boost::mpl::bool_<test_get_pytype_base<T>::value>
{
};
}
#
endif
template
<
class
T
,
class
Conversion
,
bool
has_get_pytype=
false
>
struct
to_python_converter
{
#
ifndef
BOOST_PYTHON_NO_PY_SIGNATURES
typedef
boost::mpl::bool_<has_get_pytype> HasGetPytype;
static
PyTypeObject
const
*
get_pytype_1
(boost::mpl::true_ *)
{
return
Conversion::get_pytype
();
}
static
PyTypeObject
const
*
get_pytype_1
(boost::mpl::false_ *)
{
return
0
;
}
static
PyTypeObject
const
*
get_pytype_impl
()
{
return
get_pytype_1
((HasGetPytype*)
0
);
}
#
endif
to_python_converter
();
};
//
//
implementation
//
template
<
class
T
,
class
Conversion
,
bool
has_get_pytype>
to_python_converter<T,Conversion, has_get_pytype>::to_python_converter()
{
typedef
converter::as_to_python_function<
T, Conversion
> normalized;
converter::registry::insert
(
&normalized::convert
, type_id<T>()
#
ifndef
BOOST_PYTHON_NO_PY_SIGNATURES
, &get_pytype_impl
#
endif
);
}
}}
//
namespace boost::python
#
endif
//
TO_PYTHON_CONVERTER_DWA200221_HPP
Back
|
FazBrowse Home
|
New Git URL